diff --git a/blocks/admin/block_admin.php b/blocks/admin/block_admin.php index 4ef0a888307..dec89df0012 100644 --- a/blocks/admin/block_admin.php +++ b/blocks/admin/block_admin.php @@ -201,9 +201,7 @@ class block_admin extends block_list { } function applicable_formats() { - // Yu: Separating site and site course context - // Have to enable for site as well - return array('all' => true, 'course' => true); + return array('course' => true); // Not needed on site } } diff --git a/blocks/admin_bookmarks/block_admin_bookmarks.php b/blocks/admin_bookmarks/block_admin_bookmarks.php index 9788e6071e7..f578f0d434a 100644 --- a/blocks/admin_bookmarks/block_admin_bookmarks.php +++ b/blocks/admin_bookmarks/block_admin_bookmarks.php @@ -12,7 +12,11 @@ class block_admin_bookmarks extends block_base { } function applicable_formats() { - return array('all' => true); + if (has_capability('moodle/site:mnetlogintoremote', get_context_instance(CONTEXT_SYSTEM), NULL, false)) { + return array('all' => true); + } else { + return array('all' => false); + } } function preferred_width() { @@ -24,31 +28,31 @@ class block_admin_bookmarks extends block_base { } function get_content() { - + global $CFG, $USER, $PAGE; - + require_once($CFG->libdir.'/adminlib.php'); $adminroot = admin_get_root(); - + if ($this->content !== NULL) { return $this->content; } - + $this->content = new stdClass; $this->content->text = ''; if (get_user_preferences('admin_bookmarks')) { $bookmarks = explode(',',get_user_preferences('admin_bookmarks')); // hmm... just a liiitle (potentially) processor-intensive // (recall that $adminroot->locate is a huge recursive call... and we're calling it repeatedly here - + /// Accessibility: markup as a list. $this->content->text .= '
    '."\n"; - + foreach($bookmarks as $bookmark) { $temp = $adminroot->locate($bookmark); if (is_a($temp, 'admin_settingpage')) { $this->content->text .= '
  1. ' . $temp->visiblename . "
  2. \n"; - } elseif (is_a($temp, 'admin_externalpage')) { + } else if (is_a($temp, 'admin_externalpage')) { $this->content->text .= '
  3. ' . $temp->visiblename . "
  4. \n"; } } @@ -56,20 +60,19 @@ class block_admin_bookmarks extends block_base { } else { $bookmarks = array(); } - - if(isset($PAGE->section) and $PAGE->section == 'search'){ - // the search page can't be properly bookmarked at present - $this->content->footer = ''; - }elseif (($section = (isset($PAGE->section) ? $PAGE->section : '')) && (in_array($section, $bookmarks))) { + + if (isset($PAGE->section) and $PAGE->section == 'search'){ + // the search page can't be properly bookmarked at present + $this->content->footer = ''; + } else if (($section = (isset($PAGE->section) ? $PAGE->section : '')) && (in_array($section, $bookmarks))) { $this->content->footer = '' . get_string('unbookmarkthispage','admin') . ''; - } elseif ($section = (isset($PAGE->section) ? $PAGE->section : '')) { + } else if ($section = (isset($PAGE->section) ? $PAGE->section : '')) { $this->content->footer = '' . get_string('bookmarkthispage','admin') . ''; } else { $this->content->footer = ''; } - + return $this->content; - } } diff --git a/blocks/admin_tree/block_admin_tree.php b/blocks/admin_tree/block_admin_tree.php index 222a104d0cd..bec7c109685 100644 --- a/blocks/admin_tree/block_admin_tree.php +++ b/blocks/admin_tree/block_admin_tree.php @@ -22,7 +22,11 @@ class block_admin_tree extends block_base { } function applicable_formats() { - return array('site' => true, 'admin' => true); + if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) { + return array('site' => true, 'admin' => true); + } else { + return array('all' => false); + } } function preferred_width() { diff --git a/blocks/mnet_hosts/block_mnet_hosts.php b/blocks/mnet_hosts/block_mnet_hosts.php index 1e976a1de6c..45cb8d8eae7 100644 --- a/blocks/mnet_hosts/block_mnet_hosts.php +++ b/blocks/mnet_hosts/block_mnet_hosts.php @@ -10,6 +10,14 @@ class block_mnet_hosts extends block_list { return false; } + function applicable_formats() { + if (has_capability('moodle/site:mnetlogintoremote', get_context_instance(CONTEXT_SYSTEM), NULL, false)) { + return array('all' => true, 'mod' => false); + } else { + return array('all' => false); + } + } + function get_content() { global $THEME, $CFG, $USER; @@ -19,7 +27,7 @@ class block_mnet_hosts extends block_list { } // check for outgoing roaming permission first - if (!has_capability('moodle/site:mnetlogintoremote', get_context_instance(CONTEXT_SYSTEM, SITEID))) { + if (!has_capability('moodle/site:mnetlogintoremote', get_context_instance(CONTEXT_SYSTEM), NULL, false)) { return ''; } @@ -72,4 +80,4 @@ class block_mnet_hosts extends block_list { } } -?> \ No newline at end of file +?>