I've been working on this for ages now and can't seem to get it to work.

The TagUser module has hooks that do work as I set up a basic action to occur when a user is tagged.

I have added the below code to the taguser.module file:

function taguser_activity_info() {
dsm("taguser_activity_info");
dsm(func_get_args());

$info = new stdClass();
$info->api = 2;
$info->name = 'taguser';
$info->object_type = 'taguser';
$info->objects = array(
'user who was tagged' => 'tagged uid',
'user who tagged them' => 'tagged by uid',
'node' => 'node',
);
$info->hooks = array('taguser' => array('user tagged', 'user tagged self'));
$info->realms = array('user tagged' => 'After a user is tagged in content by another user.', 'user tagged self' => 'After a user has tagged themselves in content.');
// $info->type_options = array();
$info->eid_field = 'tuid';

return $info;
}

function taguser_activity_objects_alter(&$token_objects, $activity_type) {
dsm("taguser_activity_objects_alter");
dsm(func_get_args());
}

function taguser_activity_grants($activity) {
dsm('taguser_activity_grants');
dsm($activity);
}

function taguser_activity_access_grants($account) {
dsm('taguser_activitry_access_grqantgs');
dsm($account);
}

function taguser_activity_record_alter(&$record, $context) {
dsm('taguser_activity_record_alter');
dsm($record);
dsm($context);
}

function taguser_activity_message_recorded($record, $context) {
dsm('taguser_activity_message_recorded');
dsm(func_get_args());
}

function taguser_activity_type_check($token_objects, $types) {
dsm('taguser_activity_type_check');
dsm(func_get_args());
}

and only the activity_info() function is ever called.

I can setup an 'activity publisher template' for the available hooks but no activity message is ever recorded (not surprising as none of the other functions are ever being called).

Is there something obvious i'm missing?

Comments

Scott Reynolds’s picture

Yep, so Activity's event system is Trigger. So you need to write a trigger implementation

Documentation: http://drupal.org/node/375833

When you create an issue with TagUser please use the tag activity2-integration so I can find it and do a review as well.

adam_c’s picture

I already have triggers that work (with other actions).

My problem is that those triggers do not call the activity actions.

The triggers are declared as such:

/**
* Implementation of hook_hook_info() to expose module's triggers.
*
* @return An array of trigger hook information for the module.
*/
function taguser_hook_info() {
$hooks = array();

$hooks['user tagged'] = array(
'runs when' => t('After a user is tagged in content by another user.'),
);

$hooks['user tagged self'] = array(
'runs when' => t('After a user is tags themselves in content.'),
);

$hooks['user untagged self'] = array(
'runs when' => t('After a user is untags themselves from content.'),
);

return array('taguser' => array('taguser' => $hooks));
}

I then created a very simple test action to make sure they were being triggered with the below:

function taguser_action_info(){

dsm(func_get_args());
$info['taguser_beep_action'] = array(
/'type' => 'comment',
'description' => t('Beep annoyingly'),
'configurable' => FALSE,
'hooks' => array(
'taguser' => array('user tagged', 'user tagged self'),
'any' => TRUE,
),
);
dsm("taguser_action_info");
print_r($info);
return $info;
}

function taguser_beep_action(){
watchdog('beep', 'Beep!');
}

And the action occured as expected.

I will be more than happy to post the results of this to the taguser page (when I get it to work!).

thanks

Scott Reynolds’s picture

So most of those hooks should be fired for ANY activity. So make sure that is happening. It it isn't that means the names of the functions are wrong

For instance, hook_activity_record_alter() is called via drupal_alter(). So if an activity any activity is recorded and that hook isn't called, you have named them wrong or the file those functions are in have not been included for this page.

adam_c’s picture

I can confirm that when a different activity is triggered (facebook status update) the above functions in the taguser module are called so they aren't spelt wrong.

Scott Reynolds’s picture

Then it probably has to do with these lines at the top of activity_record() function

  // find what the type is so we can do the tokenizing
  $activity_object = FALSE;
  foreach (activity_get_module_info() as $module => $info) {
    if (in_array($context['hook'], array_keys($info->hooks))) {
      // we found the activity we wanted
      $activity_object = $info;
      break;
    }
  }

  if (!$activity_object) {
    // not a valid trigger
    return;
  }
adam_c’s picture

Seem to be getting closer to the problem.

If I empty the cache and then trigger a different activity event (add comment). I can see that activity_record is called and then in activity_get_module_info, it does find and load the taguser info object into the array but as this is a comment trigger, only the comment activity is recorded.

If I clear the cache again and attempt to use a taguser trigger (tag someone), the activity_record function is not called and neither is activity_get_module_info.

So what is it that calls activity_record?

Scott Reynolds’s picture

actions_do() calls activity_record.

adam_c’s picture

I am offering a bounty to anyone who can create a sucessful patch for this (and/or a couple of other issues). Please see: http://drupal.org/node/804434 for more info.

sirkitree’s picture

Status: Active » Postponed (maintainer needs more info)

This has been open since May. Can you provide an update for us @adam_c?

3dloco’s picture

+1

pribeh’s picture

subscribing.

adam_c’s picture

Still no further.

The activity api was just too complex for me to figure it out and i've had more pressing matters since then. Hopefully one day ill figure it out.

_shy’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

D6 reached its EOL back in February 2016, and there is no active release for D6 for this module anymore.
Development or support is not planned for D6. All D6-related issues are marked as outdated in a bunch.

If the issue remains relevant for D10+ versions, merge requests with proposed solutions for a new module version (D10+) are welcome in a new follow-up issue.

Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.