Common subdirectories: workspace_old/po and workspace_new/po
diff -up workspace_old/workspace.info workspace_new/workspace.info
--- workspace_old/workspace.info	2007-11-05 17:12:36.000000000 -0700
+++ workspace_new/workspace.info	2008-03-05 18:53:20.000000000 -0700
@@ -1,9 +1,3 @@
-; $Id: workspace.info,v 1.1.2.1 2007/06/18 23:07:16 dww Exp $
+; $Id$
 name = Workspace
-description = Allows users to list/manage their own content.
-
-; Information added by drupal.org packaging script on 2007-11-06
-version = "5.x-1.x-dev"
-project = "workspace"
-datestamp = "1194307956"
-
+description = Allows users to list/manage their own content.
\ No newline at end of file
diff -up workspace_old/workspace.module workspace_new/workspace.module
--- workspace_old/workspace.module	2007-11-05 07:46:12.000000000 -0700
+++ workspace_new/workspace.module	2008-03-09 12:47:37.640625000 -0600
@@ -11,7 +11,7 @@
 */
 function workspace_help($section) {
   switch ($section) {
-    case 'admin/modules#description':
+    case 'admin/help#workspace':
       return t('For individual users to manage their workspace');
   }
 }
@@ -29,14 +29,29 @@ function workspace_menu($may_cache) {
     $items[] = array(
       'path' => 'workspace',
       'title' => t('My workspace'),
-      'callback' => 'workspace_admin',
+      'callback' => 'workspace_node_list',
       'access' => $access);
 
     $items[] = array(
-      'path' => 'workspace/list',
-      'title' => t('List'),
+      'path' => 'workspace/nodes',
+      'title' => t('Items'),
+      'callback' => 'workspace_node_list',
       'type' => MENU_DEFAULT_LOCAL_TASK,
       'weight' => -10);
+    
+    $items[] = array(
+      'path' => 'workspace/comments',
+      'title' => t('Comments'),
+      'callback' => 'workspace_comment_list',
+      'type' => MENU_LOCAL_TASK,
+      'weight' => -9);
+    
+    $items[] = array(
+      'path' => 'workspace/files',
+      'title' => t('Attachments'),
+      'callback' => 'workspace_file_list',
+      'type' => MENU_LOCAL_TASK,
+      'weight' => -8);
 
     $items[] = array(
       'path' => 'workspace/configure',
@@ -81,14 +96,14 @@ function workspace_admin() {
         $options[$type] = $typeobject->name;
       }
       if (isset($options[$node_type])) {
-        drupal_goto('node/add/' . $node_type);
+        drupal_goto('node/add/'. $node_type);
       }
     }
   }
 
-  $title = t('Workspace') . ' : ' . $user->name;
+  $title = t('Workspace') .' : '. $user->name;
   drupal_set_title($title);
-  $output = workspace_list();
+  //$output = workspace_list();
   return $output;
 }
 
@@ -102,14 +117,21 @@ function workspace_configure_form() {
     '#type' => 'textfield',
     '#title' => t('Number of items'),
     '#description' => t('Maximum number of items to display in your workspace.'),
-    '#default_value' => $user->workspaces ? $user->workspaces['default']['maxnodes'] : 50,
+    '#default_value' => $user->workspaces ? $user->workspaces['default']['maxnodes'] : 10,
+    '#size' => 4
+  );
+  $form['maxcomments'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Number of comments'),
+    '#description' => t('Maximum number of comments to display in your workspace.'),
+    '#default_value' => $user->workspaces ? $user->workspaces['default']['maxcomments'] : 10,
     '#size' => 4
   );
   $form['maxfilenames'] = array(
     '#type' => 'textfield',
     '#title' => t('Number of files'),
     '#description' => t('Maximum number of filenames to display in your workspace.'),
-    '#default_value' => $user->workspaces ? $user->workspaces['default']['maxfilenames'] : 50,
+    '#default_value' => $user->workspaces ? $user->workspaces['default']['maxfilenames'] : 10,
     '#size' => 4
   );
   $form['submit'] = array(
@@ -120,8 +142,10 @@ function workspace_configure_form() {
 }
 
 function workspace_configure() {
+  global $user;
   $output = drupal_get_form('workspace_configure_form');
-  drupal_set_title(t('Workspace : %username', array('%username' => $user->name)));
+  $title = t('Workspace') .' : '. $user->name;
+  drupal_set_title($title);
   return $output;
 }
 
@@ -129,6 +153,9 @@ function workspace_configure_form_valida
   if (!is_numeric($edit['maxnodes'])) {
     form_set_error('maxnodes', t('Please enter a numeric value.'));
   }
+  if (!is_numeric($edit['maxcomments'])) {
+    form_set_error('maxcomments', t('Please enter a numeric value.'));
+  }
   if (!is_numeric($edit['maxfilenames']) && !form_get_errors()) {
     form_set_error('maxfilenames', t('Please enter a numeric value.'));
   }
@@ -141,6 +168,7 @@ function workspace_configure_form_submit
     $user->workspaces = array();
   }
   $user->workspaces['default']['maxnodes'] = (int) $edit['maxnodes'];
+  $user->workspaces['default']['maxcomments'] = (int) $edit['maxcomments'];
   $user->workspaces['default']['maxfilenames'] = (int) $edit['maxfilenames'];
   user_save($user, array('workspaces' => $user->workspaces));
   drupal_set_message(t('Your workspace preferences have been saved.'));
@@ -152,24 +180,22 @@ function workspace_configure_form_submit
 ********************************************************************/
 
 /**
-* The default admin interface is a list of content.
+* The default workspace is a list of nodes.
 */
-function workspace_list() {
+function workspace_node_list() {
   global $user;
-  $maxnodes = $user->workspaces ? $user->workspaces['default']['maxnodes'] : 50;
-  $maxfilenames = $user->workspaces ? $user->workspaces['default']['maxfilenames'] : 50;
+  $maxnodes = $user->workspaces ? $user->workspaces['default']['maxnodes'] : 10;
   if (!is_numeric($maxnodes)) {
-    $maxnodes = 50;
-  }
-  if (!is_numeric($maxfilenames)) {
-    $maxfilenames = 50;
+    $maxnodes = 10;
   }
 
   $comments_enabled = module_exists('comment');
   $nodeperm_role_enabled = module_exists('nodeperm_role');
   $flexinode_enabled = module_exists('flexinode');
   $cck_enabled = module_exists('content');
-  $output = _workspace_addform();
+  
+  $output = workspace_admin();
+  $output .= _workspace_addform();
 
   $node_select = array('n.nid', 'n.uid', 'n.type', '0 AS cid', 'n.title', 'n.status', 'n.changed', 's.comment_count', '1 AS node');
   $node_from = array('{node} n');
@@ -186,18 +212,7 @@ function workspace_list() {
   $sql = 'SELECT '. implode(', ', $node_select) .' FROM '. implode(', ', $node_from) .' '. implode(' ', $node_join) .' WHERE '. implode(' ', $node_where);
   $count_sql = 'SELECT COUNT(n.nid) FROM '. implode(', ', $node_from) .' '. implode(' ', $node_join) .' WHERE '. implode(' ', $node_where);
 
-  if ($comments_enabled) {
-    $select = '';
-    if ($nodeperm_role_enabled) {
-      // Need to add placeholders for columns to avoid misaligning our union clause.
-      $select = ", '' AS grant_update, '' AS grant_delete";
-    }
-    $comment_sql = 'SELECT c.nid AS cnid, c.uid, "" AS type, c.cid, c.subject, c.status, c.timestamp, c.pid, 0 '. $select .' FROM {comments} AS c, {node} n LEFT JOIN {node_comment_statistics} s ON n.nid = s.nid WHERE c.uid = '. db_escape_string($user->uid);
-    $sql .= ' UNION '. $comment_sql;
-    $count_sql = 'SELECT COUNT(n.nid) + COUNT(c.cid) FROM '. implode(', ', $node_from) .' '. implode(' ', $node_join) .' LEFT JOIN {comments} AS c ON c.uid = '. db_escape_string($user->uid). ' WHERE '. implode(' ', $node_where);
-  }
-
-   // Build the combined node/comment listing.
+   // Build the node listing.
   $header = array(
     array('data' => t('Type'), 'field' => 'type'),
     array('data' => t('Title'), 'field' => 'title'),
@@ -223,13 +238,14 @@ function workspace_list() {
       $can_delete = FALSE;
 
       //Check the node type's access hook.
-      $function = $row->type. '_access';
+      $function = $row->type .'_access';
       if ($flexinode_enabled && strstr($function, 'flexinode-')) {
         $function = 'flexinode_access';
       }
       elseif ($cck_enabled && strstr($function, 'content_')) {
         $function = 'content_access';
-      } else {
+      }
+      else {
         $function = 'node_access';
       }
 
@@ -255,22 +271,81 @@ function workspace_list() {
         $can_delete ? l(t('delete'), "workspace/delete/$row->nid") : ''
         );
     }
-    else {
-      // It's a comment.
-      $num_replies = comment_num_replies($row->cid);
-      $comment->cid = $row->cid;
-      $comment->nid = $row->nid;
-
-      // Delegate access permission checks and link generation to comments.module.
-      $com_links = comment_links($comment, 0);
-      $link = l(t('edit'), "comment/edit/$comment->cid");
-      $edit_link = $com_links['comment_edit'] ? $link : '';
+  }
+
+  if ($rows) {
+    $pager = theme('pager', NULL, $maxnodes, 0);
+    if (!empty($pager)) {
+      $rows[] = array(array('data' => $pager, 'colspan' => 8));
+    }
+    $output .= theme('table', $header, $rows);
+  }
+  else {
+    $output .= t('Your item list is currently empty.');
+  }
+
+  return $output;
+}
+
+/**
+* The list of comments.
+*/
+function workspace_comment_list() {
+  global $user;
+  
+  $maxcomments = $user->workspaces ? $user->workspaces['default']['maxcomments'] : 10;
+  if (!is_numeric($maxcomments)) {
+    $maxcomments = 10;
+  }
 
-      $link = l(t('delete'), "comment/delete/$comment->cid");
-      $delete_link = $com_links['comment_delete'] ? $link : '';
+  $comments_enabled = module_exists('comment');
+  $nodeperm_role_enabled = module_exists('nodeperm_role');
+  $flexinode_enabled = module_exists('flexinode');
+  $cck_enabled = module_exists('content');
+  
+  $output = workspace_admin();
+  $output = _workspace_addform();
 
-      $rows[] = array(t('comment'), l($row->title, "node/$row->nid", array(), NULL, "comment-$row->cid", FALSE, TRUE), $user->name, $row->status ? $no : $yes, format_date($row->changed, 'small'), array('data' => $num_replies, 'align' => 'right'), $edit_link, $delete_link);
+  if ($comments_enabled) {
+    $select = '';
+    if ($nodeperm_role_enabled) {
+      // Need to add placeholders for columns to avoid misaligning our union clause.
+      $select = ", '' AS grant_update, '' AS grant_delete";
     }
+    $sql = 'SELECT * FROM {comments} c WHERE c.uid = '. db_escape_string($user->uid);
+    $count_sql = 'SELECT COUNT(c.cid) FROM {comments} c WHERE c.uid = '. db_escape_string($user->uid);
+  }
+
+   // Build the comment listing.
+  $header = array(
+    array('data' => t('Type')),
+    array('data' => t('Title'), 'field' => 'subject'),
+    array('data' => t('Owner'), 'field' => 'uid'),
+    array('data' => t('Published'), 'field' => 'status'),
+    array('data' => t('Modified'), 'field' => 'timestamp', 'sort' => 'desc'),
+    array('data' => t('Operations'), 'colspan' => 2)
+  );
+
+  $result = pager_query($sql . tablesort_sql($header), $maxcomments, 0, $count_sql);
+
+  $yes = t('yes');
+  $no = t('no');
+
+  while ($row = db_fetch_object($result)) {
+    // It's a comment.
+    $num_replies = comment_num_replies($row->cid);
+    $comment->cid = $row->cid;
+    $comment->nid = $row->nid;
+
+    // Delegate access permission checks and link generation to comments.module.
+    $com_links = comment_links($comment, 0);
+    
+    $link = l(t('edit'), "comment/edit/$comment->cid");
+    $edit_link = $com_links['comment_edit'] ? $link : '';
+    $link = l(t('delete'), "comment/delete/$comment->cid");
+    $delete_link = $com_links['comment_delete'] ? $link : '';
+
+    $rows[] = array(t('comment'), l($row->subject, "node/$row->nid", array(), NULL, "comment-$row->cid", FALSE, TRUE), $user->name, $row->status ? $no : $yes, format_date($row->timestamp, 'small'), $edit_link, $delete_link);
   }
 
   if ($rows) {
@@ -281,8 +356,42 @@ function workspace_list() {
     $output .= theme('table', $header, $rows);
   }
   else {
-    $output .= t('Your workspace is currently empty.');
+    $output .= t('Your comment list is currently empty.');
+  }
+
+  return $output;
+}
+
+/**
+* The list of files.
+*/
+function workspace_file_list() {
+  global $user;
+  $maxfilenames = $user->workspaces ? $user->workspaces['default']['maxfilenames'] : 10;
+  if (!is_numeric($maxfilenames)) {
+    $maxfilenames = 10;
   }
+  
+  $output = workspace_admin();
+  $output = _workspace_addform();
+
+  $node_select = array('n.nid', 'n.uid', 'n.type', '0 AS cid', 'n.title', 'n.status', 'n.changed', 's.comment_count', '1 AS node');
+  $node_from = array('{node} n');
+  $node_join = array('LEFT JOIN {node_comment_statistics} s ON n.nid = s.nid');
+  $node_where = array('n.uid = '. db_escape_string($user->uid));
+
+  if ($nodeperm_role_enabled) {
+    $node_select[] = 'na.grant_update';
+    $node_select[] = 'na.grant_delete';
+    $node_join[] = 'LEFT JOIN node_access na ON n.nid = na.nid';
+    $node_where[] = 'OR (na.realm = "nodeperm_role" AND na.grant_view = 1 AND na.gid IN('. db_escape_string(implode(',', array_flip($user->roles))) .'))';
+  }
+
+  $sql = 'SELECT '. implode(', ', $node_select) .' FROM '. implode(', ', $node_from) .' '. implode(' ', $node_join) .' WHERE '. implode(' ', $node_where);
+  $count_sql = 'SELECT COUNT(n.nid) FROM '. implode(', ', $node_from) .' '. implode(' ', $node_join) .' WHERE '. implode(' ', $node_where);
+
+  $yes = t('yes');
+  $no = t('no');
 
   // Build the attachment listing.
   $rows = array();
@@ -297,16 +406,17 @@ function workspace_list() {
   while ($row = db_fetch_object($result)) {
         $rows[] = array($row->filemime, l($row->filename, "node/$row->nid"), format_size($row->filesize));
   }
-
+  
   if ($rows) {
-    $output .= '<h3>' . t('Files') . '</h3>';
-    $pager = theme('pager', NULL, $maxfilenames, 2);
+    $pager = theme('pager', NULL, $maxfilenames, 0);
     if (!empty($pager)) {
-      $rows[] = array(array('data' => $pager, 'colspan' => 3));
+      $rows[] = array(array('data' => $pager, 'colspan' => 8));
     }
-
     $output .= theme('table', $header, $rows);
   }
+  else {
+    $output .= t('Your attachment list is currently empty.');
+  }
 
   return $output;
 }
@@ -317,7 +427,7 @@ function workspace_list() {
 function workspace_delete() {
   $nid = intval(arg(2));
   if (is_numeric($nid)) {
-    drupal_goto('node/' . $nid . '/delete');
+    drupal_goto('node/'. $nid .'/delete');
   }
 }
 
@@ -327,7 +437,7 @@ function workspace_delete() {
 
 function workspace_form() {
   global $user;
-  $description = t('Choose what kind of content you would like to add.') . ' [' . l(t('help'), 'node/add') . ']';
+  $description = t('Choose what kind of content you would like to add.') .' ['. l(t('help'), 'node/add') .']';
   $select = t('Select...');
   $options = array($select => $select);
   foreach (node_get_types() as $type => $typeobject) {
@@ -354,6 +464,6 @@ function _workspace_addform() {
   $form = workspace_form();
   $submit = drupal_render($form['submit']);
   $output = preg_replace("/<input.*type=\"submit\".*>/U", '', $output);
-  $output = str_replace('</select>', '</select>&nbsp;' . $submit, $output);
+  $output = str_replace('</select>', '</select>&nbsp;'. $submit, $output);
   return $output;
 }
\ No newline at end of file
