MDL-25290 cache: Fixed up issue with unit test blowing away cachedir
[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) {
b9934a17 8 $ADMIN->add('modules', new admin_page_pluginsoverview());
e106013f 9 $ADMIN->add('modules', new admin_category('modsettings', new lang_string('activitymodules')));
220a90c5 10 $ADMIN->add('modsettings', new admin_page_managemods());
73d0160f
PS
11 $modules = $DB->get_records('modules', array(), "name ASC");
12 foreach ($modules as $module) {
13 $modulename = $module->name;
14 if (!file_exists("$CFG->dirroot/mod/$modulename/lib.php")) {
15 continue;
220a90c5 16 }
e106013f 17 $strmodulename = new lang_string('modulename', 'mod_'.$modulename);
dbf9e4ba 18 if (file_exists($CFG->dirroot.'/mod/'.$modulename.'/settings.php')) {
73d0160f
PS
19 // do not show disabled modules in tree, keep only settings link on manage page
20 $settings = new admin_settingpage('modsetting'.$modulename, $strmodulename, 'moodle/site:config', !$module->visible);
dbf9e4ba
PS
21 include($CFG->dirroot.'/mod/'.$modulename.'/settings.php');
22 if ($settings) {
23 $ADMIN->add('modsettings', $settings);
220a90c5 24 }
25 }
26 }
27
b032b490 28 // hidden script for converting journals to online assignments (or something like that) linked from elsewhere
29 $ADMIN->add('modsettings', new admin_externalpage('oacleanup', 'Online Assignment Cleanup', $CFG->wwwroot.'/'.$CFG->admin.'/oacleanup.php', 'moodle/site:config', true));
220a90c5 30
e106013f 31 $ADMIN->add('modules', new admin_category('blocksettings', new lang_string('blocks')));
220a90c5 32 $ADMIN->add('blocksettings', new admin_page_manageblocks());
73d0160f
PS
33 $blocks = $DB->get_records('block', array(), "name ASC");
34 foreach ($blocks as $block) {
35 $blockname = $block->name;
36 if (!file_exists("$CFG->dirroot/blocks/$blockname/block_$blockname.php")) {
37 continue;
220a90c5 38 }
e106013f 39 $strblockname = new lang_string('pluginname', 'block_'.$blockname);
73d0160f
PS
40 if (file_exists($CFG->dirroot.'/blocks/'.$blockname.'/settings.php')) {
41 $settings = new admin_settingpage('blocksetting'.$blockname, $strblockname, 'moodle/site:config', !$block->visible);
dbf9e4ba
PS
42 include($CFG->dirroot.'/blocks/'.$blockname.'/settings.php');
43 if ($settings) {
44 $ADMIN->add('blocksettings', $settings);
220a90c5 45 }
46 }
47 }
48
75c34c23 49 // message outputs
e106013f 50 $ADMIN->add('modules', new admin_category('messageoutputs', new lang_string('messageoutputs', 'message')));
75c34c23 51 $ADMIN->add('messageoutputs', new admin_page_managemessageoutputs());
1d72e9d4 52 $ADMIN->add('messageoutputs', new admin_page_defaultmessageoutputs());
2f2137fc
RK
53 require_once($CFG->dirroot.'/message/lib.php');
54 $processors = get_message_processors();
55 foreach ($processors as $processor) {
56 $processorname = $processor->name;
57 if (!$processor->available) {
58 continue;
59 }
1d72e9d4 60 if ($processor->hassettings) {
e106013f 61 $strprocessorname = new lang_string('pluginname', 'message_'.$processorname);
2f2137fc
RK
62 $settings = new admin_settingpage('messagesetting'.$processorname, $strprocessorname, 'moodle/site:config', !$processor->enabled);
63 include($CFG->dirroot.'/message/output/'.$processor->name.'/settings.php');
64 if ($settings) {
65 $ADMIN->add('messageoutputs', $settings);
66 }
67 }
68 }
75c34c23 69
df997f84 70 // authentication plugins
e106013f 71 $ADMIN->add('modules', new admin_category('authsettings', new lang_string('authentication', 'admin')));
df997f84 72
e106013f 73 $temp = new admin_settingpage('manageauths', new lang_string('authsettings', 'admin'));
df997f84 74 $temp->add(new admin_setting_manageauths());
e106013f 75 $temp->add(new admin_setting_heading('manageauthscommonheading', new lang_string('commonsettings', 'admin'), ''));
df997f84 76 $temp->add(new admin_setting_special_registerauth());
e106013f
SH
77 $temp->add(new admin_setting_configcheckbox('authpreventaccountcreation', new lang_string('authpreventaccountcreation', 'admin'), new lang_string('authpreventaccountcreation_help', 'admin'), 0));
78 $temp->add(new admin_setting_configcheckbox('loginpageautofocus', new lang_string('loginpageautofocus', 'admin'), new lang_string('loginpageautofocus_help', 'admin'), 0));
79 $temp->add(new admin_setting_configselect('guestloginbutton', new lang_string('guestloginbutton', 'auth'),
80 new lang_string('showguestlogin', 'auth'), '1', array('0'=>new lang_string('hide'), '1'=>new lang_string('show'))));
81 $temp->add(new admin_setting_configtext('alternateloginurl', new lang_string('alternateloginurl', 'auth'),
82 new lang_string('alternatelogin', 'auth', htmlspecialchars(get_login_url())), ''));
83 $temp->add(new admin_setting_configtext('forgottenpasswordurl', new lang_string('forgottenpasswordurl', 'auth'),
84 new lang_string('forgottenpassword', 'auth'), ''));
85 $temp->add(new admin_setting_confightmleditor('auth_instructions', new lang_string('instructions', 'auth'),
86 new lang_string('authinstructions', 'auth'), ''));
87 $temp->add(new admin_setting_configtext('allowemailaddresses', new lang_string('allowemailaddresses', 'admin'), new lang_string('configallowemailaddresses', 'admin'), '', PARAM_NOTAGS));
88 $temp->add(new admin_setting_configtext('denyemailaddresses', new lang_string('denyemailaddresses', 'admin'), new lang_string('configdenyemailaddresses', 'admin'), '', PARAM_NOTAGS));
89 $temp->add(new admin_setting_configcheckbox('verifychangedemail', new lang_string('verifychangedemail', 'admin'), new lang_string('configverifychangedemail', 'admin'), 1));
90
91 $temp->add(new admin_setting_configtext('recaptchapublickey', new lang_string('recaptchapublickey', 'admin'), new lang_string('configrecaptchapublickey', 'admin'), '', PARAM_NOTAGS));
92 $temp->add(new admin_setting_configtext('recaptchaprivatekey', new lang_string('recaptchaprivatekey', 'admin'), new lang_string('configrecaptchaprivatekey', 'admin'), '', PARAM_NOTAGS));
df997f84
PS
93 $ADMIN->add('authsettings', $temp);
94
95
dbf9e4ba
PS
96 $auths = get_plugin_list('auth');
97 $authsenabled = get_enabled_auth_plugins();
98 foreach ($auths as $authname => $authdir) {
e106013f 99 $strauthname = new lang_string('pluginname', "auth_{$authname}");
dbf9e4ba
PS
100 // do not show disabled auths in tree, keep only settings link on manage page
101 $enabled = in_array($authname, $authsenabled);
102 if (file_exists($authdir.'/settings.php')) {
103 // TODO: finish implementation of common settings - locking, etc.
104 $settings = new admin_settingpage('authsetting'.$authname, $strauthname, 'moodle/site:config', !$enabled);
105 include($authdir.'/settings.php');
106 if ($settings) {
df997f84 107 $ADMIN->add('authsettings', $settings);
df997f84 108 }
dbf9e4ba
PS
109
110 } else {
111 $ADMIN->add('authsettings', new admin_externalpage('authsetting'.$authname, $strauthname, "$CFG->wwwroot/$CFG->admin/auth_config.php?auth=$authname", 'moodle/site:config', !$enabled));
df997f84
PS
112 }
113 }
114
115
116 // Enrolment plugins
e106013f
SH
117 $ADMIN->add('modules', new admin_category('enrolments', new lang_string('enrolments', 'enrol')));
118 $temp = new admin_settingpage('manageenrols', new lang_string('manageenrols', 'enrol'));
df997f84
PS
119 $temp->add(new admin_setting_manageenrols());
120 if (empty($CFG->enrol_plugins_enabled)) {
121 $enabled = array();
122 } else {
123 $enabled = explode(',', $CFG->enrol_plugins_enabled);
124 }
125 $enrols = get_plugin_list('enrol');
126 $ADMIN->add('enrolments', $temp);
127 foreach($enrols as $enrol=>$enrolpath) {
128 if (!file_exists("$enrolpath/settings.php")) {
129 continue;
130 }
131
e106013f 132 $settings = new admin_settingpage('enrolsettings'.$enrol, new lang_string('pluginname', 'enrol_'.$enrol), 'moodle/site:config', !in_array($enrol, $enabled));
df997f84
PS
133 // settings.php may create a subcategory or unset the settings completely
134 include("$enrolpath/settings.php");
135 if ($settings) {
136 $ADMIN->add('enrolments', $settings);
137 }
138
139 }
140 unset($enabled);
141 unset($enrols);
142
c5d2d0dd 143
a5747cf8 144/// Editor plugins
e106013f
SH
145 $ADMIN->add('modules', new admin_category('editorsettings', new lang_string('editors', 'editor')));
146 $temp = new admin_settingpage('manageeditors', new lang_string('editorsettings', 'editor'));
a5747cf8 147 $temp->add(new admin_setting_manageeditors());
20e5da7d 148 $htmleditors = editors_get_available();
a5747cf8 149 $ADMIN->add('editorsettings', $temp);
150
20e5da7d 151 $editors_available = editors_get_available();
7a856a93
DC
152 foreach ($editors_available as $editor=>$editorstr) {
153 if (file_exists($CFG->dirroot . '/lib/editor/'.$editor.'/settings.php')) {
e106013f 154 $settings = new admin_settingpage('editorsettings'.$editor, new lang_string('pluginname', 'editor_'.$editor), 'moodle/site:config');
6fc67fce
PS
155 // settings.php may create a subcategory or unset the settings completely
156 include($CFG->dirroot . '/lib/editor/'.$editor.'/settings.php');
157 if ($settings) {
158 $ADMIN->add('editorsettings', $settings);
159 }
df997f84 160 }
7a856a93 161 }
6fc67fce 162
1dce6261 163/// License types
e106013f
SH
164 $ADMIN->add('modules', new admin_category('licensesettings', new lang_string('licenses')));
165 $temp = new admin_settingpage('managelicenses', new lang_string('managelicenses', 'admin'));
ba74f517
DC
166
167 require_once($CFG->libdir . '/licenselib.php');
168 $licenses = array();
169 $array = explode(',', $CFG->licenses);
170 foreach ($array as $value) {
e106013f 171 $licenses[$value] = new lang_string($value, 'license');
ba74f517 172 }
e106013f 173 $temp->add(new admin_setting_configselect('sitedefaultlicense', new lang_string('configsitedefaultlicense','admin'), new lang_string('configsitedefaultlicensehelp','admin'), 'allrightsreserved', $licenses));
1dce6261
DC
174 $temp->add(new admin_setting_managelicenses());
175 $ADMIN->add('licensesettings', $temp);
a5747cf8 176
177/// Filter plugins
e106013f 178 $ADMIN->add('modules', new admin_category('filtersettings', new lang_string('managefilters')));
dcdf3b29 179
180 $ADMIN->add('filtersettings', new admin_page_managefilters());
181
220a90c5 182 // "filtersettings" settingpage
e106013f 183 $temp = new admin_settingpage('commonfiltersettings', new lang_string('commonfiltersettings', 'admin'));
220a90c5 184 if ($ADMIN->fulltree) {
5b8fa09b 185 $cachetimes = array(
e106013f
SH
186 604800 => new lang_string('numdays','',7),
187 86400 => new lang_string('numdays','',1),
188 43200 => new lang_string('numhours','',12),
189 10800 => new lang_string('numhours','',3),
190 7200 => new lang_string('numhours','',2),
191 3600 => new lang_string('numhours','',1),
192 2700 => new lang_string('numminutes','',45),
193 1800 => new lang_string('numminutes','',30),
194 900 => new lang_string('numminutes','',15),
195 600 => new lang_string('numminutes','',10),
196 540 => new lang_string('numminutes','',9),
197 480 => new lang_string('numminutes','',8),
198 420 => new lang_string('numminutes','',7),
199 360 => new lang_string('numminutes','',6),
200 300 => new lang_string('numminutes','',5),
201 240 => new lang_string('numminutes','',4),
202 180 => new lang_string('numminutes','',3),
203 120 => new lang_string('numminutes','',2),
204 60 => new lang_string('numminutes','',1),
205 30 => new lang_string('numseconds','',30),
206 0 => new lang_string('no')
5b8fa09b 207 );
109e3cb2 208 $items = array();
e106013f
SH
209 $items[] = new admin_setting_configselect('cachetext', new lang_string('cachetext', 'admin'), new lang_string('configcachetext', 'admin'), 60, $cachetimes);
210 $items[] = new admin_setting_configselect('filteruploadedfiles', new lang_string('filteruploadedfiles', 'admin'), new lang_string('configfilteruploadedfiles', 'admin'), 0,
211 array('0' => new lang_string('none'), '1' => new lang_string('allfiles'), '2' => new lang_string('htmlfilesonly')));
212 $items[] = new admin_setting_configcheckbox('filtermatchoneperpage', new lang_string('filtermatchoneperpage', 'admin'), new lang_string('configfiltermatchoneperpage', 'admin'), 0);
213 $items[] = new admin_setting_configcheckbox('filtermatchonepertext', new lang_string('filtermatchonepertext', 'admin'), new lang_string('configfiltermatchonepertext', 'admin'), 0);
109e3cb2 214 foreach ($items as $item) {
215 $item->set_updatedcallback('reset_text_filters_cache');
216 $temp->add($item);
217 }
220a90c5 218 }
219 $ADMIN->add('filtersettings', $temp);
220
5b8fa09b 221 $activefilters = filter_get_globally_enabled();
b810a4d3 222 $filternames = filter_get_all_installed();
223 foreach ($filternames as $filterpath => $strfiltername) {
224 if (file_exists("$CFG->dirroot/$filterpath/filtersettings.php")) {
225 $settings = new admin_settingpage('filtersetting'.str_replace('/', '', $filterpath),
5b8fa09b 226 $strfiltername, 'moodle/site:config', !isset($activefilters[$filterpath]));
dbf9e4ba
PS
227 include("$CFG->dirroot/$filterpath/filtersettings.php");
228 if ($settings) {
229 $ADMIN->add('filtersettings', $settings);
220a90c5 230 }
231 }
232 }
67a87e7d 233
78946b9b
PS
234
235 //== Portfolio settings ==
236 require_once($CFG->libdir. '/portfoliolib.php');
e106013f
SH
237 $catname = new lang_string('portfolios', 'portfolio');
238 $manage = new lang_string('manageportfolios', 'portfolio');
67a87e7d 239 $url = "$CFG->wwwroot/$CFG->admin/portfolio.php";
240
90658eef 241 $ADMIN->add('modules', new admin_category('portfoliosettings', $catname, empty($CFG->enableportfolios)));
67a87e7d 242
9d81733d
SM
243 // Add manage page (with table)
244 $temp = new admin_page_manageportfolios();
245 $ADMIN->add('portfoliosettings', $temp);
246
247 // Add common settings page
e106013f
SH
248 $temp = new admin_settingpage('manageportfolioscommon', new lang_string('commonportfoliosettings', 'portfolio'));
249 $temp->add(new admin_setting_heading('manageportfolioscommon', '', new lang_string('commonsettingsdesc', 'portfolio')));
bee4bce2 250 $fileinfo = portfolio_filesize_info(); // make sure this is defined in one place since its used inside portfolio too to detect insane settings
251 $fileoptions = $fileinfo['options'];
252 $temp->add(new admin_setting_configselect(
253 'portfolio_moderate_filesize_threshold',
e106013f
SH
254 new lang_string('moderatefilesizethreshold', 'portfolio'),
255 new lang_string('moderatefilesizethresholddesc', 'portfolio'),
bee4bce2 256 $fileinfo['moderate'], $fileoptions));
257 $temp->add(new admin_setting_configselect(
258 'portfolio_high_filesize_threshold',
e106013f
SH
259 new lang_string('highfilesizethreshold', 'portfolio'),
260 new lang_string('highfilesizethresholddesc', 'portfolio'),
bee4bce2 261 $fileinfo['high'], $fileoptions));
262
263 $temp->add(new admin_setting_configtext(
264 'portfolio_moderate_db_threshold',
e106013f
SH
265 new lang_string('moderatedbsizethreshold', 'portfolio'),
266 new lang_string('moderatedbsizethresholddesc', 'portfolio'),
1e12c120 267 20, PARAM_INT, 3));
bee4bce2 268
269 $temp->add(new admin_setting_configtext(
270 'portfolio_high_db_threshold',
e106013f
SH
271 new lang_string('highdbsizethreshold', 'portfolio'),
272 new lang_string('highdbsizethresholddesc', 'portfolio'),
1e12c120 273 50, PARAM_INT, 3));
a50ef3d3 274
275 $ADMIN->add('portfoliosettings', $temp);
e106013f
SH
276 $ADMIN->add('portfoliosettings', new admin_externalpage('portfolionew', new lang_string('addnewportfolio', 'portfolio'), $url, 'moodle/site:config', true), '', $url);
277 $ADMIN->add('portfoliosettings', new admin_externalpage('portfoliodelete', new lang_string('deleteportfolio', 'portfolio'), $url, 'moodle/site:config', true), '', $url);
278 $ADMIN->add('portfoliosettings', new admin_externalpage('portfoliocontroller', new lang_string('manageportfolios', 'portfolio'), $url, 'moodle/site:config', true), '', $url);
a50ef3d3 279
08d5e18b 280 foreach (portfolio_instances(false, false) as $portfolio) {
edf1fc35 281 require_once($CFG->dirroot . '/portfolio/' . $portfolio->get('plugin') . '/lib.php');
67a87e7d 282 $classname = 'portfolio_plugin_' . $portfolio->get('plugin');
a50ef3d3 283 $ADMIN->add(
284 'portfoliosettings',
08d5e18b 285 new admin_externalpage(
286 'portfoliosettings' . $portfolio->get('id'),
658837bb 287 $portfolio->get('name'),
6010eda2
MD
288 $url . '?action=edit&pf=' . $portfolio->get('id'),
289 'moodle/site:config'
08d5e18b 290 ),
a50ef3d3 291 $portfolio->get('name'),
6010eda2 292 $url . '?action=edit&pf=' . $portfolio->get('id')
a50ef3d3 293 );
67a87e7d 294 }
4a65c39a 295
296 // repository setting
297 require_once("$CFG->dirroot/repository/lib.php");
e106013f
SH
298 $catname =new lang_string('repositories', 'repository');
299 $managerepo = new lang_string('manage', 'repository');
04bd6d2d 300 $url = $CFG->wwwroot.'/'.$CFG->admin.'/repository.php';
4a65c39a 301 $ADMIN->add('modules', new admin_category('repositorysettings', $catname));
9d81733d
SM
302
303 // Add main page (with table)
304 $temp = new admin_page_managerepositories();
305 $ADMIN->add('repositorysettings', $temp);
306
307 // Add common settings page
e106013f
SH
308 $temp = new admin_settingpage('managerepositoriescommon', new lang_string('commonrepositorysettings', 'repository'));
309 $temp->add(new admin_setting_configtext('repositorycacheexpire', new lang_string('cacheexpire', 'repository'), new lang_string('configcacheexpire', 'repository'), 120));
310 $temp->add(new admin_setting_configcheckbox('repositoryallowexternallinks', new lang_string('allowexternallinks', 'repository'), new lang_string('configallowexternallinks', 'repository'), 1));
311 $temp->add(new admin_setting_configcheckbox('legacyfilesinnewcourses', new lang_string('legacyfilesinnewcourses', 'admin'), new lang_string('legacyfilesinnewcourses_help', 'admin'), 0));
4a65c39a 312 $ADMIN->add('repositorysettings', $temp);
4f2b9a4f 313 $ADMIN->add('repositorysettings', new admin_externalpage('repositorynew',
e106013f 314 new lang_string('addplugin', 'repository'), $url, 'moodle/site:config', true),
4a65c39a 315 '', $url);
316 $ADMIN->add('repositorysettings', new admin_externalpage('repositorydelete',
e106013f 317 new lang_string('deleterepository', 'repository'), $url, 'moodle/site:config', true),
4a65c39a 318 '', $url);
319 $ADMIN->add('repositorysettings', new admin_externalpage('repositorycontroller',
e106013f 320 new lang_string('manage', 'repository'), $url, 'moodle/site:config', true),
4a65c39a 321 '', $url);
0d099914 322 $ADMIN->add('repositorysettings', new admin_externalpage('repositoryinstancenew',
e106013f 323 new lang_string('createrepository', 'repository'), $url, 'moodle/site:config', true),
0d099914 324 '', $url);
325 $ADMIN->add('repositorysettings', new admin_externalpage('repositoryinstanceedit',
e106013f 326 new lang_string('editrepositoryinstance', 'repository'), $url, 'moodle/site:config', true),
0d099914 327 '', $url);
78946b9b 328 foreach (repository::get_types() as $repositorytype) {
edb50637 329 //display setup page for plugins with: general options or multiple instances (e.g. has instance config)
dbc01944 330 $typeoptionnames = repository::static_function($repositorytype->get_typename(), 'get_type_option_names');
331 $instanceoptionnames = repository::static_function($repositorytype->get_typename(), 'get_instance_option_names');
edb50637 332 if (!empty($typeoptionnames) || !empty($instanceoptionnames)) {
7992b936
DC
333
334 $params = array('action'=>'edit', 'sesskey'=>sesskey(), 'repos'=>$repositorytype->get_typename());
335 $settingsurl = new moodle_url("/$CFG->admin/repository.php", $params);
336 $repositoryexternalpage = new admin_externalpage('repositorysettings'.$repositorytype->get_typename(), $repositorytype->get_readablename(), $settingsurl);
337 $ADMIN->add('repositorysettings', $repositoryexternalpage);
338 }
4a65c39a 339 }
78946b9b 340}
bee4bce2 341
5ae9f539 342/// Web services
e106013f 343 $ADMIN->add('modules', new admin_category('webservicesettings', new lang_string('webservices', 'webservice')));
3e6161fb 344 /// overview page
e106013f 345 $temp = new admin_settingpage('webservicesoverview', new lang_string('webservicesoverview', 'webservice'));
3e6161fb 346 $temp->add(new admin_setting_webservicesoverview());
347 $ADMIN->add('webservicesettings', $temp);
cde291ed 348 //API documentation
e106013f 349 $ADMIN->add('webservicesettings', new admin_externalpage('webservicedocumentation', new lang_string('wsdocapi', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/documentation.php", 'moodle/site:config', false));
3e6161fb 350 /// manage service
e106013f 351 $temp = new admin_settingpage('externalservices', new lang_string('externalservices', 'webservice'));
c1b65883 352 $enablemobiledocurl = new moodle_url(get_docs_url('Enable_mobile_web_services'));
e106013f
SH
353 $enablemobiledoclink = html_writer::link($enablemobiledocurl, new lang_string('documentation'));
354 $temp->add(new admin_setting_enablemobileservice('enablemobilewebservice', new lang_string('enablemobilewebservice', 'admin'), new lang_string('configenablemobilewebservice', 'admin', $enablemobiledoclink), 0));
355 $temp->add(new admin_setting_heading('manageserviceshelpexplaination', new lang_string('information', 'webservice'), new lang_string('servicehelpexplanation', 'webservice')));
cc93c7da 356 $temp->add(new admin_setting_manageexternalservices());
357 $ADMIN->add('webservicesettings', $temp);
e106013f
SH
358 $ADMIN->add('webservicesettings', new admin_externalpage('externalservice', new lang_string('editaservice', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/service.php", 'moodle/site:config', true));
359 $ADMIN->add('webservicesettings', new admin_externalpage('externalservicefunctions', new lang_string('externalservicefunctions', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/service_functions.php", 'moodle/site:config', true));
360 $ADMIN->add('webservicesettings', new admin_externalpage('externalserviceusers', new lang_string('externalserviceusers', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/service_users.php", 'moodle/site:config', true));
361 $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 362 /// manage protocol page link
e106013f 363 $temp = new admin_settingpage('webserviceprotocols', new lang_string('manageprotocols', 'webservice'));
da124b5e 364 $temp->add(new admin_setting_managewebserviceprotocols());
cc93c7da 365 if (empty($CFG->enablewebservices)) {
e106013f 366 $temp->add(new admin_setting_heading('webservicesaredisabled', '', new lang_string('disabledwarning', 'webservice')));
cc93c7da 367 }
b4c91012
SH
368
369 // We cannot use $OUTPUT this early, doing so means that we lose the ability
370 // to set the page layout on all admin pages.
371 // $wsdoclink = $OUTPUT->doc_link('How_to_get_a_security_key');
372 $url = new moodle_url(get_docs_url('How_to_get_a_security_key'));
5e963820 373 $wsdoclink = html_writer::tag('a', new lang_string('supplyinfo', 'webservice'), array('href'=>$url));
e106013f
SH
374 $temp->add(new admin_setting_configcheckbox('enablewsdocumentation', new lang_string('enablewsdocumentation',
375 'admin'), new lang_string('configenablewsdocumentation', 'admin', $wsdoclink), false));
cc93c7da 376 $ADMIN->add('webservicesettings', $temp);
5ae9f539 377 /// links to protocol pages
cc93c7da 378 $webservices_available = get_plugin_list('webservice');
379 $active_webservices = empty($CFG->webserviceprotocols) ? array() : explode(',', $CFG->webserviceprotocols);
380 foreach ($webservices_available as $webservice => $location) {
381 if (file_exists("$location/settings.php")) {
e106013f 382 $name = new lang_string('pluginname', 'webservice_'.$webservice);
cc93c7da 383 $settings = new admin_settingpage('webservicesetting'.$webservice, $name, 'moodle/site:config', !in_array($webservice, $active_webservices) or empty($CFG->enablewebservices));
dbf9e4ba
PS
384 include("$location/settings.php");
385 if ($settings) {
386 $ADMIN->add('webservicesettings', $settings);
cc93c7da 387 }
cc93c7da 388 }
389 }
5ae9f539 390 /// manage token page link
e106013f
SH
391 $ADMIN->add('webservicesettings', new admin_externalpage('addwebservicetoken', new lang_string('managetokens', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/tokens.php", 'moodle/site:config', true));
392 $temp = new admin_settingpage('webservicetokens', new lang_string('managetokens', 'webservice'));
5ae9f539 393 $temp->add(new admin_setting_managewebservicetokens());
394 if (empty($CFG->enablewebservices)) {
e106013f 395 $temp->add(new admin_setting_heading('webservicesaredisabled', '', new lang_string('disabledwarning', 'webservice')));
5ae9f539 396 }
397 $ADMIN->add('webservicesettings', $temp);
df997f84 398
b6eb984a 399// Question type settings
78946b9b 400if ($hassiteconfig || has_capability('moodle/question:config', $systemcontext)) {
fde4560d 401 // Question behaviour settings.
e106013f 402 $ADMIN->add('modules', new admin_category('qbehavioursettings', new lang_string('questionbehaviours', 'admin')));
fde4560d
TH
403 $ADMIN->add('qbehavioursettings', new admin_page_manageqbehaviours());
404
bee4bce2 405 // Question type settings.
e106013f 406 $ADMIN->add('modules', new admin_category('qtypesettings', new lang_string('questiontypes', 'admin')));
bee4bce2 407 $ADMIN->add('qtypesettings', new admin_page_manageqtypes());
63b5318e
TH
408 $qtypes = get_plugin_list('qtype');
409 foreach ($qtypes as $qtype => $path) {
410 $settingsfile = $path . '/settings.php';
bee4bce2 411 if (file_exists($settingsfile)) {
63b5318e 412 $settings = new admin_settingpage('qtypesetting' . $qtype,
e106013f 413 new lang_string('pluginname', 'qtype_' . $qtype), 'moodle/question:config');
dbf9e4ba
PS
414 include($settingsfile);
415 if ($settings) {
416 $ADMIN->add('qtypesettings', $settings);
bee4bce2 417 }
bee4bce2 418 }
419 }
220a90c5 420}
b6eb984a
TH
421
422// Plagiarism plugin settings
bce59524 423if ($hassiteconfig && !empty($CFG->enableplagiarism)) {
e106013f 424 $ADMIN->add('modules', new admin_category('plagiarism', new lang_string('plagiarism', 'plagiarism')));
760007a2
DM
425 $ADMIN->add('plagiarism', new admin_externalpage('manageplagiarismplugins', new lang_string('manageplagiarism', 'plagiarism'),
426 $CFG->wwwroot . '/' . $CFG->admin . '/plagiarism.php'));
427
bce59524
DM
428 foreach (get_plugin_list('plagiarism') as $plugin => $plugindir) {
429 if (file_exists($plugindir.'/settings.php')) {
e106013f 430 $ADMIN->add('plagiarism', new admin_externalpage('plagiarism'.$plugin, new lang_string($plugin, 'plagiarism_'.$plugin), "$CFG->wwwroot/plagiarism/$plugin/settings.php", 'moodle/site:config'));
bce59524
DM
431 }
432 }
433}
e106013f 434$ADMIN->add('reports', new admin_externalpage('comments', new lang_string('comments'), $CFG->wwwroot.'/comment/', 'moodle/site:viewreports'));
b63a6a63 435
b6eb984a
TH
436// Course reports settings
437if ($hassiteconfig) {
438 $pages = array();
439 foreach (get_plugin_list('coursereport') as $report => $path) {
440 $file = $CFG->dirroot . '/course/report/' . $report . '/settings.php';
441 if (file_exists($file)) {
442 $settings = new admin_settingpage('coursereport' . $report,
e106013f 443 new lang_string('pluginname', 'coursereport_' . $report), 'moodle/site:config');
b6eb984a
TH
444 // settings.php may create a subcategory or unset the settings completely
445 include($file);
446 if ($settings) {
447 $pages[] = $settings;
448 }
449 }
450 }
451 if (!empty($pages)) {
e106013f 452 $ADMIN->add('modules', new admin_category('coursereports', new lang_string('coursereports')));
b6eb984a
TH
453 foreach ($pages as $page) {
454 $ADMIN->add('coursereports', $page);
455 }
456 }
e30cc24c 457 unset($pages);
b6eb984a
TH
458}
459
460// Now add reports
e30cc24c 461$pages = array();
bb137774 462foreach (get_plugin_list('report') as $report => $plugindir) {
17da2e6f 463 $settings_path = "$plugindir/settings.php";
b63a6a63 464 if (file_exists($settings_path)) {
e30cc24c 465 $settings = new admin_settingpage('report' . $report,
e106013f 466 new lang_string('pluginname', 'report_' . $report), 'moodle/site:config');
b63a6a63 467 include($settings_path);
e30cc24c
PS
468 if ($settings) {
469 $pages[] = $settings;
470 }
b63a6a63 471 }
e30cc24c 472}
e106013f
SH
473$ADMIN->add('modules', new admin_category('reportplugins', new lang_string('reports')));
474$ADMIN->add('reportplugins', new admin_externalpage('managereports', new lang_string('reportsmanage', 'admin'),
4f6bba20
PS
475 $CFG->wwwroot . '/' . $CFG->admin . '/reports.php'));
476foreach ($pages as $page) {
477 $ADMIN->add('reportplugins', $page);
b63a6a63 478}
479
b33e6d8e
JG
480/// Add all admin tools
481if ($hassiteconfig) {
482 $ADMIN->add('modules', new admin_category('tools', new lang_string('tools', 'admin')));
483 $ADMIN->add('tools', new admin_externalpage('managetools', new lang_string('toolsmanage', 'admin'),
484 $CFG->wwwroot . '/' . $CFG->admin . '/tools.php'));
485}
486
11b24ce7
PS
487// Now add various admin tools
488foreach (get_plugin_list('tool') as $plugin => $plugindir) {
489 $settings_path = "$plugindir/settings.php";
490 if (file_exists($settings_path)) {
491 include($settings_path);
492 }
493}
17da2e6f 494
495/// Add all local plugins - must be always last!
1ed47309 496if ($hassiteconfig) {
e106013f
SH
497 $ADMIN->add('modules', new admin_category('localplugins', new lang_string('localplugins')));
498 $ADMIN->add('localplugins', new admin_externalpage('managelocalplugins', new lang_string('localpluginsmanage'),
1ed47309
DM
499 $CFG->wwwroot . '/' . $CFG->admin . '/localplugins.php'));
500}
17da2e6f 501
502foreach (get_plugin_list('local') as $plugin => $plugindir) {
503 $settings_path = "$plugindir/settings.php";
504 if (file_exists($settings_path)) {
505 include($settings_path);
506 continue;
507 }
1bcb7eb5 508}