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