--- workspace.module.org	2009-07-13 18:17:17.000000000 +0100
+++ workspace.module	2009-07-15 09:17:27.000000000 +0100
@@ -164,6 +164,15 @@
     '#default_value' => $account->workspaces ? $account->workspaces['default']['maxfilenames'] : 50,
     '#size' => 4
   );
+  if ( module_exists('comment') ) {
+    $form['maxcomments'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Number of comments'),
+      '#description' => t('Maximum number of comments to display in your workspace.'),
+      '#default_value' => $account->workspaces['default']['maxcomments'] ? $account->workspaces['default']['maxcomments'] : 50,
+      '#size' => 4
+    );
+  }
   $form['uid'] = array(
     '#type' => 'value',
     '#value' => $account->uid,
@@ -187,6 +196,11 @@
   if (!is_numeric($form_state['values']['maxfilenames']) && !form_get_errors()) {
     form_set_error('maxfilenames', t('Please enter a numeric value.'));
   }
+  if ( module_exists('comment') ) {
+    if (!is_numeric($form_state['values']['maxcomments']) && !form_get_errors()) {
+      form_set_error('maxfilenames', t('Please enter a numeric value.'));
+    }
+  }
 }

 /**
@@ -202,6 +216,9 @@
   }
   $account->workspaces['default']['maxnodes'] = (int)$form_state['values']['maxnodes'];
   $account->workspaces['default']['maxfilenames'] = (int)$form_state['values']['maxfilenames'];
+  if ( module_exists('comment') ) {
+    $account->workspaces['default']['maxcomments'] = (int)$form_state['values']['maxcomments'];
+  }
   user_save($account, array('workspaces' => $account->workspaces));
   drupal_set_message(t('The workspace preferences have been saved.'));
   $form_state['redirect'] = 'workspace/'. $form_state['values']['uid'];
@@ -228,6 +245,15 @@
             FROM {node} n
             LEFT JOIN {node_comment_statistics} s ON n.nid = s.nid
             WHERE n.uid = %d';
+    $header = array(
+      array('data' => t('Type'), 'field' => 'type'),
+      array('data' => t('Title'), 'field' => 'title'),
+      array('data' => t('Owner'), 'field' => 'uid'),
+      array('data' => t('Published'), 'field' => 'status'),
+      array('data' => t('Modified'), 'field' => 'changed', 'sort' => 'desc'),
+      array('data' => t('Replies'), 'field' => 'comment_count'),
+      array('data' => t('Operations'), 'colspan' => 2)
+    );
   }
   else {
     // Otherwise we use a simpler query.
@@ -237,17 +263,16 @@
     $count_sql = 'SELECT COUNT(n.nid)
             FROM {node} n
             WHERE n.uid = %d';
-  }
-
   $header = array(
     array('data' => t('Type'), 'field' => 'type'),
     array('data' => t('Title'), 'field' => 'title'),
     array('data' => t('Owner'), 'field' => 'uid'),
     array('data' => t('Published'), 'field' => 'status'),
     array('data' => t('Modified'), 'field' => 'changed', 'sort' => 'desc'),
-    $comments_enabled ? array('data' => t('Replies'), 'field' => 'comment_count') : array('data' => ''),
     array('data' => t('Operations'), 'colspan' => 2)
   );
+  }
+
   $cols = 8;
   $result = pager_query(db_rewrite_sql($sql . tablesort_sql($header)), $max, 0, db_rewrite_sql($count_sql), $account->uid);
   $rows = workspace_build_rows($result, $account);
@@ -257,7 +282,7 @@
     $output = drupal_get_form('workspace_add_form');
   }

-  $output .= theme_workspace_list($header, $rows, $max, $cols);
+  $output .= theme('workspace_list', $header, $rows, $max, $cols);
   return $output;
 }

@@ -288,7 +313,7 @@
   $cols = 6;
   $result = pager_query($sql . tablesort_sql($header), $max, 0, $count_sql, $account->uid);
   $rows = workspace_build_rows($result, $account);
-  return theme_workspace_list($header, $rows, $max, $cols);
+  return theme('workspace_list', $header, $rows, $max, $cols);
 }

 /**
