Merged applicable_format fixes for MDL-9119

This commit is contained in:
moodler 2007-03-30 16:52:38 +00:00
parent b373a751d2
commit 052ba1f503
4 changed files with 35 additions and 22 deletions

View File

@ -201,9 +201,7 @@ class block_admin extends block_list {
} }
function applicable_formats() { function applicable_formats() {
// Yu: Separating site and site course context return array('course' => true); // Not needed on site
// Have to enable for site as well
return array('all' => true, 'course' => true);
} }
} }

View File

@ -12,7 +12,11 @@ class block_admin_bookmarks extends block_base {
} }
function applicable_formats() { 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() { function preferred_width() {
@ -24,31 +28,31 @@ class block_admin_bookmarks extends block_base {
} }
function get_content() { function get_content() {
global $CFG, $USER, $PAGE; global $CFG, $USER, $PAGE;
require_once($CFG->libdir.'/adminlib.php'); require_once($CFG->libdir.'/adminlib.php');
$adminroot = admin_get_root(); $adminroot = admin_get_root();
if ($this->content !== NULL) { if ($this->content !== NULL) {
return $this->content; return $this->content;
} }
$this->content = new stdClass; $this->content = new stdClass;
$this->content->text = ''; $this->content->text = '';
if (get_user_preferences('admin_bookmarks')) { if (get_user_preferences('admin_bookmarks')) {
$bookmarks = explode(',',get_user_preferences('admin_bookmarks')); $bookmarks = explode(',',get_user_preferences('admin_bookmarks'));
// hmm... just a liiitle (potentially) processor-intensive // hmm... just a liiitle (potentially) processor-intensive
// (recall that $adminroot->locate is a huge recursive call... and we're calling it repeatedly here // (recall that $adminroot->locate is a huge recursive call... and we're calling it repeatedly here
/// Accessibility: markup as a list. /// Accessibility: markup as a list.
$this->content->text .= '<ol class="list">'."\n"; $this->content->text .= '<ol class="list">'."\n";
foreach($bookmarks as $bookmark) { foreach($bookmarks as $bookmark) {
$temp = $adminroot->locate($bookmark); $temp = $adminroot->locate($bookmark);
if (is_a($temp, 'admin_settingpage')) { if (is_a($temp, 'admin_settingpage')) {
$this->content->text .= '<li><a href="' . $CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=' . $bookmark . '">' . $temp->visiblename . "</a></li>\n"; $this->content->text .= '<li><a href="' . $CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=' . $bookmark . '">' . $temp->visiblename . "</a></li>\n";
} elseif (is_a($temp, 'admin_externalpage')) { } else if (is_a($temp, 'admin_externalpage')) {
$this->content->text .= '<li><a href="' . $temp->url . '">' . $temp->visiblename . "</a></li>\n"; $this->content->text .= '<li><a href="' . $temp->url . '">' . $temp->visiblename . "</a></li>\n";
} }
} }
@ -56,20 +60,19 @@ class block_admin_bookmarks extends block_base {
} else { } else {
$bookmarks = array(); $bookmarks = array();
} }
if(isset($PAGE->section) and $PAGE->section == 'search'){ if (isset($PAGE->section) and $PAGE->section == 'search'){
// the search page can't be properly bookmarked at present // the search page can't be properly bookmarked at present
$this->content->footer = ''; $this->content->footer = '';
}elseif (($section = (isset($PAGE->section) ? $PAGE->section : '')) && (in_array($section, $bookmarks))) { } else if (($section = (isset($PAGE->section) ? $PAGE->section : '')) && (in_array($section, $bookmarks))) {
$this->content->footer = '<a href="' . $CFG->wwwroot . '/blocks/admin_bookmarks/delete.php?section=' . $section . '&amp;sesskey='.sesskey().'">' . get_string('unbookmarkthispage','admin') . '</a>'; $this->content->footer = '<a href="' . $CFG->wwwroot . '/blocks/admin_bookmarks/delete.php?section=' . $section . '&amp;sesskey='.sesskey().'">' . get_string('unbookmarkthispage','admin') . '</a>';
} elseif ($section = (isset($PAGE->section) ? $PAGE->section : '')) { } else if ($section = (isset($PAGE->section) ? $PAGE->section : '')) {
$this->content->footer = '<a href="' . $CFG->wwwroot . '/blocks/admin_bookmarks/create.php?section=' . $section . '&amp;sesskey='.sesskey().'">' . get_string('bookmarkthispage','admin') . '</a>'; $this->content->footer = '<a href="' . $CFG->wwwroot . '/blocks/admin_bookmarks/create.php?section=' . $section . '&amp;sesskey='.sesskey().'">' . get_string('bookmarkthispage','admin') . '</a>';
} else { } else {
$this->content->footer = ''; $this->content->footer = '';
} }
return $this->content; return $this->content;
} }
} }

View File

@ -22,7 +22,11 @@ class block_admin_tree extends block_base {
} }
function applicable_formats() { 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() { function preferred_width() {

View File

@ -10,6 +10,14 @@ class block_mnet_hosts extends block_list {
return false; 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() { function get_content() {
global $THEME, $CFG, $USER; global $THEME, $CFG, $USER;
@ -19,7 +27,7 @@ class block_mnet_hosts extends block_list {
} }
// check for outgoing roaming permission first // 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 ''; return '';
} }
@ -72,4 +80,4 @@ class block_mnet_hosts extends block_list {
} }
} }
?> ?>