Index: userlink.info
===================================================================
RCS file: /cvs/drupal/contributions/modules/userlink/userlink.info,v
retrieving revision 1.2
diff -u -r1.2 userlink.info
--- userlink.info	18 Jun 2007 22:54:05 -0000	1.2
+++ userlink.info	2 Dec 2008 19:58:38 -0000
@@ -1,6 +1,14 @@
-; $Id: userlink.info,v 1.2 2007/06/18 22:54:05 dww Exp $
-name = Userlink
-description = The userlink module allows users to save and share links.
-package = ""
-project = "userlink"
-
+; $Id: userlink.info,v 1.1.2.1 2007/06/18 23:07:11 dww Exp $
+name = Userlink
+description = The userlink module allows users to save and share links.
+package = ""
+project = "userlink"
+
+
+; Information added by drupal.org packaging script on 2007-06-20
+version = "5.x-1.2"
+project = "userlink"
+datestamp = "1182361212"
+
+
+core = 6.x
\ No newline at end of file
Index: userlink.install
===================================================================
RCS file: /cvs/drupal/contributions/modules/userlink/userlink.install,v
retrieving revision 1.2
diff -u -r1.2 userlink.install
--- userlink.install	27 Jan 2007 22:23:35 -0000	1.2
+++ userlink.install	2 Dec 2008 19:58:38 -0000
@@ -1,24 +1,58 @@
 <?php
 // $Id: userlink.install,v 1.2 2007/01/27 22:23:35 marcp Exp $
 
+/*
+ * @file
+ * userlink install file.
+ */
+
+/**
+ * Implementation of hook_schema().
+ */
+function userlink_schema() {
+  $schema['userlink'] = array(
+    'description' => t('TODO'),
+    'fields' => array(
+      'nid' => array(
+        'description' => t('TODO'),
+        'type' => 'int',
+        'unsigned' => 1,
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'vid' => array(
+        'description' => t('TODO'),
+        'type' => 'int',
+        'unsigned' => 1,
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'url' => array(
+        'description' => t('TODO'),
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'private' => array(
+        'description' => t('TODO'),
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+    ),
+    'primary key' => array('nid', 'vid'),
+  );
+
+  return $schema;
+}
+
 /**
  * Implementation of hook_install()
  */
 function userlink_install() {
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      db_query("CREATE TABLE {userlink} (
-        nid int(10) unsigned NOT NULL default '0',
-        vid int(10) unsigned NOT NULL default '0',
-        url varchar(255) NOT NULL default '',
-        private int(2) NOT NULL default '0',
-        PRIMARY KEY (nid, vid)
-      ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
-      break;
-    case 'pgsql':
-      break;
-  }
+  // Create tables.
+  drupal_install_schema('userlink');
   
   drupal_set_message(t('Userlink has created the required tables.'));
 }
Index: userlink.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/userlink/userlink.module,v
retrieving revision 1.4
diff -u -r1.4 userlink.module
--- userlink.module	27 Jan 2007 22:23:35 -0000	1.4
+++ userlink.module	29 Dec 2008 16:25:58 -0000
@@ -1,22 +1,21 @@
 <?php
-// $Id: userlink.module,v 1.4 2007/01/27 22:23:35 marcp Exp $
+// $Id: userlink.module,v 1.4.2.3 2007/06/20 17:32:47 marcp Exp $
 
 /*
  * @file
  * Enables storing and retrieving of userlinks (or bookmarks).
  */
 
-
 /**
  * Implementation of hook_node_info().
  */
 function userlink_node_info() {
-return array(
+  return array(
     'userlink' => array(
       'name' => t('Userlink'),
       'module' => 'userlink',
       'description' => t("Enables storing and retrieving of userlinks (or bookmarks)."),
-    )
+  )
   );
 }
 
@@ -24,21 +23,25 @@
  * Implementation of hook_perm().
  */
 function userlink_perm() {
-  return array('create userlinks', 'view all userlinks', 'view own userlinks');
+  return array(
+    'create userlinks',
+    'view all userlinks',
+    'edit all userlinks',
+    'view own userlinks',
+    'edit own userlinks'
+    );
 }
 
 /**
  * Implementation of hook_access().
  */
-function userlink_access($op, $node) {
-  global $user;
-
+function userlink_access($op, $node, $account) {
   if ($op == 'create') {
-    return user_access('create userlinks') && $user->uid;
+    return user_access('create userlinks', $account);
   }
 
   if ($op == 'update' || $op == 'delete') {
-    if (user_access('create userlinks') && ($user->uid == $node->uid)) {
+    if (user_access('edit all userlinks', $account) || (user_access('edit own userlinks', $account) && ($account->uid == $node->uid))) {
       return TRUE;
     }
   }
@@ -49,8 +52,9 @@
  */
 function userlink_user($type, &$edit, &$user) {
   if ($type == 'view' && user_access('view all userlinks', $user)) {
-    $items[] = array('title' => t('Links'),
-      'value' => l(t("View recent links."), "userlink/$user->uid/recent", array('title' => t("Read @username's links.", array('@username' => $user->name)))),
+    $items['userlinks'] = array(
+      'title' => t('Links'),
+      'value' => l(t("View recent links"), "userlink/$user->uid/recent", array('title' => t("Read @username's links.", array('@username' => $user->name)))),
       'class' => 'userlink',
     );
     return array(t('History') => $items);
@@ -60,8 +64,8 @@
 /**
  * Implementation of hook_help().
  */
-function userlink_help($section) {
-  switch ($section) {
+function userlink_help($path, $arg) {
+  switch ($path) {
     case 'admin/help#userlink':
       return t("
       <p>The userlink module allows registered users to maintain a list of links (or bookmarks).</p>
@@ -93,7 +97,7 @@
       return userlink_page_last();
     }
   }
-  
+
   return 'no links to display';
 }
 
@@ -124,22 +128,28 @@
     if (is_numeric($uid)) {
       $name = userlink_name_from_uid($uid);
     }
-    
+
     $output = '';
 
+    if ($tid == NULL) {
+      $tid = arg(3);
+    }
+
     if ($command == 'term') {
+      $nodes_main = variable_get('default_nodes_main', 10);
       if (is_numeric($uid)) {
-        $result = pager_query(db_rewrite_sql("SELECT n.nid, n.sticky, n.created FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid = %d AND n.type = 'userlink' AND n.uid = %d ORDER BY n.sticky DESC, n.created DESC"), variable_get('default_nodes_main', 10), 0, NULL, $tid, $uid);
+        $result = pager_query(db_rewrite_sql("SELECT n.nid, n.sticky, n.created FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid = %d AND n.type = 'userlink' AND n.uid = %d ORDER BY n.sticky DESC, n.created DESC"), $nodes_main, 0, NULL, $tid, $uid);
       }
       else {
-        $result = pager_query(db_rewrite_sql("SELECT n.nid, n.sticky, n.created FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid = %d AND n.type = 'userlink' ORDER BY n.sticky DESC, n.created DESC"), variable_get('default_nodes_main', 10), 0, NULL, $tid);
+        $result = pager_query(db_rewrite_sql("SELECT n.nid, n.sticky, n.created FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid = %d AND n.type = 'userlink' ORDER BY n.sticky DESC, n.created DESC"), $nodes_main, 0, NULL, $tid);
       }
-      
-      if (db_num_rows($result)) {
-        while ($node = db_fetch_object($result)) {
-          $output .= node_view(node_load($node->nid), 1);
-        }
-    
+
+      $num_rows = 0;
+      while ($node = db_fetch_object($result)) {
+        $num_rows++;
+        $output .= node_view(node_load($node->nid), 1);
+      }
+      if ($num_rows > 0) {
         $output .= theme('pager', NULL, variable_get('default_nodes_main', 10));
       }
       else {
@@ -152,19 +162,21 @@
       }
 
       $result = pager_query(db_rewrite_sql("SELECT n.nid, n.sticky, n.created FROM {node} n WHERE type = 'userlink' AND n.uid = %d ORDER BY n.sticky DESC, n.created DESC"), variable_get('default_nodes_main', 10), 0, NULL, $uid);
-      
-      if (db_num_rows($result)) {
-        while ($node = db_fetch_object($result)) {
-          $output .= node_view(node_load($node->nid), 1);
-        }
-    
+
+      $num_rows = 0;
+      while ($node = db_fetch_object($result)) {
+        $num_rows++;
+        $output .= node_view(node_load($node->nid), 1);
+      }
+
+      if ($num_rows > 0) {
         $output .= theme('pager', NULL, variable_get('default_nodes_main', 10));
       }
       else {
         $output = t("@name has not created any userlinks.", array('@name' => $name));
       }
     }
-    
+
     return $output;
   }
   else {
@@ -177,10 +189,10 @@
  */
 function userlink_page_everyone() {
   $output = "<div class=\"help\"><p>Click on a user's name to see his/her links, or ". l('click here', 'userlink/all') ." to see all links in the system.</p></div>\n";
-  
+
   $header = array(
-    array('data' => t('Username'), 'field' => 'u.name', 'sort' => 'asc'),
-    array('data' => t('# of links'), 'field' => 'numlinks')
+  array('data' => t('Username'), 'field' => 'u.name', 'sort' => 'asc'),
+  array('data' => t('# of links'), 'field' => 'numlinks')
   );
   $sql = 'SELECT u.uid AS uid, u.name AS name, COUNT(*) AS numlinks FROM {node} n INNER JOIN {userlink} ul ON n.vid = ul.vid INNER JOIN {users} u ON n.uid = u.uid GROUP BY u.uid';
   $sql .= tablesort_sql($header);
@@ -206,94 +218,98 @@
 
   $result = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'userlink' ORDER BY n.created DESC"), variable_get('default_nodes_main', 10));
 
-  if (db_num_rows($result)) {
-    while ($node = db_fetch_object($result)) {
-      $output .= node_view(node_load($node->nid), 1);
-    }
+  $num_rows = 0;
+  while ($node = db_fetch_object($result)) {
+    $num_rows++;
+    $output .= node_view(node_load($node->nid), 1);
+  }
 
+  if ($num_rows > 0) {
     $output .= theme('pager', NULL, variable_get('default_nodes_main', 10));
   }
-  
+
   if (drupal_strlen($output) == 0) {
     $output = 'There are no links in the system.';
   }
-  
+
   return $output;
 }
 
 function userlink_page_links() {
   $output = '';
-  
+
   // Add the javascript for collapsible fieldsets...
   drupal_add_js('misc/collapse.js');
-  
+
   drupal_add_css(drupal_get_path('module', 'userlink') .'/userlink.css');
 
   if (arg(1)) {
     $uid = arg(1);
-    
+
+    $basesql = "SELECT n.nid AS nid, tn.tid AS tid, td.name AS name FROM {node} n
+              INNER JOIN {term_node} tn ON n.nid = tn.nid 
+              INNER JOIN {term_data} td ON tn.tid = td.tid WHERE n.type = 'userlink'";
+
     if (arg(1) == 'all') {
-      $sql = "SELECT n.nid AS nid, tn.tid AS tid, td.name AS name FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid INNER JOIN {term_data} td ON tn.tid = td.tid WHERE n.type = 'userlink' ORDER BY name";
+      $sql = $basesql ." ORDER BY name";
+      $result = db_query(db_rewrite_sql($sql));
     }
     else {
-      $sql = "SELECT n.nid AS nid, tn.tid AS tid, td.name AS name FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid INNER JOIN {term_data} td ON tn.tid = td.tid WHERE n.type = 'userlink' AND n.uid = $uid ORDER BY name";
+      $sql = $basesql ." AND n.uid = %d ORDER BY name";
+      $result = db_query(db_rewrite_sql($sql), $uid);
       $name = userlink_name_from_uid($uid);
     }
-  
-    $result = db_query(db_rewrite_sql($sql));
 
     $group = '';
     $last_group = '';
     $num_in_group = 0;
-    
-    if (db_num_rows($result)) {
-      while ($row = db_fetch_object($result)) {
-        $node = node_load($row->nid);
-        
-        if ($row->name != $last_group) {
-          if ($last_group != '') {
-            $group .= "</ul>";
-            $output .= theme('fieldset', array('#title' => $last_group, '#children' => $group, '#attributes' => array('class' => 'collapsible userlink-group')));
-          }
-
-          $group = "<ul>\n";
-          
-          $last_group = $row->name;
-          $num_in_group = 0;
+
+    while ($row = db_fetch_object($result)) {
+      $node = node_load($row->nid);
+
+      if ($row->name != $last_group) {
+        if ($last_group != '') {
+          $group .= "</ul>";
+          $output .= theme('fieldset', array('#title' => $last_group, '#children' => $group, '#attributes' => array('class' => 'collapsible userlink-group')));
         }
-        $group .= '<li>'. l($node->title, 'node/'. $node->nid) ."</li>\n";
-        $num_in_group++;
-      }      
-      if ($num_in_group > 0) {
-        $group .= "</ul>";
-        $output .= theme('fieldset', array('#title' => $last_group, '#children' => $group, '#attributes' => array('class' => 'collapsible userlink-group')));
+
+        $group = "<ul>\n";
+
+        $last_group = $row->name;
+        $num_in_group = 0;
       }
+      $group .= '<li>'. l($node->title, 'node/'. $node->nid) ."</li>\n";
+      $num_in_group++;
+    }
+    if ($num_in_group > 0) {
+      $group .= "</ul>";
+      $output .= theme('fieldset', array('#title' => $last_group, '#children' => $group, '#attributes' => array('class' => 'collapsible userlink-group')));
     }
   }
-  
+
   if (drupal_strlen($output) == 0) {
     $output = t('there are no links to display');
   }
-  
+
   $output = '<form>'. $output .'</form>';
   return $output;
 }
 
 function userlink_page_category() {
   $header = array(
-    array('data' => t('Category'), 'field' => 'name'),
-    array('data' => t('# of links'), 'field' => 'numlinks', 'sort' => 'desc')
+  array('data' => t('Category'), 'field' => 'name'),
+  array('data' => t('# of links'), 'field' => 'numlinks', 'sort' => 'desc')
   );
-  
+
   $uid = 0;
-  
+
   if (arg(1) && is_numeric(arg(1))) {
     $uid = arg(1);
-    
+
     $sql = "SELECT tn.tid AS tid, td.name AS name, COUNT(*) AS numlinks FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid INNER JOIN {term_data} td ON tn.tid = td.tid WHERE n.type = 'userlink' AND n.uid = $uid GROUP BY tn.tid";
     $sql .= tablesort_sql($header);
     $sqlcount = "SELECT COUNT(DISTINCT tn.tid) FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid INNER JOIN {term_data} td ON tn.tid = td.tid WHERE n.type = 'userlink' AND n.uid = $uid";
-    
+
     $name = userlink_name_from_uid($uid);
   }
   else {
@@ -301,7 +317,7 @@
     $sql .= tablesort_sql($header);
     $sqlcount = "SELECT COUNT(DISTINCT tn.tid) FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid INNER JOIN {term_data} td ON tn.tid = td.tid WHERE n.type = 'userlink'";
   }
-  
+
   $result = pager_query($sql, 50, 0, $sqlcount);
 
   while ($category = db_fetch_object($result)) {
@@ -311,7 +327,7 @@
     else {
       $url = 'userlink/all/term/'. $category->tid;
     }
-  
+
     $rows[] = array(l($category->name, $url), $category->numlinks);
   }
 
@@ -324,7 +340,6 @@
  * Implementation of hook_form().
  */
 function userlink_form(&$node) {
-
   $form['url'] = array('#type' => 'textfield', '#title' => t('URL'), '#required' => TRUE, '#default_value' => $node->url ? $node->url : 'http://', '#description' => t('The URL for this link (usually begins with http://).'), '#weight' => -50);
   $form['title'] = array('#type' => 'textfield', '#title' => t('Title'), '#required' => TRUE, '#default_value' => $node->title, '#description' => t('The title of this link.'), '#weight' => -30);
   $form['body'] = array(
@@ -339,20 +354,21 @@
  */
 function userlink_view(&$node, $teaser = FALSE, $page = FALSE) {
   drupal_add_css(drupal_get_path('module', 'userlink') .'/userlink.css');
-  
+
   if ($page) {
     // Breadcrumb navigation
-    $breadcrumb[] = array('path' => 'userlink/all', 'title' => t('links'));
-    $breadcrumb[] = array('path' => 'userlink/'. $node->uid, 'title' => t("@name's links", array('@name' => $node->name)));
-    $breadcrumb[] = array('path' => 'node/'. $node->nid);
-    menu_set_location($breadcrumb);
+    $breadcrumb[] = l(t('Home'), NULL);
+    $breadcrumb[] = l(t('Links'), 'userlink/all' );
+    $breadcrumb[] = l(t("@name's links", array('@name' => $node->name)), 'userlink/'. $node->uid);
+
+    drupal_set_breadcrumb($breadcrumb);
   }
 
   $node = node_prepare($node, $teaser);
-  
+
   // If the url is longer than X characters, just display the first X...
   $url = userlink_trim_url($node->url);
-  
+
   // The link should always set a target window -- we are saving it
   // on a site-wide basis at this point...
   $atts = array('target' => variable_get('userlink_behavior', '_self'));
@@ -366,101 +382,154 @@
       '#value' => $prefix_name,
       '#suffix' => "</div>");
   }
-  
+
   // By default, put the url above the body...
   $node->content['url'] = array(
     '#weight' => 1,  
     '#prefix' => "<div class=\"userlink-url\">",
-    '#value' => l($url, $node->url, $atts),
+    '#value' => l($url, $node->url, array('attributes' => $atts)),
     '#suffix' => "</div>");
 
-  // Modify the weight of the body to drop it down... 
+  // Modify the weight of the body to drop it down...
   $node->content['body']['#weight'] = 2;
-    
+
   return $node;
 }
 
 /**
  * Implementation of hook_menu().
  */
-function userlink_menu($may_cache) {
+function userlink_menu() {
   global $user;
   $items = array();
 
-   $items[] = array(
-      'path' => 'admin/settings/userlink',
-      'title' => t('userlink'),
-      'description' => t('Describes what the settings generally do.'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('userlink_admin_settings'),
-      'access' => user_access('administer site configuration'),
-      'type' => MENU_NORMAL_ITEM);
-
-  if ($may_cache) {
-    $items[] = array('path' => 'node/add/userlink', 'title' => t('userlink entry'),
-      'access' => user_access('create userlinks'));
-    $items[] = array('path' => 'links', 'title' => t('links'),
-      'callback' => 'userlink_page',
-      'access' => user_access('access content'),
-      'type' => MENU_SUGGESTED_ITEM);
-    $items[] = array('path' => 'userlink/homepage', 'title' => t('recent links'),
-      'callback' => 'userlink_homepage',
-      'access' => user_access('view all userlinks') || user_access('view own userlinks'),
-      'type' => MENU_CALLBACK);
-  }
-  else {
-    if (arg(0) == 'userlink') {
-      if (is_numeric(arg(1)) || (arg(1) == 'all')) {
-        $uid = arg(1);
-  	  	
-        $uname = is_numeric($uid) ? userlink_name_from_uid($uid) : null;
-
-        $title = $uname ? "$uname's links..." : "all links...";
-
-        $items[] = array('path' => 'userlink/'. $uid, 'title' => $title,
-          'callback' => 'userlink_page_links',
-          'access' => user_access('view all userlinks'),
-          'type' => MENU_CALLBACK);
-  		
-        $items[] = array('path' => 'userlink/'. $uid .'/list', 'title' => t('by category'),
-          'callback' => 'userlink_page_links',
-          'access' => user_access('view all userlinks'),
-          'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -20);
-
-        $items[] = array('path' => 'userlink/'. $uid .'/categories', 'title' => t('just categories'),
-          'callback' => 'userlink_page_category',
-          'type' => MENU_LOCAL_TASK, 'weight' => -10);
-          
-        $items[] = array('path' => 'userlink/'. $uid .'/everyone', 'title' => t("other users"),
-          'callback' => 'userlink_page_everyone',
-          'access' => user_access('view all userlinks'),
-          'type' => MENU_LOCAL_TASK, 'weight' => 20);
-        
-        $items[] = array('path' => 'userlink/'. $uid .'/recent', 'title' => t('recent links'),
-          'callback' => 'userlink_recent',
-          'access' => user_access('view all userlinks'),
-          'type' => MENU_LOCAL_TASK, 'weight' => 10);
-
-        //
-        //
-        // If we are looking at a listing of links for a given term, add
-        // another tab for the listing...
-        //
-        //
-        if (arg(2) == 'term' && is_numeric(arg(3))) {
-          $term = taxonomy_get_term(arg(3));
-          $items[] = array('path' => 'userlink/'. $uid .'/term', 'title' => t("@who @termname links", array('@who' => $uname ? "$uname's" : 'all', '@termname' => $term->name)),
-            'callback' => 'userlink_page_termlinks',
-            'access' => user_access('view all userlinks'),
-            'type' => MENU_LOCAL_TASK, 'weight' => 80);
-        }
-      }
-    }
-  }
+  $items['admin/settings/userlink'] = array(
+    'title' => 'userlink',
+    'description' => 'Describes what the settings generally do.',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('userlink_admin_settings'),
+    'access arguments' => array('administer site configuration'),
+    'type' => MENU_NORMAL_ITEM
+  );
+
+
+  $items['links'] = array(
+    'title' => 'links',  
+    'page callback' => 'userlink_page',
+    'access callback' => TRUE,
+    'access arguments' => array('access content'),
+    'type' => MENU_SUGGESTED_ITEM
+  );
+  $items['userlink/homepage'] = array(
+    'title' => 'recent links',
+    'page callback' => 'userlink_homepage',
+    'access arguments' => array('view all userlinks') /*|| user_access('view own userlinks')*/,
+    'type' => MENU_CALLBACK
+  );
+
+  $items['userlink/%user' ] = array(
+    'title callback' => '_userlink_name_title',
+    'title arguments' => array(1),
+    'page callback' => 'userlink_page_links',
+    'access arguments' => array('view all userlinks'),
+    'type' => MENU_CALLBACK
+  );
+
+  $title = "all links...";
+  $items['userlink/all'] = array(
+    'title' => $title,
+    'page callback' => 'userlink_page_links',
+    'access arguments' => array('view all userlinks'),
+    'type' => MENU_CALLBACK
+  );
+
+  $items['userlink/%user/list'] = array(
+    'title' => 'by category',
+    'page callback' => 'userlink_page_links',
+    'access arguments' => array('view all userlinks'),
+    'type' => MENU_DEFAULT_LOCAL_TASK, 
+    'weight' => -20
+  );
+
+  $items['userlink/all/list'] = array(
+    'title' => 'by category',
+    'page callback' => 'userlink_page_links',
+    'access arguments' => array('view all userlinks'),
+    'type' => MENU_DEFAULT_LOCAL_TASK, 
+    'weight' => -20
+  );
+
+  $items['userlink/%user/categories'] = array(
+    'title' => 'just categories',
+    'page callback' => 'userlink_page_category',
+    'access callback' => TRUE,
+    'type' => MENU_LOCAL_TASK, 
+    'weight' => -1        
+  );
+
+  $items['userlink/all/categories'] = array(
+    'title' => 'just categories',
+    'page callback' => 'userlink_page_category',
+    'access callback' => TRUE,
+    'type' => MENU_LOCAL_TASK, 
+    'weight' => -1        
+  );
+
+  $items['userlink/%user/everyone'] = array(
+    'title' => 'other users',
+    'page callback' => 'userlink_page_everyone',
+    'access arguments' => array('view all userlinks'),
+    'type' => MENU_LOCAL_TASK, 
+    'weight' => 20
+  );
+
+  $items['userlink/%user/recent'] = array(
+    'title' => 'recent links',
+    'page callback' => 'userlink_recent',
+    'access arguments' => array('view all userlinks'),
+    'type' => MENU_LOCAL_TASK, 
+    'weight' => 10
+  );
+
+  //
+  // If we are looking at a listing of links for a given term, add
+  // another tab for the listing...
+  //
+  //if (arg(2) == 'term' && is_numeric(arg(3)))
+  $items['userlink/%user/term/%taxonomy_vocabulary'] = array(
+    'title callback' => '_userlink_term_title',
+    'title arguments' => array(1, 3),
+    'page callback' => 'userlink_page_termlinks',
+    'page arguments' => array(3),
+    'access arguments' => array('view all userlinks'),
+    'type' => MENU_LOCAL_TASK, 
+    'weight' => 80
+  );
+  $items['userlink/all/term/%taxonomy_vocabulary'] = array(
+    'title callback' => '_userlink_term_title',
+    'title arguments' => array(1, 3),
+    'page callback' => 'userlink_page_termlinks',
+    'page arguments' => array(3),
+    'access arguments' => array('view all userlinks'),
+    'type' => MENU_LOCAL_TASK, 
+    'weight' => 80
+  );
 
   return $items;
 }
 
+function _userlink_term_title($uid, $term_id) {
+  $uname = userlink_name_from_uid($uid);
+  $term = taxonomy_get_term($term_id);
+  return t("@who @termname links", array('@who' => $uname ? "$uname's" : 'all', '@termname' => $term->name));
+}
+
+function _userlink_name_title($user) {
+  $uname = $user->name;
+  return $uname .'\'s links...';
+}
+
+
 /**
  * Implementation of hook_block().
  *
@@ -479,44 +548,47 @@
   else if ($op == 'view') {
     if (($delta == 0) && user_access('view all userlinks')) {
       $block['content'] = userlink_list(db_query_range(db_rewrite_sql("SELECT n.nid, n.title, ul.url FROM {node} n INNER JOIN {userlink} ul ON n.vid = ul.vid WHERE n.type = 'userlink' ORDER BY n.title"), 0, 10));
-      $block['content'] .= '<div class="more-link">'. l(t('more'), 'links', array('title' => t('See all the links.'))) .'</div>';
+      $block['content'] .= '<div class="more-link">'.
+      l(t('more'), 'links', array('title' => t('See all the links.'))) .'</div>';
       $block['subject'] = t('All links');
       return $block;
     }
     else if (($delta == 1) && $user->uid && user_access('view own userlinks')) {
       $block['content'] = userlink_list(db_query_range(db_rewrite_sql("SELECT n.nid, n.title, ul.url FROM {node} n INNER JOIN {userlink} ul ON n.vid = ul.vid WHERE n.type = 'userlink' AND n.uid = $user->uid ORDER BY n.title"), 0, 10));
-      $block['content'] .= '<div class="more-link">'. l(t('more'), 'userlink/'. $user->uid, array('title' => t('See all the links.'))) .'</div>';
+      $block['content'] .= '<div class="more-link">'.
+      l(t('more'), 'userlink/'. $user->uid, array('title' => t('See all the links.'))) .'</div>';
       $block['subject'] = t('My Links');
       return $block;
     }
     else if (($delta == 2) && user_access('view all userlinks')) {
       $block['content'] = userlink_list(db_query_range(db_rewrite_sql("SELECT n.nid, n.title, ul.url FROM {node} n INNER JOIN {userlink} ul ON n.vid = ul.vid WHERE n.type = 'userlink' ORDER BY n.changed DESC"), 0, 10));
-      $block['content'] .= '<div class="more-link">'. l(t('more'), 'links', array('title' => t('See all the links.'))) .'</div>';
+      $block['content'] .= '<div class="more-link">'.
+      l(t('more'), 'links', array('title' => t('See all the links.'))) .'</div>';
       $block['subject'] = t('Recent Links');
       return $block;
     }
     else if (($delta == 3) && user_access('view all userlinks')) {
       $block['content'] = userlink_category_list(db_query_range(db_rewrite_sql("SELECT tn.tid AS tid, td.name AS name, COUNT(*) AS numlinks FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid INNER JOIN {term_data} td ON tn.tid = td.tid WHERE n.type = 'userlink' GROUP BY tn.tid ORDER BY numlinks DESC"), 0, 10));
-      $block['content'] .= '<div class="more-link">'. l(t('more'), 'userlink/all/categories', array('title' => t('See all the link categories.'))) .'</div>';
+      $block['content'] .= '<div class="more-link">'.
+      l(t('more'), 'userlink/all/categories', array('title' => t('See all the link categories.'))) .'</div>';
       $block['subject'] = t('Popular Link Categories');
       return $block;
     }
     else if (($delta == 4) && user_access('view all userlinks')) {
-    	
-    	// This block shows "the target user's" userlinks.  If we
-    	// are on a page looking at some user's links, by category
-    	// or otherwise, we want to show that user's categories.
-    	//
-    	// Also, if we are looking at a single userlink node, we
-    	// want to show that node's owner's userlink categories.
-    	
+      // This block shows "the target user's" userlinks.  If we
+      // are on a page looking at some user's links, by category
+      // or otherwise, we want to show that user's categories.
+      //
+      // Also, if we are looking at a single userlink node, we
+      // want to show that node's owner's userlink categories.
+
       if (arg(0) == 'userlink') {
         if (is_numeric(arg(1)) || arg(1) == 'homepage') {
           $uid = arg(1) == 'homepage' ? $user->uid : arg(1);
         }
       }
-      else if ((arg(0) == 'node') && is_numeric(arg(1))) {
-        $node = node_load(arg(1));
+      else if ($node = menu_get_object()) {//if ((arg(0) == 'node') && is_numeric(arg(1))) {
+        //$node = node_load(arg(1));
         if ($node->type == 'userlink') {
           $uid = $node->uid;
         }
@@ -527,17 +599,18 @@
           $uid = $user->uid;
         }
       }
-      
+
       if ($uid) {
         $name = userlink_name_from_uid($uid);
         $block['content'] = userlink_category_list(db_query_range(db_rewrite_sql("SELECT tn.tid AS tid, td.name AS name, COUNT(*) AS numlinks FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid INNER JOIN {term_data} td ON tn.tid = td.tid WHERE n.uid = $uid AND n.type = 'userlink' GROUP BY tn.tid ORDER BY numlinks DESC"), 0, 5), $uid, $name);
-        $block['content'] .= '<div class="more-link">'. l(t('more'), 'userlink/'. $uid, array('title' => t("See @name's link categories.", array('@name' => $name)))) .'</div>';
+        $block['content'] .= '<div class="more-link">'.
+        l(t('more'), 'userlink/'. $uid, array('title' => t("See @name's link categories.", array('@name' => $name)))) .'</div>';
 
         if ($uid == $user->uid) {
           $block['subject'] = t("My Link Categories");
         }
         else {
-          $block['subject'] = t("$name's Link Categories");
+          $block['subject'] = t("@name's Link Categories", array('@name' => $name));
         }
         return $block;
       }
@@ -584,7 +657,7 @@
  */
 function userlink_insert($node) {
   db_query("INSERT INTO {userlink} (nid, vid, url, private) VALUES (%d, %d, '%s', %d)",
-    $node->nid, $node->vid, $node->url, $node->private);
+  $node->nid, $node->vid, $node->url, $node->private);
 }
 
 /**
@@ -593,11 +666,11 @@
 function userlink_update($node) {
   if ($node->revision) {
     db_query("INSERT INTO {userlink} (nid, vid, url, private) VALUES (%d, %d, '%s', %d)",
-      $node->nid, $node->vid, $node->url, $node->private);
+    $node->nid, $node->vid, $node->url, $node->private);
   }
   else {
     db_query("UPDATE {userlink} SET url = '%s', private = %d WHERE vid = %d",
-      $node->url, $node->private, $node->vid);
+    $node->url, $node->private, $node->vid);
   }
 }
 
@@ -616,10 +689,10 @@
   // The link should always set a target window -- we are saving it
   // on a site-wide basis at this point...
   $atts = array('target' => variable_get('userlink_behavior', '_self'));
-  
+
   while ($node = db_fetch_object($result)) {
     $atts['title'] = $node->url;
-    $items[] = l($node->title, $node->url, $atts);
+    $items[] = l($node->title, $node->url, array('attributes' => $atts));
   }
 
   return theme('item_list', $items, $title);
@@ -646,7 +719,7 @@
     }
     $items[] = l($category->name, $url) ." <span class=\"userlink-count\">($category->numlinks)</span>";
   }
-  
+
   return theme('item_list', $items);
 }
 
@@ -656,17 +729,17 @@
  */
 function userlink_vids() {
   $a = array();
-  
+
   $result = db_query("SELECT vid FROM {vocabulary_node_types} WHERE type = 'userlink'");
   while ($row = db_fetch_array($result)) {
     $a[] = $row['vid'];
   }
-  
+
   return $a;
 }
 
 function userlink_name_from_uid($uid) {
-  $result = db_query("SELECT name FROM {users} u WHERE u.uid = $uid");
+  $result = db_query("SELECT name FROM {users} u WHERE u.uid = '%i' ", $uid);
   return db_result($result);
 }
 
@@ -674,7 +747,7 @@
   if (drupal_strlen($url) > $len) {
     $url = substr($url, 0, $len) .'...';
   }
-  
+
   return $url;
 }
 
@@ -704,3 +777,50 @@
 
   return system_settings_form($form);
 }
+
+/**
+ * Implementation of hook_views_tables().
+ *
+ */
+function userlink_views_tables() {
+  $tables['userlink'] = array(
+    'name' => 'userlink',
+    'provider' => 'internal',
+    'join' => array(
+      'left' => array(
+        'table' => 'node',
+        'field' => 'vid'
+        ),
+      'right' => array(
+        'field' => 'vid'
+        )
+        ),
+    'fields' => array(
+      'url' => array(
+        'name' => t('Userlink: url'),
+        'handler' => array(
+          'userlink_views_handler_url_as_link'    => t('As Link'),
+          'userlink_views_handler_url_not_as_link' => t('Without Link'),
+        ),
+        'sortable' => TRUE,
+        'help' => t('Display the url for this userlink'),
+        ),
+        ),
+    'sorts' => array(
+      'url' => array(
+        'name' => t('Userlink: url'),
+        'help' => t('Sort by url'),
+        ),
+        ),
+        );
+
+        return $tables;
+}
+
+function userlink_views_handler_url_as_link($fieldinfo, $fielddata, $value, $data) {
+  return l($value, $value);
+}
+
+function userlink_views_handler_url_not_as_link($fieldinfo, $fielddata, $value, $data) {
+  return check_plain($value);
+}

