Index: modules/nodequeue/nodequeue.views.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/nodequeue/Attic/nodequeue.views.inc,v retrieving revision 1.1.2.5 diff -u -p -u -p -r1.1.2.5 nodequeue.views.inc --- modules/nodequeue/nodequeue.views.inc 16 Aug 2007 00:06:04 -0000 1.1.2.5 +++ modules/nodequeue/nodequeue.views.inc 10 Oct 2007 01:05:38 -0000 @@ -56,6 +56,19 @@ function nodequeue_views_tables() { 'option' => 'string', 'help' => t('This filter allows nodes to be filtered by the time they were added to a given NodeQueue.') .' '. views_t_strings('filter date'), ), + "exclusion" => array( + 'name' => t('NodeQueue: Not in a queue'), + 'operator' => array('IS' => t('is')), + 'value' => array( + '#type' => 'select', + '#options' => 'nodequeue_handler_queuelist', + '#all_ok' => TRUE, + ), + 'field' => 'qid', + 'handler' => 'nodequeue_handler_filter_exclusion', + 'help' => t('This filter allows nodes to be filtered that do not belong to any node queue.'), + ), + ), "sorts" => array( "position" => array( @@ -235,7 +248,7 @@ function nodequeue_views_default_views() * Generate a list of queues for use in handlers. */ function nodequeue_handler_queuelist($op, $argument) { - if (isset($argument['#all_ok'])) { + if (isset($argument['#all_ok']) || isset($argument['value']['#all_ok'])) { $options[0] = t(''); } $queues = nodequeue_load_queues(nodequeue_get_all_qids(NULL)); @@ -370,3 +383,30 @@ function nodequeue_handler_arg_reference return check_plain($queue->title); } } + +function nodequeue_handler_filter_exclusion($op, $filter, $filterinfo, &$query) { + $table = $filterinfo['table']; + $column = $filterinfo['field']; + $value = $filter['value']; + $joininfo = array( + 'type' => 'LEFT', + 'left' => array( + 'table' => 'node', + 'field' => 'nid', + ), + 'right' => array( + 'field' => 'nid', + ), + ); + $num = $query->add_table($table, true, 1, $joininfo); + $tablename = $query->get_table_name($table, $num); + $field = "$tablename.$column"; + if (empty($value)) { + // Not in any queues. + $query->add_where("$field IS NULL"); + } + else { + // Not in a specific queue. + $query->add_where("$field IS NULL OR $field != %d", $value); + } +}