MDL-36369 Non-admin managers could not access list of plugins
[moodle.git] / admin / settings / plugins.php
CommitLineData
11b749ca 1<?php
220a90c5 2
b63a6a63 3/*
4 * Please note that is file is always loaded last - it means that you can inject entries into other categories too.
5 */
6
78946b9b 7if ($hassiteconfig) {
5cdb1893
MG
8 require_once("$CFG->libdir/pluginlib.php");
9 $allplugins = plugin_manager::instance()->get_plugins();
10
b9934a17 11 $ADMIN->add('modules', new admin_page_pluginsoverview());
fde6f79f
MG
12
13 // activity modules
e106013f 14 $ADMIN->add('modules', new admin_category('modsettings', new lang_string('activitymodules')));
220a90c5 15 $ADMIN->add('modsettings', new admin_page_managemods());
fde6f79f
MG
16 foreach ($allplugins['mod'] as $module) {
17 $module->load_settings($ADMIN, 'modsettings', $hassiteconfig);
220a90c5 18 }
19
b032b490 20 // hidden script for converting journals to online assignments (or something like that) linked from elsewhere
21 $ADMIN->add('modsettings', new admin_externalpage('oacleanup', 'Online Assignment Cleanup', $CFG->wwwroot.'/'.$CFG->admin.'/oacleanup.php', 'moodle/site:config', true));
220a90c5 22
870d4280 23 // blocks
e106013f 24 $ADMIN->add('modules', new admin_category('blocksettings', new lang_string('blocks')));
220a90c5 25 $ADMIN->add('blocksettings', new admin_page_manageblocks());
870d4280
MG
26 foreach ($allplugins['block'] as $block) {
27 $block->load_settings($ADMIN, 'blocksettings', $hassiteconfig);
220a90c5 28 }
29
75c34c23 30 // message outputs
e106013f 31 $ADMIN->add('modules', new admin_category('messageoutputs', new lang_string('messageoutputs', 'message')));
75c34c23 32 $ADMIN->add('messageoutputs', new admin_page_managemessageoutputs());
1d72e9d4 33 $ADMIN->add('messageoutputs', new admin_page_defaultmessageoutputs());
e8d16932
MG
34 foreach ($allplugins['message'] as $processor) {
35 $processor->load_settings($ADMIN, 'messageoutputs', $hassiteconfig);
2f2137fc 36 }
75c34c23 37
df997f84 38 // authentication plugins
e106013f 39 $ADMIN->add('modules', new admin_category('authsettings', new lang_string('authentication', 'admin')));
df997f84 40
e106013f 41 $temp = new admin_settingpage('manageauths', new lang_string('authsettings', 'admin'));
df997f84 42 $temp->add(new admin_setting_manageauths());
e106013f 43 $temp->add(new admin_setting_heading('manageauthscommonheading', new lang_string('commonsettings', 'admin'), ''));
df997f84 44 $temp->add(new admin_setting_special_registerauth());
e106013f
SH
45 $temp->add(new admin_setting_configcheckbox('authpreventaccountcreation', new lang_string('authpreventaccountcreation', 'admin'), new lang_string('authpreventaccountcreation_help', 'admin'), 0));
46 $temp->add(new admin_setting_configcheckbox('loginpageautofocus', new lang_string('loginpageautofocus', 'admin'), new lang_string('loginpageautofocus_help', 'admin'), 0));
47 $temp->add(new admin_setting_configselect('guestloginbutton', new lang_string('guestloginbutton', 'auth'),
48 new lang_string('showguestlogin', 'auth'), '1', array('0'=>new lang_string('hide'), '1'=>new lang_string('show'))));
49 $temp->add(new admin_setting_configtext('alternateloginurl', new lang_string('alternateloginurl', 'auth'),
50 new lang_string('alternatelogin', 'auth', htmlspecialchars(get_login_url())), ''));
51 $temp->add(new admin_setting_configtext('forgottenpasswordurl', new lang_string('forgottenpasswordurl', 'auth'),
52 new lang_string('forgottenpassword', 'auth'), ''));
53 $temp->add(new admin_setting_confightmleditor('auth_instructions', new lang_string('instructions', 'auth'),
54 new lang_string('authinstructions', 'auth'), ''));
55 $temp->add(new admin_setting_configtext('allowemailaddresses', new lang_string('allowemailaddresses', 'admin'), new lang_string('configallowemailaddresses', 'admin'), '', PARAM_NOTAGS));
56 $temp->add(new admin_setting_configtext('denyemailaddresses', new lang_string('denyemailaddresses', 'admin'), new lang_string('configdenyemailaddresses', 'admin'), '', PARAM_NOTAGS));
57 $temp->add(new admin_setting_configcheckbox('verifychangedemail', new lang_string('verifychangedemail', 'admin'), new lang_string('configverifychangedemail', 'admin'), 1));
58
59 $temp->add(new admin_setting_configtext('recaptchapublickey', new lang_string('recaptchapublickey', 'admin'), new lang_string('configrecaptchapublickey', 'admin'), '', PARAM_NOTAGS));
60 $temp->add(new admin_setting_configtext('recaptchaprivatekey', new lang_string('recaptchaprivatekey', 'admin'), new lang_string('configrecaptchaprivatekey', 'admin'), '', PARAM_NOTAGS));
df997f84
PS
61 $ADMIN->add('authsettings', $temp);
62
cbe9f609
MG
63 foreach ($allplugins['auth'] as $auth) {
64 $auth->load_settings($ADMIN, 'authsettings', $hassiteconfig);
df997f84
PS
65 }
66
df997f84 67 // Enrolment plugins
e106013f
SH
68 $ADMIN->add('modules', new admin_category('enrolments', new lang_string('enrolments', 'enrol')));
69 $temp = new admin_settingpage('manageenrols', new lang_string('manageenrols', 'enrol'));
df997f84 70 $temp->add(new admin_setting_manageenrols());
df997f84 71 $ADMIN->add('enrolments', $temp);
79c5c3fa
MG
72 foreach($allplugins['enrol'] as $enrol) {
73 $enrol->load_settings($ADMIN, 'enrolments', $hassiteconfig);
df997f84 74 }
df997f84 75
c5d2d0dd 76
a5747cf8 77/// Editor plugins
e106013f
SH
78 $ADMIN->add('modules', new admin_category('editorsettings', new lang_string('editors', 'editor')));
79 $temp = new admin_settingpage('manageeditors', new lang_string('editorsettings', 'editor'));
a5747cf8 80 $temp->add(new admin_setting_manageeditors());
81 $ADMIN->add('editorsettings', $temp);
087001ee
MG
82 foreach ($allplugins['editor'] as $editor) {
83 $editor->load_settings($ADMIN, 'editorsettings', $hassiteconfig);
7a856a93 84 }
6fc67fce 85
1dce6261 86/// License types
e106013f
SH
87 $ADMIN->add('modules', new admin_category('licensesettings', new lang_string('licenses')));
88 $temp = new admin_settingpage('managelicenses', new lang_string('managelicenses', 'admin'));
ba74f517
DC
89
90 require_once($CFG->libdir . '/licenselib.php');
91 $licenses = array();
92 $array = explode(',', $CFG->licenses);
93 foreach ($array as $value) {
e106013f 94 $licenses[$value] = new lang_string($value, 'license');
ba74f517 95 }
e106013f 96 $temp->add(new admin_setting_configselect('sitedefaultlicense', new lang_string('configsitedefaultlicense','admin'), new lang_string('configsitedefaultlicensehelp','admin'), 'allrightsreserved', $licenses));
1dce6261
DC
97 $temp->add(new admin_setting_managelicenses());
98 $ADMIN->add('licensesettings', $temp);
a5747cf8 99
100/// Filter plugins
e106013f 101 $ADMIN->add('modules', new admin_category('filtersettings', new lang_string('managefilters')));
dcdf3b29 102
103 $ADMIN->add('filtersettings', new admin_page_managefilters());
104
220a90c5 105 // "filtersettings" settingpage
e106013f 106 $temp = new admin_settingpage('commonfiltersettings', new lang_string('commonfiltersettings', 'admin'));
220a90c5 107 if ($ADMIN->fulltree) {
5b8fa09b 108 $cachetimes = array(
e106013f
SH
109 604800 => new lang_string('numdays','',7),
110 86400 => new lang_string('numdays','',1),
111 43200 => new lang_string('numhours','',12),
112 10800 => new lang_string('numhours','',3),
113 7200 => new lang_string('numhours','',2),
114 3600 => new lang_string('numhours','',1),
115 2700 => new lang_string('numminutes','',45),
116 1800 => new lang_string('numminutes','',30),
117 900 => new lang_string('numminutes','',15),
118 600 => new lang_string('numminutes','',10),
119 540 => new lang_string('numminutes','',9),
120 480 => new lang_string('numminutes','',8),
121 420 => new lang_string('numminutes','',7),
122 360 => new lang_string('numminutes','',6),
123 300 => new lang_string('numminutes','',5),
124 240 => new lang_string('numminutes','',4),
125 180 => new lang_string('numminutes','',3),
126 120 => new lang_string('numminutes','',2),
127 60 => new lang_string('numminutes','',1),
128 30 => new lang_string('numseconds','',30),
129 0 => new lang_string('no')
5b8fa09b 130 );
109e3cb2 131 $items = array();
e106013f
SH
132 $items[] = new admin_setting_configselect('cachetext', new lang_string('cachetext', 'admin'), new lang_string('configcachetext', 'admin'), 60, $cachetimes);
133 $items[] = new admin_setting_configselect('filteruploadedfiles', new lang_string('filteruploadedfiles', 'admin'), new lang_string('configfilteruploadedfiles', 'admin'), 0,
134 array('0' => new lang_string('none'), '1' => new lang_string('allfiles'), '2' => new lang_string('htmlfilesonly')));
135 $items[] = new admin_setting_configcheckbox('filtermatchoneperpage', new lang_string('filtermatchoneperpage', 'admin'), new lang_string('configfiltermatchoneperpage', 'admin'), 0);
136 $items[] = new admin_setting_configcheckbox('filtermatchonepertext', new lang_string('filtermatchonepertext', 'admin'), new lang_string('configfiltermatchonepertext', 'admin'), 0);
109e3cb2 137 foreach ($items as $item) {
138 $item->set_updatedcallback('reset_text_filters_cache');
139 $temp->add($item);
140 }
220a90c5 141 }
142 $ADMIN->add('filtersettings', $temp);
143
1de1a666
MG
144 foreach ($allplugins['filter'] as $filter) {
145 $filter->load_settings($ADMIN, 'filtersettings', $hassiteconfig);
220a90c5 146 }
67a87e7d 147
78946b9b
PS
148
149 //== Portfolio settings ==
150 require_once($CFG->libdir. '/portfoliolib.php');
e106013f
SH
151 $catname = new lang_string('portfolios', 'portfolio');
152 $manage = new lang_string('manageportfolios', 'portfolio');
67a87e7d 153 $url = "$CFG->wwwroot/$CFG->admin/portfolio.php";
154
90658eef 155 $ADMIN->add('modules', new admin_category('portfoliosettings', $catname, empty($CFG->enableportfolios)));
67a87e7d 156
9d81733d
SM
157 // Add manage page (with table)
158 $temp = new admin_page_manageportfolios();
159 $ADMIN->add('portfoliosettings', $temp);
160
161 // Add common settings page
e106013f
SH
162 $temp = new admin_settingpage('manageportfolioscommon', new lang_string('commonportfoliosettings', 'portfolio'));
163 $temp->add(new admin_setting_heading('manageportfolioscommon', '', new lang_string('commonsettingsdesc', 'portfolio')));
bee4bce2 164 $fileinfo = portfolio_filesize_info(); // make sure this is defined in one place since its used inside portfolio too to detect insane settings
165 $fileoptions = $fileinfo['options'];
166 $temp->add(new admin_setting_configselect(
167 'portfolio_moderate_filesize_threshold',
e106013f
SH
168 new lang_string('moderatefilesizethreshold', 'portfolio'),
169 new lang_string('moderatefilesizethresholddesc', 'portfolio'),
bee4bce2 170 $fileinfo['moderate'], $fileoptions));
171 $temp->add(new admin_setting_configselect(
172 'portfolio_high_filesize_threshold',
e106013f
SH
173 new lang_string('highfilesizethreshold', 'portfolio'),
174 new lang_string('highfilesizethresholddesc', 'portfolio'),
bee4bce2 175 $fileinfo['high'], $fileoptions));
176
177 $temp->add(new admin_setting_configtext(
178 'portfolio_moderate_db_threshold',
e106013f
SH
179 new lang_string('moderatedbsizethreshold', 'portfolio'),
180 new lang_string('moderatedbsizethresholddesc', 'portfolio'),
1e12c120 181 20, PARAM_INT, 3));
bee4bce2 182
183 $temp->add(new admin_setting_configtext(
184 'portfolio_high_db_threshold',
e106013f
SH
185 new lang_string('highdbsizethreshold', 'portfolio'),
186 new lang_string('highdbsizethresholddesc', 'portfolio'),
1e12c120 187 50, PARAM_INT, 3));
a50ef3d3 188
189 $ADMIN->add('portfoliosettings', $temp);
e106013f
SH
190 $ADMIN->add('portfoliosettings', new admin_externalpage('portfolionew', new lang_string('addnewportfolio', 'portfolio'), $url, 'moodle/site:config', true), '', $url);
191 $ADMIN->add('portfoliosettings', new admin_externalpage('portfoliodelete', new lang_string('deleteportfolio', 'portfolio'), $url, 'moodle/site:config', true), '', $url);
192 $ADMIN->add('portfoliosettings', new admin_externalpage('portfoliocontroller', new lang_string('manageportfolios', 'portfolio'), $url, 'moodle/site:config', true), '', $url);
a50ef3d3 193
08d5e18b 194 foreach (portfolio_instances(false, false) as $portfolio) {
edf1fc35 195 require_once($CFG->dirroot . '/portfolio/' . $portfolio->get('plugin') . '/lib.php');
67a87e7d 196 $classname = 'portfolio_plugin_' . $portfolio->get('plugin');
a50ef3d3 197 $ADMIN->add(
198 'portfoliosettings',
08d5e18b 199 new admin_externalpage(
200 'portfoliosettings' . $portfolio->get('id'),
658837bb 201 $portfolio->get('name'),
6010eda2
MD
202 $url . '?action=edit&pf=' . $portfolio->get('id'),
203 'moodle/site:config'
08d5e18b 204 ),
a50ef3d3 205 $portfolio->get('name'),
6010eda2 206 $url . '?action=edit&pf=' . $portfolio->get('id')
a50ef3d3 207 );
67a87e7d 208 }
4a65c39a 209
210 // repository setting
211 require_once("$CFG->dirroot/repository/lib.php");
e106013f
SH
212 $catname =new lang_string('repositories', 'repository');
213 $managerepo = new lang_string('manage', 'repository');
04bd6d2d 214 $url = $CFG->wwwroot.'/'.$CFG->admin.'/repository.php';
4a65c39a 215 $ADMIN->add('modules', new admin_category('repositorysettings', $catname));
9d81733d
SM
216
217 // Add main page (with table)
218 $temp = new admin_page_managerepositories();
219 $ADMIN->add('repositorysettings', $temp);
220
221 // Add common settings page
e106013f
SH
222 $temp = new admin_settingpage('managerepositoriescommon', new lang_string('commonrepositorysettings', 'repository'));
223 $temp->add(new admin_setting_configtext('repositorycacheexpire', new lang_string('cacheexpire', 'repository'), new lang_string('configcacheexpire', 'repository'), 120));
224 $temp->add(new admin_setting_configcheckbox('repositoryallowexternallinks', new lang_string('allowexternallinks', 'repository'), new lang_string('configallowexternallinks', 'repository'), 1));
225 $temp->add(new admin_setting_configcheckbox('legacyfilesinnewcourses', new lang_string('legacyfilesinnewcourses', 'admin'), new lang_string('legacyfilesinnewcourses_help', 'admin'), 0));
4a65c39a 226 $ADMIN->add('repositorysettings', $temp);
4f2b9a4f 227 $ADMIN->add('repositorysettings', new admin_externalpage('repositorynew',
e106013f 228 new lang_string('addplugin', 'repository'), $url, 'moodle/site:config', true),
4a65c39a 229 '', $url);
230 $ADMIN->add('repositorysettings', new admin_externalpage('repositorydelete',
e106013f 231 new lang_string('deleterepository', 'repository'), $url, 'moodle/site:config', true),
4a65c39a 232 '', $url);
233 $ADMIN->add('repositorysettings', new admin_externalpage('repositorycontroller',
e106013f 234 new lang_string('manage', 'repository'), $url, 'moodle/site:config', true),
4a65c39a 235 '', $url);
0d099914 236 $ADMIN->add('repositorysettings', new admin_externalpage('repositoryinstancenew',
e106013f 237 new lang_string('createrepository', 'repository'), $url, 'moodle/site:config', true),
0d099914 238 '', $url);
239 $ADMIN->add('repositorysettings', new admin_externalpage('repositoryinstanceedit',
e106013f 240 new lang_string('editrepositoryinstance', 'repository'), $url, 'moodle/site:config', true),
0d099914 241 '', $url);
c517dd68
MG
242 foreach ($allplugins['repository'] as $repositorytype) {
243 $repositorytype->load_settings($ADMIN, 'repositorysettings', $hassiteconfig);
4a65c39a 244 }
bee4bce2 245
5ae9f539 246/// Web services
e106013f 247 $ADMIN->add('modules', new admin_category('webservicesettings', new lang_string('webservices', 'webservice')));
3e6161fb 248 /// overview page
e106013f 249 $temp = new admin_settingpage('webservicesoverview', new lang_string('webservicesoverview', 'webservice'));
3e6161fb 250 $temp->add(new admin_setting_webservicesoverview());
251 $ADMIN->add('webservicesettings', $temp);
cde291ed 252 //API documentation
e106013f 253 $ADMIN->add('webservicesettings', new admin_externalpage('webservicedocumentation', new lang_string('wsdocapi', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/documentation.php", 'moodle/site:config', false));
3e6161fb 254 /// manage service
e106013f 255 $temp = new admin_settingpage('externalservices', new lang_string('externalservices', 'webservice'));
c1b65883 256 $enablemobiledocurl = new moodle_url(get_docs_url('Enable_mobile_web_services'));
e106013f
SH
257 $enablemobiledoclink = html_writer::link($enablemobiledocurl, new lang_string('documentation'));
258 $temp->add(new admin_setting_enablemobileservice('enablemobilewebservice', new lang_string('enablemobilewebservice', 'admin'), new lang_string('configenablemobilewebservice', 'admin', $enablemobiledoclink), 0));
259 $temp->add(new admin_setting_heading('manageserviceshelpexplaination', new lang_string('information', 'webservice'), new lang_string('servicehelpexplanation', 'webservice')));
cc93c7da 260 $temp->add(new admin_setting_manageexternalservices());
261 $ADMIN->add('webservicesettings', $temp);
e106013f
SH
262 $ADMIN->add('webservicesettings', new admin_externalpage('externalservice', new lang_string('editaservice', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/service.php", 'moodle/site:config', true));
263 $ADMIN->add('webservicesettings', new admin_externalpage('externalservicefunctions', new lang_string('externalservicefunctions', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/service_functions.php", 'moodle/site:config', true));
264 $ADMIN->add('webservicesettings', new admin_externalpage('externalserviceusers', new lang_string('externalserviceusers', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/service_users.php", 'moodle/site:config', true));
265 $ADMIN->add('webservicesettings', new admin_externalpage('externalserviceusersettings', new lang_string('serviceusersettings', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/service_user_settings.php", 'moodle/site:config', true));
5ae9f539 266 /// manage protocol page link
e106013f 267 $temp = new admin_settingpage('webserviceprotocols', new lang_string('manageprotocols', 'webservice'));
da124b5e 268 $temp->add(new admin_setting_managewebserviceprotocols());
cc93c7da 269 if (empty($CFG->enablewebservices)) {
e106013f 270 $temp->add(new admin_setting_heading('webservicesaredisabled', '', new lang_string('disabledwarning', 'webservice')));
cc93c7da 271 }
b4c91012
SH
272
273 // We cannot use $OUTPUT this early, doing so means that we lose the ability
274 // to set the page layout on all admin pages.
275 // $wsdoclink = $OUTPUT->doc_link('How_to_get_a_security_key');
276 $url = new moodle_url(get_docs_url('How_to_get_a_security_key'));
5e963820 277 $wsdoclink = html_writer::tag('a', new lang_string('supplyinfo', 'webservice'), array('href'=>$url));
e106013f
SH
278 $temp->add(new admin_setting_configcheckbox('enablewsdocumentation', new lang_string('enablewsdocumentation',
279 'admin'), new lang_string('configenablewsdocumentation', 'admin', $wsdoclink), false));
cc93c7da 280 $ADMIN->add('webservicesettings', $temp);
5ae9f539 281 /// links to protocol pages
2567584d
MG
282 foreach ($allplugins['webservice'] as $webservice) {
283 $webservice->load_settings($ADMIN, 'webservicesettings', $hassiteconfig);
cc93c7da 284 }
5ae9f539 285 /// manage token page link
e106013f
SH
286 $ADMIN->add('webservicesettings', new admin_externalpage('addwebservicetoken', new lang_string('managetokens', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/tokens.php", 'moodle/site:config', true));
287 $temp = new admin_settingpage('webservicetokens', new lang_string('managetokens', 'webservice'));
5ae9f539 288 $temp->add(new admin_setting_managewebservicetokens());
289 if (empty($CFG->enablewebservices)) {
e106013f 290 $temp->add(new admin_setting_heading('webservicesaredisabled', '', new lang_string('disabledwarning', 'webservice')));
5ae9f539 291 }
292 $ADMIN->add('webservicesettings', $temp);
2567584d 293}
df997f84 294
b6eb984a 295// Question type settings
78946b9b 296if ($hassiteconfig || has_capability('moodle/question:config', $systemcontext)) {
fde4560d 297 // Question behaviour settings.
22fae2a0
MG
298 require_once("$CFG->libdir/pluginlib.php");
299 $allplugins = plugin_manager::instance()->get_plugins();
e106013f 300 $ADMIN->add('modules', new admin_category('qbehavioursettings', new lang_string('questionbehaviours', 'admin')));
fde4560d
TH
301 $ADMIN->add('qbehavioursettings', new admin_page_manageqbehaviours());
302
bee4bce2 303 // Question type settings.
e106013f 304 $ADMIN->add('modules', new admin_category('qtypesettings', new lang_string('questiontypes', 'admin')));
bee4bce2 305 $ADMIN->add('qtypesettings', new admin_page_manageqtypes());
66f3684a
MG
306 foreach ($allplugins['qtype'] as $qtype) {
307 $qtype->load_settings($ADMIN, 'qtypesettings', $hassiteconfig);
bee4bce2 308 }
220a90c5 309}
b6eb984a
TH
310
311// Plagiarism plugin settings
bce59524 312if ($hassiteconfig && !empty($CFG->enableplagiarism)) {
e106013f 313 $ADMIN->add('modules', new admin_category('plagiarism', new lang_string('plagiarism', 'plagiarism')));
760007a2
DM
314 $ADMIN->add('plagiarism', new admin_externalpage('manageplagiarismplugins', new lang_string('manageplagiarism', 'plagiarism'),
315 $CFG->wwwroot . '/' . $CFG->admin . '/plagiarism.php'));
316
d98305bd
MG
317 foreach ($allplugins['plagiarism'] as $plugin) {
318 $plugin->load_settings($ADMIN, 'plagiarism', $hassiteconfig);
bce59524
DM
319 }
320}
e106013f 321$ADMIN->add('reports', new admin_externalpage('comments', new lang_string('comments'), $CFG->wwwroot.'/comment/', 'moodle/site:viewreports'));
b63a6a63 322
b6eb984a
TH
323// Course reports settings
324if ($hassiteconfig) {
325 $pages = array();
326 foreach (get_plugin_list('coursereport') as $report => $path) {
327 $file = $CFG->dirroot . '/course/report/' . $report . '/settings.php';
328 if (file_exists($file)) {
329 $settings = new admin_settingpage('coursereport' . $report,
e106013f 330 new lang_string('pluginname', 'coursereport_' . $report), 'moodle/site:config');
b6eb984a
TH
331 // settings.php may create a subcategory or unset the settings completely
332 include($file);
333 if ($settings) {
334 $pages[] = $settings;
335 }
336 }
337 }
338 if (!empty($pages)) {
e106013f 339 $ADMIN->add('modules', new admin_category('coursereports', new lang_string('coursereports')));
b6eb984a
TH
340 foreach ($pages as $page) {
341 $ADMIN->add('coursereports', $page);
342 }
343 }
e30cc24c 344 unset($pages);
b6eb984a
TH
345}
346
347// Now add reports
e30cc24c 348$pages = array();
bb137774 349foreach (get_plugin_list('report') as $report => $plugindir) {
17da2e6f 350 $settings_path = "$plugindir/settings.php";
b63a6a63 351 if (file_exists($settings_path)) {
e30cc24c 352 $settings = new admin_settingpage('report' . $report,
e106013f 353 new lang_string('pluginname', 'report_' . $report), 'moodle/site:config');
b63a6a63 354 include($settings_path);
e30cc24c
PS
355 if ($settings) {
356 $pages[] = $settings;
357 }
b63a6a63 358 }
e30cc24c 359}
e106013f
SH
360$ADMIN->add('modules', new admin_category('reportplugins', new lang_string('reports')));
361$ADMIN->add('reportplugins', new admin_externalpage('managereports', new lang_string('reportsmanage', 'admin'),
4f6bba20
PS
362 $CFG->wwwroot . '/' . $CFG->admin . '/reports.php'));
363foreach ($pages as $page) {
364 $ADMIN->add('reportplugins', $page);
b63a6a63 365}
366
b33e6d8e
JG
367/// Add all admin tools
368if ($hassiteconfig) {
369 $ADMIN->add('modules', new admin_category('tools', new lang_string('tools', 'admin')));
370 $ADMIN->add('tools', new admin_externalpage('managetools', new lang_string('toolsmanage', 'admin'),
371 $CFG->wwwroot . '/' . $CFG->admin . '/tools.php'));
372}
373
11b24ce7
PS
374// Now add various admin tools
375foreach (get_plugin_list('tool') as $plugin => $plugindir) {
376 $settings_path = "$plugindir/settings.php";
377 if (file_exists($settings_path)) {
378 include($settings_path);
379 }
380}
17da2e6f 381
f23fbfd8
SH
382// Now add the Cache plugins
383if ($hassiteconfig) {
384 $ADMIN->add('modules', new admin_category('cache', new lang_string('caching', 'cache')));
385 $ADMIN->add('cache', new admin_externalpage('cacheconfig', new lang_string('cacheconfig', 'cache'), $CFG->wwwroot .'/cache/admin.php'));
386 $ADMIN->add('cache', new admin_externalpage('cachetestperformance', new lang_string('testperformance', 'cache'), $CFG->wwwroot . '/cache/testperformance.php'));
387 $ADMIN->add('cache', new admin_category('cachestores', new lang_string('cachestores', 'cache')));
6fec1820 388 foreach (get_plugin_list('cachestore') as $plugin => $path) {
f23fbfd8
SH
389 $settingspath = $path.'/settings.php';
390 if (file_exists($settingspath)) {
6fec1820 391 $settings = new admin_settingpage('cachestore_'.$plugin.'_settings', new lang_string('pluginname', 'cachestore_'.$plugin), 'moodle/site:config');
f23fbfd8
SH
392 include($settingspath);
393 $ADMIN->add('cachestores', $settings);
394 }
395 }
396}
397
17da2e6f 398/// Add all local plugins - must be always last!
1ed47309 399if ($hassiteconfig) {
e106013f
SH
400 $ADMIN->add('modules', new admin_category('localplugins', new lang_string('localplugins')));
401 $ADMIN->add('localplugins', new admin_externalpage('managelocalplugins', new lang_string('localpluginsmanage'),
1ed47309
DM
402 $CFG->wwwroot . '/' . $CFG->admin . '/localplugins.php'));
403}
17da2e6f 404
eb30df1e
MG
405// extend settings for each local plugin. Note that their settings may be in any part of the
406// settings tree and may be visible not only for administrators. We can not use $allplugins here
17da2e6f 407foreach (get_plugin_list('local') as $plugin => $plugindir) {
408 $settings_path = "$plugindir/settings.php";
409 if (file_exists($settings_path)) {
410 include($settings_path);
411 continue;
412 }
1bcb7eb5 413}