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