MDL-26155 string: Implemented moodle_string class
[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());
ff4b9fcb 9 $ADMIN->add('modules', new admin_category('modsettings', get_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 }
73d0160f 17 $strmodulename = get_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
31 $ADMIN->add('modules', new admin_category('blocksettings', get_string('blocks')));
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 }
73d0160f
PS
39 $strblockname = get_string('pluginname', 'block_'.$blockname);
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
RK
49 // message outputs
50 $ADMIN->add('modules', new admin_category('messageoutputs', get_string('messageoutputs', 'message')));
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
RK
60 if ($processor->hassettings) {
61 $strprocessorname = get_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
PS
70 // authentication plugins
71 $ADMIN->add('modules', new admin_category('authsettings', get_string('authentication', 'admin')));
72
73 $temp = new admin_settingpage('manageauths', get_string('authsettings', 'admin'));
74 $temp->add(new admin_setting_manageauths());
75 $temp->add(new admin_setting_heading('manageauthscommonheading', get_string('commonsettings', 'admin'), ''));
76 $temp->add(new admin_setting_special_registerauth());
2c7a9147 77 $temp->add(new admin_setting_configcheckbox('authpreventaccountcreation', get_string('authpreventaccountcreation', 'admin'), get_string('authpreventaccountcreation_help', 'admin'), 0));
2d16dad0 78 $temp->add(new admin_setting_configcheckbox('loginpageautofocus', get_string('loginpageautofocus', 'admin'), get_string('loginpageautofocus_help', 'admin'), 0));
df997f84
PS
79 $temp->add(new admin_setting_configselect('guestloginbutton', get_string('guestloginbutton', 'auth'),
80 get_string('showguestlogin', 'auth'), '1', array('0'=>get_string('hide'), '1'=>get_string('show'))));
81 $temp->add(new admin_setting_configtext('alternateloginurl', get_string('alternateloginurl', 'auth'),
82 get_string('alternatelogin', 'auth', htmlspecialchars(get_login_url())), ''));
83 $temp->add(new admin_setting_configtext('forgottenpasswordurl', get_string('forgottenpasswordurl', 'auth'),
84 get_string('forgottenpassword', 'auth'), ''));
85 $temp->add(new admin_setting_confightmleditor('auth_instructions', get_string('instructions', 'auth'),
86 get_string('authinstructions', 'auth'), ''));
87 $temp->add(new admin_setting_configtext('allowemailaddresses', get_string('allowemailaddresses', 'admin'), get_string('configallowemailaddresses', 'admin'), '', PARAM_NOTAGS));
88 $temp->add(new admin_setting_configtext('denyemailaddresses', get_string('denyemailaddresses', 'admin'), get_string('configdenyemailaddresses', 'admin'), '', PARAM_NOTAGS));
89 $temp->add(new admin_setting_configcheckbox('verifychangedemail', get_string('verifychangedemail', 'admin'), get_string('configverifychangedemail', 'admin'), 1));
90
91 $temp->add(new admin_setting_configtext('recaptchapublickey', get_string('recaptchapublickey', 'admin'), get_string('configrecaptchapublickey', 'admin'), '', PARAM_NOTAGS));
92 $temp->add(new admin_setting_configtext('recaptchaprivatekey', get_string('recaptchaprivatekey', 'admin'), get_string('configrecaptchaprivatekey', 'admin'), '', PARAM_NOTAGS));
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) {
99 $strauthname = get_string('pluginname', "auth_{$authname}");
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
117 $ADMIN->add('modules', new admin_category('enrolments', get_string('enrolments', 'enrol')));
118 $temp = new admin_settingpage('manageenrols', get_string('manageenrols', 'enrol'));
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
132 $settings = new admin_settingpage('enrolsettings'.$enrol, get_string('pluginname', 'enrol_'.$enrol), 'moodle/site:config', !in_array($enrol, $enabled));
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
145 $ADMIN->add('modules', new admin_category('editorsettings', get_string('editors', 'editor')));
146 $temp = new admin_settingpage('manageeditors', get_string('editorsettings', 'editor'));
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')) {
6fc67fce
PS
154 $settings = new admin_settingpage('editorsettings'.$editor, get_string('pluginname', 'editor_'.$editor), 'moodle/site:config');
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
7936470a 164 $ADMIN->add('modules', new admin_category('licensesettings', get_string('licenses')));
47576a5e 165 $temp = new admin_settingpage('managelicenses', get_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) {
171 $licenses[$value] = get_string($value, 'license');
172 }
173 $temp->add(new admin_setting_configselect('sitedefaultlicense', get_string('configsitedefaultlicense','admin'), get_string('configsitedefaultlicensehelp','admin'), 'allrightsreserved', $licenses));
1dce6261
DC
174 $temp->add(new admin_setting_managelicenses());
175 $ADMIN->add('licensesettings', $temp);
a5747cf8 176
177/// Filter plugins
220a90c5 178 $ADMIN->add('modules', new admin_category('filtersettings', get_string('managefilters')));
dcdf3b29 179
180 $ADMIN->add('filtersettings', new admin_page_managefilters());
181
220a90c5 182 // "filtersettings" settingpage
dcdf3b29 183 $temp = new admin_settingpage('commonfiltersettings', get_string('commonfiltersettings', 'admin'));
220a90c5 184 if ($ADMIN->fulltree) {
5b8fa09b 185 $cachetimes = array(
186 604800 => get_string('numdays','',7),
187 86400 => get_string('numdays','',1),
188 43200 => get_string('numhours','',12),
189 10800 => get_string('numhours','',3),
190 7200 => get_string('numhours','',2),
191 3600 => get_string('numhours','',1),
192 2700 => get_string('numminutes','',45),
193 1800 => get_string('numminutes','',30),
194 900 => get_string('numminutes','',15),
195 600 => get_string('numminutes','',10),
196 540 => get_string('numminutes','',9),
197 480 => get_string('numminutes','',8),
198 420 => get_string('numminutes','',7),
199 360 => get_string('numminutes','',6),
200 300 => get_string('numminutes','',5),
201 240 => get_string('numminutes','',4),
202 180 => get_string('numminutes','',3),
203 120 => get_string('numminutes','',2),
204 60 => get_string('numminutes','',1),
205 30 => get_string('numseconds','',30),
206 0 => get_string('no')
207 );
109e3cb2 208 $items = array();
5b8fa09b 209 $items[] = new admin_setting_configselect('cachetext', get_string('cachetext', 'admin'), get_string('configcachetext', 'admin'), 60, $cachetimes);
210 $items[] = new admin_setting_configselect('filteruploadedfiles', get_string('filteruploadedfiles', 'admin'), get_string('configfilteruploadedfiles', 'admin'), 0,
211 array('0' => get_string('none'), '1' => get_string('allfiles'), '2' => get_string('htmlfilesonly')));
109e3cb2 212 $items[] = new admin_setting_configcheckbox('filtermatchoneperpage', get_string('filtermatchoneperpage', 'admin'), get_string('configfiltermatchoneperpage', 'admin'), 0);
213 $items[] = new admin_setting_configcheckbox('filtermatchonepertext', get_string('filtermatchonepertext', 'admin'), get_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');
b810a4d3 237 $catname = get_string('portfolios', 'portfolio');
67a87e7d 238 $manage = get_string('manageportfolios', 'portfolio');
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
248 $temp = new admin_settingpage('manageportfolioscommon', get_string('commonportfoliosettings', 'portfolio'));
249 $temp->add(new admin_setting_heading('manageportfolioscommon', '', get_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',
254 get_string('moderatefilesizethreshold', 'portfolio'),
255 get_string('moderatefilesizethresholddesc', 'portfolio'),
256 $fileinfo['moderate'], $fileoptions));
257 $temp->add(new admin_setting_configselect(
258 'portfolio_high_filesize_threshold',
259 get_string('highfilesizethreshold', 'portfolio'),
260 get_string('highfilesizethresholddesc', 'portfolio'),
261 $fileinfo['high'], $fileoptions));
262
263 $temp->add(new admin_setting_configtext(
264 'portfolio_moderate_db_threshold',
265 get_string('moderatedbsizethreshold', 'portfolio'),
266 get_string('moderatedbsizethresholddesc', 'portfolio'),
267 20, PARAM_INTEGER, 3));
268
269 $temp->add(new admin_setting_configtext(
270 'portfolio_high_db_threshold',
271 get_string('highdbsizethreshold', 'portfolio'),
272 get_string('highdbsizethresholddesc', 'portfolio'),
273 50, PARAM_INTEGER, 3));
a50ef3d3 274
275 $ADMIN->add('portfoliosettings', $temp);
276 $ADMIN->add('portfoliosettings', new admin_externalpage('portfolionew', get_string('addnewportfolio', 'portfolio'), $url, 'moodle/site:config', true), '', $url);
277 $ADMIN->add('portfoliosettings', new admin_externalpage('portfoliodelete', get_string('deleteportfolio', 'portfolio'), $url, 'moodle/site:config', true), '', $url);
278 $ADMIN->add('portfoliosettings', new admin_externalpage('portfoliocontroller', get_string('manageportfolios', 'portfolio'), $url, 'moodle/site:config', true), '', $url);
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");
298 $catname =get_string('repositories', 'repository');
04bd6d2d 299 $managerepo = get_string('manage', 'repository');
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
308 $temp = new admin_settingpage('managerepositoriescommon', get_string('commonrepositorysettings', 'repository'));
5430f05b 309 $temp->add(new admin_setting_configtext('repositorycacheexpire', get_string('cacheexpire', 'repository'), get_string('configcacheexpire', 'repository'), 120));
99d52655 310 $temp->add(new admin_setting_configcheckbox('repositoryallowexternallinks', get_string('allowexternallinks', 'repository'), get_string('configallowexternallinks', 'repository'), 1));
95dbbf3a 311 $temp->add(new admin_setting_configcheckbox('legacyfilesinnewcourses', get_string('legacyfilesinnewcourses', 'admin'), get_string('legacyfilesinnewcourses_help', 'admin'), 0));
4a65c39a 312 $ADMIN->add('repositorysettings', $temp);
4f2b9a4f 313 $ADMIN->add('repositorysettings', new admin_externalpage('repositorynew',
0d099914 314 get_string('addplugin', 'repository'), $url, 'moodle/site:config', true),
4a65c39a 315 '', $url);
316 $ADMIN->add('repositorysettings', new admin_externalpage('repositorydelete',
317 get_string('deleterepository', 'repository'), $url, 'moodle/site:config', true),
318 '', $url);
319 $ADMIN->add('repositorysettings', new admin_externalpage('repositorycontroller',
fe9d7318 320 get_string('manage', 'repository'), $url, 'moodle/site:config', true),
4a65c39a 321 '', $url);
0d099914 322 $ADMIN->add('repositorysettings', new admin_externalpage('repositoryinstancenew',
323 get_string('createrepository', 'repository'), $url, 'moodle/site:config', true),
324 '', $url);
325 $ADMIN->add('repositorysettings', new admin_externalpage('repositoryinstanceedit',
326 get_string('editrepositoryinstance', 'repository'), $url, 'moodle/site:config', true),
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)) {
4a65c39a 333 $ADMIN->add('repositorysettings',
a6600395 334 new admin_externalpage('repositorysettings'.$repositorytype->get_typename(),
335 $repositorytype->get_readablename(),
79698344 336 $url . '?action=edit&repos=' . $repositorytype->get_typename()),
4a65c39a 337 'moodle/site:config');
338 }
339 }
78946b9b 340}
bee4bce2 341
5ae9f539 342/// Web services
cc93c7da 343 $ADMIN->add('modules', new admin_category('webservicesettings', get_string('webservices', 'webservice')));
3e6161fb 344 /// overview page
345 $temp = new admin_settingpage('webservicesoverview', get_string('webservicesoverview', 'webservice'));
346 $temp->add(new admin_setting_webservicesoverview());
347 $ADMIN->add('webservicesettings', $temp);
cde291ed
JM
348 //API documentation
349 $ADMIN->add('webservicesettings', new admin_externalpage('webservicedocumentation', get_string('wsdocapi', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/documentation.php", 'moodle/site:config', false));
3e6161fb 350 /// manage service
cc93c7da 351 $temp = new admin_settingpage('externalservices', get_string('externalservices', 'webservice'));
c1b65883 352 $enablemobiledocurl = new moodle_url(get_docs_url('Enable_mobile_web_services'));
96e0194c 353 $enablemobiledoclink = html_writer::link($enablemobiledocurl, get_string('documentation'));
c1b65883 354 $temp->add(new admin_setting_enablemobileservice('enablemobilewebservice', get_string('enablemobilewebservice', 'admin'), get_string('configenablemobilewebservice', 'admin', $enablemobiledoclink), 0));
8399c714 355 $temp->add(new admin_setting_heading('manageserviceshelpexplaination', get_string('information', 'webservice'), get_string('servicehelpexplanation', 'webservice')));
cc93c7da 356 $temp->add(new admin_setting_manageexternalservices());
357 $ADMIN->add('webservicesettings', $temp);
c25662b0 358 $ADMIN->add('webservicesettings', new admin_externalpage('externalservice', get_string('editaservice', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/service.php", 'moodle/site:config', true));
72977b37 359 $ADMIN->add('webservicesettings', new admin_externalpage('externalservicefunctions', get_string('externalservicefunctions', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/service_functions.php", 'moodle/site:config', true));
360 $ADMIN->add('webservicesettings', new admin_externalpage('externalserviceusers', get_string('externalserviceusers', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/service_users.php", 'moodle/site:config', true));
86dcc6f0 361 $ADMIN->add('webservicesettings', new admin_externalpage('externalserviceusersettings', get_string('serviceusersettings', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/service_user_settings.php", 'moodle/site:config', true));
5ae9f539 362 /// manage protocol page link
cc93c7da 363 $temp = new admin_settingpage('webserviceprotocols', get_string('manageprotocols', 'webservice'));
da124b5e 364 $temp->add(new admin_setting_managewebserviceprotocols());
cc93c7da 365 if (empty($CFG->enablewebservices)) {
366 $temp->add(new admin_setting_heading('webservicesaredisabled', '', get_string('disabledwarning', 'webservice')));
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'));
373 $wsdoclink = html_writer::tag('a', get_string('supplyinfo'),array('href'=>$url));
9ef728d6 374 $temp->add(new admin_setting_configcheckbox('enablewsdocumentation', get_string('enablewsdocumentation',
375 'admin'), get_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")) {
382 $name = get_string('pluginname', 'webservice_'.$webservice);
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
15e417fe 391 $ADMIN->add('webservicesettings', new admin_externalpage('addwebservicetoken', get_string('managetokens', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/tokens.php", 'moodle/site:config', true));
5ae9f539 392 $temp = new admin_settingpage('webservicetokens', get_string('managetokens', 'webservice'));
393 $temp->add(new admin_setting_managewebservicetokens());
394 if (empty($CFG->enablewebservices)) {
395 $temp->add(new admin_setting_heading('webservicesaredisabled', '', get_string('disabledwarning', 'webservice')));
396 }
397 $ADMIN->add('webservicesettings', $temp);
df997f84 398
b6eb984a 399// Question type settings
78946b9b 400if ($hassiteconfig || has_capability('moodle/question:config', $systemcontext)) {
fde4560d
TH
401 // Question behaviour settings.
402 $ADMIN->add('modules', new admin_category('qbehavioursettings', get_string('questionbehaviours', 'admin')));
403 $ADMIN->add('qbehavioursettings', new admin_page_manageqbehaviours());
404
bee4bce2 405 // Question type settings.
406 $ADMIN->add('modules', new admin_category('qtypesettings', get_string('questiontypes', 'admin')));
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
TH
412 $settings = new admin_settingpage('qtypesetting' . $qtype,
413 get_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
DM
423if ($hassiteconfig && !empty($CFG->enableplagiarism)) {
424 $ADMIN->add('modules', new admin_category('plagiarism', get_string('plagiarism', 'plagiarism')));
425 $temp = new admin_settingpage('plagiarismsettings', get_string('plagiarismsettings', 'plagiarism'));
426 $temp->add(new admin_setting_manageplagiarism());
427 $ADMIN->add('plagiarism', $temp);
428 foreach (get_plugin_list('plagiarism') as $plugin => $plugindir) {
429 if (file_exists($plugindir.'/settings.php')) {
430 $ADMIN->add('plagiarism', new admin_externalpage('plagiarism'.$plugin, get_string($plugin, 'plagiarism_'.$plugin), "$CFG->wwwroot/plagiarism/$plugin/settings.php", 'moodle/site:config'));
431 }
432 }
433}
1bcb7eb5 434$ADMIN->add('reports', new admin_externalpage('comments', get_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,
443 get_string('pluginname', 'coursereport_' . $report), 'moodle/site:config');
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)) {
452 $ADMIN->add('modules', new admin_category('coursereports', get_string('coursereports')));
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
PS
465 $settings = new admin_settingpage('report' . $report,
466 get_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}
4f6bba20
PS
473$ADMIN->add('modules', new admin_category('reportplugins', get_string('reports')));
474$ADMIN->add('reportplugins', new admin_externalpage('managereports', get_string('reportsmanage', 'admin'),
475 $CFG->wwwroot . '/' . $CFG->admin . '/reports.php'));
476foreach ($pages as $page) {
477 $ADMIN->add('reportplugins', $page);
b63a6a63 478}
479
11b24ce7
PS
480// Now add various admin tools
481foreach (get_plugin_list('tool') as $plugin => $plugindir) {
482 $settings_path = "$plugindir/settings.php";
483 if (file_exists($settings_path)) {
484 include($settings_path);
485 }
486}
17da2e6f 487
3cdfaeef
PS
488/// Add all admin tools
489if ($hassiteconfig) {
490 $ADMIN->add('modules', new admin_category('tools', get_string('tools', 'admin')));
491 $ADMIN->add('tools', new admin_externalpage('managetools', get_string('toolsmanage', 'admin'),
492 $CFG->wwwroot . '/' . $CFG->admin . '/tools.php'));
493}
494
17da2e6f 495/// Add all local plugins - must be always last!
1ed47309
DM
496if ($hassiteconfig) {
497 $ADMIN->add('modules', new admin_category('localplugins', get_string('localplugins')));
498 $ADMIN->add('localplugins', new admin_externalpage('managelocalplugins', get_string('localpluginsmanage'),
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}