MDL-54599 Navigation: Sorting plugins by visible name
[moodle.git] / admin / settings / plugins.php
CommitLineData
11b749ca 1<?php
e87214bd
PS
2// This file is part of Moodle - http://moodle.org/
3//
4// Moodle is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Moodle is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16
17/**
18 * Load all plugins into the admin tree.
19 *
20* Please note that is file is always loaded last - it means that you can inject entries into other categories too.
21*
22* @package core
23* @copyright 2007 Petr Skoda {@link http://skodak.org}
24* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25*/
b63a6a63 26
78946b9b 27if ($hassiteconfig) {
e5e0d397
SH
28 /* @var admin_root $ADMIN */
29 $ADMIN->locate('modules')->set_sorting(true);
30
b9934a17 31 $ADMIN->add('modules', new admin_page_pluginsoverview());
fde6f79f
MG
32
33 // activity modules
e106013f 34 $ADMIN->add('modules', new admin_category('modsettings', new lang_string('activitymodules')));
6398ff53 35
b3834b36 36 $ADMIN->add('modsettings', new admin_page_managemods());
6398ff53 37
b3834b36 38 $temp = new admin_settingpage('managemodulescommon', new lang_string('commonactivitysettings', 'admin'));
6398ff53
AH
39 $temp->add(new admin_setting_configcheckbox('requiremodintro',
40 get_string('requiremodintro', 'admin'), get_string('requiremodintro_desc', 'admin'), 0));
41 $ADMIN->add('modsettings', $temp);
42
7025aeed
VD
43 $plugins = core_plugin_manager::instance()->get_plugins_of_type('mod');
44 core_collator::asort_objects_by_property($plugins, 'displayname');
45 foreach ($plugins as $plugin) {
e87214bd
PS
46 /** @var \core\plugininfo\mod $plugin */
47 $plugin->load_settings($ADMIN, 'modsettings', $hassiteconfig);
220a90c5 48 }
49
3776335c
MG
50 // course formats
51 $ADMIN->add('modules', new admin_category('formatsettings', new lang_string('courseformats')));
52 $temp = new admin_settingpage('manageformats', new lang_string('manageformats', 'core_admin'));
53 $temp->add(new admin_setting_manageformats());
54 $ADMIN->add('formatsettings', $temp);
7025aeed
VD
55 $plugins = core_plugin_manager::instance()->get_plugins_of_type('format');
56 core_collator::asort_objects_by_property($plugins, 'displayname');
57 foreach ($plugins as $plugin) {
e87214bd
PS
58 /** @var \core\plugininfo\format $plugin */
59 $plugin->load_settings($ADMIN, 'formatsettings', $hassiteconfig);
3776335c
MG
60 }
61
870d4280 62 // blocks
e106013f 63 $ADMIN->add('modules', new admin_category('blocksettings', new lang_string('blocks')));
220a90c5 64 $ADMIN->add('blocksettings', new admin_page_manageblocks());
7025aeed
VD
65 $plugins = core_plugin_manager::instance()->get_plugins_of_type('block');
66 core_collator::asort_objects_by_property($plugins, 'displayname');
67 foreach ($plugins as $plugin) {
e87214bd
PS
68 /** @var \core\plugininfo\block $plugin */
69 $plugin->load_settings($ADMIN, 'blocksettings', $hassiteconfig);
220a90c5 70 }
71
75c34c23 72 // message outputs
e106013f 73 $ADMIN->add('modules', new admin_category('messageoutputs', new lang_string('messageoutputs', 'message')));
75c34c23 74 $ADMIN->add('messageoutputs', new admin_page_managemessageoutputs());
1d72e9d4 75 $ADMIN->add('messageoutputs', new admin_page_defaultmessageoutputs());
7025aeed
VD
76 $plugins = core_plugin_manager::instance()->get_plugins_of_type('message');
77 core_collator::asort_objects_by_property($plugins, 'displayname');
78 foreach ($plugins as $plugin) {
e87214bd
PS
79 /** @var \core\plugininfo\message $plugin */
80 $plugin->load_settings($ADMIN, 'messageoutputs', $hassiteconfig);
2f2137fc 81 }
75c34c23 82
df997f84 83 // authentication plugins
e106013f 84 $ADMIN->add('modules', new admin_category('authsettings', new lang_string('authentication', 'admin')));
df997f84 85
e106013f 86 $temp = new admin_settingpage('manageauths', new lang_string('authsettings', 'admin'));
df997f84 87 $temp->add(new admin_setting_manageauths());
e106013f 88 $temp->add(new admin_setting_heading('manageauthscommonheading', new lang_string('commonsettings', 'admin'), ''));
df997f84 89 $temp->add(new admin_setting_special_registerauth());
50f5c843 90 $temp->add(new admin_setting_configcheckbox('authloginviaemail', new lang_string('authloginviaemail', 'core_auth'), new lang_string('authloginviaemail_desc', 'core_auth'), 0));
95020832
DM
91 $temp->add(new admin_setting_configcheckbox('allowaccountssameemail',
92 new lang_string('allowaccountssameemail', 'core_auth'),
93 new lang_string('allowaccountssameemail_desc', 'core_auth'), 0));
e106013f
SH
94 $temp->add(new admin_setting_configcheckbox('authpreventaccountcreation', new lang_string('authpreventaccountcreation', 'admin'), new lang_string('authpreventaccountcreation_help', 'admin'), 0));
95 $temp->add(new admin_setting_configcheckbox('loginpageautofocus', new lang_string('loginpageautofocus', 'admin'), new lang_string('loginpageautofocus_help', 'admin'), 0));
96 $temp->add(new admin_setting_configselect('guestloginbutton', new lang_string('guestloginbutton', 'auth'),
97 new lang_string('showguestlogin', 'auth'), '1', array('0'=>new lang_string('hide'), '1'=>new lang_string('show'))));
89e9321f
PS
98 $options = array(0 => get_string('no'), 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 10 => 10, 20 => 20, 50 => 50);
99 $temp->add(new admin_setting_configselect('limitconcurrentlogins',
100 new lang_string('limitconcurrentlogins', 'core_auth'),
101 new lang_string('limitconcurrentlogins_desc', 'core_auth'), 0, $options));
e106013f
SH
102 $temp->add(new admin_setting_configtext('alternateloginurl', new lang_string('alternateloginurl', 'auth'),
103 new lang_string('alternatelogin', 'auth', htmlspecialchars(get_login_url())), ''));
104 $temp->add(new admin_setting_configtext('forgottenpasswordurl', new lang_string('forgottenpasswordurl', 'auth'),
105 new lang_string('forgottenpassword', 'auth'), ''));
106 $temp->add(new admin_setting_confightmleditor('auth_instructions', new lang_string('instructions', 'auth'),
107 new lang_string('authinstructions', 'auth'), ''));
108 $temp->add(new admin_setting_configtext('allowemailaddresses', new lang_string('allowemailaddresses', 'admin'), new lang_string('configallowemailaddresses', 'admin'), '', PARAM_NOTAGS));
109 $temp->add(new admin_setting_configtext('denyemailaddresses', new lang_string('denyemailaddresses', 'admin'), new lang_string('configdenyemailaddresses', 'admin'), '', PARAM_NOTAGS));
110 $temp->add(new admin_setting_configcheckbox('verifychangedemail', new lang_string('verifychangedemail', 'admin'), new lang_string('configverifychangedemail', 'admin'), 1));
111
112 $temp->add(new admin_setting_configtext('recaptchapublickey', new lang_string('recaptchapublickey', 'admin'), new lang_string('configrecaptchapublickey', 'admin'), '', PARAM_NOTAGS));
113 $temp->add(new admin_setting_configtext('recaptchaprivatekey', new lang_string('recaptchaprivatekey', 'admin'), new lang_string('configrecaptchaprivatekey', 'admin'), '', PARAM_NOTAGS));
df997f84
PS
114 $ADMIN->add('authsettings', $temp);
115
6cf20915
PS
116 $temp = new admin_externalpage('authtestsettings', get_string('testsettings', 'core_auth'), new moodle_url("/auth/test_settings.php"), 'moodle/site:config', true);
117 $ADMIN->add('authsettings', $temp);
118
7025aeed
VD
119 $plugins = core_plugin_manager::instance()->get_plugins_of_type('auth');
120 core_collator::asort_objects_by_property($plugins, 'displayname');
121 foreach ($plugins as $plugin) {
e87214bd
PS
122 /** @var \core\plugininfo\auth $plugin */
123 $plugin->load_settings($ADMIN, 'authsettings', $hassiteconfig);
df997f84
PS
124 }
125
df997f84 126 // Enrolment plugins
e106013f
SH
127 $ADMIN->add('modules', new admin_category('enrolments', new lang_string('enrolments', 'enrol')));
128 $temp = new admin_settingpage('manageenrols', new lang_string('manageenrols', 'enrol'));
df997f84 129 $temp->add(new admin_setting_manageenrols());
df997f84 130 $ADMIN->add('enrolments', $temp);
6cf20915
PS
131
132 $temp = new admin_externalpage('enroltestsettings', get_string('testsettings', 'core_enrol'), new moodle_url("/enrol/test_settings.php"), 'moodle/site:config', true);
133 $ADMIN->add('enrolments', $temp);
134
7025aeed
VD
135 $plugins = core_plugin_manager::instance()->get_plugins_of_type('enrol');
136 core_collator::asort_objects_by_property($plugins, 'displayname');
137 foreach ($plugins as $plugin) {
e87214bd
PS
138 /** @var \core\plugininfo\enrol $plugin */
139 $plugin->load_settings($ADMIN, 'enrolments', $hassiteconfig);
df997f84 140 }
df997f84 141
c5d2d0dd 142
a5747cf8 143/// Editor plugins
e106013f
SH
144 $ADMIN->add('modules', new admin_category('editorsettings', new lang_string('editors', 'editor')));
145 $temp = new admin_settingpage('manageeditors', new lang_string('editorsettings', 'editor'));
a5747cf8 146 $temp->add(new admin_setting_manageeditors());
147 $ADMIN->add('editorsettings', $temp);
7025aeed
VD
148 $plugins = core_plugin_manager::instance()->get_plugins_of_type('editor');
149 core_collator::asort_objects_by_property($plugins, 'displayname');
150 foreach ($plugins as $plugin) {
e87214bd
PS
151 /** @var \core\plugininfo\editor $plugin */
152 $plugin->load_settings($ADMIN, 'editorsettings', $hassiteconfig);
7a856a93 153 }
6fc67fce 154
1a980fda 155 // Antivirus plugins.
146eeb76
RK
156 $ADMIN->add('modules', new admin_category('antivirussettings', new lang_string('antiviruses', 'antivirus')));
157 $temp = new admin_settingpage('manageantiviruses', new lang_string('antivirussettings', 'antivirus'));
158 $temp->add(new admin_setting_manageantiviruses());
159 $ADMIN->add('antivirussettings', $temp);
7025aeed
VD
160 $plugins = core_plugin_manager::instance()->get_plugins_of_type('antivirus');
161 core_collator::asort_objects_by_property($plugins, 'displayname');
162 foreach ($plugins as $plugin) {
1a980fda 163 /* @var \core\plugininfo\antivirus $plugin */
146eeb76
RK
164 $plugin->load_settings($ADMIN, 'antivirussettings', $hassiteconfig);
165 }
166
1dce6261 167/// License types
e106013f
SH
168 $ADMIN->add('modules', new admin_category('licensesettings', new lang_string('licenses')));
169 $temp = new admin_settingpage('managelicenses', new lang_string('managelicenses', 'admin'));
ba74f517
DC
170
171 require_once($CFG->libdir . '/licenselib.php');
172 $licenses = array();
173 $array = explode(',', $CFG->licenses);
174 foreach ($array as $value) {
e106013f 175 $licenses[$value] = new lang_string($value, 'license');
ba74f517 176 }
e106013f 177 $temp->add(new admin_setting_configselect('sitedefaultlicense', new lang_string('configsitedefaultlicense','admin'), new lang_string('configsitedefaultlicensehelp','admin'), 'allrightsreserved', $licenses));
1dce6261
DC
178 $temp->add(new admin_setting_managelicenses());
179 $ADMIN->add('licensesettings', $temp);
a5747cf8 180
181/// Filter plugins
e106013f 182 $ADMIN->add('modules', new admin_category('filtersettings', new lang_string('managefilters')));
dcdf3b29 183
184 $ADMIN->add('filtersettings', new admin_page_managefilters());
185
220a90c5 186 // "filtersettings" settingpage
e106013f 187 $temp = new admin_settingpage('commonfiltersettings', new lang_string('commonfiltersettings', 'admin'));
220a90c5 188 if ($ADMIN->fulltree) {
109e3cb2 189 $items = array();
e106013f
SH
190 $items[] = new admin_setting_configselect('filteruploadedfiles', new lang_string('filteruploadedfiles', 'admin'), new lang_string('configfilteruploadedfiles', 'admin'), 0,
191 array('0' => new lang_string('none'), '1' => new lang_string('allfiles'), '2' => new lang_string('htmlfilesonly')));
192 $items[] = new admin_setting_configcheckbox('filtermatchoneperpage', new lang_string('filtermatchoneperpage', 'admin'), new lang_string('configfiltermatchoneperpage', 'admin'), 0);
193 $items[] = new admin_setting_configcheckbox('filtermatchonepertext', new lang_string('filtermatchonepertext', 'admin'), new lang_string('configfiltermatchonepertext', 'admin'), 0);
109e3cb2 194 foreach ($items as $item) {
195 $item->set_updatedcallback('reset_text_filters_cache');
196 $temp->add($item);
197 }
220a90c5 198 }
199 $ADMIN->add('filtersettings', $temp);
200
7025aeed
VD
201 $plugins = core_plugin_manager::instance()->get_plugins_of_type('filter');
202 core_collator::asort_objects_by_property($plugins, 'displayname');
203 foreach ($plugins as $plugin) {
e87214bd
PS
204 /** @var \core\plugininfo\filter $plugin */
205 $plugin->load_settings($ADMIN, 'filtersettings', $hassiteconfig);
220a90c5 206 }
67a87e7d 207
bff1edbe
BH
208 // Data format settings.
209 $ADMIN->add('modules', new admin_category('dataformatsettings', new lang_string('dataformats')));
210 $temp = new admin_settingpage('managedataformats', new lang_string('managedataformats'));
211 $temp->add(new admin_setting_managedataformats());
212 $ADMIN->add('dataformatsettings', $temp);
78946b9b
PS
213
214 //== Portfolio settings ==
215 require_once($CFG->libdir. '/portfoliolib.php');
e106013f
SH
216 $catname = new lang_string('portfolios', 'portfolio');
217 $manage = new lang_string('manageportfolios', 'portfolio');
67a87e7d 218 $url = "$CFG->wwwroot/$CFG->admin/portfolio.php";
219
90658eef 220 $ADMIN->add('modules', new admin_category('portfoliosettings', $catname, empty($CFG->enableportfolios)));
67a87e7d 221
9d81733d
SM
222 // Add manage page (with table)
223 $temp = new admin_page_manageportfolios();
224 $ADMIN->add('portfoliosettings', $temp);
225
226 // Add common settings page
e106013f
SH
227 $temp = new admin_settingpage('manageportfolioscommon', new lang_string('commonportfoliosettings', 'portfolio'));
228 $temp->add(new admin_setting_heading('manageportfolioscommon', '', new lang_string('commonsettingsdesc', 'portfolio')));
bee4bce2 229 $fileinfo = portfolio_filesize_info(); // make sure this is defined in one place since its used inside portfolio too to detect insane settings
230 $fileoptions = $fileinfo['options'];
231 $temp->add(new admin_setting_configselect(
232 'portfolio_moderate_filesize_threshold',
e106013f
SH
233 new lang_string('moderatefilesizethreshold', 'portfolio'),
234 new lang_string('moderatefilesizethresholddesc', 'portfolio'),
bee4bce2 235 $fileinfo['moderate'], $fileoptions));
236 $temp->add(new admin_setting_configselect(
237 'portfolio_high_filesize_threshold',
e106013f
SH
238 new lang_string('highfilesizethreshold', 'portfolio'),
239 new lang_string('highfilesizethresholddesc', 'portfolio'),
bee4bce2 240 $fileinfo['high'], $fileoptions));
241
242 $temp->add(new admin_setting_configtext(
243 'portfolio_moderate_db_threshold',
e106013f
SH
244 new lang_string('moderatedbsizethreshold', 'portfolio'),
245 new lang_string('moderatedbsizethresholddesc', 'portfolio'),
1e12c120 246 20, PARAM_INT, 3));
bee4bce2 247
248 $temp->add(new admin_setting_configtext(
249 'portfolio_high_db_threshold',
e106013f
SH
250 new lang_string('highdbsizethreshold', 'portfolio'),
251 new lang_string('highdbsizethresholddesc', 'portfolio'),
1e12c120 252 50, PARAM_INT, 3));
a50ef3d3 253
254 $ADMIN->add('portfoliosettings', $temp);
56aee7c2
DM
255 $ADMIN->add('portfoliosettings', new admin_externalpage('portfolionew', new lang_string('addnewportfolio', 'portfolio'), $url, 'moodle/site:config', true));
256 $ADMIN->add('portfoliosettings', new admin_externalpage('portfoliodelete', new lang_string('deleteportfolio', 'portfolio'), $url, 'moodle/site:config', true));
257 $ADMIN->add('portfoliosettings', new admin_externalpage('portfoliocontroller', new lang_string('manageportfolios', 'portfolio'), $url, 'moodle/site:config', true));
a50ef3d3 258
08d5e18b 259 foreach (portfolio_instances(false, false) as $portfolio) {
edf1fc35 260 require_once($CFG->dirroot . '/portfolio/' . $portfolio->get('plugin') . '/lib.php');
67a87e7d 261 $classname = 'portfolio_plugin_' . $portfolio->get('plugin');
a50ef3d3 262 $ADMIN->add(
263 'portfoliosettings',
08d5e18b 264 new admin_externalpage(
265 'portfoliosettings' . $portfolio->get('id'),
658837bb 266 $portfolio->get('name'),
6010eda2
MD
267 $url . '?action=edit&pf=' . $portfolio->get('id'),
268 'moodle/site:config'
0a94e4a9 269 )
a50ef3d3 270 );
67a87e7d 271 }
4a65c39a 272
273 // repository setting
274 require_once("$CFG->dirroot/repository/lib.php");
e106013f
SH
275 $catname =new lang_string('repositories', 'repository');
276 $managerepo = new lang_string('manage', 'repository');
04bd6d2d 277 $url = $CFG->wwwroot.'/'.$CFG->admin.'/repository.php';
4a65c39a 278 $ADMIN->add('modules', new admin_category('repositorysettings', $catname));
9d81733d
SM
279
280 // Add main page (with table)
281 $temp = new admin_page_managerepositories();
282 $ADMIN->add('repositorysettings', $temp);
283
284 // Add common settings page
e106013f 285 $temp = new admin_settingpage('managerepositoriescommon', new lang_string('commonrepositorysettings', 'repository'));
c1b3ac43
RT
286 $temp->add(new admin_setting_configtext('repositorycacheexpire', new lang_string('cacheexpire', 'repository'), new lang_string('configcacheexpire', 'repository'), 120, PARAM_INT));
287 $temp->add(new admin_setting_configtext('repositorygetfiletimeout', new lang_string('getfiletimeout', 'repository'), new lang_string('configgetfiletimeout', 'repository'), 30, PARAM_INT));
288 $temp->add(new admin_setting_configtext('repositorysyncfiletimeout', new lang_string('syncfiletimeout', 'repository'), new lang_string('configsyncfiletimeout', 'repository'), 1, PARAM_INT));
289 $temp->add(new admin_setting_configtext('repositorysyncimagetimeout', new lang_string('syncimagetimeout', 'repository'), new lang_string('configsyncimagetimeout', 'repository'), 3, PARAM_INT));
e106013f
SH
290 $temp->add(new admin_setting_configcheckbox('repositoryallowexternallinks', new lang_string('allowexternallinks', 'repository'), new lang_string('configallowexternallinks', 'repository'), 1));
291 $temp->add(new admin_setting_configcheckbox('legacyfilesinnewcourses', new lang_string('legacyfilesinnewcourses', 'admin'), new lang_string('legacyfilesinnewcourses_help', 'admin'), 0));
cc0bb815 292 $temp->add(new admin_setting_configcheckbox('legacyfilesaddallowed', new lang_string('legacyfilesaddallowed', 'admin'), new lang_string('legacyfilesaddallowed_help', 'admin'), 1));
4a65c39a 293 $ADMIN->add('repositorysettings', $temp);
4f2b9a4f 294 $ADMIN->add('repositorysettings', new admin_externalpage('repositorynew',
56aee7c2 295 new lang_string('addplugin', 'repository'), $url, 'moodle/site:config', true));
4a65c39a 296 $ADMIN->add('repositorysettings', new admin_externalpage('repositorydelete',
56aee7c2 297 new lang_string('deleterepository', 'repository'), $url, 'moodle/site:config', true));
4a65c39a 298 $ADMIN->add('repositorysettings', new admin_externalpage('repositorycontroller',
56aee7c2 299 new lang_string('manage', 'repository'), $url, 'moodle/site:config', true));
0d099914 300 $ADMIN->add('repositorysettings', new admin_externalpage('repositoryinstancenew',
56aee7c2 301 new lang_string('createrepository', 'repository'), $url, 'moodle/site:config', true));
0d099914 302 $ADMIN->add('repositorysettings', new admin_externalpage('repositoryinstanceedit',
56aee7c2 303 new lang_string('editrepositoryinstance', 'repository'), $url, 'moodle/site:config', true));
7025aeed
VD
304 $plugins = core_plugin_manager::instance()->get_plugins_of_type('repository');
305 core_collator::asort_objects_by_property($plugins, 'displayname');
306 foreach ($plugins as $plugin) {
e87214bd
PS
307 /** @var \core\plugininfo\repository $plugin */
308 $plugin->load_settings($ADMIN, 'repositorysettings', $hassiteconfig);
4a65c39a 309 }
bee4bce2 310
5ae9f539 311/// Web services
e106013f 312 $ADMIN->add('modules', new admin_category('webservicesettings', new lang_string('webservices', 'webservice')));
489987af
JM
313 // Mobile
314 $temp = new admin_settingpage('mobile', new lang_string('mobile','admin'), 'moodle/site:config', false);
6b6deb8e
JL
315
316 // We should wait to the installation to finish since we depend on some configuration values that are set once
317 // the admin user profile is configured.
318 if (!during_initial_install()) {
319 $enablemobiledocurl = new moodle_url(get_docs_url('Enable_mobile_web_services'));
320 $enablemobiledoclink = html_writer::link($enablemobiledocurl, new lang_string('documentation'));
321 $default = is_https() ? 1 : 0;
322 $temp->add(new admin_setting_enablemobileservice('enablemobilewebservice',
323 new lang_string('enablemobilewebservice', 'admin'),
324 new lang_string('configenablemobilewebservice', 'admin', $enablemobiledoclink), $default));
325 }
326
489987af
JM
327 $temp->add(new admin_setting_configtext('mobilecssurl', new lang_string('mobilecssurl', 'admin'), new lang_string('configmobilecssurl','admin'), '', PARAM_URL));
328 $ADMIN->add('webservicesettings', $temp);
3e6161fb 329 /// overview page
e106013f 330 $temp = new admin_settingpage('webservicesoverview', new lang_string('webservicesoverview', 'webservice'));
3e6161fb 331 $temp->add(new admin_setting_webservicesoverview());
332 $ADMIN->add('webservicesettings', $temp);
cde291ed 333 //API documentation
e106013f 334 $ADMIN->add('webservicesettings', new admin_externalpage('webservicedocumentation', new lang_string('wsdocapi', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/documentation.php", 'moodle/site:config', false));
3e6161fb 335 /// manage service
e106013f 336 $temp = new admin_settingpage('externalservices', new lang_string('externalservices', 'webservice'));
e106013f 337 $temp->add(new admin_setting_heading('manageserviceshelpexplaination', new lang_string('information', 'webservice'), new lang_string('servicehelpexplanation', 'webservice')));
cc93c7da 338 $temp->add(new admin_setting_manageexternalservices());
339 $ADMIN->add('webservicesettings', $temp);
e106013f
SH
340 $ADMIN->add('webservicesettings', new admin_externalpage('externalservice', new lang_string('editaservice', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/service.php", 'moodle/site:config', true));
341 $ADMIN->add('webservicesettings', new admin_externalpage('externalservicefunctions', new lang_string('externalservicefunctions', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/service_functions.php", 'moodle/site:config', true));
342 $ADMIN->add('webservicesettings', new admin_externalpage('externalserviceusers', new lang_string('externalserviceusers', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/service_users.php", 'moodle/site:config', true));
343 $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 344 /// manage protocol page link
e106013f 345 $temp = new admin_settingpage('webserviceprotocols', new lang_string('manageprotocols', 'webservice'));
da124b5e 346 $temp->add(new admin_setting_managewebserviceprotocols());
cc93c7da 347 if (empty($CFG->enablewebservices)) {
e106013f 348 $temp->add(new admin_setting_heading('webservicesaredisabled', '', new lang_string('disabledwarning', 'webservice')));
cc93c7da 349 }
b4c91012
SH
350
351 // We cannot use $OUTPUT this early, doing so means that we lose the ability
352 // to set the page layout on all admin pages.
353 // $wsdoclink = $OUTPUT->doc_link('How_to_get_a_security_key');
354 $url = new moodle_url(get_docs_url('How_to_get_a_security_key'));
5e963820 355 $wsdoclink = html_writer::tag('a', new lang_string('supplyinfo', 'webservice'), array('href'=>$url));
e106013f
SH
356 $temp->add(new admin_setting_configcheckbox('enablewsdocumentation', new lang_string('enablewsdocumentation',
357 'admin'), new lang_string('configenablewsdocumentation', 'admin', $wsdoclink), false));
cc93c7da 358 $ADMIN->add('webservicesettings', $temp);
5ae9f539 359 /// links to protocol pages
7025aeed
VD
360 $plugins = core_plugin_manager::instance()->get_plugins_of_type('webservice');
361 core_collator::asort_objects_by_property($plugins, 'displayname');
362 foreach ($plugins as $plugin) {
e87214bd
PS
363 /** @var \core\plugininfo\webservice $plugin */
364 $plugin->load_settings($ADMIN, 'webservicesettings', $hassiteconfig);
cc93c7da 365 }
5ae9f539 366 /// manage token page link
e106013f
SH
367 $ADMIN->add('webservicesettings', new admin_externalpage('addwebservicetoken', new lang_string('managetokens', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/tokens.php", 'moodle/site:config', true));
368 $temp = new admin_settingpage('webservicetokens', new lang_string('managetokens', 'webservice'));
5ae9f539 369 $temp->add(new admin_setting_managewebservicetokens());
370 if (empty($CFG->enablewebservices)) {
e106013f 371 $temp->add(new admin_setting_heading('webservicesaredisabled', '', new lang_string('disabledwarning', 'webservice')));
5ae9f539 372 }
373 $ADMIN->add('webservicesettings', $temp);
2567584d 374}
df997f84 375
b6eb984a 376// Question type settings
78946b9b 377if ($hassiteconfig || has_capability('moodle/question:config', $systemcontext)) {
4125ded1 378
fde4560d 379 // Question behaviour settings.
e106013f 380 $ADMIN->add('modules', new admin_category('qbehavioursettings', new lang_string('questionbehaviours', 'admin')));
fde4560d
TH
381 $ADMIN->add('qbehavioursettings', new admin_page_manageqbehaviours());
382
bee4bce2 383 // Question type settings.
e106013f 384 $ADMIN->add('modules', new admin_category('qtypesettings', new lang_string('questiontypes', 'admin')));
bee4bce2 385 $ADMIN->add('qtypesettings', new admin_page_manageqtypes());
4125ded1
TH
386
387 // Question preview defaults.
388 $settings = new admin_settingpage('qdefaultsetting',
389 get_string('questionpreviewdefaults', 'question'),
390 'moodle/question:config');
391 $ADMIN->add('qtypesettings', $settings);
392
393 $settings->add(new admin_setting_heading('qdefaultsetting_preview_options',
394 '', get_string('questionpreviewdefaults_desc', 'question')));
395
396 // These keys are question_display_options::HIDDEN and VISIBLE.
397 $hiddenofvisible = array(
398 0 => get_string('notshown', 'question'),
399 1 => get_string('shown', 'question'),
400 );
401
402 $settings->add(new admin_setting_question_behaviour('question_preview/behaviour',
403 get_string('howquestionsbehave', 'question'), '',
404 'deferredfeedback'));
405
406 $settings->add(new admin_setting_configselect('question_preview/correctness',
407 get_string('whethercorrect', 'question'), '', 1, $hiddenofvisible));
408
409 // These keys are question_display_options::HIDDEN, MARK_ONLY and MARK_AND_MAX.
410 $marksoptions = array(
411 0 => get_string('notshown', 'question'),
412 1 => get_string('showmaxmarkonly', 'question'),
413 2 => get_string('showmarkandmax', 'question'),
414 );
415 $settings->add(new admin_setting_configselect('question_preview/marks',
96bdbe69 416 get_string('marks', 'question'), '', 2, $marksoptions));
4125ded1
TH
417
418 $settings->add(new admin_setting_configselect('question_preview/markdp',
419 get_string('decimalplacesingrades', 'question'), '', 2, array(0, 1, 2, 3, 4, 5, 6, 7)));
420
421 $settings->add(new admin_setting_configselect('question_preview/feedback',
422 get_string('specificfeedback', 'question'), '', 1, $hiddenofvisible));
423
424 $settings->add(new admin_setting_configselect('question_preview/generalfeedback',
425 get_string('generalfeedback', 'question'), '', 1, $hiddenofvisible));
426
427 $settings->add(new admin_setting_configselect('question_preview/rightanswer',
428 get_string('rightanswer', 'question'), '', 1, $hiddenofvisible));
429
430 $settings->add(new admin_setting_configselect('question_preview/history',
431 get_string('responsehistory', 'question'), '', 0, $hiddenofvisible));
432
433 // Settings for particular question types.
7025aeed
VD
434 $plugins = core_plugin_manager::instance()->get_plugins_of_type('qtype');
435 core_collator::asort_objects_by_property($plugins, 'displayname');
436 foreach ($plugins as $plugin) {
e87214bd
PS
437 /** @var \core\plugininfo\qtype $plugin */
438 $plugin->load_settings($ADMIN, 'qtypesettings', $hassiteconfig);
bee4bce2 439 }
220a90c5 440}
b6eb984a
TH
441
442// Plagiarism plugin settings
bce59524 443if ($hassiteconfig && !empty($CFG->enableplagiarism)) {
e106013f 444 $ADMIN->add('modules', new admin_category('plagiarism', new lang_string('plagiarism', 'plagiarism')));
760007a2
DM
445 $ADMIN->add('plagiarism', new admin_externalpage('manageplagiarismplugins', new lang_string('manageplagiarism', 'plagiarism'),
446 $CFG->wwwroot . '/' . $CFG->admin . '/plagiarism.php'));
447
7025aeed
VD
448 $plugins = core_plugin_manager::instance()->get_plugins_of_type('plagiarism');
449 core_collator::asort_objects_by_property($plugins, 'displayname');
450 foreach ($plugins as $plugin) {
e87214bd 451 /** @var \core\plugininfo\plagiarism $plugin */
d98305bd 452 $plugin->load_settings($ADMIN, 'plagiarism', $hassiteconfig);
bce59524
DM
453 }
454}
e106013f 455$ADMIN->add('reports', new admin_externalpage('comments', new lang_string('comments'), $CFG->wwwroot.'/comment/', 'moodle/site:viewreports'));
b63a6a63 456
b6eb984a
TH
457// Course reports settings
458if ($hassiteconfig) {
459 $pages = array();
bd3b3bba 460 foreach (core_component::get_plugin_list('coursereport') as $report => $path) {
b6eb984a
TH
461 $file = $CFG->dirroot . '/course/report/' . $report . '/settings.php';
462 if (file_exists($file)) {
463 $settings = new admin_settingpage('coursereport' . $report,
e106013f 464 new lang_string('pluginname', 'coursereport_' . $report), 'moodle/site:config');
b6eb984a
TH
465 // settings.php may create a subcategory or unset the settings completely
466 include($file);
467 if ($settings) {
468 $pages[] = $settings;
469 }
470 }
471 }
472 if (!empty($pages)) {
e106013f 473 $ADMIN->add('modules', new admin_category('coursereports', new lang_string('coursereports')));
7025aeed 474 core_collator::asort_objects_by_property($pages, 'visiblename');
b6eb984a
TH
475 foreach ($pages as $page) {
476 $ADMIN->add('coursereports', $page);
477 }
478 }
e30cc24c 479 unset($pages);
b6eb984a
TH
480}
481
482// Now add reports
e30cc24c 483$pages = array();
bd3b3bba 484foreach (core_component::get_plugin_list('report') as $report => $plugindir) {
17da2e6f 485 $settings_path = "$plugindir/settings.php";
b63a6a63 486 if (file_exists($settings_path)) {
e30cc24c 487 $settings = new admin_settingpage('report' . $report,
e106013f 488 new lang_string('pluginname', 'report_' . $report), 'moodle/site:config');
b63a6a63 489 include($settings_path);
e30cc24c
PS
490 if ($settings) {
491 $pages[] = $settings;
492 }
b63a6a63 493 }
e30cc24c 494}
e106013f
SH
495$ADMIN->add('modules', new admin_category('reportplugins', new lang_string('reports')));
496$ADMIN->add('reportplugins', new admin_externalpage('managereports', new lang_string('reportsmanage', 'admin'),
4f6bba20 497 $CFG->wwwroot . '/' . $CFG->admin . '/reports.php'));
7025aeed 498core_collator::asort_objects_by_property($pages, 'visiblename');
4f6bba20
PS
499foreach ($pages as $page) {
500 $ADMIN->add('reportplugins', $page);
b63a6a63 501}
502
46e944ae
DM
503if ($hassiteconfig) {
504 // Global Search engine plugins.
505 $ADMIN->add('modules', new admin_category('searchplugins', new lang_string('search', 'admin')));
506 $temp = new admin_settingpage('manageglobalsearch', new lang_string('globalsearchmanage', 'admin'));
db48207e 507
46e944ae
DM
508 $pages = array();
509 $engines = array();
510 foreach (core_component::get_plugin_list('search') as $engine => $plugindir) {
511 $engines[$engine] = new lang_string('pluginname', 'search_' . $engine);
512 $settingspath = "$plugindir/settings.php";
513 if (file_exists($settingspath)) {
514 $settings = new admin_settingpage('search' . $engine,
515 new lang_string('pluginname', 'search_' . $engine), 'moodle/site:config');
516 include($settingspath);
517 if ($settings) {
518 $pages[] = $settings;
519 }
db48207e
DM
520 }
521 }
db48207e 522
46e944ae
DM
523 // Setup status.
524 $temp->add(new admin_setting_searchsetupinfo());
525
526 // Search engine selection.
527 $temp->add(new admin_setting_heading('searchengineheading', new lang_string('searchengine', 'admin'), ''));
528 $temp->add(new admin_setting_configselect('searchengine',
529 new lang_string('selectsearchengine', 'admin'), '', 'solr', $engines));
530
531 // Enable search areas.
532 $temp->add(new admin_setting_heading('searchareasheading', new lang_string('availablesearchareas', 'admin'), ''));
533 $searchareas = \core_search\manager::get_search_areas_list();
534 foreach ($searchareas as $areaid => $searcharea) {
535 list($componentname, $varname) = $searcharea->get_config_var_name();
536 $temp->add(new admin_setting_configcheckbox($componentname . '/' . $varname . '_enabled', $searcharea->get_visible_name(true),
537 '', 1, 1, 0));
538 }
539 $ADMIN->add('searchplugins', $temp);
db48207e 540
7025aeed 541 core_collator::asort_objects_by_property($pages, 'visiblename');
46e944ae
DM
542 foreach ($pages as $page) {
543 $ADMIN->add('searchplugins', $page);
544 }
db48207e
DM
545}
546
b33e6d8e
JG
547/// Add all admin tools
548if ($hassiteconfig) {
549 $ADMIN->add('modules', new admin_category('tools', new lang_string('tools', 'admin')));
550 $ADMIN->add('tools', new admin_externalpage('managetools', new lang_string('toolsmanage', 'admin'),
551 $CFG->wwwroot . '/' . $CFG->admin . '/tools.php'));
552}
553
e87214bd 554// Now add various admin tools.
7025aeed
VD
555$plugins = core_plugin_manager::instance()->get_plugins_of_type('tool');
556core_collator::asort_objects_by_property($plugins, 'displayname');
557foreach ($plugins as $plugin) {
e87214bd
PS
558 /** @var \core\plugininfo\tool $plugin */
559 $plugin->load_settings($ADMIN, null, $hassiteconfig);
11b24ce7 560}
17da2e6f 561
f23fbfd8
SH
562// Now add the Cache plugins
563if ($hassiteconfig) {
564 $ADMIN->add('modules', new admin_category('cache', new lang_string('caching', 'cache')));
565 $ADMIN->add('cache', new admin_externalpage('cacheconfig', new lang_string('cacheconfig', 'cache'), $CFG->wwwroot .'/cache/admin.php'));
566 $ADMIN->add('cache', new admin_externalpage('cachetestperformance', new lang_string('testperformance', 'cache'), $CFG->wwwroot . '/cache/testperformance.php'));
567 $ADMIN->add('cache', new admin_category('cachestores', new lang_string('cachestores', 'cache')));
7025aeed 568 $ADMIN->locate('cachestores')->set_sorting(true);
bd3b3bba 569 foreach (core_component::get_plugin_list('cachestore') as $plugin => $path) {
f23fbfd8
SH
570 $settingspath = $path.'/settings.php';
571 if (file_exists($settingspath)) {
6fec1820 572 $settings = new admin_settingpage('cachestore_'.$plugin.'_settings', new lang_string('pluginname', 'cachestore_'.$plugin), 'moodle/site:config');
f23fbfd8
SH
573 include($settingspath);
574 $ADMIN->add('cachestores', $settings);
575 }
576 }
577}
578
b404b1f4
AG
579// Add Calendar type settings.
580if ($hassiteconfig) {
581 $ADMIN->add('modules', new admin_category('calendartype', new lang_string('calendartypes', 'calendar')));
7025aeed
VD
582 $plugins = core_plugin_manager::instance()->get_plugins_of_type('calendartype');
583 core_collator::asort_objects_by_property($plugins, 'displayname');
584 foreach ($plugins as $plugin) {
49f3c893
MG
585 /** @var \core\plugininfo\calendartype $plugin */
586 $plugin->load_settings($ADMIN, 'calendartype', $hassiteconfig);
b404b1f4
AG
587 }
588}
589
17da2e6f 590/// Add all local plugins - must be always last!
1ed47309 591if ($hassiteconfig) {
e106013f
SH
592 $ADMIN->add('modules', new admin_category('localplugins', new lang_string('localplugins')));
593 $ADMIN->add('localplugins', new admin_externalpage('managelocalplugins', new lang_string('localpluginsmanage'),
1ed47309
DM
594 $CFG->wwwroot . '/' . $CFG->admin . '/localplugins.php'));
595}
17da2e6f 596
e87214bd
PS
597// Extend settings for each local plugin. Note that their settings may be in any part of the
598// settings tree and may be visible not only for administrators.
7025aeed
VD
599$plugins = core_plugin_manager::instance()->get_plugins_of_type('local');
600core_collator::asort_objects_by_property($plugins, 'displayname');
601foreach ($plugins as $plugin) {
e87214bd
PS
602 /** @var \core\plugininfo\local $plugin */
603 $plugin->load_settings($ADMIN, null, $hassiteconfig);
1bcb7eb5 604}