Index: activity.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/activity/activity.module,v
retrieving revision 1.1.2.2.2.30.2.31
diff -b -u -p -r1.1.2.2.2.30.2.31 activity.module
--- activity.module	5 Mar 2009 04:38:11 -0000	1.1.2.2.2.30.2.31
+++ activity.module	6 Mar 2009 22:33:43 -0000
@@ -14,7 +14,7 @@ define('ACTIVITY_ALL', -1);
  * Implementation of hook_perm().
  */
 function activity_perm() {
-  return array('administer activity', 'delete activity', 'view own activity', 'view public activity');
+  return array('administer activity', 'delete activity', 'view own activity', 'view public activity', 'view activity comments', 'create activity comments');
 }
 
 /**
@@ -638,8 +638,11 @@ function activity_get_activity($uids = A
     $row['data']['operation'] 	= ($row['data']['operation'] ? $row['data']['operation'] : $row['operation']);
     $row['data']['created'] 	= $row['created'];
 
-    // Load Activity comments
+    // Load Activity comments if user can view comments
+    // Use a permissions check here to save comment loading if user cannot view
+    if (user_access('view activity comments')) {
     $row['comments'] = activity_comments_load($row['aid']);
+    }
 
     // Invoke activityapi
     activity_invoke_activityapi($row, 'load');
@@ -1228,9 +1231,9 @@ function theme_activity($message, $item)
   $output = $item['mark'] .'<span class="activity activity-module-'. $item['module'] .' activity-type-'. $item['type'] .' activity-operation-'. $item['operation'] .'">'. $message .'</span>';
   $output .= '<span class="activity-links">';
 
-  // If logged in user, then show link to add a comment to the activity record. 
+  // If user has permission to create an activity comment then show link to add comment
   // Click here displays the activity comment form.
-  if (!user_is_anonymous()) {
+  if (user_access('create activity comment')) {
     // Also note that the js looks for this specific class name 'activity-comments-click-to-show', so don't remove it
     $output .= '&nbsp;&ndash;&nbsp;<span class="activity-comments-click-to-show">'. t('Comment') .'</span>';
   }
@@ -1242,14 +1245,15 @@ function theme_activity($message, $item)
 
   $output .= '</span>';
 
-  if (!user_is_anonymous()) {
+  if (user_access('create activity comment')) {
     $output .= '<div class="activity-comments-form-hidden clear-block">'. drupal_get_form('activity_comment_form', $item['aid']) .'</div>';
   }
 
+  if ($item['comments']) {
   $comments = theme('activity_comments', $item['comments']);
-  if ($comments) {
     $output .= theme('item_list', $comments, NULL, 'ul', array('class' => 'activity-comments-list'));
   }
+   
   return $output;
 }
 
