MDL-38563 navigation: Removed extra parameters when calling add()
[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'
0a94e4a9 213 )
a50ef3d3 214 );
67a87e7d 215 }
4a65c39a 216
217 // repository setting
218 require_once("$CFG->dirroot/repository/lib.php");
e106013f
SH
219 $catname =new lang_string('repositories', 'repository');
220 $managerepo = new lang_string('manage', 'repository');
04bd6d2d 221 $url = $CFG->wwwroot.'/'.$CFG->admin.'/repository.php';
4a65c39a 222 $ADMIN->add('modules', new admin_category('repositorysettings', $catname));
9d81733d
SM
223
224 // Add main page (with table)
225 $temp = new admin_page_managerepositories();
226 $ADMIN->add('repositorysettings', $temp);
227
228 // Add common settings page
e106013f
SH
229 $temp = new admin_settingpage('managerepositoriescommon', new lang_string('commonrepositorysettings', 'repository'));
230 $temp->add(new admin_setting_configtext('repositorycacheexpire', new lang_string('cacheexpire', 'repository'), new lang_string('configcacheexpire', 'repository'), 120));
231 $temp->add(new admin_setting_configcheckbox('repositoryallowexternallinks', new lang_string('allowexternallinks', 'repository'), new lang_string('configallowexternallinks', 'repository'), 1));
232 $temp->add(new admin_setting_configcheckbox('legacyfilesinnewcourses', new lang_string('legacyfilesinnewcourses', 'admin'), new lang_string('legacyfilesinnewcourses_help', 'admin'), 0));
4a65c39a 233 $ADMIN->add('repositorysettings', $temp);
4f2b9a4f 234 $ADMIN->add('repositorysettings', new admin_externalpage('repositorynew',
56aee7c2 235 new lang_string('addplugin', 'repository'), $url, 'moodle/site:config', true));
4a65c39a 236 $ADMIN->add('repositorysettings', new admin_externalpage('repositorydelete',
56aee7c2 237 new lang_string('deleterepository', 'repository'), $url, 'moodle/site:config', true));
4a65c39a 238 $ADMIN->add('repositorysettings', new admin_externalpage('repositorycontroller',
56aee7c2 239 new lang_string('manage', 'repository'), $url, 'moodle/site:config', true));
0d099914 240 $ADMIN->add('repositorysettings', new admin_externalpage('repositoryinstancenew',
56aee7c2 241 new lang_string('createrepository', 'repository'), $url, 'moodle/site:config', true));
0d099914 242 $ADMIN->add('repositorysettings', new admin_externalpage('repositoryinstanceedit',
56aee7c2 243 new lang_string('editrepositoryinstance', 'repository'), $url, 'moodle/site:config', true));
c517dd68
MG
244 foreach ($allplugins['repository'] as $repositorytype) {
245 $repositorytype->load_settings($ADMIN, 'repositorysettings', $hassiteconfig);
4a65c39a 246 }
bee4bce2 247
5ae9f539 248/// Web services
e106013f 249 $ADMIN->add('modules', new admin_category('webservicesettings', new lang_string('webservices', 'webservice')));
489987af
JM
250 // Mobile
251 $temp = new admin_settingpage('mobile', new lang_string('mobile','admin'), 'moodle/site:config', false);
252 $enablemobiledocurl = new moodle_url(get_docs_url('Enable_mobile_web_services'));
253 $enablemobiledoclink = html_writer::link($enablemobiledocurl, new lang_string('documentation'));
254 $temp->add(new admin_setting_enablemobileservice('enablemobilewebservice',
255 new lang_string('enablemobilewebservice', 'admin'),
256 new lang_string('configenablemobilewebservice', 'admin', $enablemobiledoclink), 0));
257 $temp->add(new admin_setting_configtext('mobilecssurl', new lang_string('mobilecssurl', 'admin'), new lang_string('configmobilecssurl','admin'), '', PARAM_URL));
258 $ADMIN->add('webservicesettings', $temp);
3e6161fb 259 /// overview page
e106013f 260 $temp = new admin_settingpage('webservicesoverview', new lang_string('webservicesoverview', 'webservice'));
3e6161fb 261 $temp->add(new admin_setting_webservicesoverview());
262 $ADMIN->add('webservicesettings', $temp);
cde291ed 263 //API documentation
e106013f 264 $ADMIN->add('webservicesettings', new admin_externalpage('webservicedocumentation', new lang_string('wsdocapi', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/documentation.php", 'moodle/site:config', false));
3e6161fb 265 /// manage service
e106013f 266 $temp = new admin_settingpage('externalservices', new lang_string('externalservices', 'webservice'));
489987af
JM
267 $temp->add(new admin_setting_enablemobileservice('enablemobilewebservice',
268 new lang_string('enablemobilewebservice', 'admin'),
269 new lang_string('configenablemobilewebservice', 'admin', $enablemobiledoclink), 0));
e106013f 270 $temp->add(new admin_setting_heading('manageserviceshelpexplaination', new lang_string('information', 'webservice'), new lang_string('servicehelpexplanation', 'webservice')));
cc93c7da 271 $temp->add(new admin_setting_manageexternalservices());
272 $ADMIN->add('webservicesettings', $temp);
e106013f
SH
273 $ADMIN->add('webservicesettings', new admin_externalpage('externalservice', new lang_string('editaservice', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/service.php", 'moodle/site:config', true));
274 $ADMIN->add('webservicesettings', new admin_externalpage('externalservicefunctions', new lang_string('externalservicefunctions', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/service_functions.php", 'moodle/site:config', true));
275 $ADMIN->add('webservicesettings', new admin_externalpage('externalserviceusers', new lang_string('externalserviceusers', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/service_users.php", 'moodle/site:config', true));
276 $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 277 /// manage protocol page link
e106013f 278 $temp = new admin_settingpage('webserviceprotocols', new lang_string('manageprotocols', 'webservice'));
da124b5e 279 $temp->add(new admin_setting_managewebserviceprotocols());
cc93c7da 280 if (empty($CFG->enablewebservices)) {
e106013f 281 $temp->add(new admin_setting_heading('webservicesaredisabled', '', new lang_string('disabledwarning', 'webservice')));
cc93c7da 282 }
b4c91012
SH
283
284 // We cannot use $OUTPUT this early, doing so means that we lose the ability
285 // to set the page layout on all admin pages.
286 // $wsdoclink = $OUTPUT->doc_link('How_to_get_a_security_key');
287 $url = new moodle_url(get_docs_url('How_to_get_a_security_key'));
5e963820 288 $wsdoclink = html_writer::tag('a', new lang_string('supplyinfo', 'webservice'), array('href'=>$url));
e106013f
SH
289 $temp->add(new admin_setting_configcheckbox('enablewsdocumentation', new lang_string('enablewsdocumentation',
290 'admin'), new lang_string('configenablewsdocumentation', 'admin', $wsdoclink), false));
cc93c7da 291 $ADMIN->add('webservicesettings', $temp);
5ae9f539 292 /// links to protocol pages
2567584d
MG
293 foreach ($allplugins['webservice'] as $webservice) {
294 $webservice->load_settings($ADMIN, 'webservicesettings', $hassiteconfig);
cc93c7da 295 }
5ae9f539 296 /// manage token page link
e106013f
SH
297 $ADMIN->add('webservicesettings', new admin_externalpage('addwebservicetoken', new lang_string('managetokens', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/tokens.php", 'moodle/site:config', true));
298 $temp = new admin_settingpage('webservicetokens', new lang_string('managetokens', 'webservice'));
5ae9f539 299 $temp->add(new admin_setting_managewebservicetokens());
300 if (empty($CFG->enablewebservices)) {
e106013f 301 $temp->add(new admin_setting_heading('webservicesaredisabled', '', new lang_string('disabledwarning', 'webservice')));
5ae9f539 302 }
303 $ADMIN->add('webservicesettings', $temp);
2567584d 304}
df997f84 305
b6eb984a 306// Question type settings
78946b9b 307if ($hassiteconfig || has_capability('moodle/question:config', $systemcontext)) {
e75324a5
MG
308 if (!$hassiteconfig) {
309 require_once("$CFG->libdir/pluginlib.php");
310 $allplugins = plugin_manager::instance()->get_plugins();
311 }
4125ded1 312
fde4560d 313 // Question behaviour settings.
e106013f 314 $ADMIN->add('modules', new admin_category('qbehavioursettings', new lang_string('questionbehaviours', 'admin')));
fde4560d
TH
315 $ADMIN->add('qbehavioursettings', new admin_page_manageqbehaviours());
316
bee4bce2 317 // Question type settings.
e106013f 318 $ADMIN->add('modules', new admin_category('qtypesettings', new lang_string('questiontypes', 'admin')));
bee4bce2 319 $ADMIN->add('qtypesettings', new admin_page_manageqtypes());
4125ded1
TH
320
321 // Question preview defaults.
322 $settings = new admin_settingpage('qdefaultsetting',
323 get_string('questionpreviewdefaults', 'question'),
324 'moodle/question:config');
325 $ADMIN->add('qtypesettings', $settings);
326
327 $settings->add(new admin_setting_heading('qdefaultsetting_preview_options',
328 '', get_string('questionpreviewdefaults_desc', 'question')));
329
330 // These keys are question_display_options::HIDDEN and VISIBLE.
331 $hiddenofvisible = array(
332 0 => get_string('notshown', 'question'),
333 1 => get_string('shown', 'question'),
334 );
335
336 $settings->add(new admin_setting_question_behaviour('question_preview/behaviour',
337 get_string('howquestionsbehave', 'question'), '',
338 'deferredfeedback'));
339
340 $settings->add(new admin_setting_configselect('question_preview/correctness',
341 get_string('whethercorrect', 'question'), '', 1, $hiddenofvisible));
342
343 // These keys are question_display_options::HIDDEN, MARK_ONLY and MARK_AND_MAX.
344 $marksoptions = array(
345 0 => get_string('notshown', 'question'),
346 1 => get_string('showmaxmarkonly', 'question'),
347 2 => get_string('showmarkandmax', 'question'),
348 );
349 $settings->add(new admin_setting_configselect('question_preview/marks',
350 get_string('marks', 'question'), '', 1, $marksoptions));
351
352 $settings->add(new admin_setting_configselect('question_preview/markdp',
353 get_string('decimalplacesingrades', 'question'), '', 2, array(0, 1, 2, 3, 4, 5, 6, 7)));
354
355 $settings->add(new admin_setting_configselect('question_preview/feedback',
356 get_string('specificfeedback', 'question'), '', 1, $hiddenofvisible));
357
358 $settings->add(new admin_setting_configselect('question_preview/generalfeedback',
359 get_string('generalfeedback', 'question'), '', 1, $hiddenofvisible));
360
361 $settings->add(new admin_setting_configselect('question_preview/rightanswer',
362 get_string('rightanswer', 'question'), '', 1, $hiddenofvisible));
363
364 $settings->add(new admin_setting_configselect('question_preview/history',
365 get_string('responsehistory', 'question'), '', 0, $hiddenofvisible));
366
367 // Settings for particular question types.
66f3684a
MG
368 foreach ($allplugins['qtype'] as $qtype) {
369 $qtype->load_settings($ADMIN, 'qtypesettings', $hassiteconfig);
bee4bce2 370 }
220a90c5 371}
b6eb984a
TH
372
373// Plagiarism plugin settings
bce59524 374if ($hassiteconfig && !empty($CFG->enableplagiarism)) {
e106013f 375 $ADMIN->add('modules', new admin_category('plagiarism', new lang_string('plagiarism', 'plagiarism')));
760007a2
DM
376 $ADMIN->add('plagiarism', new admin_externalpage('manageplagiarismplugins', new lang_string('manageplagiarism', 'plagiarism'),
377 $CFG->wwwroot . '/' . $CFG->admin . '/plagiarism.php'));
378
d98305bd
MG
379 foreach ($allplugins['plagiarism'] as $plugin) {
380 $plugin->load_settings($ADMIN, 'plagiarism', $hassiteconfig);
bce59524
DM
381 }
382}
e106013f 383$ADMIN->add('reports', new admin_externalpage('comments', new lang_string('comments'), $CFG->wwwroot.'/comment/', 'moodle/site:viewreports'));
b63a6a63 384
b6eb984a
TH
385// Course reports settings
386if ($hassiteconfig) {
387 $pages = array();
388 foreach (get_plugin_list('coursereport') as $report => $path) {
389 $file = $CFG->dirroot . '/course/report/' . $report . '/settings.php';
390 if (file_exists($file)) {
391 $settings = new admin_settingpage('coursereport' . $report,
e106013f 392 new lang_string('pluginname', 'coursereport_' . $report), 'moodle/site:config');
b6eb984a
TH
393 // settings.php may create a subcategory or unset the settings completely
394 include($file);
395 if ($settings) {
396 $pages[] = $settings;
397 }
398 }
399 }
400 if (!empty($pages)) {
e106013f 401 $ADMIN->add('modules', new admin_category('coursereports', new lang_string('coursereports')));
b6eb984a
TH
402 foreach ($pages as $page) {
403 $ADMIN->add('coursereports', $page);
404 }
405 }
e30cc24c 406 unset($pages);
b6eb984a
TH
407}
408
409// Now add reports
e30cc24c 410$pages = array();
bb137774 411foreach (get_plugin_list('report') as $report => $plugindir) {
17da2e6f 412 $settings_path = "$plugindir/settings.php";
b63a6a63 413 if (file_exists($settings_path)) {
e30cc24c 414 $settings = new admin_settingpage('report' . $report,
e106013f 415 new lang_string('pluginname', 'report_' . $report), 'moodle/site:config');
b63a6a63 416 include($settings_path);
e30cc24c
PS
417 if ($settings) {
418 $pages[] = $settings;
419 }
b63a6a63 420 }
e30cc24c 421}
e106013f
SH
422$ADMIN->add('modules', new admin_category('reportplugins', new lang_string('reports')));
423$ADMIN->add('reportplugins', new admin_externalpage('managereports', new lang_string('reportsmanage', 'admin'),
4f6bba20
PS
424 $CFG->wwwroot . '/' . $CFG->admin . '/reports.php'));
425foreach ($pages as $page) {
426 $ADMIN->add('reportplugins', $page);
b63a6a63 427}
428
b33e6d8e
JG
429/// Add all admin tools
430if ($hassiteconfig) {
431 $ADMIN->add('modules', new admin_category('tools', new lang_string('tools', 'admin')));
432 $ADMIN->add('tools', new admin_externalpage('managetools', new lang_string('toolsmanage', 'admin'),
433 $CFG->wwwroot . '/' . $CFG->admin . '/tools.php'));
434}
435
11b24ce7
PS
436// Now add various admin tools
437foreach (get_plugin_list('tool') as $plugin => $plugindir) {
438 $settings_path = "$plugindir/settings.php";
439 if (file_exists($settings_path)) {
440 include($settings_path);
441 }
442}
17da2e6f 443
f23fbfd8
SH
444// Now add the Cache plugins
445if ($hassiteconfig) {
446 $ADMIN->add('modules', new admin_category('cache', new lang_string('caching', 'cache')));
447 $ADMIN->add('cache', new admin_externalpage('cacheconfig', new lang_string('cacheconfig', 'cache'), $CFG->wwwroot .'/cache/admin.php'));
448 $ADMIN->add('cache', new admin_externalpage('cachetestperformance', new lang_string('testperformance', 'cache'), $CFG->wwwroot . '/cache/testperformance.php'));
449 $ADMIN->add('cache', new admin_category('cachestores', new lang_string('cachestores', 'cache')));
6fec1820 450 foreach (get_plugin_list('cachestore') as $plugin => $path) {
f23fbfd8
SH
451 $settingspath = $path.'/settings.php';
452 if (file_exists($settingspath)) {
6fec1820 453 $settings = new admin_settingpage('cachestore_'.$plugin.'_settings', new lang_string('pluginname', 'cachestore_'.$plugin), 'moodle/site:config');
f23fbfd8
SH
454 include($settingspath);
455 $ADMIN->add('cachestores', $settings);
456 }
457 }
458}
459
17da2e6f 460/// Add all local plugins - must be always last!
1ed47309 461if ($hassiteconfig) {
e106013f
SH
462 $ADMIN->add('modules', new admin_category('localplugins', new lang_string('localplugins')));
463 $ADMIN->add('localplugins', new admin_externalpage('managelocalplugins', new lang_string('localpluginsmanage'),
1ed47309
DM
464 $CFG->wwwroot . '/' . $CFG->admin . '/localplugins.php'));
465}
17da2e6f 466
eb30df1e
MG
467// extend settings for each local plugin. Note that their settings may be in any part of the
468// settings tree and may be visible not only for administrators. We can not use $allplugins here
17da2e6f 469foreach (get_plugin_list('local') as $plugin => $plugindir) {
470 $settings_path = "$plugindir/settings.php";
471 if (file_exists($settings_path)) {
472 include($settings_path);
473 continue;
474 }
1bcb7eb5 475}