I'm a maintainer of the User Comment module, and in the process of adding integration with activity. Usercomment allows users to approve comments on their own nodes, and I've created a trigger to run when a comment is approved.

So far I've been able to get activity to notice the trigger and record the message, but there are no tokens listed as available in the template edit screen. The strange thing is that I'm able to use tokens like [activity-comment-author-link] and [user], but they're not listed for the site builder.

I'm wondering if anyone really familiar with Activity can give me any pointers? Attached is a copy of Usercomment with the unfinished activity integration patch already applied. The functions for trigger and activity integration are at the bottom of usercomment.module. Thanks in advance to anyone who can help!

CommentFileSizeAuthor
usercomment-DRUPAL-6--2.tar_.gz6.89 KBrschwab

Comments

rschwab’s picture

oops, here is the correct url http://drupal.org/project/usercomment

:\

Scott Reynolds’s picture

The token issue is related to the types handled to theme_activity_token_help in activity.module.

Figure out how that is working and you should be able to solve it.

pribeh’s picture

This is great. I already use user comments rschwab. Thanks for attempting integration.

rschwab’s picture

Thank you Scott! With your help I've got the tokens showing up correctly, and all is working... with one exception: The message for the comment author doesn't show - they see the public message instead. The database is showing the correct uid for my realm (usercomment_author), but no message. In the activity_messages table the message isn't recorded for the author, just the approving user and public messages.

I'm not sure what I'm messing up, but if I figure it out I'll post here. Here is the code so far:

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 owner' => 'comment', 'approving user' => 'user');
  $info->hooks = array('usercomment' => array('usercomment_approval'));
  $info->realms = array('usercomment_author' => 'The author of the comment');

  return $info;
}

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),
    );
  }
}

function usercomment_activity_access_grants($account) {
  return array('usercomment_author' => array($account->uid));
}

And for reference, $context in my trigger is:

$context = array(
      'hook' => 'usercomment',
      'op' => $op,
      'comment' => $comment,
      'author' => user_load(array('uid' => $comment->uid)),
      'user' => $user,
    );
Scott Reynolds’s picture

Add into your objects the 'author'

$info->objects = array('comment owner' => 'comment', 'approving user' => 'user', 'Author' => 'author');
rschwab’s picture

Status: Active » Fixed

Thanks again Scott! With your help usercomment is now working with activity.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.