cvs diff: Diffing views
Index: views/project.views.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project/views/project.views.inc,v
retrieving revision 1.2
diff -u -p -r1.2 project.views.inc
--- views/project.views.inc	15 Jan 2009 06:45:33 -0000	1.2
+++ views/project.views.inc	15 Jan 2009 07:07:46 -0000
@@ -353,6 +353,11 @@ function project_views_plugins() {
         'handler' => 'project_plugin_argument_validate_project_type_term',
         'path' => drupal_get_path('module', 'project') .'/views/plugins',
       ),
+      'project_nid' => array(
+        'title' => t('Project node'),
+        'handler' => 'project_plugin_argument_validate_project_nid',
+        'path' => drupal_get_path('module', 'project') .'/views/plugins',
+      ),
     ),
   );
 }
cvs diff: Diffing views/handlers
cvs diff: Diffing views/plugins
Index: views/plugins/project_plugin_argument_validate_project_nid.inc
===================================================================
RCS file: views/plugins/project_plugin_argument_validate_project_nid.inc
diff -N views/plugins/project_plugin_argument_validate_project_nid.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ views/plugins/project_plugin_argument_validate_project_nid.inc	15 Jan 2009 07:07:46 -0000
@@ -0,0 +1,26 @@
+<?php
+
+/**
+ * Validate whether an argument is a project node.
+ *
+ * This supports either numeric arguments (nid) or strings (project uri) and
+ * converts either one into the project nid.  This validator also sets the
+ * argument's title to the full title of the project node.
+ */
+class project_plugin_argument_validate_project_nid extends views_plugin_argument_validate {
+  function validate_argument($argument) {
+    if (is_numeric($argument)) {
+      $result = db_fetch_object(db_query(db_rewrite_sql("SELECT nid, title FROM {node} WHERE nid = %d AND type = '%s'"), $argument, 'project_project'));
+    }
+    else {
+      $result = db_fetch_object(db_query(db_rewrite_sql("SELECT n.nid, n.title FROM {node} n INNER JOIN {project_projects} p ON n.nid = p.nid WHERE p.uri ='%s'"), $argument));
+    }
+    if (!$result) {
+      return FALSE;
+    }
+    $this->argument->argument = $result->nid;
+    $this->argument->validated_title = check_plain($result->title);
+    return TRUE;
+  }
+}
+
cvs diff: Diffing views/theme
