This commit is contained in:
Dan Poltawski 2013-12-03 13:45:59 +08:00
commit 753eb47edc
4 changed files with 25 additions and 91 deletions

View File

@ -2,7 +2,12 @@
// This file defines settingpages and externalpages under the "appearance" category
if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
$capabilities = array(
'moodle/my:configsyspages',
'moodle/tag:manage'
);
if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) { // speedup for non-admins, add all caps used on this page
$ADMIN->add('appearance', new admin_category('themes', new lang_string('themes')));
// "themesettings" settingpage
@ -189,10 +194,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));
$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.
@ -222,7 +229,7 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
$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 File

@ -43,59 +43,24 @@ $edit = optional_param('edit', null, PARAM_BOOL); // Turn editing on and of
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');
$PAGE->set_blocks_editing_capability('moodle/my:configsyspages');
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 File

@ -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 @@ if (empty($CFG->usetags)) {
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 File

@ -37,23 +37,18 @@ $edit = optional_param('edit', null, PARAM_BOOL); // Turn editing on and of
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');
$PAGE->set_blocks_editing_capability('moodle/my:configsyspages');
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');
@ -61,35 +56,6 @@ if (!$currentpage = my_get_page(null, MY_PAGE_PUBLIC)) {
$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');