function activity_update_status in Activity 7
Update {activity} records status based on a new event.
Parameters
array $activity_records: an array of activity records.
3 calls to activity_update_status()
- activity_comment_update in ./
activity.module - Implements hook_comment_update().
- activity_node_update in ./
activity.module - Implements hook_node_update().
- activity_user_update in ./
activity.module - Implements hook_user_update().
File
- ./
activity.module, line 363 - Records Activity across the site and surfaces that to Views.
Code
function activity_update_status($activity_records) {
// Use this array to group the Activities by status so one query per status.
$updated_activity = array();
foreach ($activity_records as $record) {
$status = ACTIVITY_PUBLISHED;
// Figure out if the status should be 1 or 0.
$handler = activity_handler_load($record->actions_id);
$objects = $handler
->loadObjects($record->eid);
drupal_alter('activity_objects', $objects, $handler->type);
if (!$handler
->isPublished($objects, $record->uid)) {
$status = ACTIVITY_NOT_PUBLISHED;
}
$updated_activity[$status][] = $record->aid;
}
// Update each activity to their new status.
foreach ($updated_activity as $status => $aids) {
db_update('activity')
->fields(array(
'status' => $status,
))
->condition('aid', $aids, 'IN')
->execute();
}
}