Index: activity.module
===================================================================
retrieving revision 1.1.2.2.2.30.2.42
diff -u -r1.1.2.2.2.30.2.42 activity.module
--- activity.module	27 Apr 2009 01:45:25 -0000	1.1.2.2.2.30.2.42
+++ activity.module	31 Mar 2010 13:08:31 -0000
@@ -602,9 +602,12 @@
  * @param $tablesort_headers
  *   An array that determines the sorting of the result set.
  *
+ * @param $just_with_messages
+ *   Restrict the query to just return those activities which have a message associated.
+ *
  * @todo This should be replaced with views integration. Perhaps in 6.x.
  */
-function activity_get_activity($uids = ACTIVITY_ALL, $filters = NULL, $limit = NULL, $tablesort_headers = NULL) {
+function activity_get_activity($uids = ACTIVITY_ALL, $filters = NULL, $limit = NULL, $tablesort_headers = NULL, $just_with_messages = FALSE) {
 
   $wheres = array();
 
@@ -681,8 +684,12 @@
   // Build the sql and do the query. Wrapping it in db_rewrite_sql allows other
   // modules to impose access restrictions on activity listings.
   $sql = "SELECT activity.*, activity_targets.target_uid, activity_targets.target_role
-    FROM {activity_targets} activity_targets INNER JOIN {activity} activity ON activity.aid = activity_targets.aid
-    $where ";
+    FROM {activity_targets} activity_targets INNER JOIN {activity} activity ON activity.aid = activity_targets.aid";
+  // if we only want rows which have a message to display, we inner-join against the variable table.
+  if($just_with_messages) {
+    $sql .= " INNER JOIN variable variable ON (variable.name = CONCAT(activity.module, '_', activity.type, '_', activity.operation, '_', activity_targets.target_role))";
+  }
+  $sql .= " $where ";
   $tablesort_sql = tablesort_sql($tablesort_headers);
 
   $sql = db_rewrite_sql("$sql $tablesort_sql", 'activity_targets', 'aid', array('uids' => $uids));
@@ -874,7 +881,7 @@
   drupal_add_css(drupal_get_path('module', 'activity') .'/activity.css');
 
   if ($page == 'mine') {
-    $activities = activity_get_activity($user->uid, NULL, variable_get('activity_page_pager', 20));
+    $activities = activity_get_activity($user->uid, NULL, variable_get('activity_page_pager', 20), NULL, TRUE);
     $table = theme('activity_table', $activities);
     $feed_url = url('activity/'. $user->uid .'/feed');
     drupal_add_feed($feed_url);
@@ -882,7 +889,7 @@
     return theme('activity_page', $activities, $table);
   }
   else if ($page == 'all') {
-    $activities = activity_get_activity(ACTIVITY_ALL, NULL, variable_get('activity_page_pager', 20));
+    $activities = activity_get_activity(ACTIVITY_ALL, NULL, variable_get('activity_page_pager', 20), NULL, TRUE);
     $table = theme('activity_table', $activities);
     $feed_url = url('activity/all/feed');
     drupal_add_feed($feed_url);
