= ". TIMEFRAME;
return $sql;
}
function comment_activity_sql() {
$sql = "SELECT c.cid as id
FROM {comments} c
INNER JOIN {node} n ON c.nid = n.nid
WHERE c.timestamp >= ". TIMEFRAME;
return $sql;
}
function flag_friend_activity_sql() {
$sql = "SELECT uid as id, friend_uid as id2
FROM shared_flag_friend
WHERE created >= ". TIMEFRAME;
return $sql;
}
foreach (module_implements('activity_sql') as $module) {
// get the sql for this module
$function = $module .'_activity_sql';
$activity_sql = db_query($function());
// get the activity info for this module
$function = $module .'_activity_info';
$activity_info = $function();
// stupid nodeapi
if ($module == 'node') {
$module = 'nodeapi';
}
// get the trigger information for the system
// NOTE: makes the assumption that there is only one trigger assignment per module
$trigger_result = db_result(db_query("SELECT ta.op
FROM {actions} a
INNER JOIN {trigger_assignments} ta ON ta.aid = a.aid
WHERE a.type = 'activity' AND ta.hook = '%s'", $module));
$count = 0;
while ($result = db_fetch_array($activity_sql)) {
$count++;
$op = $trigger_result;
print $result['id'] .':';
switch ($module) {
case 'nodeapi':
$node = node_load($result['id'], NULL, FALSE);
print $node->nid .', ';
trigger_nodeapi($node, $op, NULL, NULL);
break;
case 'comment':
// works
$a1 = _comment_load($result['id']);
print $a1->cid .', ';
trigger_comment($a1, $op, NULL, NULL);
break;
case 'flag_friend':
$friend = user_load(array('uid' => $result['id2']));
$user = user_load(array('uid' => $result['id']));
print $friend->uid .':'. $user->uid .', ';
flag_friend_flag_friend($op, $friend, $user);
break;
}
}
print '
'. $count .' records inserted for '. $module;
print '