= ". 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 {flag_friend} WHERE created >= ". TIMEFRAME; return $sql; } function rsvp_activity_sql() { $sql = "SELECT uid as id FROM {rsvp_guest_list} WHERE rsvp_time >= ". 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': /** * Note that this requires you to comment out line 223 in trigger.module * where is caches the $op and (pet peeve) doesn't allow you to reset * that cache. */ $node = node_load($result['id'], NULL, FALSE); print '*node*'. $node->nid .', '; trigger_nodeapi($node, $op, NULL, NULL); break; case 'comment': // works $a1 = _comment_load($result['id']); print '*comment*'. $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*'. $friend->uid .':'. $user->uid .', '; flag_friend_flag_friend($op, $friend, $user); break; case 'rsvp': $node = node_load($result['id']); if (empty($node->rsvp)) { $node = _rsvp_load($node); } print '*rsvp*'. $node->nid .', '; rsvp_rsvp($op, $a1); break; } } print '
'. $count .' records inserted for '. $module; print '
'; ob_flush(); flush(); } $query = db_result(db_query("SELECT COUNT(*) FROM {activity}")); print $query .' records inserted.'; $query = db_query("SELECT aid FROM {activity} WHERE op = ''"); $count = 0; while ($result = db_fetch_object($query)) { $count++; activity_delete($result->aid); } print '
'; print $count .' records removed for cleanup.'; // alter the activity records being inserted to have the original timestamps function mc_activity_record_alter(&$record, $context) { // get the original created time and set it switch ($context['hook']) { case 'nodeapi': if (!$record->nid) { $record = FALSE; } else { $record->created = $context['node']->created; } break; case 'comment': $record->created = $context['comment']->timestamp; break; case 'rsvp': $record->created = $context['rsvp']->rsvp_time; break; default: $record->created = $context[$context['hook']]->created; break; } }