From 4e1e5c8db68c8407422d9ba485b14b84678512a9 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Sat, 3 Dec 2011 11:21:48 +0100 Subject: [PATCH 1/8] MDL-30340 blocks - avoid lockin'blocks in subcontexts. Everytime that one block instance is edited @ any subcontext, guarantee that the 'bring back' pattern (* = all pages) is available, so the block can be reseted to its original context --- lib/blocklib.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/blocklib.php b/lib/blocklib.php index 0cd4620d535..692a6a944e8 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -1661,6 +1661,13 @@ function generate_page_type_patterns($pagetype, $parentcontext = null, $currentc $patterns = default_page_type_list($pagetype, $parentcontext, $currentcontext); } + // Ensure that the * pattern is always available if editing block 'at distance', so + // we always can 'bring back' it to the original context. MDL-30340 + if ($currentcontext->id != $parentcontext->id && !isset($patterns['*'])) { + // TODO: We could change the string here, showing its 'bring back' meaning + $patterns['*'] = get_string('page-x', 'pagetype'); + } + return $patterns; } From 0a6326625bea995f1978c5f5b300755851828dd4 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Sat, 3 Dec 2011 15:36:00 +0100 Subject: [PATCH 2/8] MDL-30340 blocks - add back 'any page' support to course cats Added the * option that is not affected by the 'varying-pagetype' problem that has been detected and issued @ MDL-30564. So now, it's (back) possible to define coursecat blocks to be spread over children coursecats/courses/modules (contexts). --- admin/lib.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/admin/lib.php b/admin/lib.php index 7b4331961ca..ac698737e0a 100644 --- a/admin/lib.php +++ b/admin/lib.php @@ -35,5 +35,16 @@ function admin_page_type_list($pagetype, $parentcontext, $currentcontext) { 'admin-*' => get_string('page-admin-x', 'pagetype'), $pagetype => get_string('page-admin-current', 'pagetype') ); + // Add the missing * (any page) option for them. MDL-30340 + // TODO: These pages are really 'pagetype-varying' - MDL-30564 - + // and some day we should stop behaving that way, so proper pagetypes + // can be specified for it (like course-category-* or so). + // Luckly... the option we are introducing '*' is independent + // of that varying behavior, so will work. + if ($pagetype == 'admin-course-category') { + $array += array( + '*' => get_string('page-x', 'pagetype') + ); + } return $array; -} \ No newline at end of file +} From 0f9d4689fb7f503cb65a8bb2df9ffda9d3741858 Mon Sep 17 00:00:00 2001 From: David Mudrak Date: Sat, 3 Dec 2011 14:07:44 +0100 Subject: [PATCH 3/8] MDL-30340 Trivial change in PHP doc block - the function does not accept any params --- lib/blocklib.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/blocklib.php b/lib/blocklib.php index 692a6a944e8..942c24a6a64 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -1062,9 +1062,6 @@ class block_manager { /** * Process any block actions that were specified in the URL. * - * This can only be done given a valid $page object. - * - * @param moodle_page $page the page to add blocks to. * @return boolean true if anything was done. False if not. */ public function process_url_actions() { From b62b7ed0b6efdb51e6fa5cdd10b91c32ec9d1e64 Mon Sep 17 00:00:00 2001 From: David Mudrak Date: Sat, 3 Dec 2011 14:08:52 +0100 Subject: [PATCH 4/8] MDL-30340 Always generate pagetype patterns in the block settings form This is an alternative solution to MDL-27812. If the current block instance has page type set to site-index, we need to provide a way how that page type pattern can be reset back to other value. --- blocks/edit_form.php | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/blocks/edit_form.php b/blocks/edit_form.php index 80b361ea3bf..1e1cf8ca3e8 100644 --- a/blocks/edit_form.php +++ b/blocks/edit_form.php @@ -126,23 +126,19 @@ class block_edit_form extends moodleform { $mform->addElement('select', 'bui_contexts', get_string('contexts', 'block'), $contextoptions); } + // Generate pagetype patterns by callbacks $displaypagetypewarning = false; - if ($this->page->pagetype == 'site-index') { // No need for pagetype list on home page - $pagetypelist = array('*'=>get_string('page-x', 'pagetype')); - } else { - // Generate pagetype patterns by callbacks - $pagetypelist = generate_page_type_patterns($this->page->pagetype, $parentcontext, $this->page->context); - if (!array_key_exists($this->block->instance->pagetypepattern, $pagetypelist)) { - // Pushing block's existing page type pattern - $pagetypestringname = 'page-'.str_replace('*', 'x', $this->block->instance->pagetypepattern); - if (get_string_manager()->string_exists($pagetypestringname, 'pagetype')) { - $pagetypelist[$this->block->instance->pagetypepattern] = get_string($pagetypestringname, 'pagetype'); - } else { - //as a last resort we could put the page type pattern in the select box - //however this causes mod-data-view to be added if the only option available is mod-data-* - // so we are just showing a warning to users about their prev setting being reset - $displaypagetypewarning = true; - } + $pagetypelist = generate_page_type_patterns($this->page->pagetype, $parentcontext, $this->page->context); + if (!array_key_exists($this->block->instance->pagetypepattern, $pagetypelist)) { + // Pushing block's existing page type pattern + $pagetypestringname = 'page-'.str_replace('*', 'x', $this->block->instance->pagetypepattern); + if (get_string_manager()->string_exists($pagetypestringname, 'pagetype')) { + $pagetypelist[$this->block->instance->pagetypepattern] = get_string($pagetypestringname, 'pagetype'); + } else { + //as a last resort we could put the page type pattern in the select box + //however this causes mod-data-view to be added if the only option available is mod-data-* + // so we are just showing a warning to users about their prev setting being reset + $displaypagetypewarning = true; } } From 555fdea7e61414769925c5a0f0dc41f78ebd91b0 Mon Sep 17 00:00:00 2001 From: David Mudrak Date: Sat, 3 Dec 2011 14:11:26 +0100 Subject: [PATCH 5/8] 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 942c24a6a64..19bf9dd46d7 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -1236,20 +1236,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'; + } } } } From 2805eb38167c202ab57047758de614e1f0a23568 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Mon, 5 Dec 2011 00:48:08 +0100 Subject: [PATCH 6/8] MDL-30340 blocks - hide some redundant pagetypepattern options at front page The dual front-page/system-wide form to edit blocks can be reduced asuming that, always: A) system sets the context to system, recursively and with page-type set to "*" B) frontpage only sets the context to site-course, non-recursively and with page-type set to "site-index" C) frontpage all added sets the context to site-course, recursively and with paget-type set to "*" And that is the change that this patch provides, by: 1) detecting properly if we are editing blocks @ protpage 2) passing that information to the form data processor 3) setting parentcontextid, showinsubcontexts and pagetypepattern following the A, B, C immutables above. Finally, and affecting some other system-wide pages, there are cases (my, user templates...) having only one possible pagetypepattern, and it looks badly if the page has subpages, so for those system-wide cases we are showing exceptionaly the pagetypepattern statically. This will be revisited once MDL-30574 is decided and implemented, although perhaps it's ok to leave it as default to places with only one pagetypepattern available. --- blocks/edit_form.php | 97 +++++++++++++++++++++++++++++++------------- lib/blocklib.php | 58 ++++++++++++++++---------- 2 files changed, 105 insertions(+), 50 deletions(-) diff --git a/blocks/edit_form.php b/blocks/edit_form.php index 1e1cf8ca3e8..9b7198c0c50 100644 --- a/blocks/edit_form.php +++ b/blocks/edit_form.php @@ -93,24 +93,44 @@ class block_edit_form extends moodleform { $mform->addElement('static', 'bui_homecontext', get_string('createdat', 'block'), print_context_name($parentcontext)); $mform->addHelpButton('bui_homecontext', 'createdat', 'block'); + // For pre-calculated (fixed) pagetype lists + $pagetypelist = array(); + // parse pagetype patterns $bits = explode('-', $this->page->pagetype); - $contextoptions = array(); - if ( ($parentcontext->contextlevel == CONTEXT_COURSE && $parentcontext->instanceid == SITEID) || - ($parentcontext->contextlevel == CONTEXT_SYSTEM)) { // Home page - if ($bits[0] == 'tag' || $bits[0] == 'admin') { - // tag and admin pages always use system context - // the contexts options don't make differences, so we use - // page type patterns only - $mform->addElement('hidden', 'bui_contexts', BUI_CONTEXTS_ENTIRE_SITE); - } else { - $contextoptions[BUI_CONTEXTS_FRONTPAGE_ONLY] = get_string('showonfrontpageonly', 'block'); - $contextoptions[BUI_CONTEXTS_FRONTPAGE_SUBS] = get_string('showonfrontpageandsubs', 'block'); - $contextoptions[BUI_CONTEXTS_ENTIRE_SITE] = get_string('showonentiresite', 'block'); - $mform->addElement('select', 'bui_contexts', get_string('contexts', 'block'), $contextoptions); - $mform->addHelpButton('bui_contexts', 'contexts', 'block'); - } + // First of all, check if we are editing blocks @ front-page or no and + // make some dark magic if so (MDL-30340) because each page context + // implies one (and only one) harcoded page-type that will be set later + // when processing the form data at {@link block_manager::process_url_edit()} + + // There are some conditions to check related to contexts + $ctxconditions = $this->page->context->contextlevel == CONTEXT_COURSE && + $this->page->context->instanceid == get_site()->id; + // And also some pagetype conditions + $pageconditions = isset($bits[0]) && isset($bits[1]) && $bits[0] == 'site' && $bits[1] == 'index'; + // So now we can be 100% sure if edition is happening at frontpage + $editingatfrontpage = $ctxconditions && $pageconditions; + + // Let the form to know about that, can be useful later + $mform->addElement('hidden', 'bui_editingatfrontpage', (int)$editingatfrontpage); + + // Front page, show the page-contexts element and set $pagetypelist to 'any page' (*) + // as unique option. Processign the form will do any change if needed + if ($editingatfrontpage) { + $contextoptions = array(); + $contextoptions[BUI_CONTEXTS_FRONTPAGE_ONLY] = get_string('showonfrontpageonly', 'block'); + $contextoptions[BUI_CONTEXTS_FRONTPAGE_SUBS] = get_string('showonfrontpageandsubs', 'block'); + $contextoptions[BUI_CONTEXTS_ENTIRE_SITE] = get_string('showonentiresite', 'block'); + $mform->addElement('select', 'bui_contexts', get_string('contexts', 'block'), $contextoptions); + $mform->addHelpButton('bui_contexts', 'contexts', 'block'); + $pagetypelist['*'] = '*'; // This is not going to be shown ever, it's an unique option + + // Any other system context block, hide the page-contexts element, + // it's always system-wide BUI_CONTEXTS_ENTIRE_SITE + } else if ($parentcontext->contextlevel == CONTEXT_SYSTEM) { + $mform->addElement('hidden', 'bui_contexts', BUI_CONTEXTS_ENTIRE_SITE); + } else if ($parentcontext->contextlevel == CONTEXT_COURSE) { // 0 means display on current context only, not child contexts // but if course managers select mod-* as pagetype patterns, block system will overwrite this option @@ -126,19 +146,21 @@ class block_edit_form extends moodleform { $mform->addElement('select', 'bui_contexts', get_string('contexts', 'block'), $contextoptions); } - // Generate pagetype patterns by callbacks - $displaypagetypewarning = false; - $pagetypelist = generate_page_type_patterns($this->page->pagetype, $parentcontext, $this->page->context); - if (!array_key_exists($this->block->instance->pagetypepattern, $pagetypelist)) { - // Pushing block's existing page type pattern - $pagetypestringname = 'page-'.str_replace('*', 'x', $this->block->instance->pagetypepattern); - if (get_string_manager()->string_exists($pagetypestringname, 'pagetype')) { - $pagetypelist[$this->block->instance->pagetypepattern] = get_string($pagetypestringname, 'pagetype'); - } else { - //as a last resort we could put the page type pattern in the select box - //however this causes mod-data-view to be added if the only option available is mod-data-* - // so we are just showing a warning to users about their prev setting being reset - $displaypagetypewarning = true; + // Generate pagetype patterns by callbacks if necessary (has not been set specifically) + if (empty($pagetypelist)) { + $pagetypelist = generate_page_type_patterns($this->page->pagetype, $parentcontext, $this->page->context); + $displaypagetypewarning = false; + if (!array_key_exists($this->block->instance->pagetypepattern, $pagetypelist)) { + // Pushing block's existing page type pattern + $pagetypestringname = 'page-'.str_replace('*', 'x', $this->block->instance->pagetypepattern); + if (get_string_manager()->string_exists($pagetypestringname, 'pagetype')) { + $pagetypelist[$this->block->instance->pagetypepattern] = get_string($pagetypestringname, 'pagetype'); + } else { + //as a last resort we could put the page type pattern in the select box + //however this causes mod-data-view to be added if the only option available is mod-data-* + // so we are just showing a warning to users about their prev setting being reset + $displaypagetypewarning = true; + } } } @@ -152,6 +174,25 @@ class block_edit_form extends moodleform { } else { $value = array_pop(array_keys($pagetypelist)); $mform->addElement('hidden', 'bui_pagetypepattern', $value); + // Now we are really hiding a lot (both page-contexts and page-type-patterns), + // specially in some systemcontext pages having only one option (my/user...) + // so, until it's decided if we are going to add the 'bring-back' pattern to + // all those pages or no (see MDL-30574), we are going to show the unique + // element statically + // TODO: Revisit this once MDL-30574 has been decided and implemented, although + // perhaps it's not bad to always show this statically when only one pattern is + // available. + if (!$editingatfrontpage) { + // Try to beautify it + $strvalue = $value; + $strkey = 'page-'.str_replace('*', 'x', $strvalue); + if (get_string_manager()->string_exists($strkey, 'pagetype')) { + $strvalue = get_string($strkey, 'pagetype'); + } + // Show as static (hidden has been set already) + $mform->addElement('static', 'bui_staticpagetypepattern', + get_string('restrictpagetypes','block'), $strvalue); + } } if ($this->page->subpage) { diff --git a/lib/blocklib.php b/lib/blocklib.php index 19bf9dd46d7..0396db743ef 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -1228,35 +1228,49 @@ class block_manager { $bi->subpagepattern = $data->bui_subpagepattern; } - $parentcontext = get_context_instance_by_id($data->bui_parentcontextid); $systemcontext = get_context_instance(CONTEXT_SYSTEM); + $frontpagecontext = get_context_instance(CONTEXT_COURSE, SITEID); + $parentcontext = get_context_instance_by_id($data->bui_parentcontextid); // Updating stickiness and contexts. See MDL-21375 for details. if (has_capability('moodle/site:manageblocks', $parentcontext)) { // Check permissions in destination - // Explicitly set the context + + // Explicitly set the default context $bi->parentcontextid = $parentcontext->id; - // 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; - - } 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; - 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'; + // Perform some exceptions for system/frontpage data. MDL-30340 + switch ($data->bui_contexts) { + case BUI_CONTEXTS_ENTIRE_SITE: + // it's a system-wide block. 100% guaranteed, set parentcontextid and showinsubcontexts + $bi->parentcontextid = $systemcontext->id; + $bi->showinsubcontexts = true; + // and also, if it's one edition @ frontpage, set its pagetypepattern to '*' + // it already arrives that way from the form, but just re-enforce it here + if ($data->bui_editingatfrontpage) { + $bi->pagetypepattern = '*'; } - } + break; + case BUI_CONTEXTS_FRONTPAGE_SUBS: + // it's a frontpage-wide (with subcontexts) block. 100% guaranteed, set parentcontextid and showinsubcontexts + $bi->parentcontextid = $frontpagecontext->id; + $bi->showinsubcontexts = true; + // and also, if it's one edition @ frontpage, set its pagetypepattern to '*' + // it already arrives that way from the form, but just re-enforce it here + if ($data->bui_editingatfrontpage) { + $bi->pagetypepattern = '*'; + } + break; + case BUI_CONTEXTS_FRONTPAGE_ONLY: + // it's a frontpage-only (no subcontexts) block. 100% guaranteed, set parentcontextid and showinsubcontexts + $bi->parentcontextid = $frontpagecontext->id; + $bi->showinsubcontexts = false; + // and also, if it's one edition @ frontpage, set its pagetypepattern to 'site-index' + // it originally comes as '*' from the form, here we change that in proviosion of + // future 'site-index' pages + if ($data->bui_editingatfrontpage) { + $bi->pagetypepattern = 'site-index'; + } + break; } } From 01343e6835c9668bb94c7e7e495976b792893c1a Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Mon, 5 Dec 2011 01:14:19 +0100 Subject: [PATCH 7/8] MDL-30340 blocks - incorrect option in user profile template and missing lang string in my template --- lib/blocklib.php | 2 +- user/lib.php | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/blocklib.php b/lib/blocklib.php index 0396db743ef..e34f85f06d5 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -1725,7 +1725,7 @@ function default_page_type_list($pagetype, $parentcontext = null, $currentcontex * @return array */ function my_page_type_list($pagetype, $parentcontext = null, $currentcontext = null) { - return array('my-index' => 'my-index'); + return array('my-index' => get_string('page-my-index', 'pagetype')); } /** diff --git a/user/lib.php b/user/lib.php index 5685942d4b7..4bea392d47c 100644 --- a/user/lib.php +++ b/user/lib.php @@ -347,8 +347,5 @@ function user_get_user_details($user, $course = null) { * @param stdClass $currentcontext Current context of block */ function user_page_type_list($pagetype, $parentcontext, $currentcontext) { - return array( - 'user-profile'=>get_string('page-user-profile', 'pagetype'), - 'my-index'=>get_string('page-my-index', 'pagetype') - ); + return array('user-profile'=>get_string('page-user-profile', 'pagetype')); } From 2f4a98c99d76127dc635c640b8a96d49d4081bee Mon Sep 17 00:00:00 2001 From: Martin Dougiamas Date: Mon, 5 Dec 2011 10:28:54 +0100 Subject: [PATCH 8/8] MDL-30340 blocks - fix/restrict frontpage dark magic application It seems that there are some overlapping constants in the blocks subsystem that were causing some code, initially planned only to frontpage, to be executed in other contexts. This commit moves the bui_editingatfrontpage condition as root condition. --- lib/blocklib.php | 54 +++++++++++++++++++++--------------------------- 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/lib/blocklib.php b/lib/blocklib.php index e34f85f06d5..17a9ba779d3 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -1238,39 +1238,33 @@ class block_manager { // Explicitly set the default context $bi->parentcontextid = $parentcontext->id; - // Perform some exceptions for system/frontpage data. MDL-30340 - switch ($data->bui_contexts) { - case BUI_CONTEXTS_ENTIRE_SITE: - // it's a system-wide block. 100% guaranteed, set parentcontextid and showinsubcontexts - $bi->parentcontextid = $systemcontext->id; - $bi->showinsubcontexts = true; - // and also, if it's one edition @ frontpage, set its pagetypepattern to '*' - // it already arrives that way from the form, but just re-enforce it here - if ($data->bui_editingatfrontpage) { + if ($data->bui_editingatfrontpage) { // The block is being edited on the front page + + // The interface here is a special case because the pagetype pattern is + // totally derived from the context menu. Here are the excpetions. MDL-30340 + + switch ($data->bui_contexts) { + case BUI_CONTEXTS_ENTIRE_SITE: + // The user wants to show the block across the entire site + $bi->parentcontextid = $systemcontext->id; + $bi->showinsubcontexts = true; $bi->pagetypepattern = '*'; - } - break; - case BUI_CONTEXTS_FRONTPAGE_SUBS: - // it's a frontpage-wide (with subcontexts) block. 100% guaranteed, set parentcontextid and showinsubcontexts - $bi->parentcontextid = $frontpagecontext->id; - $bi->showinsubcontexts = true; - // and also, if it's one edition @ frontpage, set its pagetypepattern to '*' - // it already arrives that way from the form, but just re-enforce it here - if ($data->bui_editingatfrontpage) { + break; + case BUI_CONTEXTS_FRONTPAGE_SUBS: + // The user wants the block shown on the front page and all subcontexts + $bi->parentcontextid = $frontpagecontext->id; + $bi->showinsubcontexts = true; $bi->pagetypepattern = '*'; - } - break; - case BUI_CONTEXTS_FRONTPAGE_ONLY: - // it's a frontpage-only (no subcontexts) block. 100% guaranteed, set parentcontextid and showinsubcontexts - $bi->parentcontextid = $frontpagecontext->id; - $bi->showinsubcontexts = false; - // and also, if it's one edition @ frontpage, set its pagetypepattern to 'site-index' - // it originally comes as '*' from the form, here we change that in proviosion of - // future 'site-index' pages - if ($data->bui_editingatfrontpage) { + break; + case BUI_CONTEXTS_FRONTPAGE_ONLY: + // The user want to show the front page on the frontpage only + $bi->parentcontextid = $frontpagecontext->id; + $bi->showinsubcontexts = false; $bi->pagetypepattern = 'site-index'; - } - break; + // This is the only relevant page type anyway but we'll set it explicitly just + // in case the front page grows site-index-* subpages of its own later + break; + } } }