summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorSteven Wittens <steven@10.no-reply.drupal.org>2004-08-06 11:10:15 +0000
committerSteven Wittens <steven@10.no-reply.drupal.org>2004-08-06 11:10:15 +0000
commit300f91f4a7c7e4ae177176ba4421128597144ade (patch)
treed8b1859f67555f2efa280f0b36e116505949ecb8 /modules
parentcabd6c892cbce8c1483c46fe76ce3885cd5f9e41 (diff)
downloadbrdo-300f91f4a7c7e4ae177176ba4421128597144ade.tar.gz
brdo-300f91f4a7c7e4ae177176ba4421128597144ade.tar.bz2
- Cleaning up the rediculously long 'if' statement for checking block visibility.
- #9811: Remove session ID before matching block path
Diffstat (limited to 'modules')
-rw-r--r--modules/block.module18
-rw-r--r--modules/block/block.module18
2 files changed, 32 insertions, 4 deletions
diff --git a/modules/block.module b/modules/block.module
index 1678509b7..18461edca 100644
--- a/modules/block.module
+++ b/modules/block.module
@@ -351,9 +351,23 @@ function block_list($region) {
if ($block['custom'] && $user->uid && !isset($user->block[$block['module']][$block['delta']])) {
$user->block[$block['module']][$block['delta']] = $block['status'];
}
- $base = parse_url($base_url);
- if ((($block['status'] && (!$user->uid || !$block['custom'])) || ($block['custom'] && $user->block[$block['module']][$block['delta']])) && (!$block['path'] || preg_match($block['path'], ereg_replace('^/(\?q=)?', '', str_replace($base['path'], '', request_uri()))))) {
+ // Determine block visibility
+ $enabled = $block['status'] && (!$user->uid || !$block['custom']);
+ $custom = $block['custom'] && $user->block[$block['module']][$block['delta']];
+
+ // Match path if necessary
+ if ($block['path']) {
+ $base = parse_url($base_url);
+ $session = session_name() .'='. session_id();
+ $url = str_replace(array($base['path'], '?'. $session), '', request_uri());
+ $matched = preg_match($block['path'], ereg_replace('^/(\?q=)?', '', $path);
+ }
+ else {
+ $matched = true;
+ }
+
+ if (($enabled || $custom) && $matched) {
/*
** Check the current throttle status and see if block should be displayed
** based on server load.
diff --git a/modules/block/block.module b/modules/block/block.module
index 1678509b7..18461edca 100644
--- a/modules/block/block.module
+++ b/modules/block/block.module
@@ -351,9 +351,23 @@ function block_list($region) {
if ($block['custom'] && $user->uid && !isset($user->block[$block['module']][$block['delta']])) {
$user->block[$block['module']][$block['delta']] = $block['status'];
}
- $base = parse_url($base_url);
- if ((($block['status'] && (!$user->uid || !$block['custom'])) || ($block['custom'] && $user->block[$block['module']][$block['delta']])) && (!$block['path'] || preg_match($block['path'], ereg_replace('^/(\?q=)?', '', str_replace($base['path'], '', request_uri()))))) {
+ // Determine block visibility
+ $enabled = $block['status'] && (!$user->uid || !$block['custom']);
+ $custom = $block['custom'] && $user->block[$block['module']][$block['delta']];
+
+ // Match path if necessary
+ if ($block['path']) {
+ $base = parse_url($base_url);
+ $session = session_name() .'='. session_id();
+ $url = str_replace(array($base['path'], '?'. $session), '', request_uri());
+ $matched = preg_match($block['path'], ereg_replace('^/(\?q=)?', '', $path);
+ }
+ else {
+ $matched = true;
+ }
+
+ if (($enabled || $custom) && $matched) {
/*
** Check the current throttle status and see if block should be displayed
** based on server load.