From fa62ca18e863689fc33cfbcc4ee0208a8c1db901 Mon Sep 17 00:00:00 2001 From: defacer Date: Mon, 13 Jun 2005 01:56:25 +0000 Subject: [PATCH] Fix for bug 2925: When editing is turned on, the Main Menu should always display and give the option of adding resources/activities in section 0 of the site. Bad optimization code caused the drop downs to not be shown if there was no section 0 (i.e., the site never had a news forum or an activity in the Main Menu block). FINALLY! :) PS: Version bump, so that we know if people have the latest version of the block. I 'm going to bump versions from now on when bugs are fixed. --- blocks/site_main_menu/block_site_main_menu.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/blocks/site_main_menu/block_site_main_menu.php b/blocks/site_main_menu/block_site_main_menu.php index 65d0b515bb1..9df47dfe9b8 100644 --- a/blocks/site_main_menu/block_site_main_menu.php +++ b/blocks/site_main_menu/block_site_main_menu.php @@ -3,7 +3,7 @@ class block_site_main_menu extends block_list { function init() { $this->title = get_string('mainmenu'); - $this->version = 2004052700; + $this->version = 2005061300; } function applicable_formats() { @@ -17,7 +17,7 @@ class block_site_main_menu extends block_list { return $this->content; } - $this->content = New stdClass; + $this->content = new stdClass; $this->content->items = array(); $this->content->icons = array(); $this->content->footer = ''; @@ -33,13 +33,12 @@ class block_site_main_menu extends block_list { $ismoving = ismoving($this->instance->pageid); $sections = get_all_sections($this->instance->pageid); - if(empty($sections) or !isset($sections[0])) { - return $this->content; + + if(!empty($sections) && isset($sections[0])) { + $section = $sections[0]; } - $section = $sections[0]; - - if (!empty($section->sequence) || $isediting) { + if (!empty($section) || $isediting) { get_all_mods($this->instance->pageid, $mods, $modnames, $modnamesplural, $modnamesused); } @@ -61,7 +60,7 @@ class block_site_main_menu extends block_list { $this->content->items[] = $USER->activitycopyname.' ('.$strcancel.')'; } - if (!empty($section->sequence)) { + if (!empty($section) && !empty($section->sequence)) { $sectionmods = explode(',', $section->sequence); foreach ($sectionmods as $modnumber) { if (empty($mods[$modnumber])) {