diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-10-15 21:19:31 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-10-15 21:19:31 +0000 |
commit | 6abcc47e25e936aea84c2f1e287bc5e1a045fff4 (patch) | |
tree | 800c3c256246f6c0399b9f3ec89d8a8aa83f5005 /modules/system/system.module | |
parent | 945fd9e269fd1ddee861a079660862c56ee54f74 (diff) | |
download | brdo-6abcc47e25e936aea84c2f1e287bc5e1a045fff4.tar.gz brdo-6abcc47e25e936aea84c2f1e287bc5e1a045fff4.tar.bz2 |
#538660 by JacobSingh, dww, JoshuaRogers, adrian, Crell, chx, anarcat, and cwgordon7: Add a functioning Plugin Manager to core. Can you say module installation and updates through the UI? I knew you could! :D
Diffstat (limited to 'modules/system/system.module')
-rw-r--r-- | modules/system/system.module | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/modules/system/system.module b/modules/system/system.module index e89eb625b..cb63659ec 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -1416,6 +1416,70 @@ function _system_themes_access($theme) { } /** + * Invoke a given callback via authorize.php to run with elevated privileges. + * + * To use authorize.php, certain variables must be stashed into + * $_SESSION. This function sets up all the necessary $_SESSION variables, + * then redirects to authorize.php to initiate 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. + * + * @param $callback + * The name of the function to invoke one the user authorizes the operation. + * @param $file + * The full path to the file where the callback function is implemented. + * @param $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. + * @param $page_title + * Optional string to use as the page title once redirected to authorize.php. + * @return + * Nothing. This function redirects to authorize.php and does not return. + */ +function system_run_authorized($callback, $file, $arguments = array(), $page_title = NULL) { + global $base_url; + + // 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; + } + + // Finally, redirect to authorize.php. + drupal_goto($base_url . '/authorize.php'); +} + +/** + * Implement hook_updater_info(). + */ +function system_updater_info() { + return array( + 'module' => array( + 'class' => 'ModuleUpdater', + 'name' => t('Update modules'), + 'weight' => 0, + ), + 'theme' => array( + 'class' => 'ThemeUpdater', + 'name' => t('Update themes'), + 'weight' => 0, + ), + ); +} + +/** * Implement hook_filetransfer_backends(). */ function system_filetransfer_backends() { |