Skip to content
Browse files

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.
  • Loading branch information...
1 parent b62b7ed commit 555fdea7e61414769925c5a0f0dc41f78ebd91b0 @mudrd8mz mudrd8mz committed with stronk7 Dec 3, 2011
Showing with 11 additions and 5 deletions.
  1. +11 −5 lib/blocklib.php
View
16 lib/blocklib.php
@@ -1236,20 +1236,26 @@ public function process_url_edit() {
// 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';
+ }
}
}
}

0 comments on commit 555fdea

Please sign in to comment.
Something went wrong with that request. Please try again.