You are here

function background_batch_page in Background Process 7

Same name and namespace in other branches
  1. 6 background_batch/background_batch.pages.inc \background_batch_page()
  2. 7.2 background_batch/background_batch.pages.inc \background_batch_page()

State-based dispatcher for the batch processing page.

1 string reference to 'background_batch_page'
background_batch_menu_alter in background_batch/background_batch.module
Implements hook_menu_alter().

File

background_batch/background_batch.pages.inc, line 80
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_query("SELECT batch FROM {batch} WHERE bid = :bid", array(
    ':bid' => $id,
  ))
    ->fetchColumn();
  if (!$data) {
    return drupal_not_found();
  }
  $batch =& batch_get();
  $batch = unserialize($data);

  // 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':
      progress_remove_progress('_background_batch:' . $id);
      return _batch_finished();
    default:
      drupal_goto('admin/config/system/batch/overview');
  }
}