Index: views_node.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views/modules/views_node.inc,v
--- views_node.inc	5 May 2007 00:54:53 -0000	1.30.2.17
+++ views_node.inc	8 Jun 2007 18:11:20 -0000
@@ -241,6 +241,24 @@
         'handler' => 'views_handler_filter_body',
         'help' => t('This filter allows nodes to be filtered by their body.'),
       ),
+      'nid' => array(
+        'name' => t('Node: ID'),
+        'operator' => 'views_handler_operator_or',
+        'cacheable' => 'no',
+        'handler' => 'views_handler_filter_nid',
+        'value' => array(
+          '#type' => 'textarea',
+          '#process' => array('views_filter_nid_process_form' => array()),
+        ),
+        'option' => array(
+          '#type' => 'select',
+          '#options' => array(
+            'php' => 'PHP code',
+            'id' => 'ID list'
+          ),
+        ),
+        'help' => t('This filter allows nodes to be filtered by Node ID.  PHP code should return an array with node IDs.  ID lists should be separated by commas.'),
+      ),
     ),
   );
 
@@ -744,6 +762,47 @@
   views_handler_filter_like($op, $filter, $filterinfo, $query);
 }
 
+function views_handler_filter_nid($op, $filter, $filterinfo, &$query) {
+  if (isset ($filter['value'])) {
+    if (is_array($filter['value'])) {
+      $filter['value']=trim(implode(',', $filter['value']));
+    }
+    error_log('php: ' . print_r($filter['value'],TRUE));
+    if ($filter['options'] == 'php') {
+      $result = eval ($filter['value']);
+      error_log('eval: ' . print_r($result,TRUE));
+      if ($result === FALSE) {
+        // PHP parse error; return error to user
+      }
+      else if ($result === NULL) {
+        // Nothing was returned; return error to user
+      }
+      else if (!is_array($result)) {
+        // An array was not returned
+      }
+      else {
+        $nids = trim(implode(',',$result),' \t\n\r\0\x0B,');
+      }
+    }
+    error_log('result: ' . print_r($nids,TRUE));
+    if ($nids != '') {
+      if ($filter['operator'] == 'OR') {
+        $query->add_where("node.nid IN (%s)", $nids);
+      }
+      else {
+        $query->add_where("node.nid NOT IN (%s)", $nids);
+      }
+    }
+  }
+}
+
+function views_filter_nid_process_form($element) {
+  if (is_array($element['#value'])) {
+    $element['#value'] = implode(',', $element['#value']);
+  }
+  return $element;
+}
+
 function views_handler_sort_random($action, &$query, $sortinfo, $sort) {
   switch ($GLOBALS['db_type']) {
     case 'mysql':
