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

This commit is contained in:
Rajesh Taneja 2013-11-25 12:12:38 +08:00
parent b58bc15af5
commit 823c593fc5
4 changed files with 17 additions and 90 deletions

View file

@ -186,10 +186,12 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
$temp->add(new admin_setting_configcheckbox('doctonewwindow', new lang_string('doctonewwindow', 'admin'), new lang_string('configdoctonewwindow', 'admin'), 0)); $temp->add(new admin_setting_configcheckbox('doctonewwindow', new lang_string('doctonewwindow', 'admin'), new lang_string('configdoctonewwindow', 'admin'), 0));
$ADMIN->add('appearance', $temp); $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); $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); $ADMIN->add('appearance', $temp);
// coursecontact is the person responsible for course - usually manages enrolments, receives notification, etc. // coursecontact is the person responsible for course - usually manages enrolments, receives notification, etc.
@ -219,7 +221,7 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
$ADMIN->add('appearance', $temp); $ADMIN->add('appearance', $temp);
// link to tag management interface // 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 = 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'))); $temp->add(new admin_setting_heading('additionalhtml_heading', new lang_string('additionalhtml_heading', 'admin'), new lang_string('additionalhtml_desc', 'admin')));

View file

@ -43,59 +43,23 @@ $edit = optional_param('edit', null, PARAM_BOOL); // Turn editing on and of
require_login(); 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').")"; $header = "$SITE->shortname: ".get_string('myhome')." (".get_string('mypage', 'admin').")";
// Start setting up the page admin_externalpage_setup('mypage', '', null, '', array('pagelayout' => 'mydashboard'));
$params = array();
$PAGE->set_url('/my/indexsys.php', $params); // Override pagetype to show blocks properly.
$PAGE->set_pagelayout('mydashboard');
$PAGE->set_pagetype('my-index'); $PAGE->set_pagetype('my-index');
$PAGE->set_context($context);
$PAGE->set_title($header); $PAGE->set_title($header);
$PAGE->set_heading($header); $PAGE->set_heading($header);
$PAGE->blocks->add_region('content'); $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. // Get the My Moodle page info. Should always return something unless the database is broken.
if (!$currentpage = my_get_page(null, MY_PAGE_PRIVATE)) { if (!$currentpage = my_get_page(null, MY_PAGE_PRIVATE)) {
print_error('mymoodlesetup'); print_error('mymoodlesetup');
} }
$PAGE->set_subpage($currentpage->id); $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->header();
echo $OUTPUT->blocks_for_region('content'); echo $OUTPUT->blocks_for_region('content');

View file

@ -25,6 +25,7 @@
require_once('../config.php'); require_once('../config.php');
require_once($CFG->libdir.'/tablelib.php'); require_once($CFG->libdir.'/tablelib.php');
require_once('lib.php'); require_once('lib.php');
require_once($CFG->libdir.'/adminlib.php');
define('SHOW_ALL_PAGE_SIZE', 50000); define('SHOW_ALL_PAGE_SIZE', 50000);
define('DEFAULT_PAGE_SIZE', 30); define('DEFAULT_PAGE_SIZE', 30);
@ -41,21 +42,16 @@ if (empty($CFG->usetags)) {
print_error('tagsaredisabled', 'tag'); print_error('tagsaredisabled', 'tag');
} }
$systemcontext = context_system::instance();
require_capability('moodle/tag:manage', $systemcontext);
$params = array(); $params = array();
if ($perpage != DEFAULT_PAGE_SIZE) { if ($perpage != DEFAULT_PAGE_SIZE) {
$params['perpage'] = $perpage; $params['perpage'] = $perpage;
} }
$PAGE->set_url('/tag/manage.php', $params); admin_externalpage_setup('managetags', '', $params, '', array('pagelayout' => 'standard'));
$PAGE->set_context($systemcontext);
$PAGE->set_blocks_editing_capability('moodle/tag:editblocks'); $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('tags', 'tag'), new moodle_url('/tag/search.php'));
$PAGE->navbar->add(get_string('managetags', 'tag')); $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(); echo $OUTPUT->header();
$err_notice = ''; $err_notice = '';

View file

@ -37,23 +37,17 @@ $edit = optional_param('edit', null, PARAM_BOOL); // Turn editing on and of
require_login(); 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').")"; $header = "$SITE->shortname: ".get_string('publicprofile')." (".get_string('myprofile', 'admin').")";
// Start setting up the page admin_externalpage_setup('mypage', '', null, '', array('pagelayout' => 'mydashboard'));
$params = array();
$PAGE->set_url('/user/profilesys.php', $params); // Override pagetype to show blocks properly.
$PAGE->set_pagelayout('mydashboard');
$PAGE->set_pagetype('user-profile'); $PAGE->set_pagetype('user-profile');
$PAGE->set_context($context);
$PAGE->set_title($header); $PAGE->set_title($header);
$PAGE->set_heading($header); $PAGE->set_heading($header);
$PAGE->blocks->add_region('content'); $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. // Get the Public Profile page info. Should always return something unless the database is broken.
if (!$currentpage = my_get_page(null, MY_PAGE_PUBLIC)) { if (!$currentpage = my_get_page(null, MY_PAGE_PUBLIC)) {
print_error('publicprofilesetup'); print_error('publicprofilesetup');
@ -61,35 +55,6 @@ if (!$currentpage = my_get_page(null, MY_PAGE_PUBLIC)) {
$PAGE->set_subpage($currentpage->id); $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->header();
echo $OUTPUT->blocks_for_region('content'); echo $OUTPUT->blocks_for_region('content');