Browse files

MDL-43028 Navigation: Setting proper page properties on admin pages

  • Loading branch information...
1 parent b58bc15 commit 823c593fc54f8fc4ff1c7de8ef029e68f68ddc55 @rajeshtaneja rajeshtaneja committed Nov 25, 2013
Showing with 17 additions and 90 deletions.
  1. +5 −3 admin/settings/appearance.php
  2. +4 −40 my/indexsys.php
  3. +4 −8 tag/manage.php
  4. +4 −39 user/profilesys.php
View
8 admin/settings/appearance.php
@@ -186,10 +186,12 @@
$temp->add(new admin_setting_configcheckbox('doctonewwindow', new lang_string('doctonewwindow', 'admin'), new lang_string('configdoctonewwindow', 'admin'), 0));
$ADMIN->add('appearance', $temp);
- $temp = new admin_externalpage('mypage', new lang_string('mypage', 'admin'), $CFG->wwwroot . '/my/indexsys.php');
+ $temp = new admin_externalpage('mypage', new lang_string('mypage', 'admin'), $CFG->wwwroot . '/my/indexsys.php',
+ 'moodle/my:configsyspages');
$ADMIN->add('appearance', $temp);
- $temp = new admin_externalpage('profilepage', new lang_string('myprofile', 'admin'), $CFG->wwwroot . '/user/profilesys.php');
+ $temp = new admin_externalpage('profilepage', new lang_string('myprofile', 'admin'), $CFG->wwwroot . '/user/profilesys.php',
+ 'moodle/my:configsyspages');
$ADMIN->add('appearance', $temp);
// coursecontact is the person responsible for course - usually manages enrolments, receives notification, etc.
@@ -219,7 +221,7 @@
$ADMIN->add('appearance', $temp);
// link to tag management interface
- $ADMIN->add('appearance', new admin_externalpage('managetags', new lang_string('managetags', 'tag'), "$CFG->wwwroot/tag/manage.php"));
+ $ADMIN->add('appearance', new admin_externalpage('managetags', new lang_string('managetags', 'tag'), $CFG->wwwroot.'/tag/manage.php', 'moodle/tag:manage'));
$temp = new admin_settingpage('additionalhtml', new lang_string('additionalhtml', 'admin'));
$temp->add(new admin_setting_heading('additionalhtml_heading', new lang_string('additionalhtml_heading', 'admin'), new lang_string('additionalhtml_desc', 'admin')));
View
44 my/indexsys.php
@@ -43,59 +43,23 @@
require_login();
-$context = context_system::instance();
-require_capability('moodle/my:configsyspages', $context);
-$PAGE->set_blocks_editing_capability('moodle/my:configsyspages');
$header = "$SITE->shortname: ".get_string('myhome')." (".get_string('mypage', 'admin').")";
-// Start setting up the page
-$params = array();
-$PAGE->set_url('/my/indexsys.php', $params);
-$PAGE->set_pagelayout('mydashboard');
+admin_externalpage_setup('mypage', '', null, '', array('pagelayout' => 'mydashboard'));
+
+// Override pagetype to show blocks properly.
$PAGE->set_pagetype('my-index');
-$PAGE->set_context($context);
+
$PAGE->set_title($header);
$PAGE->set_heading($header);
$PAGE->blocks->add_region('content');
-// TODO: Make the page be selected properly in the Settings block
-
// Get the My Moodle page info. Should always return something unless the database is broken.
if (!$currentpage = my_get_page(null, MY_PAGE_PRIVATE)) {
print_error('mymoodlesetup');
}
$PAGE->set_subpage($currentpage->id);
-
-// Toggle the editing state and switches
-if ($PAGE->user_allowed_editing()) {
- if ($edit !== null) { // Editing state was specified
- $USER->editing = $edit; // Change editing state
- } else { // Editing state is in session
- if (!empty($USER->editing)) {
- $edit = 1;
- } else {
- $edit = 0;
- }
- }
-
- // Add button for editing page
- $params['edit'] = !$edit;
-
- if (empty($edit)) {
- $editstring = get_string('updatemymoodleon');
- } else {
- $editstring = get_string('updatemymoodleoff');
- }
-
- $url = new moodle_url("$CFG->wwwroot/my/indexsys.php", $params);
- $button = $OUTPUT->single_button($url, $editstring);
- $PAGE->set_button($button);
-
-} else {
- $USER->editing = $edit = 0;
-}
-
echo $OUTPUT->header();
echo $OUTPUT->blocks_for_region('content');
View
12 tag/manage.php
@@ -25,6 +25,7 @@
require_once('../config.php');
require_once($CFG->libdir.'/tablelib.php');
require_once('lib.php');
+require_once($CFG->libdir.'/adminlib.php');
define('SHOW_ALL_PAGE_SIZE', 50000);
define('DEFAULT_PAGE_SIZE', 30);
@@ -41,21 +42,16 @@
print_error('tagsaredisabled', 'tag');
}
-$systemcontext = context_system::instance();
-require_capability('moodle/tag:manage', $systemcontext);
-
$params = array();
if ($perpage != DEFAULT_PAGE_SIZE) {
$params['perpage'] = $perpage;
}
-$PAGE->set_url('/tag/manage.php', $params);
-$PAGE->set_context($systemcontext);
+admin_externalpage_setup('managetags', '', $params, '', array('pagelayout' => 'standard'));
+
$PAGE->set_blocks_editing_capability('moodle/tag:editblocks');
$PAGE->navbar->add(get_string('tags', 'tag'), new moodle_url('/tag/search.php'));
$PAGE->navbar->add(get_string('managetags', 'tag'));
-$PAGE->set_title(get_string('managetags', 'tag'));
-$PAGE->set_heading($COURSE->fullname);
-$PAGE->set_pagelayout('standard');
+
echo $OUTPUT->header();
$err_notice = '';
View
43 user/profilesys.php
@@ -37,59 +37,24 @@
require_login();
-$context = context_system::instance();
-require_capability('moodle/my:configsyspages', $context);
-$PAGE->set_blocks_editing_capability('moodle/my:configsyspages');
$header = "$SITE->shortname: ".get_string('publicprofile')." (".get_string('myprofile', 'admin').")";
-// Start setting up the page
-$params = array();
-$PAGE->set_url('/user/profilesys.php', $params);
-$PAGE->set_pagelayout('mydashboard');
+admin_externalpage_setup('mypage', '', null, '', array('pagelayout' => 'mydashboard'));
+
+// Override pagetype to show blocks properly.
$PAGE->set_pagetype('user-profile');
-$PAGE->set_context($context);
+
$PAGE->set_title($header);
$PAGE->set_heading($header);
$PAGE->blocks->add_region('content');
-// TODO: Make the page be selected properly in the Settings block
-
// Get the Public Profile page info. Should always return something unless the database is broken.
if (!$currentpage = my_get_page(null, MY_PAGE_PUBLIC)) {
print_error('publicprofilesetup');
}
$PAGE->set_subpage($currentpage->id);
-// Toggle the editing state and switches
-if ($PAGE->user_allowed_editing()) {
- if ($edit !== null) { // Editing state was specified
- $USER->editing = $edit; // Change editing state
- } else { // Editing state is in session
- if (!empty($USER->editing)) {
- $edit = 1;
- } else {
- $edit = 0;
- }
- }
-
- // Add button for editing page
- $params['edit'] = !$edit;
-
- if (empty($edit)) {
- $editstring = get_string('updatemymoodleon');
- } else {
- $editstring = get_string('updatemymoodleoff');
- }
-
- $url = new moodle_url("$CFG->wwwroot/user/profilesys.php", $params);
- $button = $OUTPUT->single_button($url, $editstring);
- $PAGE->set_button($button);
-
-} else {
- $USER->editing = $edit = 0;
-}
-
echo $OUTPUT->header();
echo $OUTPUT->blocks_for_region('content');

0 comments on commit 823c593

Please sign in to comment.