]> git.mjollnir.org Git - moodle.git/commitdiff
Merged applicable_format fixes for MDL-9119
authormoodler <moodler>
Fri, 30 Mar 2007 16:52:38 +0000 (16:52 +0000)
committermoodler <moodler>
Fri, 30 Mar 2007 16:52:38 +0000 (16:52 +0000)
blocks/admin/block_admin.php
blocks/admin_bookmarks/block_admin_bookmarks.php
blocks/admin_tree/block_admin_tree.php
blocks/mnet_hosts/block_mnet_hosts.php

index 4ef0a88830720d511e3accc0b109c87f1486c0cc..dec89df00124a566979359364ffa128362e58f42 100644 (file)
@@ -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
     }
 }
 
index 9788e6071e7201bd8237751b59b00a5cd00830ff..f578f0d434a968dfbfe86a559d2013a243979014 100644 (file)
@@ -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 .= '<ol class="list">'."\n";
-
+    
             foreach($bookmarks as $bookmark) {
                 $temp = $adminroot->locate($bookmark);
                 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";
-                } 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";
                 }
             }
@@ -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 = '<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>';
         } else {
             $this->content->footer = '';
         }
-
+    
         return $this->content;
-
     }
 }
 
index 222a104d0cd9e577218213d757273fc3d04e84d7..bec7c10968504414c166d820f194788eeb9f5059 100644 (file)
@@ -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() {
index 1e976a1de6ce41ca6a1d4d309d04f82c9f9aa9b3..45cb8d8eae7ca71c2b760da515fd184c7f5d1606 100644 (file)
@@ -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
+?>