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