summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/system/system.admin.inc125
-rw-r--r--modules/system/system.module14
-rw-r--r--modules/system/system.test2
3 files changed, 112 insertions, 29 deletions
diff --git a/modules/system/system.admin.inc b/modules/system/system.admin.inc
index df12ae6c8..b7fb7d38d 100644
--- a/modules/system/system.admin.inc
+++ b/modules/system/system.admin.inc
@@ -1511,41 +1511,52 @@ function system_ip_blocking_delete_submit($form, &$form_state) {
* @see system_settings_form()
*/
function system_site_information_settings() {
- $form['site_name'] = array(
+ $form['site_information'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Site details'),
+ );
+ $form['site_information']['site_name'] = array(
'#type' => 'textfield',
'#title' => t('Site name'),
'#default_value' => variable_get('site_name', 'Drupal'),
'#required' => TRUE
);
- $form['site_slogan'] = array(
+ $form['site_information']['site_slogan'] = array(
'#type' => 'textfield',
'#title' => t('Slogan'),
'#default_value' => variable_get('site_slogan', ''),
'#description' => t("How this is used depends on your site's theme."),
);
- $form['site_mail'] = array(
+ $form['site_information']['site_mail'] = array(
'#type' => 'textfield',
'#title' => t('E-mail address'),
'#default_value' => variable_get('site_mail', ini_get('sendmail_from')),
'#description' => t("The <em>From</em> address in automated e-mails sent during registration and new password requests, and other notifications. (Use an address ending in your site's domain to help prevent this e-mail being flagged as spam.)"),
'#required' => TRUE,
);
- $form['site_frontpage'] = array(
- '#type' => 'textfield',
- '#title' => t('Default front page'),
- '#default_value' => drupal_get_path_alias(variable_get('site_frontpage', 'node')),
- '#size' => 40,
- '#description' => t('The home page displays content from this relative URL. If unsure, specify "node".'),
- '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='),
- '#required' => TRUE,
+ $form['front_page'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Front page'),
);
- $form['default_nodes_main'] = array(
+ $form['front_page']['default_nodes_main'] = array(
'#type' => 'select', '#title' => t('Number of posts on front page'),
'#default_value' => variable_get('default_nodes_main', 10),
'#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)),
'#description' => t('The maximum number of posts displayed on overview pages such as the front page.')
);
- $form['site_403'] = array(
+ $form['front_page']['site_frontpage'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Default front page'),
+ '#default_value' => (variable_get('site_frontpage')!='node'?drupal_get_path_alias(variable_get('site_frontpage', 'node')):''),
+ '#size' => 40,
+ '#description' => t('Optionally, specify a relative URL to display as the front page. Leave blank to display the default content feed.'),
+ '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='),
+ );
+ $form['error_page'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Error pages'),
+ );
+ $form['error_page']['site_403'] = array(
'#type' => 'textfield',
'#title' => t('Default 403 (access denied) page'),
'#default_value' => variable_get('site_403', ''),
@@ -1553,7 +1564,7 @@ function system_site_information_settings() {
'#description' => t('This page is displayed when the requested document is denied to the current user. Leave blank to display a generic "access denied" page.'),
'#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q=')
);
- $form['site_404'] = array(
+ $form['error_page']['site_404'] = array(
'#type' => 'textfield',
'#title' => t('Default 404 (not found) page'),
'#default_value' => variable_get('site_404', ''),
@@ -1561,13 +1572,6 @@ function system_site_information_settings() {
'#description' => t('This page is displayed when no other content matches the requested document. Leave blank to display a generic "page not found" page.'),
'#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q=')
);
- $form['cron_safe_threshold'] = array(
- '#type' => 'select',
- '#title' => t('Automatically run cron'),
- '#default_value' => variable_get('cron_safe_threshold', DRUPAL_CRON_DEFAULT_THRESHOLD),
- '#options' => array(0 => t('Never')) + drupal_map_assoc(array(3600, 10800, 21600, 43200, 86400, 604800), 'format_interval'),
- '#description' => t('When enabled, the site will check whether cron has been run in the configured interval and automatically run it upon the next page request. For more information visit the <a href="@status-report-url">status report page</a>.', array('@status-report-url' => url('admin/reports/status'))),
- );
$form['#validate'][] = 'system_site_information_settings_validate';
@@ -1575,19 +1579,90 @@ function system_site_information_settings() {
}
/**
- * Validate the submitted site-information form.
+ * Validates the submitted site-information form.
*/
function system_site_information_settings_validate($form, &$form_state) {
// Validate the e-mail address.
if ($error = user_validate_mail($form_state['values']['site_mail'])) {
form_set_error('site_mail', $error);
}
- // Get the normal path of the front page.
- form_set_value($form['site_frontpage'], drupal_get_normal_path($form_state['values']['site_frontpage']), $form_state);
+ // Check for empty front page path.
+ if (empty($form_state['values']['site_frontpage'])) {
+ // Set to default "node".
+ form_set_value($form['front_page']['site_frontpage'], 'node', $form_state);
+ }
+ else {
+ // Get the normal path of the front page.
+ form_set_value($form['front_page']['site_frontpage'], drupal_get_normal_path($form_state['values']['site_frontpage']), $form_state);
+ }
// Validate front page path.
if (!drupal_valid_path($form_state['values']['site_frontpage'])) {
- form_set_error('site_frontpage', t("The path '@path' is either invalid or you do not have access to it.", array('@path' => $form_state['values']['site_frontpage'])));
+ form_set_error('site_frontpage', t("The path '%path' is either invalid or you do not have access to it.", array('%path' => $form_state['values']['site_frontpage'])));
}
+ // Get the normal paths of both error pages.
+ if (!empty($form_state['values']['site_403'])) {
+ form_set_value($form['error_page']['site_403'], drupal_get_normal_path($form_state['values']['site_403']), $form_state);
+ }
+ if (!empty($form_state['values']['site_404'])) {
+ form_set_value($form['error_page']['site_404'], drupal_get_normal_path($form_state['values']['site_404']), $form_state);
+ }
+ // Validate 403 error path.
+ if (!empty($form_state['values']['site_403']) && !drupal_valid_path($form_state['values']['site_403'])) {
+ form_set_error('site_403', t("The path '%path' is either invalid or you do not have access to it.", array('%path' => $form_state['values']['site_403'])));
+ }
+ // Validate 404 error path.
+ if (!empty($form_state['values']['site_404']) && !drupal_valid_path($form_state['values']['site_404'])) {
+ form_set_error('site_404', t("The path '%path' is either invalid or you do not have access to it.", array('%path' => $form_state['values']['site_404'])));
+ }
+}
+
+/**
+ * Form builder; Cron form.
+ *
+ * @see system_settings_form()
+ * @ingroup forms
+ */
+function system_cron_settings() {
+ $form['description'] = array(
+ '#markup' => '<p>'.t('Cron takes care of running periodical tasks like checking for updates and indexing content for search.').'</p>',
+ );
+ $form['run'] = array(
+ '#type' => 'submit',
+ '#value' => t('Run cron'),
+ '#submit' => array('system_run_cron_submit'),
+ );
+ $status = '<p>' . t('Last run: %cron-last ago.', array('%cron-last' => format_interval(REQUEST_TIME - variable_get('cron_last')),)) . '</p>';
+ $form['status'] = array(
+ '#markup' => $status,
+ );
+ $form['cron'] = array(
+ '#type' => 'fieldset',
+ );
+ $form['cron']['cron_safe_threshold'] = array(
+ '#type' => 'select',
+ '#title' => t('Run cron every'),
+ '#default_value' => variable_get('cron_safe_threshold', DRUPAL_CRON_DEFAULT_THRESHOLD),
+ '#options' => array(0 => t('Never')) + drupal_map_assoc(array(3600, 10800, 21600, 43200, 86400, 604800), 'format_interval'),
+ );
+
+ return system_settings_form($form, FALSE);
+}
+
+/**
+ * Submit callback; run cron.
+ *
+ * @ingroup forms
+ */
+function system_run_cron_submit($form, &$form_state) {
+ // Run cron manually from Cron form.
+ if (drupal_cron_run()) {
+ drupal_set_message(t('Cron run successfully.'));
+ }
+ else {
+ drupal_set_message(t('Cron run failed.'), 'error');
+ }
+
+ drupal_goto('admin/config/system/cron');
}
/**
diff --git a/modules/system/system.module b/modules/system/system.module
index 9be91061b..364feb0e0 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -80,7 +80,7 @@ function system_help($path, $arg) {
$output .= '<dt>' . t('Managing caching') . '</dt>';
$output .= '<dd>' . t("The System module allows users with the appropriate permissions to manage caching on the <a href='@cache-settings'>Performance settings page</a>. Drupal has a robust caching system that allows the efficient re-use of previously-constructed web pages and web page components. Pages requested by anonymous users are stored in a compressed format; depending on your site configuration and the amount of your web traffic tied to anonymous visitors, the caching system may significantly increase the speed of your site.", array('@cache-settings' => url('admin/config/development/performance'))) . '</dd>';
$output .= '<dt>' . t('Performing system maintenance') . '</dt>';
- $output .= '<dd>' . t('In order for the site and its modules to continue to operate well, a set of routine administrative operations must run on a regular basis. The System module manages this task by making use of a system cron job. You can verify the status of cron tasks by visiting the <a href="@status">Status report page</a>. For more information, see the online handbook entry for <a href="@handbook">configuring cron jobs</a>.', array('@status' => url('admin/reports/status'), '@handbook' => 'http://drupal.org/cron')) . '</dd>';
+ $output .= '<dd>' . t('In order for the site and its modules to continue to operate well, a set of routine administrative operations must run on a regular basis. The System module manages this task by making use of a system cron job. You can verify the status of cron tasks by visiting the <a href="@status">Status report page</a>. For more information, see the online handbook entry for <a href="@handbook">configuring cron jobs</a>. You can set up cron job by visiting <a href="@cron">Cron configuration</a> page', array('@status' => url('admin/reports/status'), '@handbook' => 'http://drupal.org/cron', '@cron' => url('admin/config/system/cron'))) . '</dd>';
$output .= '<dt>' . t('Configuring basic site settings') . '</dt>';
$output .= '<dd>' . t('The System module also handles basic configuration options for your site, including <a href="@date-time-settings">Date and time settings</a>, <a href="@file-system">File system settings</a>, <a href="@clean-url">Clean URL support</a>, <a href="@site-info">Site name and other information</a>, and a <a href="@maintenance-mode">Maintenance mode</a> for taking your site temporarily offline.', array('@date-time-settings' => url('admin/config/regional/date-time'), '@file-system' => url('admin/config/media/file-system'), '@clean-url' => url('admin/config/search/clean-urls'), '@site-info' => url('admin/config/system/site-information'), '@maintenance-mode' => url('admin/config/development/maintenance'))) . '</dd>';
$output .= '<dt>' . t('Configuring actions') . '</dt>';
@@ -957,14 +957,22 @@ function system_menu() {
);
$items['admin/config/system/site-information'] = array(
'title' => 'Site information',
- 'description' => 'Change site name, e-mail address, slogan, default front page, number of posts per page, error pages and cron.',
+ 'description' => t('Change site name, e-mail address, slogan, default front page, and number of posts per page, error pages.'),
'page callback' => 'drupal_get_form',
'page arguments' => array('system_site_information_settings'),
'access arguments' => array('administer site configuration'),
'file' => 'system.admin.inc',
'weight' => -20,
);
-
+ $items['admin/config/system/cron'] = array(
+ 'title' => t('Cron'),
+ 'description' => t('Manage automatic site maintenance tasks.'),
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('system_cron_settings'),
+ 'access arguments' => array('administer site configuration'),
+ 'file' => 'system.admin.inc',
+ 'weight' => 20,
+ );
// Additional categories
$items['admin/config/user-interface'] = array(
'title' => 'User interface',
diff --git a/modules/system/system.test b/modules/system/system.test
index c5a67f9d0..1e5777c3b 100644
--- a/modules/system/system.test
+++ b/modules/system/system.test
@@ -553,7 +553,7 @@ class CronRunTestCase extends DrupalWebTestCase {
// Disable the cron threshold through the interface.
$admin_user = $this->drupalCreateUser(array('administer site configuration'));
$this->drupalLogin($admin_user);
- $this->drupalPost('admin/config/system/site-information', array('cron_safe_threshold' => 0), t('Save configuration'));
+ $this->drupalPost('admin/config/system/cron', array('cron_safe_threshold' => 0), t('Save configuration'));
$this->assertText(t('The configuration options have been saved.'));
$this->drupalLogout();