? facebook_status-898886.patch
Index: submodules/fbss_activity/fbss_activity.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/facebook_status/submodules/fbss_activity/Attic/fbss_activity.module,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 fbss_activity.module
--- submodules/fbss_activity/fbss_activity.module	30 Nov 2010 07:20:45 -0000	1.1.2.1
+++ submodules/fbss_activity/fbss_activity.module	19 Dec 2010 19:12:45 -0000
@@ -32,6 +32,8 @@ function fbss_activity_activity_info() {
   $info->objects = array('Owner' => 'facebook_status', 'Poster' => 'poster');
   $info->hooks = array('facebook_status' => array('fbss_deleted', 'fbss_edited', 'fbss_submitted', 'fbss_submitted_other'));
   $info->realms = array('facebook_status_poster' => 'Facebook-style Statuses Poster', 'facebook_status_owner' => 'Facebook-style Statuses Owner');
+  $info->list_callback = 'facebook_status_list_activity_actions';
+  $info->context_load_callback = 'facebook_status_load_activity_context';
   return $info;
 }
 
@@ -70,3 +72,80 @@ function fbss_activity_form_activity_for
     }
   }
 }
+
+/**
+ * List all the Activity Actions that match the hook and op.
+ *
+ * @param $hook
+ *  The hook that is to be fired.
+ * @param $op
+ *  The op to be used in the hook.
+ * @param $max_age
+ *  The max age from right now to list activities.
+ *
+ * @return array
+ *  An array of arrays with 'id', 'created' and 'actor' keys.
+ */
+function facebook_status_list_activity_actions($hook, $op, $max_age) {
+  $actions = array();
+  if (!empty($max_age)) {
+    $min_time = time() - $max_age;
+  }
+  else {
+    $min_time = 0;
+  }
+  
+  if ($op == 'fbss_submitted') {
+     $sql = 'SELECT sid as id, status_time as created, pid as actor FROM {facebook_status} WHERE status_time > %d AND uid = pid';
+  }
+  if ($op == 'fbss_submitted_other') {
+    $sql = 'SELECT sid as id, status_time as created, pid as actor FROM {facebook_status} WHERE status_time > %d AND uid <> pid';
+  }
+
+  if (isset($sql)) {
+    $result = db_query($sql, $min_time);
+    while ($row = db_fetch_array($result)) {
+      $actions[] = $row;
+    }
+  }
+  
+  drupal_alter('facebook_status_list_activity_actions', $actions);
+  return $actions;
+}
+
+/**
+ * Load up the context array to pass to activity_record.
+ *
+ * @param string $hook
+ *  The hook that is being fired.
+ * @param string $op
+ *  The op for that hook.
+ * @param string $id
+ *  The id for the action.
+ *
+ * @return array
+ *   The context array for activity_record.
+ * @see trigger_facebook_status
+ */
+function facebook_status_load_activity_context($hook, $op, $id) {
+  $status = facebook_status_load($id);
+  $context = array();
+  
+  if (!empty($status)) {
+    $owner = user_load($status->uid);
+    $poster = user_load($status->pid);
+    
+    $owner->facebook_status = $status;
+    $poster->facebook_status = $status;
+
+    $context = array(
+      'hook' => $hook,
+      'op' => $op,
+      'owner' => $owner,
+      'poster' => $poster,
+      'facebook_status' => $status,
+    );
+  }
+  
+  return $context;
+}
\ No newline at end of file
