MDL-80813 core_admin: fix caps checks in admin tree, add all categories
Unconditionally create all categories in the admin tree since they can be referred to in the plugins for pages that require different capabilities
This commit is contained in:
+34
-42
@@ -24,6 +24,40 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$ADMIN->add('modules', new admin_category('modsettings', new lang_string('activitymodules')));
|
||||
$ADMIN->add('modules', new admin_category('formatsettings', new lang_string('courseformats')));
|
||||
$ADMIN->add('modules', new admin_category('customfieldsettings', new lang_string('customfields', 'core_customfield')));
|
||||
$ADMIN->add('modules', new admin_category('blocksettings', new lang_string('blocks')));
|
||||
$ADMIN->add('modules', new admin_category('authsettings', new lang_string('authentication', 'admin')));
|
||||
$ADMIN->add('modules', new admin_category('enrolments', new lang_string('enrolments', 'enrol')));
|
||||
$ADMIN->add('modules', new admin_category('editorsettings', new lang_string('editors', 'editor')));
|
||||
$ADMIN->add('modules', new admin_category('antivirussettings', new lang_string('antiviruses', 'antivirus')));
|
||||
$ADMIN->add('modules', new admin_category('mlbackendsettings', new lang_string('mlbackendsettings', 'admin')));
|
||||
$ADMIN->add('modules', new admin_category('filtersettings', new lang_string('managefilters')));
|
||||
$ADMIN->add('modules', new admin_category('mediaplayers', new lang_string('type_media_plural', 'plugin')));
|
||||
$ADMIN->add('modules', new admin_category('fileconverterplugins', new lang_string('type_fileconverter_plural', 'plugin')));
|
||||
$ADMIN->add('modules', new admin_category('paymentgateways', new lang_string('type_paygw_plural', 'plugin')));
|
||||
$ADMIN->add('modules', new admin_category('dataformatsettings', new lang_string('dataformats')));
|
||||
$ADMIN->add('modules', new admin_category('portfoliosettings', new lang_string('portfolios', 'portfolio'),
|
||||
empty($CFG->enableportfolios)));
|
||||
$ADMIN->add('modules', new admin_category('repositorysettings', new lang_string('repositories', 'repository')));
|
||||
$ADMIN->add('modules', new admin_category('qbanksettings', new lang_string('type_qbank_plural', 'plugin')));
|
||||
$ADMIN->add('modules', new admin_category('qbehavioursettings', new lang_string('questionbehaviours', 'admin')));
|
||||
$ADMIN->add('modules', new admin_category('qtypesettings', new lang_string('questiontypes', 'admin')));
|
||||
$ADMIN->add('modules', new admin_category('plagiarism', new lang_string('plagiarism', 'plagiarism')));
|
||||
$ADMIN->add('modules', new admin_category('coursereports', new lang_string('coursereports')));
|
||||
$ADMIN->add('modules', new admin_category('reportplugins', new lang_string('reports')));
|
||||
$ADMIN->add('modules', new admin_category('searchplugins', new lang_string('search', 'admin')));
|
||||
$ADMIN->add('modules', new admin_category('tools', new lang_string('tools', 'admin')));
|
||||
$ADMIN->add('modules', new admin_category('cache', new lang_string('caching', 'cache')));
|
||||
$ADMIN->add('cache', new admin_category('cachestores', new lang_string('cachestores', 'cache')));
|
||||
$ADMIN->add('modules', new admin_category('calendartype', new lang_string('calendartypes', 'calendar')));
|
||||
$ADMIN->add('modules', new admin_category('communicationsettings', new lang_string('communication', 'core_communication')));
|
||||
$ADMIN->add('modules', new admin_category('sms', new lang_string('sms', 'core_sms')));
|
||||
$ADMIN->add('modules', new admin_category('contentbanksettings', new lang_string('contentbank')));
|
||||
$ADMIN->add('modules', new admin_category('localplugins', new lang_string('localplugins')));
|
||||
|
||||
|
||||
if ($hassiteconfig) {
|
||||
/* @var admin_root $ADMIN */
|
||||
$ADMIN->locate('modules')->set_sorting(true);
|
||||
@@ -31,7 +65,6 @@ if ($hassiteconfig) {
|
||||
$ADMIN->add('modules', new admin_page_pluginsoverview());
|
||||
|
||||
// activity modules
|
||||
$ADMIN->add('modules', new admin_category('modsettings', new lang_string('activitymodules')));
|
||||
|
||||
$ADMIN->add('modsettings', new admin_page_managemods());
|
||||
|
||||
@@ -48,7 +81,6 @@ if ($hassiteconfig) {
|
||||
}
|
||||
|
||||
// course formats
|
||||
$ADMIN->add('modules', new admin_category('formatsettings', new lang_string('courseformats')));
|
||||
$temp = new admin_settingpage('manageformats', new lang_string('manageformats', 'core_admin'));
|
||||
$temp->add(new admin_setting_manageformats());
|
||||
$ADMIN->add('formatsettings', $temp);
|
||||
@@ -60,7 +92,6 @@ if ($hassiteconfig) {
|
||||
}
|
||||
|
||||
// Custom fields.
|
||||
$ADMIN->add('modules', new admin_category('customfieldsettings', new lang_string('customfields', 'core_customfield')));
|
||||
$temp = new admin_settingpage('managecustomfields', new lang_string('managecustomfields', 'core_admin'));
|
||||
$temp->add(new admin_setting_managecustomfields());
|
||||
$ADMIN->add('customfieldsettings', $temp);
|
||||
@@ -72,7 +103,6 @@ if ($hassiteconfig) {
|
||||
}
|
||||
|
||||
// blocks
|
||||
$ADMIN->add('modules', new admin_category('blocksettings', new lang_string('blocks')));
|
||||
$ADMIN->add('blocksettings', new admin_page_manageblocks());
|
||||
$plugins = core_plugin_manager::instance()->get_plugins_of_type('block');
|
||||
core_collator::asort_objects_by_property($plugins, 'displayname');
|
||||
@@ -82,8 +112,6 @@ if ($hassiteconfig) {
|
||||
}
|
||||
|
||||
// authentication plugins
|
||||
$ADMIN->add('modules', new admin_category('authsettings', new lang_string('authentication', 'admin')));
|
||||
|
||||
$temp = new admin_settingpage('manageauths', new lang_string('authsettings', 'admin'));
|
||||
$temp->add(new admin_setting_manageauths());
|
||||
$temp->add(new admin_setting_heading('manageauthscommonheading', new lang_string('commonsettings', 'admin'), ''));
|
||||
@@ -160,7 +188,6 @@ if ($hassiteconfig) {
|
||||
}
|
||||
|
||||
// Enrolment plugins
|
||||
$ADMIN->add('modules', new admin_category('enrolments', new lang_string('enrolments', 'enrol')));
|
||||
$temp = new admin_settingpage('manageenrols', new lang_string('manageenrols', 'enrol'));
|
||||
$temp->add(new admin_setting_manageenrols());
|
||||
$ADMIN->add('enrolments', $temp);
|
||||
@@ -177,7 +204,6 @@ if ($hassiteconfig) {
|
||||
|
||||
|
||||
/// Editor plugins
|
||||
$ADMIN->add('modules', new admin_category('editorsettings', new lang_string('editors', 'editor')));
|
||||
$temp = new admin_settingpage('manageeditors', new lang_string('editorsettings', 'editor'));
|
||||
$temp->add(new \core_admin\admin\admin_setting_plugin_manager(
|
||||
'editor',
|
||||
@@ -194,7 +220,6 @@ if ($hassiteconfig) {
|
||||
}
|
||||
|
||||
// Antivirus plugins.
|
||||
$ADMIN->add('modules', new admin_category('antivirussettings', new lang_string('antiviruses', 'antivirus')));
|
||||
$temp = new admin_settingpage('manageantiviruses', new lang_string('antivirussettings', 'antivirus'));
|
||||
$temp->add(new admin_setting_manageantiviruses());
|
||||
|
||||
@@ -266,14 +291,12 @@ if ($hassiteconfig) {
|
||||
}
|
||||
|
||||
// Machine learning backend plugins.
|
||||
$ADMIN->add('modules', new admin_category('mlbackendsettings', new lang_string('mlbackendsettings', 'admin')));
|
||||
$plugins = core_plugin_manager::instance()->get_plugins_of_type('mlbackend');
|
||||
foreach ($plugins as $plugin) {
|
||||
$plugin->load_settings($ADMIN, 'mlbackendsettings', $hassiteconfig);
|
||||
}
|
||||
|
||||
/// Filter plugins
|
||||
$ADMIN->add('modules', new admin_category('filtersettings', new lang_string('managefilters')));
|
||||
|
||||
$ADMIN->add('filtersettings', new admin_page_managefilters());
|
||||
|
||||
@@ -303,7 +326,6 @@ if ($hassiteconfig) {
|
||||
}
|
||||
|
||||
// Media players.
|
||||
$ADMIN->add('modules', new admin_category('mediaplayers', new lang_string('type_media_plural', 'plugin')));
|
||||
$temp = new admin_settingpage('managemediaplayers', new lang_string('managemediaplayers', 'media'));
|
||||
$temp->add(new admin_setting_heading('mediaformats', get_string('mediaformats', 'core_media'),
|
||||
format_text(get_string('mediaformats_desc', 'core_media'), FORMAT_MARKDOWN)));
|
||||
@@ -323,7 +345,6 @@ if ($hassiteconfig) {
|
||||
$ADMIN->add('mediaplayers', $temp);
|
||||
|
||||
// Convert plugins.
|
||||
$ADMIN->add('modules', new admin_category('fileconverterplugins', new lang_string('type_fileconverter_plural', 'plugin')));
|
||||
$temp = new admin_settingpage('managefileconverterplugins', new lang_string('type_fileconvertermanage', 'plugin'));
|
||||
$temp->add(new admin_setting_manage_fileconverter_plugins());
|
||||
$ADMIN->add('fileconverterplugins', $temp);
|
||||
@@ -343,7 +364,6 @@ if ($hassiteconfig) {
|
||||
}
|
||||
|
||||
// Payment gateway plugins.
|
||||
$ADMIN->add('modules', new admin_category('paymentgateways', new lang_string('type_paygw_plural', 'plugin')));
|
||||
$temp = new admin_settingpage('managepaymentgateways', new lang_string('type_paygwmanage', 'plugin'));
|
||||
$temp->add(new \core_admin\local\settings\manage_payment_gateway_plugins());
|
||||
$temp->add(new admin_setting_description(
|
||||
@@ -362,7 +382,6 @@ if ($hassiteconfig) {
|
||||
}
|
||||
|
||||
// Data format settings.
|
||||
$ADMIN->add('modules', new admin_category('dataformatsettings', new lang_string('dataformats')));
|
||||
$temp = new admin_settingpage('managedataformats', new lang_string('managedataformats'));
|
||||
$temp->add(new admin_setting_managedataformats());
|
||||
$ADMIN->add('dataformatsettings', $temp);
|
||||
@@ -376,12 +395,9 @@ if ($hassiteconfig) {
|
||||
|
||||
//== Portfolio settings ==
|
||||
require_once($CFG->libdir. '/portfoliolib.php');
|
||||
$catname = new lang_string('portfolios', 'portfolio');
|
||||
$manage = new lang_string('manageportfolios', 'portfolio');
|
||||
$url = "$CFG->wwwroot/$CFG->admin/portfolio.php";
|
||||
|
||||
$ADMIN->add('modules', new admin_category('portfoliosettings', $catname, empty($CFG->enableportfolios)));
|
||||
|
||||
// Add manage page (with table)
|
||||
$temp = new admin_page_manageportfolios();
|
||||
$ADMIN->add('portfoliosettings', $temp);
|
||||
@@ -435,10 +451,8 @@ if ($hassiteconfig) {
|
||||
|
||||
// repository setting
|
||||
require_once("$CFG->dirroot/repository/lib.php");
|
||||
$catname =new lang_string('repositories', 'repository');
|
||||
$managerepo = new lang_string('manage', 'repository');
|
||||
$url = $CFG->wwwroot.'/'.$CFG->admin.'/repository.php';
|
||||
$ADMIN->add('modules', new admin_category('repositorysettings', $catname));
|
||||
|
||||
// Add main page (with table)
|
||||
$temp = new admin_page_managerepositories();
|
||||
@@ -474,8 +488,6 @@ if ($hassiteconfig) {
|
||||
|
||||
// Question bank settings.
|
||||
if ($hassiteconfig || has_capability('moodle/question:config', $systemcontext)) {
|
||||
$ADMIN->add('modules', new admin_category('qbanksettings',
|
||||
new lang_string('type_qbank_plural', 'plugin')));
|
||||
$temp = new admin_settingpage('manageqbanks', new lang_string('manageqbanks', 'admin'));
|
||||
$temp->add(new \core_question\admin\manage_qbank_plugins_page());
|
||||
$ADMIN->add('qbanksettings', $temp);
|
||||
@@ -491,11 +503,9 @@ if ($hassiteconfig || has_capability('moodle/question:config', $systemcontext))
|
||||
if ($hassiteconfig || has_capability('moodle/question:config', $systemcontext)) {
|
||||
|
||||
// Question behaviour settings.
|
||||
$ADMIN->add('modules', new admin_category('qbehavioursettings', new lang_string('questionbehaviours', 'admin')));
|
||||
$ADMIN->add('qbehavioursettings', new admin_page_manageqbehaviours());
|
||||
|
||||
// Question type settings.
|
||||
$ADMIN->add('modules', new admin_category('qtypesettings', new lang_string('questiontypes', 'admin')));
|
||||
$ADMIN->add('qtypesettings', new admin_page_manageqtypes());
|
||||
|
||||
// Question preview defaults.
|
||||
@@ -567,7 +577,6 @@ if ($hassiteconfig || has_capability('moodle/question:config', $systemcontext))
|
||||
|
||||
// Plagiarism plugin settings
|
||||
if ($hassiteconfig && !empty($CFG->enableplagiarism)) {
|
||||
$ADMIN->add('modules', new admin_category('plagiarism', new lang_string('plagiarism', 'plagiarism')));
|
||||
$ADMIN->add('plagiarism', new admin_externalpage('manageplagiarismplugins', new lang_string('manageplagiarism', 'plagiarism'),
|
||||
$CFG->wwwroot . '/' . $CFG->admin . '/plagiarism.php'));
|
||||
|
||||
@@ -599,7 +608,6 @@ if ($hassiteconfig) {
|
||||
}
|
||||
}
|
||||
if (!empty($pages)) {
|
||||
$ADMIN->add('modules', new admin_category('coursereports', new lang_string('coursereports')));
|
||||
core_collator::asort_objects_by_property($pages, 'visiblename');
|
||||
foreach ($pages as $page) {
|
||||
$ADMIN->add('coursereports', $page);
|
||||
@@ -621,7 +629,6 @@ foreach (core_component::get_plugin_list('report') as $report => $plugindir) {
|
||||
}
|
||||
}
|
||||
}
|
||||
$ADMIN->add('modules', new admin_category('reportplugins', new lang_string('reports')));
|
||||
$ADMIN->add('reportplugins', new admin_externalpage('managereports', new lang_string('reportsmanage', 'admin'),
|
||||
$CFG->wwwroot . '/' . $CFG->admin . '/reports.php'));
|
||||
core_collator::asort_objects_by_property($pages, 'visiblename');
|
||||
@@ -631,7 +638,6 @@ foreach ($pages as $page) {
|
||||
|
||||
if ($hassiteconfig) {
|
||||
// Global Search engine plugins.
|
||||
$ADMIN->add('modules', new admin_category('searchplugins', new lang_string('search', 'admin')));
|
||||
$temp = new admin_settingpage('manageglobalsearch', new lang_string('globalsearchmanage', 'admin'));
|
||||
|
||||
$pages = array();
|
||||
@@ -773,7 +779,6 @@ if ($hassiteconfig) {
|
||||
|
||||
/// Add all admin tools
|
||||
if ($hassiteconfig) {
|
||||
$ADMIN->add('modules', new admin_category('tools', new lang_string('tools', 'admin')));
|
||||
$settingspage = new admin_settingpage('toolsmanagement', new lang_string('toolsmanage', 'admin'));
|
||||
$ADMIN->add('tools', $settingspage);
|
||||
$settingspage->add(new \core_admin\admin\admin_setting_plugin_manager(
|
||||
@@ -794,12 +799,10 @@ foreach ($plugins as $plugin) {
|
||||
|
||||
// Now add the Cache plugins
|
||||
if ($hassiteconfig) {
|
||||
$ADMIN->add('modules', new admin_category('cache', new lang_string('caching', 'cache')));
|
||||
$ADMIN->add('cache', new admin_externalpage('cacheconfig', new lang_string('cacheconfig', 'cache'), $CFG->wwwroot .'/cache/admin.php'));
|
||||
$ADMIN->add('cache', new admin_externalpage('cachetestperformance', new lang_string('testperformance', 'cache'), $CFG->wwwroot . '/cache/testperformance.php'));
|
||||
$ADMIN->add('cache', new admin_externalpage('cacheusage',
|
||||
new lang_string('cacheusage', 'cache'), $CFG->wwwroot . '/cache/usage.php'));
|
||||
$ADMIN->add('cache', new admin_category('cachestores', new lang_string('cachestores', 'cache')));
|
||||
$ADMIN->locate('cachestores')->set_sorting(true);
|
||||
foreach (core_component::get_plugin_list('cachestore') as $plugin => $path) {
|
||||
$settingspath = $path.'/settings.php';
|
||||
@@ -813,7 +816,6 @@ if ($hassiteconfig) {
|
||||
|
||||
// Add Calendar type settings.
|
||||
if ($hassiteconfig) {
|
||||
$ADMIN->add('modules', new admin_category('calendartype', new lang_string('calendartypes', 'calendar')));
|
||||
$plugins = core_plugin_manager::instance()->get_plugins_of_type('calendartype');
|
||||
core_collator::asort_objects_by_property($plugins, 'displayname');
|
||||
foreach ($plugins as $plugin) {
|
||||
@@ -824,7 +826,6 @@ if ($hassiteconfig) {
|
||||
|
||||
// Communication plugins.
|
||||
if ($hassiteconfig && core_communication\api::is_available()) {
|
||||
$ADMIN->add('modules', new admin_category('communicationsettings', new lang_string('communication', 'core_communication')));
|
||||
$temp = new admin_settingpage('managecommunicationproviders',
|
||||
new lang_string('managecommunicationproviders', 'core_communication'));
|
||||
$temp->add(new \core_communication\admin\manage_communication_providers_page());
|
||||
@@ -838,13 +839,6 @@ if ($hassiteconfig && core_communication\api::is_available()) {
|
||||
|
||||
// SMS plugins.
|
||||
if ($hassiteconfig) {
|
||||
$ADMIN->add(
|
||||
'modules',
|
||||
new admin_category(
|
||||
'sms',
|
||||
new lang_string('sms', 'core_sms'),
|
||||
),
|
||||
);
|
||||
$ADMIN->add(
|
||||
'sms',
|
||||
new admin_externalpage(
|
||||
@@ -869,7 +863,6 @@ if ($hassiteconfig) {
|
||||
|
||||
// Content bank content types.
|
||||
if ($hassiteconfig) {
|
||||
$ADMIN->add('modules', new admin_category('contentbanksettings', new lang_string('contentbank')));
|
||||
$temp = new admin_settingpage('managecontentbanktypes', new lang_string('managecontentbanktypes'));
|
||||
$temp->add(new admin_setting_managecontentbankcontenttypes());
|
||||
$ADMIN->add('contentbanksettings', $temp);
|
||||
@@ -888,7 +881,6 @@ if ($hassiteconfig) {
|
||||
|
||||
/// Add all local plugins - must be always last!
|
||||
if ($hassiteconfig) {
|
||||
$ADMIN->add('modules', new admin_category('localplugins', new lang_string('localplugins')));
|
||||
$ADMIN->add('localplugins', new admin_externalpage('managelocalplugins', new lang_string('localpluginsmanage'),
|
||||
$CFG->wwwroot . '/' . $CFG->admin . '/localplugins.php'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user