From 9d2c424d832404155fb03bd244813ecfdfddb9e0 Mon Sep 17 00:00:00 2001 From: David Mudrak Date: Sat, 3 Dec 2011 14:11:26 +0100 Subject: [PATCH] MDL-30340 Block stickiness computation improvements This is an attempt to clean up and fix the computation of the block stickiness. At first, the page pattern can't be ignored because the user may want to currently try to limit the page pattern. Second, the site-index pattern can be forced only if the user selected 'Front page only' as the page context. --- lib/blocklib.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/blocklib.php b/lib/blocklib.php index b39badb51a2..a25b5d4b515 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -1235,20 +1235,26 @@ class block_manager { // Explicitly set the context $bi->parentcontextid = $parentcontext->id; - // If the context type is > 0 then we'll explicitly set the block as sticky, otherwise not - $bi->showinsubcontexts = (int)(!empty($data->bui_contexts)); + // Should the block be sticky + if ($data->bui_contexts == BUI_CONTEXTS_ENTIRE_SITE or $data->bui_contexts == BUI_CONTEXTS_FRONTPAGE_SUBS) { + $bi->showinsubcontexts = true; + } else { + $bi->showinsubcontexts = false; + } // If the block wants to be system-wide, then explicitly set that if ($data->bui_contexts == BUI_CONTEXTS_ENTIRE_SITE) { // Only possible on a frontpage or system page $bi->parentcontextid = $systemcontext->id; - $bi->showinsubcontexts = BUI_CONTEXTS_CURRENT_SUBS; //show in current and sub contexts - $bi->pagetypepattern = '*'; } else { // The block doesn't want to be system-wide, so let's ensure that if ($parentcontext->id == $systemcontext->id) { // We need to move it to the front page $frontpagecontext = get_context_instance(CONTEXT_COURSE, SITEID); $bi->parentcontextid = $frontpagecontext->id; - $bi->pagetypepattern = 'site-index'; + if ($data->bui_contexts == BUI_CONTEXTS_FRONTPAGE_ONLY) { + // If the front page only is specified, the page type setting is ignored + // as explicitely set to site-index + $bi->pagetypepattern = 'site-index'; + } } } } -- 2.43.0