function _background_batch_page in Background Process 6
State-based dispatcher for the batch processing page.
1 call to _background_batch_page()
- background_batch_page in background_batch/
background_batch.pages.inc - Default page callback for batches.
File
- background_batch/
background_batch.pages.inc, line 88 - Pages for background batch.
Code
function _background_batch_page() {
$id = isset($_REQUEST['id']) ? $_REQUEST['id'] : FALSE;
if (!$id) {
return drupal_not_found();
}
// Retrieve the current state of batch from db.
$data = db_result(db_query("SELECT batch FROM {batch} WHERE bid = %d", $id));
if (!$data) {
return drupal_not_found();
}
$batch =& batch_get();
$batch = unserialize($data);
// Manually call our alter if hook_batch_alter() is unsupported on this system.
if (empty($batch['batch_altered'])) {
background_batch_batch_alter($batch);
// Save batch to DB.
_batch_shutdown();
}
// Check if the current user owns (has access to) this batch.
global $user;
if ($batch['uid'] != $user->uid) {
return drupal_access_denied();
}
$op = isset($_REQUEST['op']) ? $_REQUEST['op'] : '';
switch ($op) {
case 'start':
return _background_batch_page_start();
case 'do':
return _background_batch_page_do_js();
case 'do_nojs':
return _background_batch_page_do_nojs();
case 'finished':
require_once 'includes/batch.inc';
progress_remove_progress('_background_batch:' . $id);
return _batch_finished();
default:
drupal_goto('admin/settings/batch/overview');
}
}