You are here

function activity_delete in Activity 7

Same name and namespace in other branches
  1. 5.4 activity.module \activity_delete()
  2. 6.2 activity.module \activity_delete()
  3. 6 activity.module \activity_delete()

Delete a set of Activities.

Parameters

array $aids: An array of {activity}.aid.

Return value

array An array with two keys 'activities' and 'messages' whose values are the count of records deleted.

5 calls to activity_delete()
activity_batch_delete in ./activity.batch.inc
Batch deletion step.
activity_comment_delete in ./activity.module
Implements hook_comment_delete().
activity_delete_confirm_submit in ./activity.admin.inc
Execute activity deletion
activity_node_delete in ./activity.module
Implements hook_node_delete().
activity_user_delete in ./activity.module
Implements hook_user_delete().

File

./activity.module, line 502
Records Activity across the site and surfaces that to Views.

Code

function activity_delete($aids) {
  $amids = array();
  $count_activities = 0;
  $count_messages = 0;
  if (!empty($aids)) {
    $amids = db_query("SELECT amid FROM {activity_targets} WHERE aid IN (:aids)", array(
      ':aids' => $aids,
    ))
      ->fetchCol();
  }
  if (!empty($amids)) {
    db_delete('activity_targets')
      ->condition('amid', $amids, 'IN')
      ->execute();
    $count_messages = db_delete('activity_messages')
      ->condition('amid', $amids, 'IN')
      ->execute();
  }
  if (!empty($aids)) {
    $count_activities = db_delete('activity')
      ->condition('aid', $aids, 'IN')
      ->execute();
  }
  return array(
    'activities' => $count_activities,
    'messages' => $count_messages,
  );
}