Same name and namespace in other branches
  1. 5.x modules/node/node.module \node_build_filter_query()
  2. 6.x modules/node/node.admin.inc \node_build_filter_query()
  3. 7.x modules/node/node.admin.inc \node_build_filter_query()

Build query for node administration filters based on session.

1 call to node_build_filter_query()
node_admin_nodes in modules/node.module
Menu callback: content administration.

File

modules/node.module, line 969
The core that allows content to be submitted to the site.

Code

function node_build_filter_query() {
  $filters = node_filters();

  // Build query
  $where = $args = array();
  $join = '';
  foreach ($_SESSION['node_overview_filter'] as $index => $filter) {
    list($key, $value) = $filter;
    switch ($key) {
      case 'status':

        // Note: no exploitable hole as $key/$value have already been checked when submitted
        list($key, $value) = explode('-', $value, 2);
        $where[] = 'n.' . $key . ' = %d';
        break;
      case 'category':
        $table = "tn{$index}";
        $where[] = "{$table}.tid = %d";
        $join .= "INNER JOIN {term_node} {$table} ON n.nid = {$table}.nid ";
        break;
      case 'type':
        $where[] = "n.type = '%s'";
    }
    $args[] = $value;
  }
  $where = count($where) ? 'WHERE ' . implode(' AND ', $where) : '';
  return array(
    'where' => $where,
    'join' => $join,
    'args' => $args,
  );
}