Index: modules/blog/blog.module =================================================================== RCS file: /cvs/drupal/drupal/modules/blog/blog.module,v retrieving revision 1.299 diff -u -p -r1.299 blog.module --- modules/blog/blog.module 20 Feb 2008 13:46:38 -0000 1.299 +++ modules/blog/blog.module 14 Mar 2008 01:30:47 -0000 @@ -175,7 +175,7 @@ function blog_menu() { function blog_block($op = 'list', $delta = 0) { global $user; if ($op == 'list') { - $block[0]['info'] = t('Recent blog posts'); + $block['recent']['info'] = t('Recent blog posts'); return $block; } else if ($op == 'view') { Index: modules/book/book.module =================================================================== RCS file: /cvs/drupal/drupal/modules/book/book.module,v retrieving revision 1.457 diff -u -p -r1.457 book.module --- modules/book/book.module 20 Feb 2008 13:46:39 -0000 1.457 +++ modules/book/book.module 14 Mar 2008 01:30:49 -0000 @@ -182,8 +182,8 @@ function book_block($op = 'list', $delta $block = array(); switch ($op) { case 'list': - $block[0]['info'] = t('Book navigation'); - $block[0]['cache'] = BLOCK_CACHE_PER_PAGE | BLOCK_CACHE_PER_ROLE; + $block['navigation']['info'] = t('Book navigation'); + $block['navigation']['cache'] = BLOCK_CACHE_PER_PAGE | BLOCK_CACHE_PER_ROLE; return $block; case 'view': $current_bid = 0; Index: modules/comment/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v retrieving revision 1.621 diff -u -p -r1.621 comment.module --- modules/comment/comment.module 23 Feb 2008 08:02:48 -0000 1.621 +++ modules/comment/comment.module 14 Mar 2008 01:30:51 -0000 @@ -287,7 +287,7 @@ function comment_perm() { function comment_block($op = 'list', $delta = 0, $edit = array()) { switch ($op) { case 'list': - $blocks[0]['info'] = t('Recent comments'); + $blocks['recent']['info'] = t('Recent comments'); return $blocks; case 'configure': Index: modules/forum/forum.install =================================================================== RCS file: /cvs/drupal/drupal/modules/forum/forum.install,v retrieving revision 1.16 diff -u -p -r1.16 forum.install --- modules/forum/forum.install 31 Dec 2007 16:58:34 -0000 1.16 +++ modules/forum/forum.install 14 Mar 2008 01:30:53 -0000 @@ -57,8 +57,8 @@ function forum_uninstall() { variable_del('forum_hot_topic'); variable_del('forum_per_page'); variable_del('forum_order'); - variable_del('forum_block_num_0'); - variable_del('forum_block_num_1'); + variable_del('forum_block_num_active'); + variable_del('forum_block_num_new'); } /** Index: modules/forum/forum.module =================================================================== RCS file: /cvs/drupal/drupal/modules/forum/forum.module,v retrieving revision 1.452 diff -u -p -r1.452 forum.module --- modules/forum/forum.module 20 Feb 2008 13:46:39 -0000 1.452 +++ modules/forum/forum.module 14 Mar 2008 01:30:53 -0000 @@ -404,8 +404,8 @@ function forum_load($node) { function forum_block($op = 'list', $delta = 0, $edit = array()) { switch ($op) { case 'list': - $blocks[0]['info'] = t('Active forum topics'); - $blocks[1]['info'] = t('New forum topics'); + $blocks['active']['info'] = t('Active forum topics'); + $blocks['new']['info'] = t('New forum topics'); return $blocks; case 'configure': @@ -419,17 +419,17 @@ function forum_block($op = 'list', $delt case 'view': if (user_access('access content')) { switch ($delta) { - case 0: + case 'active': $title = t('Active forum topics'); $sql = db_rewrite_sql("SELECT n.nid, n.title, l.comment_count, l.last_comment_timestamp FROM {node} n INNER JOIN {term_node} tn ON tn.vid = n.vid INNER JOIN {term_data} td ON td.tid = tn.tid INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.status = 1 AND td.vid = %d ORDER BY l.last_comment_timestamp DESC"); - $result = db_query_range($sql, variable_get('forum_nav_vocabulary', ''), 0, variable_get('forum_block_num_0', '5')); + $result = db_query_range($sql, variable_get('forum_nav_vocabulary', ''), 0, variable_get('forum_block_num_active', '5')); $content = node_title_list($result); break; - case 1: + case 'new': $title = t('New forum topics'); $sql = db_rewrite_sql("SELECT n.nid, n.title, l.comment_count FROM {node} n INNER JOIN {term_node} tn ON tn.vid = n.vid INNER JOIN {term_data} td ON td.tid = tn.tid INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.status = 1 AND td.vid = %d ORDER BY n.nid DESC"); - $result = db_query_range($sql, variable_get('forum_nav_vocabulary', ''), 0, variable_get('forum_block_num_1', '5')); + $result = db_query_range($sql, variable_get('forum_nav_vocabulary', ''), 0, variable_get('forum_block_num_new', '5')); $content = node_title_list($result); break; } Index: modules/locale/locale.module =================================================================== RCS file: /cvs/drupal/drupal/modules/locale/locale.module,v retrieving revision 1.214 diff -u -p -r1.214 locale.module --- modules/locale/locale.module 20 Feb 2008 13:46:39 -0000 1.214 +++ modules/locale/locale.module 14 Mar 2008 01:30:54 -0000 @@ -558,9 +558,9 @@ function locale_update_js_files() { */ function locale_block($op = 'list', $delta = 0) { if ($op == 'list') { - $block[0]['info'] = t('Language switcher'); + $block['language-switcher']['info'] = t('Language switcher'); // Not worth caching. - $block[0]['cache'] = BLOCK_NO_CACHE; + $block['language-switcher']['cache'] = BLOCK_NO_CACHE; return $block; } Index: modules/node/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.module,v retrieving revision 1.951 diff -u -p -r1.951 node.module --- modules/node/node.module 13 Mar 2008 21:26:08 -0000 1.951 +++ modules/node/node.module 14 Mar 2008 01:30:57 -0000 @@ -1609,9 +1609,9 @@ function node_revision_list($node) { */ function node_block($op = 'list', $delta = 0) { if ($op == 'list') { - $blocks[0]['info'] = t('Syndicate'); + $blocks['syndicate']['info'] = t('Syndicate'); // Not worth caching. - $blocks[0]['cache'] = BLOCK_NO_CACHE; + $blocks['syndicate']['cache'] = BLOCK_NO_CACHE; return $blocks; } else if ($op == 'view') { Index: modules/poll/poll.module =================================================================== RCS file: /cvs/drupal/drupal/modules/poll/poll.module,v retrieving revision 1.264 diff -u -p -r1.264 poll.module --- modules/poll/poll.module 20 Feb 2008 13:46:40 -0000 1.264 +++ modules/poll/poll.module 14 Mar 2008 01:30:59 -0000 @@ -137,7 +137,7 @@ function _poll_menu_access($node, $perm, function poll_block($op = 'list', $delta = 0) { if (user_access('access content')) { if ($op == 'list') { - $blocks[0]['info'] = t('Most recent poll'); + $blocks['recent']['info'] = t('Most recent poll'); return $blocks; } else if ($op == 'view') { Index: modules/profile/profile.module =================================================================== RCS file: /cvs/drupal/drupal/modules/profile/profile.module,v retrieving revision 1.236 diff -u -p -r1.236 profile.module --- modules/profile/profile.module 3 Feb 2008 19:36:46 -0000 1.236 +++ modules/profile/profile.module 14 Mar 2008 01:31:00 -0000 @@ -134,11 +134,11 @@ function profile_menu() { function profile_block($op = 'list', $delta = 0, $edit = array()) { if ($op == 'list') { - $blocks[0]['info'] = t('Author information'); - $blocks[0]['cache'] = BLOCK_CACHE_PER_PAGE | BLOCK_CACHE_PER_ROLE; + $blocks['author-information']['info'] = t('Author information'); + $blocks['author-information']['cache'] = BLOCK_CACHE_PER_PAGE | BLOCK_CACHE_PER_ROLE; return $blocks; } - else if ($op == 'configure' && $delta == 0) { + else if ($op == 'configure') { // Compile a list of fields to show $fields = array(); $result = db_query('SELECT name, title, weight, visibility FROM {profile_fields} WHERE visibility IN (%d, %d) ORDER BY weight', PROFILE_PUBLIC, PROFILE_PUBLIC_LISTINGS); @@ -146,7 +146,8 @@ function profile_block($op = 'list', $de $fields[$record->name] = check_plain($record->title); } $fields['user_profile'] = t('Link to full user profile'); - $form['profile_block_author_fields'] = array('#type' => 'checkboxes', + $form['profile_block_author_fields'] = array( + '#type' => 'checkboxes', '#title' => t('Profile fields to display'), '#default_value' => variable_get('profile_block_author_fields', NULL), '#options' => $fields, @@ -154,7 +155,7 @@ function profile_block($op = 'list', $de ); return $form; } - else if ($op == 'save' && $delta == 0) { + else if ($op == 'save') { variable_set('profile_block_author_fields', $edit['profile_block_author_fields']); } else if ($op == 'view') { Index: modules/search/search.module =================================================================== RCS file: /cvs/drupal/drupal/modules/search/search.module,v retrieving revision 1.251 diff -u -p -r1.251 search.module --- modules/search/search.module 20 Feb 2008 13:46:40 -0000 1.251 +++ modules/search/search.module 14 Mar 2008 01:31:01 -0000 @@ -153,9 +153,9 @@ function search_perm() { */ function search_block($op = 'list', $delta = 0) { if ($op == 'list') { - $blocks[0]['info'] = t('Search form'); + $blocks['form']['info'] = t('Search form'); // Not worth caching. - $blocks[0]['cache'] = BLOCK_NO_CACHE; + $blocks['form']['cache'] = BLOCK_NO_CACHE; return $blocks; } else if ($op == 'view' && user_access('search content')) { Index: modules/statistics/statistics.module =================================================================== RCS file: /cvs/drupal/drupal/modules/statistics/statistics.module,v retrieving revision 1.273 diff -u -p -r1.273 statistics.module --- modules/statistics/statistics.module 20 Feb 2008 13:46:40 -0000 1.273 +++ modules/statistics/statistics.module 14 Mar 2008 01:31:01 -0000 @@ -246,9 +246,9 @@ function statistics_block($op = 'list', switch ($op) { case 'list': if (variable_get('statistics_count_content_views', 0)) { - $blocks[0]['info'] = t('Popular content'); + $blocks['popular']['info'] = t('Popular content'); // Too dynamic to cache. - $blocks[0]['cache'] = BLOCK_NO_CACHE; + $blocks['popular']['cache'] = BLOCK_NO_CACHE; return $blocks; } break; Index: modules/system/block.tpl.php =================================================================== RCS file: /cvs/drupal/drupal/modules/system/block.tpl.php,v retrieving revision 1.4 diff -u -p -r1.4 block.tpl.php --- modules/system/block.tpl.php 1 Sep 2007 05:42:48 -0000 1.4 +++ modules/system/block.tpl.php 14 Mar 2008 01:31:01 -0000 @@ -10,7 +10,7 @@ * - $block->subject: Block title. * - $block->content: Block content. * - $block->module: Module that generated the block. - * - $block->delta: This is a numeric id connected to each module. + * - $block->delta: An ID for the block, unique within each module. * - $block->region: The block region embedding the current block. * * Helper variables: Index: modules/system/system.install =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.install,v retrieving revision 1.240 diff -u -p -r1.240 system.install --- modules/system/system.install 23 Feb 2008 08:13:09 -0000 1.240 +++ modules/system/system.install 14 Mar 2008 01:31:04 -0000 @@ -371,9 +371,9 @@ function system_install() { db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", 'theme_default', 's:7:"garland";'); db_query("UPDATE {system} SET status = %d WHERE type = '%s' AND name = '%s'", 1, 'theme', 'garland'); - db_query("INSERT INTO {blocks} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'user', '0', 'garland', 1, 0, 'left', '', -1); - db_query("INSERT INTO {blocks} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'user', '1', 'garland', 1, 0, 'left', '', -1); - db_query("INSERT INTO {blocks} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'system', '0', 'garland', 1, 10, 'footer', '', -1); + db_query("INSERT INTO {blocks} (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 {blocks} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'user', 'navigation', 'garland', 1, 0, 'left', '', -1); + db_query("INSERT INTO {blocks} (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); db_query("INSERT INTO {node_access} (nid, gid, realm, grant_view, grant_update, grant_delete) VALUES (%d, %d, '%s', %d, %d, %d)", 0, 0, 'all', 1, 0, 0); @@ -2549,6 +2549,96 @@ function system_update_7000() { } /** + * Remove hardcoded numeric deltas from all blocks in core. + */ +function system_update_7001(&$sandbox) { + $ret = array(); + // Get an array of the renamed block deltas, organized by module. + $renamed_deltas = array( + 'blog' => array('0' => 'recent'), + 'book' => array('0' => 'navigation'), + 'comment' => array('0' => 'recent'), + 'forum' => array( + '0' => 'active', + '1' => 'new', + ), + 'locale' => array('0' => 'language-switcher'), + 'node' => array('0' => 'syndicate'), + 'poll' => array('0' => 'recent'), + 'profile' => array('0' => 'author-information'), + 'search' => array('0' => 'form'), + 'statistics' => array('0' => 'popular'), + 'system' => array('0' => 'powered-by'), + 'user' => array( + '0' => 'login', + '1' => 'navigation', + '2' => 'new', + '3' => 'online', + ), + ); + // Loop through each block and make changes to the core block tables. + // Only run this the first time through the batch update. + if (!isset($sandbox['progress'])) { + $block_tables = array('blocks', 'blocks_roles'); + foreach ($block_tables as $table) { + foreach ($renamed_deltas as $module => $deltas) { + foreach ($deltas as $old_delta => $new_delta) { + // Only do the update if the old block actually exists. + if (db_result(db_query("SELECT COUNT(*) FROM {". $table ."} WHERE module = '%s' AND delta = '%s'", $module, $old_delta))) { + $ret[] = update_sql("UPDATE {". $table ."} SET delta = '". $new_delta ."' WHERE module = '". $module ."' AND delta = '". $old_delta ."'"); + } + } + } + } + // Rename forum module's block variables. + $forum_block_num_0 = variable_get('forum_block_num_0', NULL); + if (isset($forum_block_num_0)) { + variable_set('forum_block_num_active', $forum_block_num_0); + variable_del('forum_block_num_0'); + } + $forum_block_num_1 = variable_get('forum_block_num_1', NULL); + if (isset($forum_block_num_1)) { + variable_set('forum_block_num_new', $forum_block_num_1); + variable_del('forum_block_num_1'); + } + // Initialize batch update information. + $sandbox['progress'] = 0; + $sandbox['last_user_processed'] = -1; + $sandbox['max'] = db_result(db_query("SELECT COUNT(*) FROM {users} WHERE data IS NOT NULL")); + } + // Now do the batch update of the user-specific block visibility settings. + $limit = 100; + $result = db_query_range("SELECT uid, data FROM {users} WHERE uid > %d AND data IS NOT NULL", $sandbox['last_user_processed'], 0, $limit); + while ($row = db_fetch_object($result)) { + $data = unserialize($row->data); + $user_needs_update = FALSE; + foreach ($renamed_deltas as $module => $deltas) { + foreach ($deltas as $old_delta => $new_delta) { + if (isset($data['block'][$module][$old_delta])) { + // Transfer the old block visibility settings to the newly-renamed + // block, and mark this user for a database update. + $data['block'][$module][$new_delta] = $data['block'][$module][$old_delta]; + unset($data['block'][$module][$old_delta]); + $user_needs_update = TRUE; + } + } + } + // Update the current user. + if ($user_needs_update) { + db_query("UPDATE {users} SET data = '%s' WHERE uid = %d", serialize($data), $row->uid); + } + // Update our progress information for the batch update. + $sandbox['progress']++; + $sandbox['last_user_processed'] = $row->uid; + } + // Indicate our current progress to the batch update system. + if ($sandbox['progress'] < $sandbox['max']) { + $ret['#finished'] = $sandbox['progress'] / $sandbox['max']; + } + return $ret; +} + +/** * @} End of "defgroup updates-6.x-to-7.x" * The next series of updates should start at 8000. */ Index: modules/system/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.module,v retrieving revision 1.593 diff -u -p -r1.593 system.module --- modules/system/system.module 11 Mar 2008 08:13:14 -0000 1.593 +++ modules/system/system.module 14 Mar 2008 01:31:05 -0000 @@ -580,7 +580,7 @@ function system_user($type, $edit, &$use function system_block($op = 'list', $delta = 0, $edit = NULL) { switch ($op) { case 'list': - $blocks[0] = array( + $blocks['powered-by'] = array( 'info' => t('Powered by Drupal'), 'weight' => '10', // Not worth caching. Index: modules/user/user.module =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.module,v retrieving revision 1.896 diff -u -p -r1.896 user.module --- modules/user/user.module 20 Feb 2008 13:46:43 -0000 1.896 +++ modules/user/user.module 14 Mar 2008 01:31:12 -0000 @@ -633,23 +633,23 @@ function user_block($op = 'list', $delta global $user; if ($op == 'list') { - $blocks[0]['info'] = t('User login'); + $blocks['login']['info'] = t('User login'); // Not worth caching. - $blocks[0]['cache'] = BLOCK_NO_CACHE; + $blocks['login']['cache'] = BLOCK_NO_CACHE; - $blocks[1]['info'] = t('Navigation'); + $blocks['navigation']['info'] = t('Navigation'); // Menu blocks can't be cached because each menu item can have // a custom access callback. menu.inc manages its own caching. - $blocks[1]['cache'] = BLOCK_NO_CACHE; + $blocks['navigation']['cache'] = BLOCK_NO_CACHE; - $blocks[2]['info'] = t('Who\'s new'); + $blocks['new']['info'] = t('Who\'s new'); // Too dynamic to cache. - $blocks[3]['info'] = t('Who\'s online'); - $blocks[3]['cache'] = BLOCK_NO_CACHE; + $blocks['online']['info'] = t('Who\'s online'); + $blocks['online']['cache'] = BLOCK_NO_CACHE; return $blocks; } - else if ($op == 'configure' && $delta == 2) { + else if ($op == 'configure' && $delta == 'new') { $form['user_block_whois_new_count'] = array( '#type' => 'select', '#title' => t('Number of users to display'), @@ -658,17 +658,17 @@ function user_block($op = 'list', $delta ); return $form; } - else if ($op == 'configure' && $delta == 3) { + else if ($op == 'configure' && $delta == 'online') { $period = drupal_map_assoc(array(30, 60, 120, 180, 300, 600, 900, 1800, 2700, 3600, 5400, 7200, 10800, 21600, 43200, 86400), 'format_interval'); $form['user_block_seconds_online'] = array('#type' => 'select', '#title' => t('User activity'), '#default_value' => variable_get('user_block_seconds_online', 900), '#options' => $period, '#description' => t('A user is considered online for this long after they have last viewed a page.')); $form['user_block_max_list_count'] = array('#type' => 'select', '#title' => t('User list length'), '#default_value' => variable_get('user_block_max_list_count', 10), '#options' => drupal_map_assoc(array(0, 5, 10, 15, 20, 25, 30, 40, 50, 75, 100)), '#description' => t('Maximum number of currently online users to display.')); return $form; } - else if ($op == 'save' && $delta == 2) { + else if ($op == 'save' && $delta == 'new') { variable_set('user_block_whois_new_count', $edit['user_block_whois_new_count']); } - else if ($op == 'save' && $delta == 3) { + else if ($op == 'save' && $delta == 'online') { variable_set('user_block_seconds_online', $edit['user_block_seconds_online']); variable_set('user_block_max_list_count', $edit['user_block_max_list_count']); } @@ -676,7 +676,7 @@ function user_block($op = 'list', $delta $block = array(); switch ($delta) { - case 0: + case 'login': // For usability's sake, avoid showing two login forms on one page. if (!$user->uid && !(arg(0) == 'user' && !is_numeric(arg(1)))) { @@ -685,14 +685,14 @@ function user_block($op = 'list', $delta } return $block; - case 1: + case 'navigation': if ($menu = menu_tree()) { $block['subject'] = $user->uid ? check_plain($user->name) : t('Navigation'); $block['content'] = $menu; } return $block; - case 2: + case 'new': if (user_access('access content')) { // Retrieve a list of new users who have subsequently accessed the site successfully. $result = db_query_range('SELECT uid, name FROM {users} WHERE status != 0 AND access != 0 ORDER BY created DESC', 0, variable_get('user_block_whois_new_count', 5)); @@ -706,7 +706,7 @@ function user_block($op = 'list', $delta } return $block; - case 3: + case 'online': if (user_access('access content')) { // Count users active within the defined period. $interval = time() - variable_get('user_block_seconds_online', 900); Index: themes/garland/style-rtl.css =================================================================== RCS file: /cvs/drupal/drupal/themes/garland/style-rtl.css,v retrieving revision 1.8 diff -u -p -r1.8 style-rtl.css --- themes/garland/style-rtl.css 13 Mar 2008 20:02:18 -0000 1.8 +++ themes/garland/style-rtl.css 14 Mar 2008 01:31:14 -0000 @@ -220,17 +220,17 @@ html.js fieldset.collapsed legend a { /** * Syndication Block */ -#block-node-0 h2 { +#block-node-syndicate h2 { float: right; padding-right: 0; padding-left: 20px; } -#block-node-0 img { +#block-node-syndicate img { float: left; } -#block-node-0 .content { +#block-node-syndicate .content { clear: left; } Index: themes/garland/style.css =================================================================== RCS file: /cvs/drupal/drupal/themes/garland/style.css,v retrieving revision 1.40 diff -u -p -r1.40 style.css --- themes/garland/style.css 13 Mar 2008 20:02:18 -0000 1.40 +++ themes/garland/style.css 14 Mar 2008 01:31:14 -0000 @@ -868,17 +868,17 @@ html.js fieldset.collapsed legend a { /** * Syndication icons and block */ -#block-node-0 h2 { +#block-node-syndicate h2 { float: left; /* LTR */ padding-right: 20px; /* LTR */ } -#block-node-0 img, .feed-icon { +#block-node-syndicate img, .feed-icon { float: right; /* LTR */ padding-top: 4px; } -#block-node-0 .content { +#block-node-syndicate .content { clear: right; /* LTR */ }