system_authorized_init

Versions
mediamosa-21
system_authorized_init($callback, $file, $arguments = array(), $page_title = NULL)

Setup a given callback to run via authorize.php with elevated privileges.

To use authorize.php, certain variables must be stashed into $_SESSION. This function sets up all the necessary $_SESSION variables, then returns the full path to authorize.php so the caller can redirect to authorize.php. That initiates the workflow that will eventually lead to the callback being invoked. The callback will be invoked at a low bootstrap level, without all modules being invoked, so it needs to be careful not to assume any code exists.

Parameters

$callback The name of the function to invoke one the user authorizes the operation.

$file The full path to the file where the callback function is implemented.

$arguments Optional array of arguments to pass into the callback when it is invoked. Note that the first argument to the callback is always the FileTransfer object created by authorize.php when the user authorizes the operation.

$page_title Optional string to use as the page title once redirected to authorize.php.

Return value

Nothing, this function just initializes variables in the user's session.

Related topics

▾ 3 functions call system_authorized_init()

system_authorized_run in modules/system/system.module
Setup and invoke an operation using authorize.php.
update_manager_install_form_submit in modules/update/update.manager.inc
Handle form submission when installing new projects via the update manager.
update_manager_update_ready_form_submit in modules/update/update.manager.inc
Submit handler for the form to confirm that an update should continue.

Code

modules/system/system.module, line 1610

<?php
function system_authorized_init($callback, $file, $arguments = array(), $page_title = NULL) {
  // First, figure out what file transfer backends the site supports, and put
  // all of those in the SESSION so that authorize.php has access to all of
  // them via the class autoloader, even without a full bootstrap.
  $_SESSION['authorize_filetransfer_backends'] = module_invoke_all('filetransfer_backends');

  // Now, define the callback to invoke.
  $_SESSION['authorize_operation'] = array(
    'callback' => $callback,
    'file' => $file,
    'arguments' => $arguments,
  );

  if (isset($page_title)) {
    $_SESSION['authorize_operation']['page_title'] = $page_title;
  }
}
?>