' . t('The system module is at the foundation of your Drupal website, and provides basic but extensible functionality for use by other modules and themes. Some integral elements of Drupal are contained in and managed by the system module, including caching, enabling or disabling of modules and themes, preparing and displaying the administrative page, and configuring fundamental site settings. A number of key system maintenance operations are also part of the system module.') . '
'; $output .= '' . t('The system module provides:') . '
'; $output .= '' . t('For more information, see the online handbook entry for System module.', array('@system' => 'http://drupal.org/handbook/modules/system/')) . '
'; return $output; case 'admin/by-module': return '' . t('This page shows you all available administration tasks for each module.') . '
'; case 'admin/appearance': $output = '' . t('Set and configure the default theme for your website. Alternative themes are available.', array('@themes' => 'http://drupal.org/project/themes')) . '
'; return $output; case 'admin/appearance/settings/' . $arg[3]: $reference = explode('.', $arg[3], 2); $theme = array_pop($reference); return '' . t('These options control the display settings for the %template
theme. When your site is displayed using this theme, these settings will be used. By clicking "Reset to defaults," you can choose to use the global settings for this theme.', array('%template' => $theme, '@global' => url('admin/appearance/settings'))) . '
' . t('These options control the default display settings for your entire site, across all themes. Unless they have been overridden by a specific theme, these settings will be used.') . '
'; case 'admin/config/modules': $output = '' . t('Modules are plugins that extend Drupal\'s core functionality. To further extend your site\'s functionality, a number of contributed modules are available for download.', array('@permissions' => url('admin/config/people/permissions'), '@modules' => 'http://drupal.org/project/modules')) . '
'; $output .= '' . t('Module-related tasks can be located on the administration by module page. New module-related permissions may also become available as new modules are enabled.', array('@by-module' => url('admin/by-module'), '@permissions' => url('admin/config/people/permissions'))) . '
'; if (module_exists('update')) { if (update_manager_access()) { $output .= '' . t('Each time a module is updated, it is important that update.php is run. To help manage the update process, the Update manager module provides information on new versions of modules (and themes) as they are released, and allows you to upgrade any missing updates or install new modules and themes. Regular review of the available updates page is essential to maintaining a secure and current site.', array('@update-php' => $base_url . '/update.php', '@updates' => url('admin/reports/updates'), '@update-manager-update' => url('admin/config/modules/update'), '@update-manager-install' => url('admin/config/modules/install'))) . '
'; } else { $output .= '' . t('Each time a module is updated, it is important that update.php is run. To help manage the update process, the Update manager module provides information on new versions of modules (and themes) as they are released. Regular review of the available updates page is essential to maintaining a secure and current site.', array('@update-php' => $base_url . '/update.php', '@updates' => url('admin/reports/updates'))) . '
'; } } else { $output .= '' . t('Each time a module is updated, it is important that update.php is run. If you enable the Update manager module, it will provide a report about new versions of modules (and themes) as they are released, can notify you via e-mail if your site is out of date, and let you install missing updates. Regular review of available updates is essential to maintaining a secure and current site.', array('@update-php' => $base_url . '/update.php')) . '
'; } return $output; case 'admin/config/modules/uninstall': return '' . t('The uninstall process removes all data related to a module. To uninstall a module, you must first disable it on the main modules page. Not all modules support this feature.', array('@modules' => url('admin/config/modules'))) . '
'; case 'admin/structure/block/manage': if ($arg[4] == 'system' && $arg[5] == 'powered-by') { return '' . t('The Powered by Drupal block is an optional link to the home page of the Drupal project. While there is absolutely no requirement that sites feature this link, it may be used to show support for Drupal.') . '
'; } break; case 'admin/config/development/maintenance': global $user; if ($user->uid == 1) { return '' . t('If you are upgrading to a newer version of Drupal or upgrading contributed modules or themes you may need to run !update-php.', array('!update-php' => l('update.php', 'update.php'))) . '
'; } case 'admin/config/system/actions': case 'admin/config/system/actions/manage': $output = '' . t('Actions are individual tasks that the system can do, such as unpublishing a piece of content or banning a user. Modules, such as the trigger module, can fire these actions when certain system events happen; for example, when a new post is added or when a user logs in. Modules may also provide additional actions.') . '
'; $output .= '' . t('There are two types of actions: simple and advanced. Simple actions do not require any additional configuration, and are listed here automatically. Advanced actions can do more than simple actions; for example, send an e-mail to a specified address, or check for certain words within a piece of content. These actions need to be created and configured first before they may be used. To create an advanced action, select the action from the drop-down below and click the Create button.') . '
'; if (module_exists('trigger')) { $output .= '' . t('You may proceed to the Triggers page to assign these actions to system events.', array('@url' => url('admin/structure/trigger'))) . '
'; } return $output; case 'admin/config/system/actions/configure': return t('An advanced action offers additional configuration options which may be filled out below. Changing the Description field is recommended, in order to better identify the precise action taking place. This description will be displayed in modules such as the trigger module when assigning actions to system events, so it is best if it is as descriptive as possible (for example, "Send e-mail to Moderation Team" rather than simply "Send e-mail").'); case 'admin/config/people/ip-blocking': return '' . t('IP addresses listed here are blocked from your site before any modules are loaded. You may add IP addresses to the list, or delete existing entries.') . '
'; case 'admin/reports/status': return '' . t("Here you can find a short overview of your site's parameters as well as any problems detected with your installation. It may be useful to copy and paste this information into support requests filed on drupal.org's support forums and project issue queues.") . '
'; } } /** * Implement hook_theme(). */ function system_theme() { return array_merge(drupal_common_theme(), array( 'system_themes_form' => array( 'render element' => 'form', 'file' => 'system.admin.inc', ), 'system_settings_form' => array( 'render element' => 'form', ), 'confirm_form' => array( 'render element' => 'form', ), 'system_modules_fieldset' => array( 'render element' => 'form', 'file' => 'system.admin.inc', ), 'system_modules_incompatible' => array( 'variables' => array('message' => NULL), 'file' => 'system.admin.inc', ), 'system_modules_uninstall' => array( 'render element' => 'form', 'file' => 'system.admin.inc', ), 'status_report' => array( 'render element' => 'requirements', 'file' => 'system.admin.inc', ), 'admin_page' => array( 'variables' => array('blocks' => NULL), 'file' => 'system.admin.inc', ), 'admin_block' => array( 'variables' => array('block' => NULL), 'file' => 'system.admin.inc', ), 'admin_block_content' => array( 'variables' => array('content' => NULL), 'file' => 'system.admin.inc', ), 'system_admin_by_module' => array( 'variables' => array('menu_items' => NULL), 'file' => 'system.admin.inc', ), 'system_powered_by' => array( 'variables' => array(), ), 'system_compact_link' => array( 'variables' => array(), ), 'system_run_cron_image' => array( 'variables' => array('image_path' => NULL), ), 'system_date_time_settings' => array( 'render element' => 'form', 'file' => 'system.admin.inc', ), )); } /** * Implement hook_permission(). */ function system_permission() { return array( 'administer site configuration' => array( 'title' => t('Administer site configuration'), 'description' => t('Configure site-wide settings such as module or theme administration settings.'), ), 'administer software updates' => array( 'title' => t('Administer software updates'), 'description' => t('Run the update.php script.'), ), 'administer actions' => array( 'title' => t('Administer actions'), 'description' => t('Manage the actions defined for your site.'), ), 'administer files' => array( 'title' => t('Administer files'), 'description' => t('Manage user-uploaded files.'), ), 'access administration pages' => array( 'title' => t('Access administration pages'), 'description' => t('View the administration panel and browse the help system.'), ), 'access contextual links' => array( 'title' => t('Access contextual links'), 'description' => t('Use contextual links to perform actions related to elements on a page.'), ), 'access site in maintenance mode' => array( 'title' => t('Access site in maintenance mode'), 'description' => t('Log in when the site is in maintenance mode.'), ), 'access site reports' => array( 'title' => t('Access site reports'), 'description' => t('View reports from system logs and other status information.'), ), 'block IP addresses' => array( 'title' => t('Block IP addresses'), 'description' => t('Block IP addresses from accessing your site.'), ), ); } /** * Implement hook_rdf_namespaces(). */ function system_rdf_namespaces() { return array( 'admin' => 'http://webns.net/mvcb/', 'content' => 'http://purl.org/rss/1.0/modules/content/', 'dc' => 'http://purl.org/dc/terms/', 'foaf' => 'http://xmlns.com/foaf/0.1/', 'owl' => 'http://www.w3.org/2002/07/owl#', 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#', 'rss' => 'http://purl.org/rss/1.0/', 'tags' => 'http://www.holygoat.co.uk/owl/redwood/0.1/tags/', 'sioc' => 'http://rdfs.org/sioc/ns#', 'sioct' => 'http://rdfs.org/sioc/types#', 'ctag' => 'http://commontag.org/ns#', 'skos' => 'http://www.w3.org/2004/02/skos/core#', 'xsd' => 'http://www.w3.org/2001/XMLSchema#', ); } /** * Implement hook_hook_info(). */ function system_hook_info() { $hooks['token_info'] = array( 'group' => 'tokens', ); $hooks['tokens'] = array( 'group' => 'tokens', ); return $hooks; } /** * Implement hook_entity_info(). */ function system_entity_info() { return array( 'file' => array( 'label' => t('File'), 'base table' => 'file', 'object keys' => array( 'id' => 'fid', ), 'static cache' => FALSE, ), ); } /** * Implement hook_element_info(). */ function system_element_info() { // Top level elements. $types['form'] = array( '#method' => 'post', '#action' => request_uri(), '#theme_wrappers' => array('form'), ); $types['page'] = array( '#show_messages' => TRUE, '#theme' => 'page', '#theme_wrappers' => array('html'), ); $types['list'] = array( '#title' => '', '#list_type' => 'ul', '#attributes' => array(), '#items' => array(), ); // By default, we don't want AJAX commands being rendered in the context of an // HTML page, so we don't provide defaults for #theme or #theme_wrappers. // However, modules can set these properties (for example, to provide an HTML // debugging page that displays rather than executes AJAX commands). $types['ajax_commands'] = array( '#ajax_commands' => array(), ); $types['html_tag'] = array( '#theme' => 'html_tag', '#attributes' => array(), '#value' => NULL, ); // Input elements. $types['submit'] = array( '#input' => TRUE, '#name' => 'op', '#button_type' => 'submit', '#executes_submit_callback' => TRUE, '#process' => array('ajax_process_form'), '#theme_wrappers' => array('button'), ); $types['button'] = array( '#input' => TRUE, '#name' => 'op', '#button_type' => 'submit', '#executes_submit_callback' => FALSE, '#process' => array('ajax_process_form'), '#theme_wrappers' => array('button'), ); $types['image_button'] = array( '#input' => TRUE, '#button_type' => 'submit', '#executes_submit_callback' => TRUE, '#process' => array('ajax_process_form'), '#return_value' => TRUE, '#has_garbage_value' => TRUE, '#src' => NULL, '#theme_wrappers' => array('image_button'), ); $types['textfield'] = array( '#input' => TRUE, '#size' => 60, '#maxlength' => 128, '#autocomplete_path' => FALSE, '#process' => array('form_process_text_format', 'ajax_process_form'), '#theme' => 'textfield', '#theme_wrappers' => array('form_element'), ); $types['password'] = array( '#input' => TRUE, '#size' => 60, '#maxlength' => 128, '#process' => array('ajax_process_form'), '#theme' => 'password', '#theme_wrappers' => array('form_element'), ); $types['password_confirm'] = array( '#input' => TRUE, '#process' => array('form_process_password_confirm'), '#theme_wrappers' => array('form_element'), ); $types['textarea'] = array( '#input' => TRUE, '#cols' => 60, '#rows' => 5, '#resizable' => TRUE, '#process' => array('form_process_text_format', 'ajax_process_form'), '#theme' => 'textarea', '#theme_wrappers' => array('form_element'), ); $types['radios'] = array( '#input' => TRUE, '#process' => array('form_process_radios'), '#theme_wrappers' => array('radios'), '#pre_render' => array('form_pre_render_conditional_form_element'), ); $types['radio'] = array( '#input' => TRUE, '#default_value' => NULL, '#process' => array('ajax_process_form'), '#theme' => 'radio', '#theme_wrappers' => array('form_element'), '#form_element_skip_title' => TRUE, ); $types['checkboxes'] = array( '#input' => TRUE, '#tree' => TRUE, '#process' => array('form_process_checkboxes'), '#theme_wrappers' => array('checkboxes'), '#pre_render' => array('form_pre_render_conditional_form_element'), ); $types['checkbox'] = array( '#input' => TRUE, '#return_value' => 1, '#process' => array('ajax_process_form'), '#theme' => 'checkbox', '#theme_wrappers' => array('form_element'), '#form_element_skip_title' => TRUE, ); $types['select'] = array( '#input' => TRUE, '#size' => 0, '#multiple' => FALSE, '#process' => array('ajax_process_form'), '#theme' => 'select', '#theme_wrappers' => array('form_element'), ); $types['weight'] = array( '#input' => TRUE, '#delta' => 10, '#default_value' => 0, '#process' => array('form_process_weight', 'ajax_process_form'), ); $types['date'] = array( '#input' => TRUE, '#element_validate' => array('date_validate'), '#process' => array('form_process_date'), '#theme' => 'date', '#theme_wrappers' => array('form_element'), ); $types['file'] = array( '#input' => TRUE, '#size' => 60, '#theme' => 'file', '#theme_wrappers' => array('form_element'), ); $types['tableselect'] = array( '#input' => TRUE, '#js_select' => TRUE, '#multiple' => TRUE, '#process' => array('form_process_tableselect'), '#options' => array(), '#empty' => '', '#theme' => 'tableselect', ); // Form structure. $types['item'] = array( '#markup' => '', '#pre_render' => array('drupal_pre_render_markup'), '#theme_wrappers' => array('form_element'), ); $types['hidden'] = array( '#input' => TRUE, '#process' => array('ajax_process_form'), '#theme' => 'hidden', ); $types['value'] = array( '#input' => TRUE, ); $types['markup'] = array( '#markup' => '', '#pre_render' => array('drupal_pre_render_markup'), ); $types['link'] = array( '#pre_render' => array('drupal_pre_render_link', 'drupal_pre_render_markup'), ); $types['fieldset'] = array( '#collapsible' => FALSE, '#collapsed' => FALSE, '#value' => NULL, '#process' => array('form_process_fieldset', 'ajax_process_form'), '#pre_render' => array('form_pre_render_fieldset'), '#theme_wrappers' => array('fieldset'), ); $types['vertical_tabs'] = array( '#theme_wrappers' => array('vertical_tabs'), '#default_tab' => '', '#process' => array('form_process_vertical_tabs'), ); $types['container'] = array( '#theme_wrappers' => array('container'), '#process' => array('form_process_container'), ); $types['token'] = array( '#input' => TRUE, '#theme' => array('hidden'), ); return $types; } /** * Implement hook_menu(). */ function system_menu() { $items['system/files'] = array( 'title' => 'File download', 'page callback' => 'file_download', 'page arguments' => array('private'), 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); $items['system/temporary'] = array( 'title' => 'Temporary files', 'page callback' => 'file_download', 'page arguments' => array('temporary'), 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); $items['system/ajax'] = array( 'title' => 'AHAH callback', 'page callback' => 'ajax_form_callback', 'delivery callback' => 'ajax_deliver', 'access callback' => TRUE, 'type' => MENU_CALLBACK, 'file path' => 'includes', 'file' => 'form.inc', ); $items['system/timezone'] = array( 'title' => 'Time zone', 'page callback' => 'system_timezone', 'access callback' => TRUE, 'type' => MENU_CALLBACK, 'file' => 'system.admin.inc', ); $items['system/run-cron-image'] = array( 'title' => 'Execute cron', 'page callback' => 'system_run_cron_image', 'access callback' => 'system_run_cron_image_access', 'type' => MENU_CALLBACK, 'file' => 'system.admin.inc', ); $items['admin'] = array( 'title' => 'Administer', 'access arguments' => array('access administration pages'), 'page callback' => 'system_main_admin_page', 'weight' => 9, 'menu_name' => 'management', 'theme callback' => 'variable_get', 'theme arguments' => array('admin_theme'), 'file' => 'system.admin.inc', ); $items['admin/compact'] = array( 'title' => 'Compact mode', 'page callback' => 'system_admin_compact_page', 'access arguments' => array('access administration pages'), 'type' => MENU_CALLBACK, 'file' => 'system.admin.inc', ); $items['admin/by-task'] = array( 'title' => 'By task', 'page callback' => 'system_main_admin_page', 'access arguments' => array('access administration pages'), 'type' => MENU_DEFAULT_LOCAL_TASK, 'file' => 'system.admin.inc', ); $items['admin/by-module'] = array( 'title' => 'By module', 'page callback' => 'system_admin_by_module', 'access arguments' => array('access administration pages'), 'type' => MENU_LOCAL_TASK, 'weight' => 2, 'file' => 'system.admin.inc', ); // Menu items that are basically just menu blocks. $items['admin/structure'] = array( 'title' => 'Structure', 'description' => 'Control how your site looks and feels.', 'position' => 'right', 'weight' => -8, 'page callback' => 'system_admin_menu_block_page', 'access arguments' => array('access administration pages'), 'file' => 'system.admin.inc', ); // Appearance. $items['admin/appearance'] = array( 'title' => 'Appearance', 'description' => 'Select and configure your site theme.', 'page callback' => 'drupal_get_form', 'page arguments' => array('system_themes_form'), 'access arguments' => array('administer site configuration'), 'position' => 'left', 'weight' => -6, 'file' => 'system.admin.inc', ); $items['admin/appearance/select'] = array( 'title' => 'List', 'description' => 'Select the default theme for your site.', 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -1, 'file' => 'system.admin.inc', ); $items['admin/appearance/settings'] = array( 'title' => 'Configure', 'description' => 'Configure default and theme specific settings.', 'page arguments' => array('system_theme_settings'), 'access arguments' => array('administer site configuration'), 'type' => MENU_LOCAL_TASK, 'file' => 'system.admin.inc', ); // Theme configuration subtabs. $items['admin/appearance/settings/global'] = array( 'title' => 'Global settings', 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -1, ); foreach (list_themes() as $theme) { $items['admin/appearance/settings/' . $theme->name] = array( 'title' => $theme->info['name'], 'page arguments' => array('system_theme_settings', $theme->name), 'type' => MENU_LOCAL_TASK, 'access callback' => '_system_themes_access', 'access arguments' => array($theme), 'file' => 'system.admin.inc', ); } // Configuration and modules. $items['admin/config'] = array( 'title' => 'Configuration and modules', 'page callback' => 'system_admin_config_page', 'access arguments' => array('access administration pages'), 'file' => 'system.admin.inc', ); $items['admin/config/config'] = array( 'title' => 'Configuration', 'access arguments' => array('administer site configuration'), 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10, 'file' => 'system.admin.inc', ); $items['admin/config/modules'] = array( 'title' => 'Modules', 'description' => 'Enable or disable add-on modules for your site.', 'page callback' => 'drupal_get_form', 'page arguments' => array('system_modules'), 'access arguments' => array('administer site configuration'), 'file' => 'system.admin.inc', 'type' => MENU_LOCAL_TASK, 'weight' => 10, ); $items['admin/config/modules/list'] = array( 'title' => 'List', 'type' => MENU_DEFAULT_LOCAL_TASK, ); $items['admin/config/modules/list/confirm'] = array( 'title' => 'List', 'access arguments' => array('administer site configuration'), 'type' => MENU_CALLBACK, ); $items['admin/config/modules/uninstall'] = array( 'title' => 'Uninstall', 'page arguments' => array('system_modules_uninstall'), 'access arguments' => array('administer site configuration'), 'type' => MENU_LOCAL_TASK, 'file' => 'system.admin.inc', ); $items['admin/config/modules/uninstall/confirm'] = array( 'title' => 'Uninstall', 'access arguments' => array('administer site configuration'), 'type' => MENU_CALLBACK, 'file' => 'system.admin.inc', ); // Actions. $items['admin/config/system/actions'] = array( 'title' => 'Actions', 'description' => 'Manage the actions defined for your site.', 'access arguments' => array('administer actions'), 'page callback' => 'system_actions_manage', 'file' => 'system.admin.inc', ); $items['admin/config/system/actions/manage'] = array( 'title' => 'Manage actions', 'description' => 'Manage the actions defined for your site.', 'page callback' => 'system_actions_manage', 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -2, 'file' => 'system.admin.inc', ); $items['admin/config/system/actions/configure'] = array( 'title' => 'Configure an advanced action', 'page callback' => 'drupal_get_form', 'page arguments' => array('system_actions_configure'), 'access arguments' => array('administer actions'), 'type' => MENU_CALLBACK, 'file' => 'system.admin.inc', ); $items['admin/config/system/actions/delete/%actions'] = array( 'title' => 'Delete action', 'description' => 'Delete an action.', 'page callback' => 'drupal_get_form', 'page arguments' => array('system_actions_delete_form', 5), 'access arguments' => array('administer actions'), 'type' => MENU_CALLBACK, 'file' => 'system.admin.inc', ); $items['admin/config/system/actions/orphan'] = array( 'title' => 'Remove orphans', 'page callback' => 'system_actions_remove_orphans', 'access arguments' => array('administer actions'), 'type' => MENU_CALLBACK, 'file' => 'system.admin.inc', ); // IP address blocking. $items['admin/config/people/ip-blocking'] = array( 'title' => 'IP address blocking', 'description' => 'Manage blocked IP addresses.', 'page callback' => 'system_ip_blocking', 'access arguments' => array('block IP addresses'), 'file' => 'system.admin.inc', ); $items['admin/config/people/ip-blocking/%'] = array( 'title' => 'IP address blocking', 'description' => 'Manage blocked IP addresses.', 'page callback' => 'system_ip_blocking', 'access arguments' => array('block IP addresses'), 'type' => MENU_CALLBACK, 'file' => 'system.admin.inc', ); $items['admin/config/people/ip-blocking/delete/%blocked_ip'] = array( 'title' => 'Delete IP address', 'page callback' => 'drupal_get_form', 'page arguments' => array('system_ip_blocking_delete', 5), 'access arguments' => array('block IP addresses'), 'type' => MENU_CALLBACK, 'file' => 'system.admin.inc', ); // Configuration. $items['admin/config/development'] = array( 'title' => 'Development', 'description' => 'Development tools.', 'position' => 'left', 'weight' => 10, 'page callback' => 'system_admin_menu_block_page', 'access arguments' => array('access administration pages'), 'file' => 'system.admin.inc', ); $items['admin/config/development/maintenance'] = array( 'title' => 'Maintenance mode', 'description' => 'Take the site offline for maintenance or bring it back online.', 'page callback' => 'drupal_get_form', 'page arguments' => array('system_site_maintenance_mode'), 'access arguments' => array('administer site configuration'), 'file' => 'system.admin.inc', ); $items['admin/config/development/performance'] = array( 'title' => 'Performance', 'description' => 'Enable or disable page caching for anonymous users and set CSS and JS bandwidth optimization options.', 'page callback' => 'drupal_get_form', 'page arguments' => array('system_performance_settings'), 'access arguments' => array('administer site configuration'), 'file' => 'system.admin.inc', ); $items['admin/config/media'] = array( 'title' => 'Media', 'description' => 'Media tools.', 'position' => 'left', 'weight' => 10, 'page callback' => 'system_admin_menu_block_page', 'access arguments' => array('access administration pages'), 'file' => 'system.admin.inc', ); $items['admin/config/media/file-system'] = array( 'title' => 'File system', 'description' => 'Tell Drupal where to store uploaded files and how they are accessed.', 'page callback' => 'drupal_get_form', 'page arguments' => array('system_file_system_settings'), 'access arguments' => array('administer site configuration'), 'file' => 'system.admin.inc', ); $items['admin/config/media/image-toolkit'] = array( 'title' => 'Image toolkit', 'description' => 'Choose which image toolkit to use if you have installed optional toolkits.', 'page callback' => 'drupal_get_form', 'page arguments' => array('system_image_toolkit_settings'), 'access arguments' => array('administer site configuration'), 'file' => 'system.admin.inc', ); $items['admin/config/services'] = array( 'title' => 'Web services', 'description' => 'Tools related to web services.', 'page callback' => 'system_admin_menu_block_page', 'access arguments' => array('access administration pages'), 'file' => 'system.admin.inc', ); $items['admin/config/services/rss-publishing'] = array( 'title' => 'RSS publishing', 'description' => 'Configure the site description, the number of items per feed and whether feeds should be titles/teasers/full-text.', 'page callback' => 'drupal_get_form', 'page arguments' => array('system_rss_feeds_settings'), 'access arguments' => array('administer site configuration'), 'file' => 'system.admin.inc', ); $items['admin/config/development/logging'] = array( 'title' => 'Logging and errors', 'description' => "Settings for logging and alerts modules. Various modules can route Drupal's system events to different destinations, such as syslog, database, email, etc.", 'page callback' => 'drupal_get_form', 'page arguments' => array('system_logging_settings'), 'access arguments' => array('administer site configuration'), 'file' => 'system.admin.inc', ); // Regional and date settings. $items['admin/config/regional'] = array( 'title' => 'Regional and language', 'description' => 'Regional settings, localization and translation.', 'position' => 'left', 'weight' => -7, 'page callback' => 'system_admin_menu_block_page', 'access arguments' => array('access administration pages'), 'file' => 'system.admin.inc', ); $items['admin/config/regional/settings'] = array( 'title' => 'Regional settings', 'description' => "Settings for the site's default time zone and country.", 'page callback' => 'drupal_get_form', 'page arguments' => array('system_regional_settings'), 'access arguments' => array('administer site configuration'), 'weight' => -10, 'file' => 'system.admin.inc', ); $items['admin/config/regional/date-time'] = array( 'title' => 'Date and time', 'description' => 'Configure display formats for date and time.', 'page callback' => 'drupal_get_form', 'page arguments' => array('system_date_time_settings'), 'access arguments' => array('administer site configuration'), 'weight' => -9, 'file' => 'system.admin.inc', ); $items['admin/config/regional/date-time/types'] = array( 'title' => 'Types', 'description' => 'Configure display formats for date and time.', 'page callback' => 'drupal_get_form', 'page arguments' => array('system_date_time_settings'), 'access arguments' => array('administer site configuration'), 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10, 'file' => 'system.admin.inc', ); $items['admin/config/regional/date-time/types/add'] = array( 'title' => 'Add date type', 'description' => 'Add new date type.', 'page callback' => 'drupal_get_form', 'page arguments' => array('system_add_date_format_type_form'), 'access arguments' => array('administer site configuration'), 'type' => MENU_LOCAL_ACTION, 'weight' => -10, 'file' => 'system.admin.inc', ); $items['admin/config/regional/date-time/types/%/delete'] = array( 'title' => 'Delete date type', 'description' => 'Allow users to delete a configured date type.', 'type' => MENU_CALLBACK, 'page callback' => 'drupal_get_form', 'page arguments' => array('system_delete_date_format_type_form', 5), 'access arguments' => array('administer site configuration'), 'file' => 'system.admin.inc', ); $items['admin/config/regional/date-time/formats'] = array( 'title' => 'Formats', 'description' => 'Configure display format strings for date and time.', 'page callback' => 'system_date_time_formats', 'access arguments' => array('administer site configuration'), 'type' => MENU_LOCAL_TASK, 'weight' => -9, 'file' => 'system.admin.inc', ); $items['admin/config/regional/date-time/formats/add'] = array( 'title' => 'Add format', 'description' => 'Allow users to add additional date formats.', 'type' => MENU_LOCAL_ACTION, 'page callback' => 'drupal_get_form', 'page arguments' => array('system_configure_date_formats_form'), 'access arguments' => array('administer site configuration'), 'weight' => -10, 'file' => 'system.admin.inc', ); $items['admin/config/regional/date-time/formats/%/edit'] = array( 'title' => 'Edit date format', 'description' => 'Allow users to edit a configured date format.', 'type' => MENU_CALLBACK, 'page callback' => 'drupal_get_form', 'page arguments' => array('system_configure_date_formats_form', 5), 'access arguments' => array('administer site configuration'), 'file' => 'system.admin.inc', ); $items['admin/config/regional/date-time/formats/%/delete'] = array( 'title' => 'Delete date format', 'description' => 'Allow users to delete a configured date format.', 'type' => MENU_CALLBACK, 'page callback' => 'drupal_get_form', 'page arguments' => array('system_date_delete_format_form', 5), 'access arguments' => array('administer site configuration'), 'file' => 'system.admin.inc', ); $items['admin/config/regional/date-time/formats/lookup'] = array( 'title' => 'Date and time lookup', 'type' => MENU_CALLBACK, 'page callback' => 'system_date_time_lookup', 'access arguments' => array('administer site configuration'), 'file' => 'system.admin.inc', ); $items['admin/config/search'] = array( 'title' => 'Search and metadata', 'description' => 'Local site search, metadata and SEO.', 'page callback' => 'system_admin_menu_block_page', 'access arguments' => array('access administration pages'), 'file' => 'system.admin.inc', ); $items['admin/config/search/clean-urls'] = array( 'title' => 'Clean URLs', 'description' => 'Enable or disable clean URLs for your site.', 'page callback' => 'drupal_get_form', 'page arguments' => array('system_clean_url_settings'), 'access arguments' => array('administer site configuration'), 'file' => 'system.admin.inc', ); $items['admin/config/search/clean-urls/check'] = array( 'title' => 'Clean URL check', 'page callback' => 'drupal_json_output', 'page arguments' => array(array('status' => TRUE)), 'access callback' => TRUE, 'type' => MENU_CALLBACK, 'file' => 'system.admin.inc', ); $items['admin/config/content'] = array( 'title' => 'Content authoring', 'description' => 'Settings related to formatting and authoring content.', 'position' => 'right', 'weight' => 5, 'page callback' => 'system_admin_menu_block_page', 'access arguments' => array('access administration pages'), 'file' => 'system.admin.inc', ); $items['admin/config/system'] = array( 'title' => 'System', 'description' => 'General system related configuration.', 'position' => 'right', 'weight' => -5, 'page callback' => 'system_admin_menu_block_page', 'access arguments' => array('access administration pages'), 'file' => 'system.admin.inc', ); $items['admin/config/system/site-information'] = array( 'title' => 'Site information', 'description' => 'Change basic site name, e-mail address, slogan, default front page, number of posts per page, error pages and cron.', 'page callback' => 'drupal_get_form', 'page arguments' => array('system_site_information_settings'), 'access arguments' => array('administer site configuration'), 'file' => 'system.admin.inc', 'weight' => -10, ); // Reports. $items['admin/reports'] = array( 'title' => 'Reports', 'description' => 'View reports from system logs and other status information.', 'page callback' => 'system_admin_menu_block_page', 'access arguments' => array('access site reports'), 'weight' => 5, 'position' => 'left', 'file' => 'system.admin.inc', ); $items['admin/reports/status'] = array( 'title' => 'Status report', 'description' => "Get a status report about your site's operation and any detected problems.", 'page callback' => 'system_status', 'weight' => 10, 'access arguments' => array('administer site configuration'), 'file' => 'system.admin.inc', ); $items['admin/reports/status/run-cron'] = array( 'title' => 'Run cron', 'page callback' => 'system_run_cron', 'access arguments' => array('administer site configuration'), 'type' => MENU_CALLBACK, 'file' => 'system.admin.inc', ); $items['admin/reports/status/php'] = array( 'title' => 'PHP', 'page callback' => 'system_php', 'access arguments' => array('administer site configuration'), 'type' => MENU_CALLBACK, 'file' => 'system.admin.inc', ); // Default page for batch operations. $items['batch'] = array( 'page callback' => 'system_batch_page', 'access callback' => TRUE, 'theme callback' => '_system_batch_theme', 'type' => MENU_CALLBACK, 'file' => 'system.admin.inc', ); return $items; } /** * Theme callback for the default batch page. */ function _system_batch_theme() { // Retrieve the current state of the batch. $batch = &batch_get(); if (!$batch && isset($_REQUEST['id'])) { require_once DRUPAL_ROOT . '/includes/batch.inc'; $batch = batch_load($_REQUEST['id']); } // Use the same theme as the page that started the batch. if (!empty($batch['theme'])) { return $batch['theme']; } } /** * Implementation of hook_library(). */ function system_library() { // jQuery. $libraries['jquery'] = array( 'title' => 'jQuery', 'website' => 'http://jquery.com', 'version' => '1.3.2', 'js' => array( 'misc/jquery.js' => array('weight' => JS_LIBRARY - 20), ), ); // jQuery Once. $libraries['once'] = array( 'title' => 'jQuery Once', 'website' => 'http://plugins.jquery.com/project/once', 'version' => '1.2', 'js' => array( 'misc/jquery.once.js' => array('weight' => JS_LIBRARY - 19), ), ); // jQuery Form Plugin. $libraries['form'] = array( 'title' => 'jQuery Form Plugin', 'website' => 'http://malsup.com/jquery/form/', 'version' => '2.16', 'js' => array( 'misc/jquery.form.js' => array(), ), ); // Contextual links. $libraries['contextual-links'] = array( 'title' => 'Contextual links', 'website' => 'http://drupal.org/node/473268', 'version' => '1.0', 'js' => array( 'misc/contextual_links.js' => array(), ), 'css' => array( 'misc/contextual_links.css' => array(), ), ); // Vertical Tabs. $libraries['vertical-tabs'] = array( 'title' => 'Vertical Tabs', 'website' => 'http://drupal.org/node/323112', 'version' => '1.0', 'js' => array( 'misc/vertical-tabs.js' => array(), ), 'css' => array( 'misc/vertical-tabs.css' => array(), ), ); // Farbtastic. $libraries['farbtastic'] = array( 'title' => 'Farbtastic', 'website' => 'http://code.google.com/p/farbtastic/', 'version' => '1.2', 'js' => array( 'misc/farbtastic/farbtastic.js' => array(), ), 'css' => array( 'misc/farbtastic/farbtastic.css' => array('preprocess' => FALSE), ), ); // Cookie. $libraries['cookie'] = array( 'title' => 'Cookie', 'website' => 'http://plugins.jquery.com/project/cookie', 'version' => '1.0', 'js' => array( 'misc/jquery.cookie.js' => array(), ), ); // jQuery UI. $libraries['ui'] = array( 'title' => 'jQuery UI: Core', 'website' => 'http://jqueryui.com', 'version' => '1.7.2', 'js' => array( 'misc/ui/ui.core.js' => array('weight' => JS_LIBRARY - 10), ), 'css' => array( 'misc/ui/ui.core.css' => array(), 'misc/ui/ui.theme.css' => array(), ), ); $libraries['ui.accordion'] = array( 'title' => 'jQuery UI: Accordion', 'website' => 'http://jqueryui.com/demos/accordion/', 'version' => '1.7.2', 'js' => array( 'misc/ui/ui.accordion.js' => array(), ), 'css' => array( 'misc/ui/ui.accordion.css' => array(), ), 'dependencies' => array( array('system', 'ui'), ), ); $libraries['ui.datepicker'] = array( 'title' => 'jQuery UI: Date Picker', 'website' => 'http://jqueryui.com/demos/datepicker/', 'version' => '1.7.2', 'js' => array( 'misc/ui/ui.datepicker.js' => array(), ), 'css' => array( 'misc/ui/ui.datepicker.css' => array(), ), 'dependencies' => array( array('system', 'ui'), ), ); $libraries['ui.dialog'] = array( 'title' => 'jQuery UI: Dialog', 'website' => 'http://jqueryui.com/demos/dialog/', 'version' => '1.7.2', 'js' => array( 'misc/ui/ui.dialog.js' => array(), ), 'css' => array( 'misc/ui/ui.dialog.css' => array(), ), 'dependencies' => array( array('system', 'ui'), ), ); $libraries['ui.draggable'] = array( 'title' => 'jQuery UI: Dialog', 'website' => 'http://jqueryui.com/demos/draggable/', 'version' => '1.7.2', 'js' => array( 'misc/ui/ui.draggable.js' => array(), ), 'dependencies' => array( array('system', 'ui'), ), ); $libraries['ui.droppable'] = array( 'title' => 'jQuery UI: Droppable', 'website' => 'http://jqueryui.com/demos/droppable/', 'version' => '1.7.2', 'js' => array( 'misc/ui/ui.droppable.js' => array(), ), 'dependencies' => array( array('system', 'ui'), array('system', 'ui.draggable'), ), ); $libraries['ui.progressbar'] = array( 'title' => 'jQuery UI: Progress Bar', 'website' => 'http://jqueryui.com/demos/progressbar/', 'version' => '1.7.2', 'js' => array( 'misc/ui/ui.progressbar.js' => array(), ), 'css' => array( 'misc/ui/ui.progressbar.css' => array(), ), 'dependencies' => array( array('system', 'ui'), ), ); $libraries['ui.resizable'] = array( 'title' => 'jQuery UI: Resizable', 'website' => 'http://jqueryui.com/demos/resizable/', 'version' => '1.7.2', 'js' => array( 'misc/ui/ui.resizable.js' => array(), ), 'css' => array( 'misc/ui/ui.resizable.css' => array(), ), 'dependencies' => array( array('system', 'ui'), ), ); $libraries['ui.selectable'] = array( 'title' => 'jQuery UI: Selectable', 'website' => 'http://jqueryui.com/demos/selectable/', 'version' => '1.7.2', 'js' => array( 'misc/ui/ui.selectable.js' => array(), ), 'css' => array( 'misc/ui/ui.selectable.css' => array(), ), 'dependencies' => array( array('system', 'ui'), ), ); $libraries['ui.slider'] = array( 'title' => 'jQuery UI: Slider', 'website' => 'http://jqueryui.com/demos/slider/', 'version' => '1.7.2', 'js' => array( 'misc/ui/ui.slider.js' => array(), ), 'css' => array( 'misc/ui/ui.slider.css' => array(), ), 'dependencies' => array( array('system', 'ui'), ), ); $libraries['ui.sortable'] = array( 'title' => 'jQuery UI: Sortable', 'website' => 'http://jqueryui.com/demos/sortable/', 'version' => '1.7.2', 'js' => array( 'misc/ui/ui.sortable.js' => array(), ), 'dependencies' => array( array('system', 'ui'), ), ); $libraries['ui.tabs'] = array( 'title' => 'jQuery UI: Tabs', 'website' => 'http://jqueryui.com/demos/tabs/', 'version' => '1.7.2', 'js' => array( 'misc/ui/ui.tabs.js' => array(), ), 'css' => array( 'misc/ui/ui.tabs.css' => array(), ), 'dependencies' => array( array('system', 'ui'), ), ); $libraries['effects'] = array( 'title' => 'jQuery UI: Effects', 'website' => 'http://jqueryui.com/demos/effect/', 'version' => '1.7.2', 'js' => array( 'misc/ui/effects.core.js' => array('weight' => JS_LIBRARY - 9), ), 'dependencies' => array( array('system', 'ui'), ), ); $libraries['effects.blind'] = array( 'title' => 'jQuery UI: Effects Blind', 'website' => 'http://jqueryui.com/demos/effect/', 'version' => '1.7.2', 'js' => array( 'misc/ui/effects.blind.js' => array(), ), 'dependencies' => array( array('system', 'effects'), ), ); $libraries['effects.bounce'] = array( 'title' => 'jQuery UI: Effects Bounce', 'website' => 'http://jqueryui.com/demos/effect/', 'version' => '1.7.2', 'js' => array( 'misc/ui/effects.bounce.js' => array(), ), 'dependencies' => array( array('system', 'effects'), ), ); $libraries['effects.clip'] = array( 'title' => 'jQuery UI: Effects Clip', 'website' => 'http://jqueryui.com/demos/effect/', 'version' => '1.7.2', 'js' => array( 'misc/ui/effects.clip.js' => array(), ), 'dependencies' => array( array('system', 'effects'), ), ); $libraries['effects.drop'] = array( 'title' => 'jQuery UI: Effects Drop', 'website' => 'http://jqueryui.com/demos/effect/', 'version' => '1.7.2', 'js' => array( 'misc/ui/effects.drop.js' => array(), ), 'dependencies' => array( array('system', 'effects'), ), ); $libraries['effects.explode'] = array( 'title' => 'jQuery UI: Effects Explode', 'website' => 'http://jqueryui.com/demos/effect/', 'version' => '1.7.2', 'js' => array( 'misc/ui/effects.explode.js' => array(), ), 'dependencies' => array( array('system', 'effects'), ), ); $libraries['effects.fold'] = array( 'title' => 'jQuery UI: Effects Fold', 'website' => 'http://jqueryui.com/demos/effect/', 'version' => '1.7.2', 'js' => array( 'misc/ui/effects.fold.js' => array(), ), 'dependencies' => array( array('system', 'effects'), ), ); $libraries['effects.highlight'] = array( 'title' => 'jQuery UI: Effects Fold', 'website' => 'http://jqueryui.com/demos/effect/', 'version' => '1.7.2', 'js' => array( 'misc/ui/effects.highlight.js' => array(), ), 'dependencies' => array( array('system', 'effects'), ), ); $libraries['effects.pulsate'] = array( 'title' => 'jQuery UI: Effects Pulsate', 'website' => 'http://jqueryui.com/demos/effect/', 'version' => '1.7.2', 'js' => array( 'misc/ui/effects.pulsate.js' => array(), ), 'dependencies' => array( array('system', 'effects'), ), ); $libraries['effects.scale'] = array( 'title' => 'jQuery UI: Effects Pulsate', 'website' => 'http://jqueryui.com/demos/effect/', 'version' => '1.7.2', 'js' => array( 'misc/ui/effects.scale.js' => array(), ), 'dependencies' => array( array('system', 'effects'), ), ); $libraries['effects.shake'] = array( 'title' => 'jQuery UI: Effects Shake', 'website' => 'http://jqueryui.com/demos/effect/', 'version' => '1.7.2', 'js' => array( 'misc/ui/effects.scale.js' => array(), ), 'dependencies' => array( array('system', 'effects'), ), ); $libraries['effects.slide'] = array( 'title' => 'jQuery UI: Effects Slide', 'website' => 'http://jqueryui.com/demos/effect/', 'version' => '1.7.2', 'js' => array( 'misc/ui/effects.slide.js' => array(), ), 'dependencies' => array( array('system', 'effects'), ), ); $libraries['effects.transfer'] = array( 'title' => 'jQuery UI: Effects Transfer', 'website' => 'http://jqueryui.com/demos/effect/', 'version' => '1.7.2', 'js' => array( 'misc/ui/effects.transfer.js' => array(), ), 'dependencies' => array( array('system', 'effects'), ), ); return $libraries; } /** * Implement hook_stream_wrappers(). */ function system_stream_wrappers() { return array( 'public' => array( 'name' => t('Public files'), 'class' => 'DrupalPublicStreamWrapper', 'description' => t('Public local files served by the webserver.'), ), 'private' => array( 'name' => t('Private files'), 'class' => 'DrupalPrivateStreamWrapper', 'description' => t('Private local files served by Drupal.'), ), 'temporary' => array( 'name' => t('Temporary files'), 'class' => 'DrupalTemporaryStreamWrapper', 'description' => t('Temporary local files for upload and previews.'), ) ); } /** * Retrieve a blocked IP address from the database. * * @param $iid integer * The ID of the blocked IP address to retrieve. * * @return * The blocked IP address from the database as an array. */ function blocked_ip_load($iid) { return db_query("SELECT * FROM {blocked_ips} WHERE iid = :iid", array(':iid' => $iid))->fetchAssoc(); } /** * Menu item access callback - only admin or enabled themes can be accessed. */ function _system_themes_access($theme) { return user_access('administer site configuration') && drupal_theme_access($theme); } /** * @defgroup authorize Authorized operations * @{ * Functions to run operations with elevated privileges via authorize.php. * * Because of the Update manager functionality included in Drupal core, there * is a mechanism for running operations with elevated file system privileges, * the top-level authorize.php script. This script runs at a reduced Drupal * bootstrap level so that it is not reliant on the entire site being * functional. The operations use a FileTransfer class to manipulate code * installed on the system as the user that owns the files, not the user that * the httpd is running as. * * The first setup is to define a callback function that should be authorized * to run with the elevated privileges. This callback should take a * FileTransfer as its first argument, although you can define an array of * other arguments it should be invoked with. The callback should be placed in * a separate .inc file that will be included by authorize.php. * * To run the operation, certain data must be saved into the SESSION, and then * the flow of control should be redirected to the authorize.php script. There * are two ways to do this, either to call system_authorized_run() directly, * or to call system_authorized_init() and then redirect to authorize.php, * using the URL from system_authorized_get_url(). Redirecting yourself is * necessary when your authorized operation is being triggered by a form * submit handler, since calling drupal_goto() in a submit handler is a bad * idea, and you should instead set $form_state['redirect']. * * Once the SESSION is setup for the operation and the user is redirected to * authorize.php, they will be prompted for their connection credentials (core * provides FTP and SSH by default, although other connection classes can be * added via contributed modules). With valid credentials, authorize.php will * instantiate the appropriate FileTransfer object, and then invoke the * desired operation passing in that object. The authorize.php script can act * as a Batch API processing page, if the operation requires a batch. * * @see authorize.php * @see FileTransfer * @see hook_filetransfer_backends() */ /** * 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. * * @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 just initializes variables in the user's session. */ 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; } } /** * Return the URL for the authorize.php script. * * @param array $options * Optional array of options to pass to url(). * @return * The full URL to authorize.php, using https if available. */ function system_authorized_get_url(array $options = array()) { global $base_url; // Force https if available, regardless of what the caller specifies. $options['https'] = TRUE; // We prefix with $base_url so we get a full path even if clean URLs are // disabled. return url($base_url . '/authorize.php', $options); } /** * Setup and invoke an operation using authorize.php. * * @see system_authorized_init */ function system_authorized_run($callback, $file, $arguments = array(), $page_title = NULL) { system_authorized_init($callback, $file, $arguments, $page_title); drupal_goto(system_authorized_get_url()); } /** * Use authorize.php to run batch_process(). * * @see batch_process() */ function system_authorized_batch_process() { $finish_url = system_authorized_get_url(); $process_url = system_authorized_get_url(array('query' => array('batch' => '1'))); batch_process($finish_url, $process_url); } /** * @} End of "defgroup authorize". */ /** * 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() { $backends = array(); // This is the default, will be available on most systems. if (function_exists('ftp_connect') || ini_get('allow_url_fopen')) { $backends['ftp'] = array( 'title' => t('FTP'), 'class' => 'FileTransferFTP', 'settings_form' => 'system_filetransfer_backend_form_ftp', 'weight' => 0, ); } // SSH2 lib connection is only available if the proper PHP extension is // installed. if (function_exists('ssh2_connect')) { $backends['ssh'] = array( 'title' => t('SSH'), 'class' => 'FileTransferSSH', 'settings_form' => 'system_filetransfer_backend_form_ssh', 'weight' => 20, ); } return $backends; } /** * Helper function to return a form for configuring a filetransfer backend. * * @param string $filetransfer_backend_name * The name of the backend to return a form for. * * @param string $defaults * An associative array of settings to pre-populate the form with. */ function system_get_filetransfer_settings_form($filetransfer_backend_name, $defaults) { $available_backends = module_invoke_all('filetransfer_backends'); $form = call_user_func($available_backends[$filetransfer_backend_name]['settings_form']); foreach ($form as $name => &$element) { if (isset($defaults[$name])) { $element['#default_value'] = $defaults[$name]; } } return $form; } /** * Returns the form to configure the filetransfer class for FTP */ function system_filetransfer_backend_form_ftp() { $form = _system_filetransfer_backend_form_common(); $form['advanced']['port']['#default_value'] = 21; return $form; } /** * Returns the form to configure the filetransfer class for SSH */ function system_filetransfer_backend_form_ssh() { $form = _system_filetransfer_backend_form_common(); $form['advanced']['port']['#default_value'] = 22; return $form; } /** * Helper function because SSH and FTP backends share the same elements */ function _system_filetransfer_backend_form_common() { $form['username'] = array( '#type' => 'textfield', '#title' => t('Username'), ); $form['password'] = array( '#type' => 'password', '#title' => t('Password'), '#description' => t('Your password is not saved in the database and is only used to establish a connection.'), ); $form['advanced'] = array( '#type' => 'fieldset', '#title' => t('Advanced settings'), '#collapsible' => TRUE, '#collapsed' => TRUE, ); $form['advanced']['hostname'] = array( '#type' => 'textfield', '#title' => t('Host'), '#default_value' => 'localhost', '#description' => t('The connection will be created between your web server and the machine hosting the web server files. In the vast majority of cases, this will be the same machine, and "localhost" is correct.'), ); $form['advanced']['port'] = array( '#type' => 'textfield', '#title' => t('Port'), '#default_value' => NULL, ); return $form; } /** * Implement hook_init(). */ function system_init() { // Add the CSS for this module. if (arg(0) == 'admin' || (variable_get('node_admin_theme', '0') && arg(0) == 'node' && (arg(1) == 'add' || arg(2) == 'edit'))) { drupal_add_css(drupal_get_path('module', 'system') . '/admin.css', array('weight' => CSS_SYSTEM)); } drupal_add_css(drupal_get_path('module', 'system') . '/defaults.css', array('weight' => CSS_SYSTEM)); drupal_add_css(drupal_get_path('module', 'system') . '/system.css', array('weight' => CSS_SYSTEM)); drupal_add_css(drupal_get_path('module', 'system') . '/system-menus.css', array('weight' => CSS_SYSTEM)); // Ignore slave database servers for this request. // // In Drupal's distributed database structure, new data is written to the master // and then propagated to the slave servers. This means there is a lag // between when data is written to the master and when it is available on the slave. // At these times, we will want to avoid using a slave server temporarily. // For example, if a user posts a new node then we want to disable the slave // server for that user temporarily to allow the slave server to catch up. // That way, that user will see their changes immediately while for other // users we still get the benefits of having a slave server, just with slightly // stale data. Code that wants to disable the slave server should use the // db_set_ignore_slave() function to set $_SESSION['ignore_slave_server'] to // the timestamp after which the slave can be re-enabled. if (isset($_SESSION['ignore_slave_server'])) { if ($_SESSION['ignore_slave_server'] >= REQUEST_TIME) { Database::ignoreTarget('default', 'slave'); } else { unset($_SESSION['ignore_slave_server']); } } } /** * Implement hook_form_FORM_ID_alter(). */ function system_form_user_profile_form_alter(&$form, &$form_state) { if ($form['#user_category'] == 'account') { if (variable_get('configurable_timezones', 1)) { system_user_timezone($form, $form_state); } return $form; } } /** * Implement hook_form_FORM_ID_alter(). */ function system_form_user_register_form_alter(&$form, &$form_state) { if (variable_get('configurable_timezones', 1)) { if (variable_get('user_default_timezone', DRUPAL_USER_TIMEZONE_DEFAULT) == DRUPAL_USER_TIMEZONE_SELECT) { system_user_timezone($form, $form_state); } else { $form['account']['timezone'] = array( '#type' => 'hidden', '#value' => variable_get('user_default_timezone', DRUPAL_USER_TIMEZONE_DEFAULT) ? '' : variable_get('date_default_timezone', ''), ); } return $form; } } /** * Implement hook_user_login(). */ function system_user_login(&$edit, $account) { // If the user has a NULL time zone, notify them to set a time zone. if (!$account->timezone && variable_get('configurable_timezones', 1) && variable_get('empty_timezone_message', 0)) { drupal_set_message(t('Please configure your account time zone setting.', array('@user-edit' => url("user/$account->uid/edit", array('query' => drupal_get_destination(), 'fragment' => 'edit-timezone'))))); } } /** * Add the time zone field to the user edit and register forms. */ function system_user_timezone(&$form, &$form_state) { global $user; $account = $form['#user']; $form['timezone'] = array( '#type' => 'fieldset', '#title' => t('Locale settings'), '#weight' => 6, '#collapsible' => TRUE, ); $form['timezone']['timezone'] = array( '#type' => 'select', '#title' => t('Time zone'), '#default_value' => isset($account->timezone) ? $account->timezone : ($account->uid == $user->uid ? variable_get('date_default_timezone', '') : ''), '#options' => system_time_zones($account->uid != $user->uid), '#description' => t('Select the desired local time and time zone. Dates and times throughout this site will be displayed using this time zone.'), ); if (!isset($account->timezone) && $account->uid == $user->uid) { $form['timezone']['#description'] = t('Your time zone setting will be automatically detected if possible. Please confirm the selection and click save.'); $form['timezone']['timezone']['#attributes'] = array('class' => array('timezone-detect')); drupal_add_js('misc/timezone.js'); } } /** * Implement hook_block_info(). */ function system_block_info() { $blocks['main'] = array( 'info' => t('Main page content'), // Cached elsewhere. 'cache' => DRUPAL_NO_CACHE, ); $blocks['powered-by'] = array( 'info' => t('Powered by Drupal'), 'weight' => '10', 'cache' => DRUPAL_NO_CACHE, ); $blocks['help'] = array( 'info' => t('System help'), 'weight' => '5', ); // System-defined menu blocks. foreach (menu_list_system_menus() as $menu_name => $title) { $blocks[$menu_name]['info'] = t($title); // Menu blocks can't be cached because each menu item can have // a custom access callback. menu.inc manages its own caching. $blocks[$menu_name]['cache'] = DRUPAL_NO_CACHE; } return $blocks; } /** * Implement hook_block_view(). * * Generate a block with a promotional link to Drupal.org and * all system menu blocks. */ function system_block_view($delta = '') { $block = array(); switch ($delta) { case 'main': $block['subject'] = NULL; $block['content'] = drupal_set_page_content(); return $block; case 'powered-by': $block['subject'] = NULL; $block['content'] = theme('system_powered_by'); return $block; case 'help': $block['subject'] = NULL; $block['content'] = menu_get_active_help(); return $block; default: // All system menu blocks. $system_menus = menu_list_system_menus(); if (isset($system_menus[$delta])) { $block['subject'] = t($system_menus[$delta]); $block['content'] = menu_tree($delta); return $block; } break; } } /** * Provide a single block on the administration overview page. * * @param $item * The menu item to be displayed. */ function system_admin_menu_block($item) { $cache = &drupal_static(__FUNCTION__, array()); if (!isset($item['mlid'])) { $item += db_query("SELECT mlid, menu_name FROM {menu_links} ml WHERE ml.router_path = :path AND module = 'system'", array(':path' => $item['path']))->fetchAssoc(); } if (isset($cache[$item['mlid']])) { return $cache[$item['mlid']]; } $content = array(); $default_task = NULL; $has_subitems = FALSE; $result = db_query(" SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.delivery_callback, m.title, m.title_callback, m.title_arguments, m.theme_callback, m.theme_arguments, m.type, m.description, m.path, m.weight as router_weight, ml.* FROM {menu_router} m LEFT JOIN {menu_links} ml ON m.path = ml.router_path WHERE (ml.plid = :plid AND ml.menu_name = :name AND hidden = 0) OR (m.tab_parent = :path AND m.type IN (:local_task, :default_task))", array(':plid' => $item['mlid'], ':name' => $item['menu_name'], ':path' => $item['path'], ':local_task' => MENU_LOCAL_TASK, ':default_task' => MENU_DEFAULT_LOCAL_TASK), array('fetch' => PDO::FETCH_ASSOC)); foreach ($result as $link) { if (!isset($link['link_path'])) { // If this was not an actual link, fake the tab as a menu link, so we // don't need to special case it beyond this point. $link['link_title'] = $link['title']; $link['link_path'] = $link['path']; $link['options'] = 'a:0:{}'; $link['weight'] = $link['router_weight']; } else { // We found a non-tab subitem, remember that. $has_subitems = TRUE; } _menu_link_translate($link); if (!$link['access']) { continue; } // The link 'description' either derived from the hook_menu 'description' or // entered by the user via menu module is saved as the title attribute. if (!empty($link['localized_options']['attributes']['title'])) { $link['description'] = $link['localized_options']['attributes']['title']; } // Prepare for sorting as in function _menu_tree_check_access(). // The weight is offset so it is always positive, with a uniform 5-digits. $key = (50000 + $link['weight']) . ' ' . drupal_strtolower($link['title']) . ' ' . $link['mlid']; $content[$key] = $link; if ($link['type'] == MENU_DEFAULT_LOCAL_TASK) { $default_task = $key; } } if ($has_subitems) { // If we've had at least one non-tab subitem, remove the link for the // default task, since that is already broken down to subitems. unset($content[$default_task]); } ksort($content); $cache[$item['mlid']] = $content; return $content; } /** * Checks the existence of the directory specified in $form_element. This * function is called from the system_settings form to check both core file * directories (file_public_path, file_private_path, file_temporary_path). * * @param $form_element * The form element containing the name of the directory to check. */ function system_check_directory($form_element) { $directory = $form_element['#value']; if (!is_dir($directory) && !drupal_mkdir($directory, NULL, TRUE)) { // If the directory does not exists and cannot be created. form_set_error($form_element['#parents'][0], t('The directory %directory does not exist and could not be created.', array('%directory' => $directory))); watchdog('file system', 'The directory %directory does not exist and could not be created.', array('%directory' => $directory), WATCHDOG_ERROR); } if (is_dir($directory) && !is_writable($directory) && !drupal_chmod($directory)) { // If the directory is not writable and cannont be made so. form_set_error($form_element['#parents'][0], t('The directory %directory exists but is not writable and could not be made writable.', array('%directory' => $directory))); watchdog('file system', 'The directory %directory exists but is not writable and could not be made writable.', array('%directory' => $directory), WATCHDOG_ERROR); } else { if ($form_element['#name'] == 'file_public_path') { // Create public .htaccess file. file_create_htaccess($directory, FALSE); } else { // Create private .htaccess file. file_create_htaccess($directory); } } return $form_element; } /** * Retrieves the current status of an array of files in the system table. * * @param $files * An array of files to check. * @param $type * The type of the files. */ function system_get_files_database(&$files, $type) { // Extract current files from database. $result = db_query("SELECT filename, name, type, status, schema_version, weight FROM {system} WHERE type = :type", array(':type' => $type)); foreach ($result as $file) { if (isset($files[$file->name]) && is_object($files[$file->name])) { $file->uri = $file->filename; foreach ($file as $key => $value) { if (!isset($files[$file->name]->key)) { $files[$file->name]->$key = $value; } } } } } /** * Updates the records in the system table based on the files array. * * @param $files * An array of files. * @param $type * The type of the files. */ function system_update_files_database(&$files, $type) { $result = db_query("SELECT * FROM {system} WHERE type = :type", array(':type' => $type)); // Add all files that need to be deleted to a DatabaseCondition. $delete = db_or(); foreach ($result as $file) { if (isset($files[$file->name]) && is_object($files[$file->name])) { // Keep the old filename from the database in case the file has moved. $old_filename = $file->filename; $updated_fields = array(); // Handle info specially, compare the serialized value. $serialized_info = serialize($files[$file->name]->info); if ($serialized_info != $file->info) { $updated_fields['info'] = $serialized_info; } unset($file->info); // Scan remaining fields to find only the updated values. foreach ($file as $key => $value) { if (isset($files[$file->name]->$key) && $files[$file->name]->$key != $value) { $updated_fields[$key] = $files[$file->name]->$key; } } // Update the record. if (count($updated_fields)) { db_update('system') ->fields($updated_fields) ->condition('filename', $old_filename) ->execute(); } // Indiciate that the file exists already. $files[$file->name]->exists = TRUE; } else { // File is not found in file system, so delete record from the system table. $delete->condition('filename', $file->filename); } } if (count($delete) > 0) { // Delete all missing files from the system table db_delete('system') ->condition($delete) ->execute(); } // All remaining files are not in the system table, so we need to add them. $query = db_insert('system')->fields(array('filename', 'name', 'type', 'owner', 'info')); foreach($files as &$file) { if (isset($file->exists)) { unset($file->exists); } else { $query->values(array( 'filename' => $file->uri, 'name' => $file->name, 'type' => $type, 'owner' => isset($file->owner) ? $file->owner : '', 'info' => serialize($file->info), )); $file->type = $type; $file->status = 0; $file->schema_version = -1; } } $query->execute(); } /** * Returns an array of information about active modules or themes. * * This function returns the information from the {system} table corresponding * to the cached contents of the .info file for each active module or theme. * * @param $type * Either 'module' or 'theme'. * @return * An associative array of module or theme information keyed by name. * * @see system_rebuild_module_data() * @see system_rebuild_theme_data() */ function system_get_info($type) { $info = array(); $result = db_query('SELECT name, info FROM {system} WHERE type = :type AND status = 1', array(':type' => $type)); foreach ($result as $item) { $info[$item->name] = unserialize($item->info); } return $info; } /** * Helper function to scan and collect module .info data. * * @return * An associative array of module information. */ function _system_rebuild_module_data() { // Find modules $modules = drupal_system_listing('/\.module$/', 'modules', 'name', 0); // Include the install profile in modules that are loaded. $profile = drupal_get_profile(); $modules[$profile]->name = $profile; $modules[$profile]->uri = 'profiles/' . $profile . '/' . $profile . '.profile'; $modules[$profile]->filename = $profile . '.profile'; // Install profile hooks are always executed last. $modules[$profile]->weight = 1000; // Set defaults for module info. $defaults = array( 'dependencies' => array(), 'dependents' => array(), 'description' => '', 'package' => 'Other', 'version' => NULL, 'php' => DRUPAL_MINIMUM_PHP, 'files' => array(), 'bootstrap' => 0, ); // Read info files for each module. foreach ($modules as $key => $module) { // Look for the info file. $module->info = drupal_parse_info_file(dirname($module->uri) . '/' . $module->name . '.info'); // Skip modules that don't provide info. if (empty($module->info)) { unset($modules[$key]); continue; } // Merge in defaults and save. $modules[$key]->info = $module->info + $defaults; // Invoke hook_system_info_alter() to give installed modules a chance to // modify the data in the .info files if necessary. $type = 'module'; drupal_alter('system_info', $modules[$key]->info, $modules[$key], $type); } // The install profile is required. $modules[$profile]->info['required'] = TRUE; return $modules; } /** * Rebuild, save, and return data about all currently available modules. * * @return * Array of all available modules and their data. */ function system_rebuild_module_data() { $modules = _system_rebuild_module_data(); ksort($modules); system_get_files_database($modules, 'module'); system_update_files_database($modules, 'module'); // Refresh bootstrap status. $bootstrap_modules = array(); foreach (bootstrap_hooks() as $hook) { foreach (module_implements($hook) as $module) { $bootstrap_modules[] = $module; } } $query = db_update('system')->fields(array('bootstrap' => 0)); if ($bootstrap_modules) { db_update('system') ->fields(array('bootstrap' => 1)) ->condition('name', $bootstrap_modules, 'IN') ->execute(); $query->condition('name', $bootstrap_modules, 'NOT IN'); } $query->execute(); $modules = _module_build_dependencies($modules); return $modules; } /** * Helper function to scan and collect theme .info data and their engines. * * @return * An associative array of themes information. */ function _system_rebuild_theme_data() { $themes_info = &drupal_static(__FUNCTION__, array()); if (empty($themes_info)) { // Find themes $themes = drupal_system_listing('/\.info$/', 'themes'); // Find theme engines $engines = drupal_system_listing('/\.engine$/', 'themes/engines'); // Set defaults for theme info. $defaults = array( 'regions' => array( 'sidebar_first' => 'Left sidebar', 'sidebar_second' => 'Right sidebar', 'content' => 'Content', 'header' => 'Header', 'footer' => 'Footer', 'highlight' => 'Highlighted content', 'help' => 'Help', 'page_top' => 'Page top', 'page_bottom' => 'Page bottom', ), 'description' => '', 'features' => array( 'comment_user_picture', 'comment_user_verification', 'favicon', 'logo', 'name', 'node_user_picture', 'search', 'slogan', 'main_menu', 'secondary_menu', ), 'screenshot' => 'screenshot.png', 'php' => DRUPAL_MINIMUM_PHP, ); $sub_themes = array(); // Read info files for each theme foreach ($themes as $key => $theme) { $themes[$key]->filename = $theme->uri; $themes[$key]->info = drupal_parse_info_file($theme->uri) + $defaults; // Invoke hook_system_info_alter() to give installed modules a chance to // modify the data in the .info files if necessary. $type = 'theme'; drupal_alter('system_info', $themes[$key]->info, $themes[$key], $type); if (!empty($themes[$key]->info['base theme'])) { $sub_themes[] = $key; } if (empty($themes[$key]->info['engine'])) { $filename = dirname($themes[$key]->uri) . '/' . $themes[$key]->name . '.theme'; if (file_exists($filename)) { $themes[$key]->owner = $filename; $themes[$key]->prefix = $key; } } else { $engine = $themes[$key]->info['engine']; if (isset($engines[$engine])) { $themes[$key]->owner = $engines[$engine]->uri; $themes[$key]->prefix = $engines[$engine]->name; $themes[$key]->template = TRUE; } } // Give the stylesheets proper path information. $pathed_stylesheets = array(); if (isset($themes[$key]->info['stylesheets'])) { foreach ($themes[$key]->info['stylesheets'] as $media => $stylesheets) { foreach ($stylesheets as $stylesheet) { $pathed_stylesheets[$media][$stylesheet] = dirname($themes[$key]->uri) . '/' . $stylesheet; } } } $themes[$key]->info['stylesheets'] = $pathed_stylesheets; // Give the scripts proper path information. $scripts = array(); if (isset($themes[$key]->info['scripts'])) { foreach ($themes[$key]->info['scripts'] as $script) { $scripts[$script] = dirname($themes[$key]->uri) . '/' . $script; } } $themes[$key]->info['scripts'] = $scripts; // Give the screenshot proper path information. if (!empty($themes[$key]->info['screenshot'])) { $themes[$key]->info['screenshot'] = dirname($themes[$key]->uri) . '/' . $themes[$key]->info['screenshot']; } } // Now that we've established all our master themes, go back and fill in // data for subthemes. foreach ($sub_themes as $key) { $themes[$key]->base_themes = system_find_base_themes($themes, $key); // Don't proceed if there was a problem with the root base theme. if (!current($themes[$key]->base_themes)) { continue; } $base_key = key($themes[$key]->base_themes); foreach (array_keys($themes[$key]->base_themes) as $base_theme) { $themes[$base_theme]->sub_themes[$key] = $themes[$key]->info['name']; } // Copy the 'owner' and 'engine' over if the top level theme uses a // theme engine. if (isset($themes[$base_key]->owner)) { if (isset($themes[$base_key]->info['engine'])) { $themes[$key]->info['engine'] = $themes[$base_key]->info['engine']; $themes[$key]->owner = $themes[$base_key]->owner; $themes[$key]->prefix = $themes[$base_key]->prefix; } else { $themes[$key]->prefix = $key; } } } $themes_info = $themes; } return $themes_info; } /** * Rebuild, save, and return data about all currently available themes. * * @return * Array of all available themes and their data. */ function system_rebuild_theme_data() { $themes = _system_rebuild_theme_data(); ksort($themes); system_get_files_database($themes, 'theme'); system_update_files_database($themes, 'theme'); return $themes; } /** * Find all the base themes for the specified theme. * * Themes can inherit templates and function implementations from earlier themes. * * @param $themes * An array of available themes. * @param $key * The name of the theme whose base we are looking for. * @param $used_keys * A recursion parameter preventing endless loops. * @return * Returns an array of all of the theme's ancestors; the first element's value * will be NULL if an error occurred. */ function system_find_base_themes($themes, $key, $used_keys = array()) { $base_key = $themes[$key]->info['base theme']; // Does the base theme exist? if (!isset($themes[$base_key])) { return array($base_key => NULL); } $current_base_theme = array($base_key => $themes[$base_key]->info['name']); // Is the base theme itself a child of another theme? if (isset($themes[$base_key]->info['base theme'])) { // Do we already know the base themes of this theme? if (isset($themes[$base_key]->base_themes)) { return $themes[$base_key]->base_themes + $current_base_theme; } // Prevent loops. if (!empty($used_keys[$base_key])) { return array($base_key => NULL); } $used_keys[$base_key] = TRUE; return system_find_base_themes($themes, $base_key, $used_keys) + $current_base_theme; } // If we get here, then this is our parent theme. return $current_base_theme; } /** * Get a list of available regions from a specified theme. * * @param $theme_key * The name of a theme. * @param $show * Possible values: REGIONS_ALL or REGIONS_VISIBLE. Visible excludes hidden * regions. * @return * An array of regions in the form $region['name'] = 'description'. */ function system_region_list($theme_key, $show = REGIONS_ALL) { $list = &drupal_static(__FUNCTION__, array()); if (empty($list[$theme_key][$show])) { $themes = list_themes(); $info = $themes[$theme_key]->info; // If requested, suppress hidden regions. @see block_admin_display_form(). foreach ($info['regions'] as $name => $label) { if ($show == REGIONS_ALL || !isset($info['regions_hidden']) || !in_array($name, $info['regions_hidden'])) { $list[$theme_key][$show][$name] = $label; } } } return $list[$theme_key][$show]; } /** * Implement hook_system_info_alter(). */ function system_system_info_alter(&$info, $file, $type) { // Remove page-top from the blocks UI since it is reserved for modules to // populate from outside the blocks system. if ($type == 'theme') { $info['regions_hidden'][] = 'page_top'; $info['regions_hidden'][] = 'page_bottom'; } } /** * Get the name of the default region for a given theme. * * @param $theme * The name of a theme. * @return * A string that is the region name. */ function system_default_region($theme) { $regions = array_keys(system_region_list($theme)); return isset($regions[0]) ? $regions[0] : ''; } function _system_settings_form_automatic_defaults($form) { // Get an array of all non-property keys $keys = element_children($form); foreach ($keys as $key) { // If the property (key) '#default_value' exists, replace it. if (array_key_exists('#default_value', $form[$key])) { $form[$key]['#default_value'] = variable_get($key, $form[$key]['#default_value']); } else { // Recurse through child elements $form[$key] = _system_settings_form_automatic_defaults($form[$key]); } } return $form; } /** * Add default buttons to a form and set its prefix. * * @ingroup forms * @see system_settings_form_submit() * @param $form * An associative array containing the structure of the form. * @param $automatic_defaults * Automatically load the saved values for each field from the system variables * (defaults to TRUE). * @return * The form structure. */ function system_settings_form($form, $automatic_defaults = TRUE) { $form['buttons']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration') ); if ($automatic_defaults) { $form = _system_settings_form_automatic_defaults($form); } if (!empty($_POST) && form_get_errors()) { drupal_set_message(t('The settings have not been saved because of the errors.'), 'error'); } $form['#submit'][] = 'system_settings_form_submit'; // By default, render the form using theme_system_settings_form(). if (!isset($form['#theme'])) { $form['#theme'] = 'system_settings_form'; } return $form; } /** * Execute the system_settings_form. * * If you want node type configure style handling of your checkboxes, * add an array_filter value to your form. */ function system_settings_form_submit($form, &$form_state) { // Exclude unnecessary elements. form_state_values_clean($form_state); foreach ($form_state['values'] as $key => $value) { if (is_array($value) && isset($form_state['values']['array_filter'])) { $value = array_keys(array_filter($value)); } variable_set($key, $value); } drupal_set_message(t('The configuration options have been saved.')); cache_clear_all(); drupal_theme_rebuild(); } /** * Helper function to sort requirements. */ function _system_sort_requirements($a, $b) { if (!isset($a['weight'])) { if (!isset($b['weight'])) { return strcmp($a['title'], $b['title']); } return -$b['weight']; } return isset($b['weight']) ? $a['weight'] - $b['weight'] : $a['weight']; } /** * Output a confirmation form * * This function returns a complete form for confirming an action. A link is * offered to go back to the item that is being changed in case the user changes * his/her mind. * * If the submit handler for this form is invoked, the user successfully * confirmed the action. You should never directly inspect $_POST to see if an * action was confirmed. * * Note - if the parameters $question, $description, $yes, or $no could contain * any user input (such as node titles or taxonomy terms), it is the * responsibility of the code calling confirm_form() to sanitize them first with * a function like check_plain() or filter_xss(). * * @ingroup forms * @param $form * Additional elements to inject into the form, for example hidden elements. * @param $question * The question to ask the user (e.g. "Are you sure you want to delete the * block foo?"). * @param $path * The page to go to if the user denies the action. * Can be either a drupal path, or an array with the keys 'path', 'query', 'fragment'. * @param $description * Additional text to display (defaults to "This action cannot be undone."). * @param $yes * A caption for the button which confirms the action (e.g. "Delete", * "Replace", ...). * @param $no * A caption for the link which denies the action (e.g. "Cancel"). * @param $name * The internal name used to refer to the confirmation item. * @return * The form. */ function confirm_form($form, $question, $path, $description = NULL, $yes = NULL, $no = NULL, $name = 'confirm') { $description = isset($description) ? $description : t('This action cannot be undone.'); // Prepare cancel link. if (isset($_GET['destination'])) { $options = drupal_parse_url(urldecode($_GET['destination'])); } elseif (is_array($path)) { $options = $path; } else { $options = array('path' => $path); } $cancel = l($no ? $no : t('Cancel'), $options['path'], $options); drupal_set_title($question, PASS_THROUGH); // Confirm form fails duplication check, as the form values rarely change -- so skip it. $form['#skip_duplicate_check'] = TRUE; $form['#attributes'] = array('class' => array('confirmation')); $form['description'] = array('#markup' => $description); $form[$name] = array('#type' => 'hidden', '#value' => 1); $form['actions'] = array('#prefix' => '