Skip to content

Commit

Permalink
MDL-56641 admin: Managers can access search page
Browse files Browse the repository at this point in the history
  • Loading branch information
Damyon Wiese committed Nov 3, 2016
1 parent cad8adc commit 2a7c540
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 10 deletions.
24 changes: 16 additions & 8 deletions admin/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

$query = trim(optional_param('query', '', PARAM_NOTAGS)); // Search string

$PAGE->set_context(context_system::instance());
$context = context_system::instance();
$PAGE->set_context($context);

admin_externalpage_setup('search', '', array('query' => $query)); // now hidden page

Expand All @@ -19,6 +20,7 @@

// now we'll deal with the case that the admin has submitted the form with changed settings
if ($data = data_submitted() and confirm_sesskey()) {
require_capability('moodle/site:config', $context);
if (admin_write_settings($data)) {
redirect($PAGE->url, get_string('changessaved'), null, \core\output\notification::NOTIFY_SUCCESS);
}
Expand All @@ -45,14 +47,20 @@
echo $OUTPUT->notification($statusmsg, 'notifysuccess');
}

require_once("admin_settings_search_form.php");
$form = new admin_settings_search_form();
$form->display();
echo '<hr>';
$showsettingslinks = true;

if ($query) {
echo admin_search_settings_html($query);
} else {
if (has_capability('moodle/site:config', $context)) {
require_once("admin_settings_search_form.php");
$form = new admin_settings_search_form();
$form->display();
echo '<hr>';
if ($query) {
echo admin_search_settings_html($query);
$showsettingslinks = false;
}
}

if ($showsettingslinks) {
$node = $PAGE->settingsnav->find('root', navigation_node::TYPE_SITE_ADMIN);
if ($node) {
echo $OUTPUT->render_from_template('core/settings_link_page', ['node' => $node]);
Expand Down
2 changes: 1 addition & 1 deletion admin/settings/top.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@
$ADMIN->add('root', new admin_category('unsupported', new lang_string('unsupported', 'admin'), true));

// hidden search script
$ADMIN->add('root', new admin_externalpage('search', new lang_string('search', 'admin'), "$CFG->wwwroot/$CFG->admin/search.php", 'moodle/site:config', true));
$ADMIN->add('root', new admin_externalpage('search', new lang_string('search', 'admin'), "$CFG->wwwroot/$CFG->admin/search.php", 'moodle/site:configview', true));
1 change: 1 addition & 0 deletions lang/en/role.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@
$string['site:approvecourse'] = 'Approve course creation';
$string['site:backup'] = 'Backup courses';
$string['site:config'] = 'Change site configuration';
$string['site:configview'] = 'View the site administration tree (but not all the pages in it)';
$string['site:deleteanymessage'] = 'Delete any messages on the site';
$string['site:deleteownmessage'] = 'Delete messages sent by and to the user';
$string['site:doanything'] = 'Allowed to do everything';
Expand Down
7 changes: 7 additions & 0 deletions lib/db/access.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@
'archetypes' => array(
)
),
'moodle/site:configview' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => array(
'manager' => CAP_ALLOW,
)
),

'moodle/site:readallmessages' => array(

Expand Down
2 changes: 2 additions & 0 deletions lib/upgrade.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ information provided here is intended especially for developers.

=== 3.2 ===

* Custom roles with access to any part of site administration that do not use the manager archetype will need
moodle/site:configview capability added.
* Admin setting "Show My courses expanded on Dashboard" has been removed.
* Some backwards and forwards compatibility has been added for different bootstrap versions.
This is to allow the same markup to work in "clean" and "boost" themes alot of the time. It is also to allow user text
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

defined('MOODLE_INTERNAL') || die();

$version = 2016110200.00; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2016110300.00; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.

Expand Down

0 comments on commit 2a7c540

Please sign in to comment.