Index: views_bookmark.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views_bookmark/views_bookmark.module,v
retrieving revision 1.6.2.37
diff -u -F^f -r1.6.2.37 views_bookmark.module
--- views_bookmark.module	14 Jan 2008 05:12:57 -0000	1.6.2.37
+++ views_bookmark.module	20 Jan 2008 08:47:30 -0000
@@ -614,11 +614,19 @@ function views_bookmark_views_tables() {
           'name' => t('Bookmark: User for @s', array('@s' => $bookmark->title)),
           'handler' => 'views_bookmark_field_handler_username',
           'query_handler' => 'views_bookmark_qhandler_username',
-          'sortable' => true,
-          'help' => t('This will display the author of the node.'),
+          'sortable' => FALSE,
+          'help' => t('This will display the name of the user who bookmarked this node.'),
           'uid' => 'uid',
           'vbid' => $bookmark->vbid,
         ),
+        'timestamp' => array(
+          'name' => t('Bookmark: @s Marked Time', array('@s' => $bookmark->title)),
+          'handler' => views_handler_field_dates(),
+          'option' => 'string',
+          'sortable' => TRUE,
+          'help' => t('Display the time the node was bookmarked by a user.')
+            .' '. t('The option field may be used to specify the custom date format as it\'s required by the date() function or if "as time ago" has been chosen to customize the granularity of the time interval.'),
+        ),
       ),
       'filters' => array(
         'uid' => array(
@@ -648,6 +656,11 @@ function views_bookmark_views_tables() {
           'name' => t('Bookmark: @s Marked Time', array('@s' => $bookmark->title)),
           'help' => t('Sort by the time a node was last bookmarked using the %s mark.', array('%s' => $bookmark->title)),
         ),
+        'name' => array(
+          'name' => t('Bookmark: User for @s', array('@s' => $bookmark->title)),
+          'help' => t('Sort by the the name of the users who bookmarked the node using the %s mark. This probably makes sense only when the list is filtered for a single node; e.g., on a "Who\'s bookmarked this" tab.', array('%s' => $bookmark->title)),
+          'handler' => 'views_bookmark_sort_handler_username',
+        ),
       ),
     );
     $tables["views_bookmark_nodes_$bookmark->vbid"] = $table;
@@ -810,6 +823,7 @@ function views_bookmark_qhandler_ops($fi
  * Handler that makes sure the user name field is available for a bookmark.
  */
 function views_bookmark_qhandler_username($field, $fieldinfo, &$query) {
+  $query->ensure_table($field['tablename']);
   $num = $query->add_table('users', false, 1, array(
     'left' => array(
       'table' => $field['tablename'],
@@ -823,6 +837,23 @@ function views_bookmark_qhandler_usernam
 }
 
 /**
+ * Handler to sort by the name of the user who bookmarked a node.
+ */
+function views_bookmark_sort_handler_username($op, &$query, $sortinfo, $sortdata) {
+  $query->ensure_table($sortinfo['table']);
+  $num = $query->add_table('users', false, 1, array(
+    'left' => array(
+      'table' => $sortinfo['table'],
+      'field' => 'uid',
+    ),
+    'right' => array(
+      'field' => 'uid'
+    ),
+  ));
+  $query->add_orderby($query->get_table_name('users', $num), 'name', $sortdata['sortorder']);
+}
+
+/**
  * Handler that lets us filter nodes to include only those by a particular user.
  */
 function views_bookmark_filter_handler_uid($op, $filter, $filterinfo, &$query) {
