]> git.mjollnir.org Git - moodle.git/commitdiff
Blocks fixed in admin pagelib, and (hopefully) many notices pointed out in the genera...
authorvinkmar <vinkmar>
Fri, 18 Aug 2006 22:00:37 +0000 (22:00 +0000)
committervinkmar <vinkmar>
Fri, 18 Aug 2006 22:00:37 +0000 (22:00 +0000)
admin/adminlib.php
admin/pagelib.php
admin/settings.php
admin/settings/authenticationandsecurity.php
admin/settings/first.php

index a05b7015be3cd93d69291788ef2cea4bc9a4f135..3b237f9f5b89cda0bfc4a651f2e31e1f02e9ed3b 100644 (file)
@@ -189,6 +189,7 @@ class admin_settingpage implements part_of_admin_tree {
        }
        
        function admin_settingpage($name, $visiblename, $role = 'moodle/legacy:admin') {
+           global $CFG;
            $this->settings = new stdClass();
                $this->name = $name;
                $this->visiblename = $visiblename;
@@ -1167,7 +1168,7 @@ class admin_setting_special_perfdebug extends admin_setting_configcheckbox {
 // N.B.: THIS FUNCTION HANDLES AUTHENTICATION
 function admin_externalpage_setup($section) {
 
-    global $CFG, $ADMIN, $PAGE, $_GET, $root;
+    global $CFG, $ADMIN, $PAGE, $_GET, $USER;
     
     require_once($CFG->libdir . '/blocklib.php');
     require_once($CFG->dirroot . '/admin/pagelib.php');
@@ -1199,21 +1200,35 @@ function admin_externalpage_setup($section) {
     }
 
     if (!($root instanceof admin_externalpage)) {
-        error('Section does not exist, is invalid, or should not be accessed via this URL.');
+        error(get_string('sectionerror','admin'));
        die;
     }
 
     // this eliminates our need to authenticate on the actual pages
     if (!($root->check_access())) {
-        error('Access denied.');
+        error(get_string('accessdenied', 'admin'));
        die;
     }
     
+    $adminediting = optional_param('adminedit', PARAM_BOOL);
+    
+    if (!isset($USER->adminediting)) {
+        $USER->adminediting = true;
+    }
+    
+    if ($PAGE->user_allowed_editing()) {
+        if ($adminediting == 'on') {
+            $USER->adminediting = true;
+        } elseif ($adminediting == 'off') {
+            $USER->adminediting = false;
+        }
+    }
+    
 }
 
 function admin_externalpage_print_header() {
 
-    global $CFG, $ADMIN, $PAGE, $_GET, $root;
+    global $CFG, $ADMIN, $PAGE;
     
     $pageblocks = blocks_setup($PAGE);
 
index 68513d33338077b365a762272a55e105697a79db..f6d3637602a20cc0c03b7b25dd667f39d6f6ec2b 100644 (file)
@@ -61,15 +61,17 @@ class page_admin extends page_base {
     // has to be fixed. i know there's a "proper" way to do this
     function user_is_editing() { 
         global $USER;
-        return (($_GET["edit"] == 'on') && isadmin());
+        return $USER->adminediting;
     }
 
     function url_get_path() { 
-        global $ADMIN, $root;
-        if (!$root) {
-            $root = $ADMIN->locate($this->section);
+        global $ADMIN, $CFG;
+        $root = $ADMIN->locate($this->section);
+        if ($root instanceof admin_externalpage) {
+            return $root->url;
+        } else {
+            return ($CFG->admin . '/settings.php?section=' . $this->section);
         }
-        return $root->url;
     }
 
     function url_get_parameters() {  // only handles parameters relevant to the admin pagetype
@@ -98,7 +100,7 @@ class page_admin extends page_base {
         // should this rely on showblocksonmodpages in any way? after all, teachers aren't accessing this...
         if ($this->user_allowed_editing()) {
             $buttons = '<table><tr><td><form target="' . $CFG->framename . '" method="get" action="' . $this->url_get_path() . '">'.
-                       '<input type="hidden" name="edit" value="'.($this->user_is_editing()?'off':'on').'" />'.
+                       '<input type="hidden" name="adminedit" value="'.($this->user_is_editing()?'off':'on').'" />'.
                        '<input type="hidden" name="section" value="'.$this->section.'" />'.
                        '<input type="submit" value="'.get_string($this->user_is_editing()?'blockseditoff':'blocksediton').'" /></form></td>' . 
                        '</tr></table>';
@@ -106,7 +108,7 @@ class page_admin extends page_base {
             $buttons = '&nbsp;';
         }
                
-/*ML*/  print_header("$SITE->shortname: " . implode(": ",$this->visiblepathtosection), $SITE->fullname, implode(" -> ",$this->visiblepathtosection),'', '', true, $buttons, '');
+        print_header("$SITE->shortname: " . implode(": ",$this->visiblepathtosection), $SITE->fullname, implode(" -> ",$this->visiblepathtosection),'', '', true, $buttons, '');
     }
 
     function get_type() {
index 284afdec4ba0dfca5a73e34a915f40adae1885e1..8bd595b666e57f1cac15e45eede9785f9401af0d 100644 (file)
@@ -15,6 +15,20 @@ if ($site = get_site()) { //d
     require_login(); //d
 } //d
 
+$adminediting = optional_param('adminedit', PARAM_BOOL);
+   
+if (!isset($USER->adminediting)) {
+    $USER->adminediting = true;
+}
+
+if ($PAGE->user_allowed_editing()) {
+    if ($adminediting == 'on') {
+        $USER->adminediting = true;
+    } elseif ($adminediting == 'off') {
+        $USER->adminediting = false;
+    }
+}
+
 // Question: what pageid should be used for this?
 
 define('TEMPORARY_ADMIN_PAGE_ID',26); //d
index da53020ee94120e4b587dc755db7e6827cca1a12..07639daccdc878d6ae1baa456781816ffdfe1dee 100644 (file)
@@ -2,8 +2,12 @@
 
 // This file defines settingpages and externalpages under the "authenticationandsecurity" category
 
+global $USER;
 
-
+// this depends on what file is including us
+if (!isset($site)) {
+    $site = get_site();
+}
 
 // stuff under the "usermanagement" subcategory
 $ADMIN->add('authenticationandsecurity', new admin_category('usermanagement', get_string('usermanagement', 'admin')), 0);
index f648f15eaa70e0cd6755b4b9b9c3a362a40ef5d5..15811e3292201b4f732024557bfbf4eac41e8eaa 100644 (file)
@@ -24,6 +24,10 @@ $ADMIN->add('plugins', new admin_externalpage('modulemanagement', get_string('mo
 
 $ADMIN->add('root', new admin_category('unsorted', 'Unsorted', 999));
 
+if (!isset($site)) {
+    $site = get_site();
+}
+
 $ADMIN->add('unsorted', new admin_externalpage('sitefiles', get_string('sitefiles'), $CFG->wwwroot . '/files/index.php?id=' . $site->id));
 $ADMIN->add('unsorted', new admin_externalpage('stickyblocks', get_string('stickyblocks'), $CFG->wwwroot . '/admin/stickyblocks.php'));