Skip to content

Commit

Permalink
MDL-43028 Navigation: Setting proper page properties on admin pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajesh Taneja committed Nov 25, 2013
1 parent b58bc15 commit 823c593
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 90 deletions.
8 changes: 5 additions & 3 deletions admin/settings/appearance.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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')));
Expand Down
44 changes: 4 additions & 40 deletions my/indexsys.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
12 changes: 4 additions & 8 deletions tag/manage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 = '';
Expand Down
43 changes: 4 additions & 39 deletions user/profilesys.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 823c593

Please sign in to comment.