summaryrefslogtreecommitdiff
path: root/modules/system
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 /modules/system
parent1ed25923a356008fd0148de5d41ee3623d4c8f3e (diff)
downloadbrdo-94c3dceedae0123f7a1bd518d00aa2839ca82d14.tar.gz
brdo-94c3dceedae0123f7a1bd518d00aa2839ca82d14.tar.bz2
- Patch #240873 by Gábor Hojtsy: move custom help settings to blocks. Very exciting.
Diffstat (limited to 'modules/system')
-rw-r--r--modules/system/system.install44
-rw-r--r--modules/system/system.module12
2 files changed, 56 insertions, 0 deletions
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(