Closed (fixed)
Project:
Activity
Version:
6.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
23 Feb 2010 at 11:38 UTC
Updated:
10 Mar 2010 at 14:40 UTC
I´m trying to create a custom integration with a module that keeps track of visiting records from an external database.
It seems to work just fine when I pass a certain node through the trigger, the node is recorded in the activity but the user object seems to get ignored. I'm curious what I'm doing wrong here. Whatever I seem to try, the UID is 1 in the DB record (has it something to do with the fact that the activity records are being added during a cron job?)
To clarify things, here is my code, why is the $user argument not being passed when the trigger is called?
<?php
function x_visitorhistory_x_visitorhistory($op,$user,$node) {
if (function_exists('_trigger_get_hook_aids')) {
$aids = _trigger_get_hook_aids('x_visitorhistory', $op);
switch ($op) {
case 'insert':
$context = array(
'hook' => 'x_visitorhistory',
'op' => $op,
'user' => $user,
'node' => $node,
);
break;
}
if ($aids) {
actions_do(array_keys($aids), $user, $context);
}
}
}
function x_visitorhistory_activity_info() {
$info = new stdClass();
$info->api = 2;
$info->name = 'x_visitorhistory';
$info->object_type = 'x_visitorhistory';
$info->objects = array('user' => 'user'); // array keys are the labels
$info->hooks = array('x_visitorhistory' => array('insert'));
$info->realms = array('x_visitorhistory' => 'X Visitor History');
return $info;
}
?>
Comments
Comment #1
Scott Reynolds commentedI believe that the user object is being used for the tokens (so if you have the token [user] it is based on the $user object) but when the activity is recorded to the database it has uid of the person running cron. If this is correct it is because of this set of lines around 516 of activity.module
So what that means is that in the context, it expects an object 'x_vistorhistory' that has a uid on it.
My suggestion is to change the $info->object_type = 'user', so this code for your activity_info. As the 'type' of activity is 'user'.
Comment #2
eelke commentedThanks so much for your quick response, your suggestion solved it!