Index: views_bookmark.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views_bookmark/views_bookmark.module,v
retrieving revision 1.6.2.54
diff -u -r1.6.2.54 views_bookmark.module
--- views_bookmark.module	8 Mar 2008 23:37:54 -0000	1.6.2.54
+++ views_bookmark.module	8 Mar 2008 23:44:18 -0000
@@ -247,6 +247,10 @@
       );
     }
   }
+  else if ($form_id == 'views_edit_view') {
+    // Append help for the Views tokens this module provides.
+    $form['page-info']['url']['#description'] .= _views_bookmark_tokens_help();
+  }
 }
 
 /**
Index: views_bookmark.views.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views_bookmark/Attic/views_bookmark.views.inc,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 views_bookmark.views.inc
--- views_bookmark.views.inc	8 Mar 2008 23:37:54 -0000	1.1.2.1
+++ views_bookmark.views.inc	8 Mar 2008 23:44:19 -0000
@@ -457,7 +457,147 @@
     }
 
     $views[$view->name] = $view;
+
+    $view = new stdClass();
+    $view->name = "bookmarks_who_$vbid";
+    $view->disabled = TRUE; // The administrator has to explicitly enable this tab.
+    $view->access = array ();
+    $view->description = t('Node tab view for bookmark: !bookmark-title', array('!bookmark-title' => $bookmark->title));
+    $view->page = TRUE;
+    if ($vbid == 1) {
+      // Pick a nicer title
+      $view->page_title = t('Who\'s bookmarked this page');
+    }
+    else {
+      $view->page_title = t('Who\'s bookmarked this page, !bookmark-title', array('!bookmark-title' => $bookmark->title));
+    }
+    $view->page_empty = t('Nobody has bookmarked this page yet.');
+    $view->page_empty_format = '1';
+    $view->page_type = 'table';
+    if ($vbid == 1) {
+      // Pick a nicer URL
+      $view->url = "node/\$bookmarkable-$vbid/who";
+    }
+    else {
+      $view->url = "node/\$bookmarkable-$vbid/who_$vbid";
+    }
+    $view->use_pager = TRUE;
+    $view->nodes_per_page = '30';
+    $view->menu = TRUE;
+    $view->menu_tab = TRUE;
+    $view->menu_tab_weight = '0';
+    $view->menu_tab_default = FALSE;
+    $view->menu_tab_default_parent = NULL;
+    $view->menu_tab_default_parent_type = 'existing';
+    $view->menu_parent_tab_weight = '0';
+    $view->menu_parent_title = '';
+    $view->sort = array (
+    );
+    $view->argument = array (
+      array (
+        'type' => 'nid',
+        'argdefault' => '1',
+        'title' => '',
+        'options' => '0',
+        'wildcard' => '',
+        'wildcard_substitution' => '',
+      ),
+    );
+    $view->field = array (
+      array (
+        'tablename' => "views_bookmark_users_$vbid",
+        'field' => 'name',
+        'label' => 'User',
+        'sortable' => '1',
+        'defaultsort' => 'ASC',
+      ),
+      array (
+        'tablename' => "views_bookmark_nodes_$vbid",
+        'field' => 'timestamp',
+        'label' => 'Time when bookmarked',
+        'handler' => 'views_handler_field_date_small',
+        'sortable' => '1',
+      ),
+    );
+    $view->filter = array (
+      array (
+        'tablename' => "views_bookmark_nodes_$vbid",
+        'field' => 'uid',
+        'operator' => 'IS NOT',
+        'options' => '',
+        'value' => 'uid',
+      ),
+    );
+    $view->requires = array('node', 'users');
+    $views[$view->name] = $view;
   }
   return $views;
 }
 
+// ---------------------------------------------------------------------------
+// Views token support
+
+function _views_bookmark_tokens_help() {
+  return t("<p>Note to users of the <em>Views Bookmark</em> module: To display a view as a tab on a page that can be bookmarked, set the url to 'node/\$bookmarkable-nnn/custom' --where <em>nnn</em> you replace with the bookmark ID and  <em>custom</em> is whatever you wish. Then open Page >> Menu and check <em>Provide Menu</em> and <em>Provide Menu as Tab</em>; also make the first argument in the View be the <em>Node: ID</em> argument. The <em>\$bookmarkable-nnn</em> path element is a placeholder for the node nid and is preferable to using <em>\$arg</em> or <em>\$node</em> because it ensures that the tab appears <strong>only</strong> on nodes that are bookmarkable. Besides <em>\$bookmarkable-nnn</em> this module also provides the <em>\$bookmarked-nnn</em> placeholder, which only matches nodes that were actually bookmarked, and the <em>\$selfbookmarked-nnn</em> placeholder, which only matches nodes that were bookmarked by the user viewing the page. More information is available <a href='@url-handbook'>in the module handbook</a>.</p>", array('@url-handbook' => 'http://drupal.org/node/224045'));
+}
+
+/**
+ * Implementation of hook_views_url_tokens.
+ *
+ * Usually, when we want to put a 'Node: ID' argument in a view URL we use the
+ * '$arg' or '$node' tokens; e.g., 'node/$node/who-bookmarked-this'. This hook
+ * introduces several new tokens which only match nodes whose type is bookmarkable
+ * and, optionally, which are bookmarked. See help text in hook_form_alter().
+ */
+function views_bookmark_views_url_tokens() {
+  return array(
+    '$bookmarkable'   => 'views_bookmark_token_predicate_bookmarkable',
+    '$bookmarked'     => 'views_bookmark_token_predicate_bookmarked',
+    '$selfbookmarked' => 'views_bookmark_token_predicate_selfbookmarked',
+  );
+}
+
+/**
+ * Handle '$bookmarkable-vbid' in a view URL.
+ *
+ * Returns TRUE if $nid is a node ID and the node is of a bookmarkable type in
+ * the 'vbid' context.
+ */
+function views_bookmark_token_predicate_bookmarkable($url, $vbid, $nid) {
+  if (!is_numeric($nid) || !$vbid) {
+    return FALSE;
+  }
+  if (!($node = node_load($nid))) {
+    return FALSE;
+  }
+  return (bool)db_result(db_query("SELECT vbid FROM {views_bookmark_nodetypes} WHERE vbid = %d AND type = '%s'", $vbid, $node->type));
+}
+
+/**
+ * Handle '$bookmarked-vbid' in a view URL.
+ *
+ * Returns TRUE if $nid is a node ID and the node was bookmarked in the
+ * 'vbid' context.
+ */
+function views_bookmark_token_predicate_bookmarked($url, $vbid, $nid) {
+  if (!is_numeric($nid) || !$vbid) {
+    return FALSE;
+  }
+  return (bool)db_result(db_query_range("SELECT nid FROM {views_bookmark_nodes} WHERE vbid = %d AND nid = %d", $vbid, $nid, 0, 1));
+}
+
+/**
+ * Handle '$selfbookmarked-vbid' in a view URL.
+ *
+ * Returns TRUE if $nid is a node ID and the node was bookmarked in the
+ * 'vbid' context by the user viewing the page.
+ */
+function views_bookmark_token_predicate_selfbookmarked($url, $vbid, $nid) {
+  if (!is_numeric($nid) || !$vbid) {
+    return FALSE;
+  }
+  global $user;
+  return (bool)db_result(db_query("SELECT nid FROM {views_bookmark_nodes} WHERE vbid = %d AND nid = %d AND uid = %d", $vbid, $nid, $user->uid));
+}
+
+
