summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-04-29 08:04:24 +0000
committerDries Buytaert <dries@buytaert.net>2009-04-29 08:04:24 +0000
commit94c3dceedae0123f7a1bd518d00aa2839ca82d14 (patch)
tree807ea8505fec1bce86ef7f4bc584e46e917ca456
parent1ed25923a356008fd0148de5d41ee3623d4c8f3e (diff)
downloadbrdo-94c3dceedae0123f7a1bd518d00aa2839ca82d14.tar.gz
brdo-94c3dceedae0123f7a1bd518d00aa2839ca82d14.tar.bz2
- Patch #240873 by Gábor Hojtsy: move custom help settings to blocks. Very exciting.
-rw-r--r--includes/theme.inc12
-rw-r--r--modules/contact/contact.admin.inc5
-rw-r--r--modules/contact/contact.pages.inc3
-rw-r--r--modules/contact/contact.test7
-rw-r--r--modules/system/system.install44
-rw-r--r--modules/system/system.module12
-rw-r--r--modules/user/user.admin.inc1
-rw-r--r--modules/user/user.module5
-rw-r--r--profiles/default/default.profile63
-rw-r--r--profiles/expert/expert.profile52
10 files changed, 163 insertions, 41 deletions
diff --git a/includes/theme.inc b/includes/theme.inc
index b23ba547c..a12c3b5ae 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -1238,17 +1238,6 @@ function theme_breadcrumb($breadcrumb) {
}
/**
- * Return a themed help message.
- *
- * @return a string containing the helptext for the current page.
- */
-function theme_help() {
- if ($help = menu_get_active_help()) {
- return '<div class="help">' . $help . '</div>';
- }
-}
-
-/**
* Return a themed submenu, typically displayed under the tabs.
*
* @param $links
@@ -1859,7 +1848,6 @@ function template_preprocess_page(&$variables) {
$variables['feed_icons'] = drupal_get_feeds();
$variables['footer_message'] = filter_xss_admin(variable_get('site_footer', FALSE));
$variables['head'] = drupal_get_html_head();
- $variables['help'] = theme('help');
$variables['language'] = $GLOBALS['language'];
$variables['language']->dir = $GLOBALS['language']->direction ? 'rtl' : 'ltr';
$variables['logo'] = theme_get_setting('logo');
diff --git a/modules/contact/contact.admin.inc b/modules/contact/contact.admin.inc
index 6fa4404f0..624c01cbf 100644
--- a/modules/contact/contact.admin.inc
+++ b/modules/contact/contact.admin.inc
@@ -164,11 +164,6 @@ function contact_admin_delete_submit($form, &$form_state) {
}
function contact_admin_settings() {
- $form['contact_form_information'] = array('#type' => 'textarea',
- '#title' => t('Additional information'),
- '#default_value' => t('You can leave a message using the contact form below.'),
- '#description' => t('Information to show on the <a href="@form">contact page</a>. Can be anything from submission guidelines to your postal address or telephone number.', array('@form' => url('contact'))),
- );
$form['contact_hourly_threshold'] = array('#type' => 'select',
'#title' => t('Hourly threshold'),
'#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50)),
diff --git a/modules/contact/contact.pages.inc b/modules/contact/contact.pages.inc
index 2984b0d53..65ac85a4f 100644
--- a/modules/contact/contact.pages.inc
+++ b/modules/contact/contact.pages.inc
@@ -47,9 +47,6 @@ function contact_mail_page() {
}
$form['#token'] = $user->uid ? $user->name . $user->mail : '';
- $form['contact_information'] = array(
- '#markup' => filter_xss_admin(variable_get('contact_form_information', t('You can leave a message using the contact form below.'))),
- );
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Your name'),
diff --git a/modules/contact/contact.test b/modules/contact/contact.test
index 692b3c752..ae5fbe1ec 100644
--- a/modules/contact/contact.test
+++ b/modules/contact/contact.test
@@ -27,8 +27,6 @@ class ContactSitewideTestCase extends DrupalWebTestCase {
// Set settings.
$edit = array();
- $contact_form_information = $this->randomName(100);
- $edit['contact_form_information'] = $contact_form_information;
$edit['contact_hourly_threshold'] = 3;
$edit['contact_default_status'] = TRUE;
$this->drupalPost('admin/build/contact/settings', $edit, t('Save configuration'));
@@ -82,7 +80,7 @@ class ContactSitewideTestCase extends DrupalWebTestCase {
$this->setPermission('anonymous user', array('access site-wide contact form' => TRUE));
$this->drupalLogout();
$this->drupalGet('contact');
- $this->assertText($contact_form_information, t('Contact form is shown when there is one category.'));
+ $this->assertText(t('Contact'), t('Contact form is shown when there is one category.'));
$this->assertNoText(t('Category'), t('When there is only one category, the category selection element is hidden.'));
$this->drupalLogin($admin_user);
@@ -113,9 +111,6 @@ class ContactSitewideTestCase extends DrupalWebTestCase {
$this->drupalGet('contact');
$this->assertResponse(200, t('Access granted to anonymous user with permission.'));
- // Check that "Additional information" is displayed on the page.
- $this->assertText($edit['contact_form_information'], t('Contact information displayed.'));
-
// Submit contact form with invalid values.
$this->submitContact('', $recipients[0], $this->randomName(16), $categories[0], $this->randomName(64));
$this->assertText(t('Your name field is required.'), t('Name required.'));
diff --git a/modules/system/system.install b/modules/system/system.install
index 46d4deaa2..84f0eaa76 100644
--- a/modules/system/system.install
+++ b/modules/system/system.install
@@ -3255,6 +3255,50 @@ function system_update_7020() {
}
/**
+ * Add help block to the help region, migrate custom variables to blocks.
+ */
+function system_update_7021() {
+ $ret = array();
+
+ // Collect a list of themes with blocks.
+ $themes_with_blocks = array();
+ $result = db_query("SELECT s.name FROM {system} s INNER JOIN {block} b ON s.name = b.theme WHERE s.type = 'theme' GROUP by s.name");
+ foreach ($result as $theme) {
+ $themes_with_blocks[] = $theme->name;
+ // Add new system generated help block.
+ $ret[] = update_sql("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('system', 'help', '". $theme->name ."', 1, 0, 'help', '', 1)");
+ }
+
+ // Migrate contact form information and user register help to blocks.
+ $bid_max = db_query("SELECT MAX(bid) FROM {box}")->fetchField();
+ if ($contact_help = variable_get('contact_form_information', '')) {
+ db_insert('box')->fields(array('body' => $contact_help, 'info' => 'Contact page help', 'format' => FILTER_FORMAT_DEFAULT))->execute();
+ foreach ($themes_with_blocks as $theme) {
+ // Add contact help block for themes, which had blocks.
+ $ret[] = update_sql("INSERT INTO {block} (module, delta, theme, status, weight, region, visibility, pages, cache) VALUES ('block', '". ($bid_max + 1) ."', '". $theme ."', 1, 5, 'help', 1, 'contact', -1)");
+ }
+ drupal_set_message('The contact form information setting was migrated to <a href="'. url('admin/build/block/configure/block/' . ($bid_max + 1)) . '">a custom block</a> and set up to only show on the site-wide contact page. The block was set to use the default text format, which might differ from the HTML based format used before. Please check the block and ensure that the output is right.');
+ }
+ if ($user_help = variable_get('user_registration_help', '')) {
+ db_insert('box')->fields(array('body' => $user_help, 'info' => 'User registration guidelines', 'format' => FILTER_FORMAT_DEFAULT))->execute();
+ foreach ($themes_with_blocks as $theme) {
+ // Add user registration help block for themes, which had blocks.
+ $ret[] = update_sql("INSERT INTO {block} (module, delta, theme, status, weight, region, visibility, pages, cache) VALUES ('block', '". ($bid_max + 2) ."', '". $theme ."', 1, 5, 'help', 1, 'user/register', -1)");
+ }
+ drupal_set_message('The user registration guidelines were migrated to <a href="'. url('admin/build/block/configure/block/' . ($bid_max + 2)) . '">a custom block</a> and set up to only show on the user registration page. The block was set to use the default text format, which might differ from the HTML based format used before. Please check the block and ensure that the output is right.');
+ }
+ // Remove the two variables (even if they were saved empty on the admin interface),
+ // to avoid keeping clutter in the variables table.
+ variable_del('contact_form_information');
+ variable_del('user_registration_help');
+
+ // Rebuild theme data, so the new 'help' region is identified.
+ system_theme_data();
+
+ return $ret;
+}
+
+/**
* @} End of "defgroup updates-6.x-to-7.x"
* The next series of updates should start at 8000.
*/
diff --git a/modules/system/system.module b/modules/system/system.module
index 96897c6e2..bf10db57a 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -895,6 +895,10 @@ function system_block_list() {
// Not worth caching.
'cache' => BLOCK_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);
@@ -960,6 +964,13 @@ function system_block_view($delta = '') {
$block['subject'] = NULL;
$block['content'] = theme('system_powered_by', $image_path);
return $block;
+ case 'help':
+ return array(
+ // Don't display a title.
+ 'subject' => NULL,
+ 'content' => menu_get_active_help(),
+ );
+ break;
default:
// All system menu blocks.
$system_menus = menu_list_system_menus();
@@ -1121,6 +1132,7 @@ function system_theme_default() {
'content' => 'Content',
'header' => 'Header',
'footer' => 'Footer',
+ 'help' => 'Help',
),
'description' => '',
'features' => array(
diff --git a/modules/user/user.admin.inc b/modules/user/user.admin.inc
index eb5e621f9..dd7430bb5 100644
--- a/modules/user/user.admin.inc
+++ b/modules/user/user.admin.inc
@@ -242,7 +242,6 @@ function user_admin_settings() {
$form['registration'] = array('#type' => 'fieldset', '#title' => t('User registration settings'));
$form['registration']['user_register'] = array('#type' => 'radios', '#title' => t('Public registrations'), '#default_value' => variable_get('user_register', 1), '#options' => array(t('Only site administrators can create new user accounts.'), t('Visitors can create accounts and no administrator approval is required.'), t('Visitors can create accounts but administrator approval is required.')));
$form['registration']['user_email_verification'] = array('#type' => 'checkbox', '#title' => t('Require e-mail verification when a visitor creates an account'), '#default_value' => variable_get('user_email_verification', TRUE), '#description' => t('If this box is checked, new users will be required to validate their e-mail address prior to logging into the site, and will be assigned a system-generated password. With it unchecked, users will be logged in immediately upon registering, and may select their own passwords during registration.'));
- $form['registration']['user_registration_help'] = array('#type' => 'textarea', '#title' => t('User registration guidelines'), '#default_value' => variable_get('user_registration_help', ''), '#description' => t('This text is displayed at the top of the user registration form and is useful for helping or instructing your users.'));
// Account cancellation settings.
module_load_include('inc', 'user', 'user.pages');
diff --git a/modules/user/user.module b/modules/user/user.module
index dc4e95343..c4193c7a3 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -2850,11 +2850,6 @@ function user_register() {
$form = array();
- // Display the registration form.
- if (!$admin) {
- $form['user_registration_help'] = array('#markup' => filter_xss_admin(variable_get('user_registration_help', '')));
- }
-
// Merge in the default user edit fields.
$form = array_merge($form, user_edit_form($form_state, NULL, NULL, TRUE));
if ($admin) {
diff --git a/profiles/default/default.profile b/profiles/default/default.profile
index da4732edb..ab7f1be56 100644
--- a/profiles/default/default.profile
+++ b/profiles/default/default.profile
@@ -91,11 +91,64 @@ function default_profile_task_list() {
*/
function default_profile_tasks(&$task, $url) {
- // Enable 4 standard blocks.
- db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'user', 'login', 'garland', 1, 0, 'left', '', -1);
- db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'system', 'navigation', 'garland', 1, 0, 'left', '', -1);
- db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'system', 'management', 'garland', 1, 1, 'left', '', -1);
- db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'system', 'powered-by', 'garland', 1, 10, 'footer', '', -1);
+ // Enable 5 standard blocks.
+ $values = array(
+ array(
+ 'module' => 'user',
+ 'delta' => 'login',
+ 'theme' => 'garland',
+ 'status' => 1,
+ 'weight' => 0,
+ 'region' => 'left',
+ 'pages' => '',
+ 'cache' => -1
+ ),
+ array(
+ 'module' => 'system',
+ 'delta' => 'navigation',
+ 'theme' => 'garland',
+ 'status' => 1,
+ 'weight' => 0,
+ 'region' => 'left',
+ 'pages' => '',
+ 'cache' => -1
+ ),
+ array(
+ 'module' => 'system',
+ 'delta' => 'management',
+ 'theme' => 'garland',
+ 'status' => 1,
+ 'weight' => 1,
+ 'region' => 'left',
+ 'pages' => '',
+ 'cache' => -1
+ ),
+ array(
+ 'module' => 'system',
+ 'delta' => 'powered-by',
+ 'theme' => 'garland',
+ 'status' => 1,
+ 'weight' => 10,
+ 'region' => 'footer',
+ 'pages' => '',
+ 'cache' => -1
+ ),
+ array(
+ 'module' => 'system',
+ 'delta' => 'help',
+ 'theme' => 'garland',
+ 'status' => 1,
+ 'weight' => 0,
+ 'region' => 'help',
+ 'pages' => '',
+ 'cache' => -1
+ ),
+ );
+ $query = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache'));
+ foreach ($values as $record) {
+ $query->values($record);
+ }
+ $query->execute();
// Insert default user-defined node types into the database. For a complete
// list of available node type attributes, refer to the node type API
diff --git a/profiles/expert/expert.profile b/profiles/expert/expert.profile
index 545f098db..b78fd1241 100644
--- a/profiles/expert/expert.profile
+++ b/profiles/expert/expert.profile
@@ -42,10 +42,54 @@ function expert_profile_task_list() {
* Perform any final installation tasks for this profile.
*/
function expert_profile_tasks(&$task, $url) {
- // Enable 3 standard blocks.
- db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'user', 'login', 'garland', 1, 0, 'left', '', -1);
- db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'system', 'navigation', 'garland', 1, 0, 'left', '', -1);
- db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'system', 'management', 'garland', 1, 1, 'left', '', -1);
+ // Enable 4 standard blocks.
+ $values = array(
+ array(
+ 'module' => 'user',
+ 'delta' => 'login',
+ 'theme' => 'garland',
+ 'status' => 1,
+ 'weight' => 0,
+ 'region' => 'left',
+ 'pages' => '',
+ 'cache' => -1
+ ),
+ array(
+ 'module' => 'system',
+ 'delta' => 'navigation',
+ 'theme' => 'garland',
+ 'status' => 1,
+ 'weight' => 0,
+ 'region' => 'left',
+ 'pages' => '',
+ 'cache' => -1
+ ),
+ array(
+ 'module' => 'system',
+ 'delta' => 'management',
+ 'theme' => 'garland',
+ 'status' => 1,
+ 'weight' => 1,
+ 'region' => 'left',
+ 'pages' => '',
+ 'cache' => -1
+ ),
+ array(
+ 'module' => 'system',
+ 'delta' => 'help',
+ 'theme' => 'garland',
+ 'status' => 1,
+ 'weight' => 0,
+ 'region' => 'help',
+ 'pages' => '',
+ 'cache' => -1
+ ),
+ );
+ $query = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache'));
+ foreach ($values as $record) {
+ $query->values($record);
+ }
+ $query->execute();
}
/**