--- coherent_access/coherent_access.module	2008-09-24 19:21:58.000000000 -0500
+++ ./coherent_access.module	2008-10-05 18:27:43.000000000 -0500
@@ -65,22 +65,24 @@ function coherent_access_block($op = 'li
   }
 }
 
+// This function is currently not used:
+
 function coherent_access_show_collaborative_content($uid = NULL) {
-  if ($uid === NULL) {
+  if ($uid === NULL) { 
     global $user;
     $uid = $user->uid;
   }
-  
+
   $nodes = coherent_access_get_user_nodes($uid);
   
 }
 
 function coherent_access_show_my_nodes($num = 0, $uid = NULL) {
-  if ($uid === NULL) {
+  if ($uid == NULL) {
     global $user;
     $uid = $user->uid;
   }
-    
+
   $text['mine'] = t('Mine:');
   $text['editor'] = t('Edit:');
   $text['viewer'] = t('View:');
@@ -91,7 +93,7 @@ function coherent_access_show_my_nodes($
   if (!empty($nodes)) {
     $items = array();
     foreach ($nodes as $mode => $node) {
-      if (!empty($node)) {
+      if (!empty($mode)) { // changed by MN
         $items[$mode]['data'] = $text[$mode];
         $items[$mode]['children'] = array();
         foreach ($node as $nid => $info) {
@@ -170,7 +172,7 @@ function coherent_access_admin_settings_
 */
 function coherent_access_menu() {
   $items = array();
-  global $user; 
+//  global $user;   // this is not used here... omit?  MN
   
   $items['admin/settings/coherent-access'] = array(
     'title' => 'Coherent Access',
@@ -180,6 +182,11 @@ function coherent_access_menu() {
     'access arguments' => array('administer site configuration'),
   );
 
+// MN:  thinking through this...
+// with %user, the argument passed to the callback function 
+// will be user_load(xxx) for a url of user/xxx/shared-posts
+// so it is not a user id that is being passed, but the user object
+
   $items['user/%user/shared-posts'] = array( //TEST: ensure links are created properly
     'type' => MENU_LOCAL_TASK,
     'title' => 'Shared Posts',
@@ -643,9 +650,12 @@ function coherent_access_get_gids($nid, 
   return $gids;
 }
 
-function coherent_access_collaborative_content($uid) {
-  $account = user_load(array('uid' => $uid));
-  drupal_set_title($uid < 0 ? t('Shared Posts') : check_plain($account->name));
+function coherent_access_collaborative_content($u) { // changed to $u less confusing
+// $u is the result of user_load(%user), i.e. a user object here
+//  $account = user_load(array('uid' => $uid));  MN: Not needed!
+
+  $uid = $u->uid;
+  drupal_set_title($uid < 0 ? t('Shared Posts') : 'Shared Posts for ' . check_plain($u->name));
   $content = coherent_access_show_my_nodes(0, $uid);
   if ($content) {
     return $content;
@@ -732,10 +742,11 @@ function theme_node_viewers($node) {
  *  with those being keyed by nid => array('title' => $title, 'type' => $type)
  */
 function coherent_access_get_user_nodes($uid) {
+
   $return = array('mine' => array(), 'editor' => array(), 'viewer' => array());
   
   // load mynodes
-  $result = db_query('SELECT n.nid, n.title, n.type FROM {node} n WHERE uid = %d ORDER BY n.changed DESC', $uid);
+  $result = db_query('SELECT n.nid, n.title, n.type FROM {node} n WHERE n.uid = %d ORDER BY n.changed DESC', $uid);
   while ($row = db_fetch_object($result)) {
     if (_coherent_access_is_coherently_accessible($row)) {
       $return['mine'][$row->nid] = array('title' => $row->title, 'type' => $row->type);
@@ -770,21 +781,19 @@ function coherent_access_get_user_nodes(
 // this function determines if the currently logged in user 
 // or the user with uid=$vuid if $vuid non-zero can access 
 // the shared shared post listing for user $uid
-function coherent_access_access_user_shared_posts($uid, $vuid = 0) {
+
+// MN: note callback only has one argument user_load(%user)
+// removed second argument and simplified code
+function coherent_access_access_user_shared_posts($u) {
   global $user;
-  if ($vuid == 0) {
-    $vuid = $user->uid;
-  }
-  
-  if (is_object($uid)) {
-    $uid = $uid->uid;
-  }
+
+  $vuid = $user->uid;
+  $uid = $u->uid;
   
   // as long as the user is the requesting user or admin, grant access
   if ($vuid == $uid || $vuid == 1) {
     return TRUE;
-  }
-  else {
+  } else {
     return FALSE;
   }
-}
\ No newline at end of file
+}
