? feb8th.patch
? usercomment-activity.patch
? whatsup.patch
Index: usercomment.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/usercomment/usercomment.module,v
retrieving revision 1.5.4.9
diff -u -p -r1.5.4.9 usercomment.module
--- usercomment.module	28 Dec 2010 01:04:17 -0000	1.5.4.9
+++ usercomment.module	14 Feb 2011 17:48:24 -0000
@@ -397,13 +397,13 @@ function usercomment_approve($cid) {
         '@node_owner' => $node->name,
         '@subject'    => $comment->subject,
       ));
+    }
+    drupal_set_message($status_msg);
   }
 
   // Invoke the comment approval trigger
-  module_invoke_all('usercomment', 'usercomment_approval', $user);
+  module_invoke_all('usercomment', 'usercomment_approval', $comment, $user);
 
-  drupal_set_message($status_msg);
-  }
   drupal_goto('node/'. $node->nid);
 }
 
@@ -601,9 +601,7 @@ function theme_usercomment_empty() {
 }
 
 /**
-* The following two functions provide integration with trigger module
-*
-* Implementation of hook_hook_info() and hook_trigger_name()
+* Implementation of hook_hook_info() for integration with trigger module.
 */
 function usercomment_hook_info() {
   return array(
@@ -617,15 +615,72 @@ function usercomment_hook_info() {
   );
 }
 
-function usercomment_trigger_name($op, $user) {
+/**
+* Implementation of hook_trigger_name() for integration with trigger module.
+*/
+function usercomment_usercomment($op, $comment, $user) {
   if (!in_array($op, array('usercomment_approval'))) {
     return;
   }
-  $aids = _trigger_get_hook_aids('usercomment', $op);
-  $context = array(
-    'hook' => 'usercomment',
-    'op' => $op,
-    'approver' => $user,
-  );
-  actions_do(array_keys($aids), $user, $context);
+  if (module_exists('trigger')) {
+    $aids = _trigger_get_hook_aids('usercomment', $op);
+
+    $context = array(
+      'hook' => 'usercomment',
+      'op' => $op,
+      'comment' => $comment,
+      'author' => user_load(array('uid' => $comment->uid)),
+      'user' => $user,
+    );
+    actions_do(array_keys($aids), $comment, $context);
+  }
+}
+
+/******************************
+*   Activity2 integration.
+*******************************/
+
+/**
+* Implementation of hook_activity_info().
+*/
+function usercomment_activity_info() {
+  $info = new stdClass();
+  $info->api = 2;
+  $info->name = 'usercomment';
+  $info->object_type = 'comment';
+  $info->eid_field = 'cid';
+  $info->objects = array('comment author' => 'author', 'approving user' => 'user');
+  $info->hooks = array('usercomment' => array('usercomment_approval'));
+  $info->realms = array('usercomment_author' => 'The author of the comment');
+
+  return $info;
+}
+
+/**
+* Implementation of hook_activity_grants().
+*/
+function usercomment_activity_grants($activity) {
+  if ($activity->type == 'usercomment') {
+    $result = db_fetch_object(db_query("SELECT uid FROM {comments} WHERE cid = %d", $activity->eid));
+    return array(
+      'usercomment_author' => array($result->uid),
+    );
+  }
+}
+
+/**
+* Implementation of hook_activity_access_grants().
+*/
+function usercomment_activity_access_grants($account) {
+  return array('usercomment_author' => array($account->uid));
+}
+
+/**
+ * Implementation of hook_activity_objects_alter().
+ */
+function usercomment_activity_objects_alter(&$token_objects, $activity_type) {
+  if ($activity_type == 'usercomment') {
+    $token_objects['node'] = node_load($token_objects['comment']->nid);
+    $token_objects['user'] = user_load(array('uid' => $token_objects['comment']->uid));
+  }
 }
