function activity_batch_delete in Activity 6.2
Same name and namespace in other branches
- 7 activity.batch.inc \activity_batch_delete()
Batch deletion step.
Parameters
$aid: The actions.aid for this template.
$batch_context: The context array for this batch operation.
2 string references to 'activity_batch_delete'
- activity_actions_delete_form_submit in ./
activity.admin.inc - Process activity_actions_delete form submissions.
- activity_batch_regenerate in ./
activity.admin.inc - Set a batch process to regenerate activity for a specific hook and op pair.
File
- ./
activity.admin.inc, line 745 - activity.admin.inc Contains administrative forms for activity.module
Code
function activity_batch_delete($aid, &$batch_context) {
if (!isset($batch_context['sandbox']['last_activity_id'])) {
$batch_context['sandbox']['last_activity_id'] = 0;
$batch_context['sandbox']['progress'] = 0;
$batch_context['sandbox']['max'] = db_result(db_query("SELECT COUNT(aid) FROM {activity} WHERE actions_id = '%s'", $aid));
}
$limit = 200;
$activity_to_be_deleted = db_query_range("SELECT aid FROM {activity} WHERE aid > %d AND actions_id = '%s' ORDER BY aid ASC", $batch_context['sandbox']['last_activity_id'], $aid, 0, $limit);
$activity_ids = array();
while ($row = db_fetch_object($activity_to_be_deleted)) {
$activity_ids[] = $row->aid;
$batch_context['sandbox']['last_activity_id'] = $row->aid;
$batch_context['sandbox']['progress']++;
}
activity_delete($activity_ids);
// Check if not finished.
if ($batch_context['sandbox']['progress'] < $batch_context['sandbox']['max']) {
$batch_context['finished'] = $batch_context['sandbox']['progress'] / $batch_context['sandbox']['max'];
}
else {
// If finished, delete the sandbox.
unset($batch_context['sandbox']);
}
}