Commit 35dde8e3 authored by Dries's avatar Dries

- Patch #769540 by cafuego: block variables lack defines.

parent 0ee32d7c
......@@ -272,10 +272,10 @@ function block_admin_configure($form, &$form_state, $module, $delta) {
);
$access = user_access('use PHP for settings');
if (isset($block->visibility) && $block->visibility == 2 && !$access) {
if (isset($block->visibility) && $block->visibility == BLOCK_VISIBILITY_PHP && !$access) {
$form['visibility']['path']['visibility'] = array(
'#type' => 'value',
'#value' => 2,
'#value' => BLOCK_VISIBILITY_PHP,
);
$form['visibility']['path']['pages'] = array(
'#type' => 'value',
......@@ -284,13 +284,13 @@ function block_admin_configure($form, &$form_state, $module, $delta) {
}
else {
$options = array(
t('All pages except those listed'),
t('Only the listed pages'),
BLOCK_VISIBILITY_NOTLISTED => t('All pages except those listed'),
BLOCK_VISIBILITY_LISTED => t('Only the listed pages'),
);
$description = t("Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>'));
if (module_exists('php') && $access) {
$options[] = t('Pages on which this PHP code returns <code>TRUE</code> (experts only)');
$options += array(BLOCK_VISIBILITY_PHP => t('Pages on which this PHP code returns <code>TRUE</code> (experts only)'));
$title = t('Pages or PHP code');
$description .= ' ' . t('If the PHP option is chosen, enter PHP code between %php. Note that executing incorrect PHP code can break your Drupal site.', array('%php' => '<?php ?>'));
}
......@@ -301,7 +301,7 @@ function block_admin_configure($form, &$form_state, $module, $delta) {
'#type' => 'radios',
'#title' => t('Show block on specific pages'),
'#options' => $options,
'#default_value' => isset($block->visibility) ? $block->visibility : 0,
'#default_value' => isset($block->visibility) ? $block->visibility : BLOCK_VISIBILITY_NOTLISTED,
);
$form['visibility']['path']['pages'] = array(
'#type' => 'textarea',
......@@ -346,12 +346,12 @@ function block_admin_configure($form, &$form_state, $module, $delta) {
'#type' => 'radios',
'#title' => t('Customizable per user'),
'#options' => array(
t('Not customizable'),
t('Customizable, visible by default'),
t('Customizable, hidden by default'),
BLOCK_CUSTOM_FIXED => t('Not customizable'),
BLOCK_CUSTOM_ENABLED => t('Customizable, visible by default'),
BLOCK_CUSTOM_DISABLED => t('Customizable, hidden by default'),
),
'#description' => t('Allow individual users to customize the visibility of this block in their account settings.'),
'#default_value' => isset($block->custom) ? $block->custom : 0,
'#default_value' => isset($block->custom) ? $block->custom : BLOCK_CUSTOM_FIXED,
);
$form['actions'] = array('#type' => 'actions');
......
......@@ -91,7 +91,7 @@ function block_schema() {
'not null' => TRUE,
'default' => 1,
'size' => 'tiny',
'description' => 'Binary flag to indicate block cache mode. (-1: Do not cache, 1: Cache per role, 2: Cache per user, 4: Cache per page, 8: Block cache global) See BLOCK_CACHE_* constants in block.module for more detailed information.',
'description' => 'Binary flag to indicate block cache mode. (-2: Custom cache, -1: Do not cache, 1: Cache per role, 2: Cache per user, 4: Cache per page, 8: Block cache global) See DRUPAL_CACHE_* constants in ../includes/common.inc for more detailed information.',
),
),
'primary key' => array('bid'),
......@@ -254,7 +254,7 @@ function block_update_7004() {
'weight' => 0,
'region' => 'help',
'pages' => '',
'cache' => 1,
'cache' => DRUPAL_CACHE_PER_ROLE,
));
// Add new system generated main page content block.
$insert->values(array(
......@@ -265,7 +265,7 @@ function block_update_7004() {
'weight' => 0,
'region' => 'content',
'pages' => '',
'cache' => -1,
'cache' => DRUPAL_NO_CACHE,
));
}
$insert->execute();
......@@ -301,9 +301,9 @@ function block_update_7004() {
'status' => 1,
'weight' => 5,
'region' => 'help',
'visibility' => 1,
'visibility' => BLOCK_VISIBILITY_LISTED,
'pages' => 'contact',
'cache' => -1,
'cache' => DRUPAL_NO_CACHE,
));
}
drupal_set_message('The contact form information setting was migrated to <a href="' . url('admin/structure/block/manage/block/' . $bid . '/configure') . '">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. Check the block and ensure that the output is right.');
......@@ -324,9 +324,9 @@ function block_update_7004() {
'status' => 1,
'weight' => 5,
'region' => 'help',
'visibility' => 1,
'visibility' => BLOCK_VISIBILITY_LISTED,
'pages' => 'user/register',
'cache' => -1,
'cache' => DRUPAL_NO_CACHE,
));
}
drupal_set_message('The user registration guidelines were migrated to <a href="' . url('admin/structure/block/manage/block/' . $bid . '/configure') . '">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. Check the block and ensure that the output is right.');
......@@ -347,9 +347,9 @@ function block_update_7004() {
'status' => 1,
'weight' => 0,
'region' => 'highlight',
'visibility' => 1,
'visibility' => BLOCK_VISIBILITY_LISTED,
'pages' => '<front>',
'cache' => -1,
'cache' => DRUPAL_NO_CACHE,
));
}
drupal_set_message('The site mission was migrated to <a href="' . url('admin/structure/block/manage/block/' . $bid . '/configure') . '">a custom block</a> and set up to only show on the front page in the highlighted content region. The block was set to use the default text format, which might differ from the HTML based format used before. Check the block and ensure that the output is right. If your theme does not have a highlighted content region, you might need to <a href="' . url('admin/structure/block') . '">relocate the block</a>.');
......@@ -375,7 +375,7 @@ function block_update_7004() {
'weight' => -10,
'region' => 'footer',
'pages' => '',
'cache' => -1,
'cache' => DRUPAL_NO_CACHE,
));
}
drupal_set_message('The footer message was migrated to <a href="' . url('admin/structure/block/manage/block/' . $bid . '/configure') . '">a custom block</a> and set up to appear in the footer. The block was set to use the default text format, which might differ from the HTML based format used before. Check the block and ensure that the output is right. If your theme does not have a footer region, you might need to <a href="' . url('admin/structure/block') . '">relocate the block</a>.');
......
......@@ -11,6 +11,36 @@
*/
define('BLOCK_REGION_NONE', -1);
/**
* Users cannot control whether or not they see this block.
*/
define('BLOCK_CUSTOM_FIXED', 0);
/**
* Show this block by default, but let individual users hide it.
*/
define('BLOCK_CUSTOM_ENABLED', 1);
/**
* Hide this block by default but let individual users show it.
*/
define('BLOCK_CUSTOM_DISABLED', 2);
/**
* Show this block on every page except the listed pages.
*/
define('BLOCK_VISIBILITY_NOTLISTED', 0);
/**
* Show this block on only the listed pages.
*/
define('BLOCK_VISIBILITY_LISTED', 1);
/**
* Show this block if the associated PHP code returns TRUE.
*/
define('BLOCK_VISIBILITY_PHP', 2);
/**
* Implements hook_help().
*/
......@@ -700,12 +730,12 @@ function block_block_list_alter(&$blocks) {
}
// Use the user's block visibility setting, if necessary.
if ($block->custom != 0) {
if ($block->custom != BLOCK_CUSTOM_FIXED) {
if ($user->uid && isset($user->block[$block->module][$block->delta])) {
$enabled = $user->block[$block->module][$block->delta];
}
else {
$enabled = ($block->custom == 1);
$enabled = ($block->custom == BLOCK_CUSTOM_ENABLED);
}
}
else {
......@@ -721,7 +751,7 @@ function block_block_list_alter(&$blocks) {
// Convert path to lowercase. This allows comparison of the same path
// with different case. Ex: /Page, /page, /PAGE.
$pages = drupal_strtolower($block->pages);
if ($block->visibility < 2) {
if ($block->visibility < BLOCK_VISIBILITY_PHP) {
// Convert the Drupal path to lowercase
$path = drupal_strtolower(drupal_get_path_alias($_GET['q']));
// Compare the lowercase internal and lowercase path alias (if any).
......@@ -729,9 +759,10 @@ function block_block_list_alter(&$blocks) {
if ($path != $_GET['q']) {
$page_match = $page_match || drupal_match_path($_GET['q'], $pages);
}
// When $block->visibility has a value of 0, the block is displayed on
// all pages except those listed in $block->pages. When set to 1, it
// is displayed only on those pages listed in $block->pages.
// When $block->visibility has a value of 0 (BLOCK_VISIBILITY_NOTLISTED),
// the block is displayed on all pages except those listed in $block->pages.
// When set to 1 (BLOCK_VISIBILITY_LISTED), it is displayed only on those
// pages listed in $block->pages.
$page_match = !($block->visibility xor $page_match);
}
elseif (module_exists('php')) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment