}
function admin_settingpage($name, $visiblename, $role = 'moodle/legacy:admin') {
+ global $CFG;
$this->settings = new stdClass();
$this->name = $name;
$this->visiblename = $visiblename;
// 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');
}
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);
// 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
// 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>';
$buttons = ' ';
}
-/*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() {
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
// 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);
$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'));