MDL-68729 Search: Allow query on one server while indexing another
[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
01c10959
DNA
62 // Custom fields.
63 $ADMIN->add('modules', new admin_category('customfieldsettings', new lang_string('customfields', 'core_customfield')));
64 $temp = new admin_settingpage('managecustomfields', new lang_string('managecustomfields', 'core_admin'));
65 $temp->add(new admin_setting_managecustomfields());
66 $ADMIN->add('customfieldsettings', $temp);
67 $plugins = core_plugin_manager::instance()->get_plugins_of_type('customfield');
68 core_collator::asort_objects_by_property($plugins, 'displayname');
69 foreach ($plugins as $plugin) {
70 /** @var \core\plugininfo\customfield $plugin */
71 $plugin->load_settings($ADMIN, 'customfieldsettings', $hassiteconfig);
72 }
73
870d4280 74 // blocks
e106013f 75 $ADMIN->add('modules', new admin_category('blocksettings', new lang_string('blocks')));
220a90c5 76 $ADMIN->add('blocksettings', new admin_page_manageblocks());
7025aeed
VD
77 $plugins = core_plugin_manager::instance()->get_plugins_of_type('block');
78 core_collator::asort_objects_by_property($plugins, 'displayname');
79 foreach ($plugins as $plugin) {
e87214bd
PS
80 /** @var \core\plugininfo\block $plugin */
81 $plugin->load_settings($ADMIN, 'blocksettings', $hassiteconfig);
220a90c5 82 }
83
df997f84 84 // authentication plugins
e106013f 85 $ADMIN->add('modules', new admin_category('authsettings', new lang_string('authentication', 'admin')));
df997f84 86
e106013f 87 $temp = new admin_settingpage('manageauths', new lang_string('authsettings', 'admin'));
df997f84 88 $temp->add(new admin_setting_manageauths());
e106013f 89 $temp->add(new admin_setting_heading('manageauthscommonheading', new lang_string('commonsettings', 'admin'), ''));
df997f84 90 $temp->add(new admin_setting_special_registerauth());
50f5c843 91 $temp->add(new admin_setting_configcheckbox('authloginviaemail', new lang_string('authloginviaemail', 'core_auth'), new lang_string('authloginviaemail_desc', 'core_auth'), 0));
95020832
DM
92 $temp->add(new admin_setting_configcheckbox('allowaccountssameemail',
93 new lang_string('allowaccountssameemail', 'core_auth'),
94 new lang_string('allowaccountssameemail_desc', 'core_auth'), 0));
e106013f
SH
95 $temp->add(new admin_setting_configcheckbox('authpreventaccountcreation', new lang_string('authpreventaccountcreation', 'admin'), new lang_string('authpreventaccountcreation_help', 'admin'), 0));
96 $temp->add(new admin_setting_configcheckbox('loginpageautofocus', new lang_string('loginpageautofocus', 'admin'), new lang_string('loginpageautofocus_help', 'admin'), 0));
97 $temp->add(new admin_setting_configselect('guestloginbutton', new lang_string('guestloginbutton', 'auth'),
98 new lang_string('showguestlogin', 'auth'), '1', array('0'=>new lang_string('hide'), '1'=>new lang_string('show'))));
89e9321f
PS
99 $options = array(0 => get_string('no'), 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 10 => 10, 20 => 20, 50 => 50);
100 $temp->add(new admin_setting_configselect('limitconcurrentlogins',
101 new lang_string('limitconcurrentlogins', 'core_auth'),
102 new lang_string('limitconcurrentlogins_desc', 'core_auth'), 0, $options));
e106013f
SH
103 $temp->add(new admin_setting_configtext('alternateloginurl', new lang_string('alternateloginurl', 'auth'),
104 new lang_string('alternatelogin', 'auth', htmlspecialchars(get_login_url())), ''));
105 $temp->add(new admin_setting_configtext('forgottenpasswordurl', new lang_string('forgottenpasswordurl', 'auth'),
6078d420 106 new lang_string('forgottenpassword', 'auth'), '', PARAM_URL));
e106013f
SH
107 $temp->add(new admin_setting_confightmleditor('auth_instructions', new lang_string('instructions', 'auth'),
108 new lang_string('authinstructions', 'auth'), ''));
113efed5
FM
109 $setting = new admin_setting_configtext('allowemailaddresses', new lang_string('allowemailaddresses', 'admin'),
110 new lang_string('configallowemailaddresses', 'admin'), '', PARAM_NOTAGS);
111 $setting->set_force_ltr(true);
112 $temp->add($setting);
113 $setting = new admin_setting_configtext('denyemailaddresses', new lang_string('denyemailaddresses', 'admin'),
114 new lang_string('configdenyemailaddresses', 'admin'), '', PARAM_NOTAGS);
115 $setting->set_force_ltr(true);
116 $temp->add($setting);
e106013f
SH
117 $temp->add(new admin_setting_configcheckbox('verifychangedemail', new lang_string('verifychangedemail', 'admin'), new lang_string('configverifychangedemail', 'admin'), 1));
118
113efed5
FM
119 $setting = new admin_setting_configtext('recaptchapublickey', new lang_string('recaptchapublickey', 'admin'), new lang_string('configrecaptchapublickey', 'admin'), '', PARAM_NOTAGS);
120 $setting->set_force_ltr(true);
121 $temp->add($setting);
122 $setting = new admin_setting_configtext('recaptchaprivatekey', new lang_string('recaptchaprivatekey', 'admin'), new lang_string('configrecaptchaprivatekey', 'admin'), '', PARAM_NOTAGS);
123 $setting->set_force_ltr(true);
124 $temp->add($setting);
df997f84
PS
125 $ADMIN->add('authsettings', $temp);
126
6cf20915
PS
127 $temp = new admin_externalpage('authtestsettings', get_string('testsettings', 'core_auth'), new moodle_url("/auth/test_settings.php"), 'moodle/site:config', true);
128 $ADMIN->add('authsettings', $temp);
129
7025aeed
VD
130 $plugins = core_plugin_manager::instance()->get_plugins_of_type('auth');
131 core_collator::asort_objects_by_property($plugins, 'displayname');
132 foreach ($plugins as $plugin) {
e87214bd
PS
133 /** @var \core\plugininfo\auth $plugin */
134 $plugin->load_settings($ADMIN, 'authsettings', $hassiteconfig);
df997f84
PS
135 }
136
df997f84 137 // Enrolment plugins
e106013f
SH
138 $ADMIN->add('modules', new admin_category('enrolments', new lang_string('enrolments', 'enrol')));
139 $temp = new admin_settingpage('manageenrols', new lang_string('manageenrols', 'enrol'));
df997f84 140 $temp->add(new admin_setting_manageenrols());
df997f84 141 $ADMIN->add('enrolments', $temp);
6cf20915
PS
142
143 $temp = new admin_externalpage('enroltestsettings', get_string('testsettings', 'core_enrol'), new moodle_url("/enrol/test_settings.php"), 'moodle/site:config', true);
144 $ADMIN->add('enrolments', $temp);
145
7025aeed
VD
146 $plugins = core_plugin_manager::instance()->get_plugins_of_type('enrol');
147 core_collator::asort_objects_by_property($plugins, 'displayname');
148 foreach ($plugins as $plugin) {
e87214bd
PS
149 /** @var \core\plugininfo\enrol $plugin */
150 $plugin->load_settings($ADMIN, 'enrolments', $hassiteconfig);
df997f84 151 }
df997f84 152
c5d2d0dd 153
a5747cf8 154/// Editor plugins
e106013f
SH
155 $ADMIN->add('modules', new admin_category('editorsettings', new lang_string('editors', 'editor')));
156 $temp = new admin_settingpage('manageeditors', new lang_string('editorsettings', 'editor'));
a5747cf8 157 $temp->add(new admin_setting_manageeditors());
158 $ADMIN->add('editorsettings', $temp);
7025aeed
VD
159 $plugins = core_plugin_manager::instance()->get_plugins_of_type('editor');
160 core_collator::asort_objects_by_property($plugins, 'displayname');
161 foreach ($plugins as $plugin) {
e87214bd
PS
162 /** @var \core\plugininfo\editor $plugin */
163 $plugin->load_settings($ADMIN, 'editorsettings', $hassiteconfig);
7a856a93 164 }
6fc67fce 165
1a980fda 166 // Antivirus plugins.
146eeb76
RK
167 $ADMIN->add('modules', new admin_category('antivirussettings', new lang_string('antiviruses', 'antivirus')));
168 $temp = new admin_settingpage('manageantiviruses', new lang_string('antivirussettings', 'antivirus'));
169 $temp->add(new admin_setting_manageantiviruses());
170 $ADMIN->add('antivirussettings', $temp);
7025aeed
VD
171 $plugins = core_plugin_manager::instance()->get_plugins_of_type('antivirus');
172 core_collator::asort_objects_by_property($plugins, 'displayname');
173 foreach ($plugins as $plugin) {
1a980fda 174 /* @var \core\plugininfo\antivirus $plugin */
146eeb76
RK
175 $plugin->load_settings($ADMIN, 'antivirussettings', $hassiteconfig);
176 }
177
aa5b7056
DM
178 // Machine learning backend plugins.
179 $ADMIN->add('modules', new admin_category('mlbackendsettings', new lang_string('mlbackendsettings', 'admin')));
180 $plugins = core_plugin_manager::instance()->get_plugins_of_type('mlbackend');
181 foreach ($plugins as $plugin) {
182 $plugin->load_settings($ADMIN, 'mlbackendsettings', $hassiteconfig);
183 }
184
a5747cf8 185/// Filter plugins
e106013f 186 $ADMIN->add('modules', new admin_category('filtersettings', new lang_string('managefilters')));
dcdf3b29 187
188 $ADMIN->add('filtersettings', new admin_page_managefilters());
189
220a90c5 190 // "filtersettings" settingpage
e106013f 191 $temp = new admin_settingpage('commonfiltersettings', new lang_string('commonfiltersettings', 'admin'));
220a90c5 192 if ($ADMIN->fulltree) {
109e3cb2 193 $items = array();
e106013f
SH
194 $items[] = new admin_setting_configselect('filteruploadedfiles', new lang_string('filteruploadedfiles', 'admin'), new lang_string('configfilteruploadedfiles', 'admin'), 0,
195 array('0' => new lang_string('none'), '1' => new lang_string('allfiles'), '2' => new lang_string('htmlfilesonly')));
196 $items[] = new admin_setting_configcheckbox('filtermatchoneperpage', new lang_string('filtermatchoneperpage', 'admin'), new lang_string('configfiltermatchoneperpage', 'admin'), 0);
197 $items[] = new admin_setting_configcheckbox('filtermatchonepertext', new lang_string('filtermatchonepertext', 'admin'), new lang_string('configfiltermatchonepertext', 'admin'), 0);
109e3cb2 198 foreach ($items as $item) {
199 $item->set_updatedcallback('reset_text_filters_cache');
200 $temp->add($item);
201 }
220a90c5 202 }
203 $ADMIN->add('filtersettings', $temp);
204
7025aeed
VD
205 $plugins = core_plugin_manager::instance()->get_plugins_of_type('filter');
206 core_collator::asort_objects_by_property($plugins, 'displayname');
207 foreach ($plugins as $plugin) {
e87214bd
PS
208 /** @var \core\plugininfo\filter $plugin */
209 $plugin->load_settings($ADMIN, 'filtersettings', $hassiteconfig);
220a90c5 210 }
67a87e7d 211
fab11235
MG
212 // Media players.
213 $ADMIN->add('modules', new admin_category('mediaplayers', new lang_string('type_media_plural', 'plugin')));
214 $temp = new admin_settingpage('managemediaplayers', new lang_string('managemediaplayers', 'media'));
215 $temp->add(new admin_setting_heading('mediaformats', get_string('mediaformats', 'core_media'),
216 format_text(get_string('mediaformats_desc', 'core_media'), FORMAT_MARKDOWN)));
217 $temp->add(new admin_setting_managemediaplayers());
218 $temp->add(new admin_setting_heading('managemediaplayerscommonheading', new lang_string('commonsettings', 'admin'), ''));
219 $temp->add(new admin_setting_configtext('media_default_width',
220 new lang_string('defaultwidth', 'core_media'), new lang_string('defaultwidthdesc', 'core_media'),
221 400, PARAM_INT, 10));
222 $temp->add(new admin_setting_configtext('media_default_height',
223 new lang_string('defaultheight', 'core_media'), new lang_string('defaultheightdesc', 'core_media'),
224 300, PARAM_INT, 10));
225 $ADMIN->add('mediaplayers', $temp);
226
34df779a
AN
227 // Convert plugins.
228 $ADMIN->add('modules', new admin_category('fileconverterplugins', new lang_string('type_fileconverter_plural', 'plugin')));
b5eff766 229 $temp = new admin_settingpage('managefileconverterplugins', new lang_string('type_fileconvertermanage', 'plugin'));
34df779a
AN
230 $temp->add(new admin_setting_manage_fileconverter_plugins());
231 $ADMIN->add('fileconverterplugins', $temp);
232
233 $plugins = core_plugin_manager::instance()->get_plugins_of_type('fileconverter');
234 core_collator::asort_objects_by_property($plugins, 'displayname');
235 foreach ($plugins as $plugin) {
236 /** @var \core\plugininfo\media $plugin */
237 $plugin->load_settings($ADMIN, 'fileconverterplugins', $hassiteconfig);
238 }
239
fab11235
MG
240 $plugins = core_plugin_manager::instance()->get_plugins_of_type('media');
241 core_collator::asort_objects_by_property($plugins, 'displayname');
242 foreach ($plugins as $plugin) {
243 /** @var \core\plugininfo\media $plugin */
244 $plugin->load_settings($ADMIN, 'mediaplayers', $hassiteconfig);
245 }
246
bff1edbe
BH
247 // Data format settings.
248 $ADMIN->add('modules', new admin_category('dataformatsettings', new lang_string('dataformats')));
249 $temp = new admin_settingpage('managedataformats', new lang_string('managedataformats'));
250 $temp->add(new admin_setting_managedataformats());
251 $ADMIN->add('dataformatsettings', $temp);
78946b9b
PS
252
253 //== Portfolio settings ==
254 require_once($CFG->libdir. '/portfoliolib.php');
e106013f
SH
255 $catname = new lang_string('portfolios', 'portfolio');
256 $manage = new lang_string('manageportfolios', 'portfolio');
67a87e7d 257 $url = "$CFG->wwwroot/$CFG->admin/portfolio.php";
258
90658eef 259 $ADMIN->add('modules', new admin_category('portfoliosettings', $catname, empty($CFG->enableportfolios)));
67a87e7d 260
9d81733d
SM
261 // Add manage page (with table)
262 $temp = new admin_page_manageportfolios();
263 $ADMIN->add('portfoliosettings', $temp);
264
265 // Add common settings page
e106013f
SH
266 $temp = new admin_settingpage('manageportfolioscommon', new lang_string('commonportfoliosettings', 'portfolio'));
267 $temp->add(new admin_setting_heading('manageportfolioscommon', '', new lang_string('commonsettingsdesc', 'portfolio')));
bee4bce2 268 $fileinfo = portfolio_filesize_info(); // make sure this is defined in one place since its used inside portfolio too to detect insane settings
269 $fileoptions = $fileinfo['options'];
270 $temp->add(new admin_setting_configselect(
271 'portfolio_moderate_filesize_threshold',
e106013f
SH
272 new lang_string('moderatefilesizethreshold', 'portfolio'),
273 new lang_string('moderatefilesizethresholddesc', 'portfolio'),
bee4bce2 274 $fileinfo['moderate'], $fileoptions));
275 $temp->add(new admin_setting_configselect(
276 'portfolio_high_filesize_threshold',
e106013f
SH
277 new lang_string('highfilesizethreshold', 'portfolio'),
278 new lang_string('highfilesizethresholddesc', 'portfolio'),
bee4bce2 279 $fileinfo['high'], $fileoptions));
280
281 $temp->add(new admin_setting_configtext(
282 'portfolio_moderate_db_threshold',
e106013f
SH
283 new lang_string('moderatedbsizethreshold', 'portfolio'),
284 new lang_string('moderatedbsizethresholddesc', 'portfolio'),
1e12c120 285 20, PARAM_INT, 3));
bee4bce2 286
287 $temp->add(new admin_setting_configtext(
288 'portfolio_high_db_threshold',
e106013f
SH
289 new lang_string('highdbsizethreshold', 'portfolio'),
290 new lang_string('highdbsizethresholddesc', 'portfolio'),
1e12c120 291 50, PARAM_INT, 3));
a50ef3d3 292
293 $ADMIN->add('portfoliosettings', $temp);
56aee7c2
DM
294 $ADMIN->add('portfoliosettings', new admin_externalpage('portfolionew', new lang_string('addnewportfolio', 'portfolio'), $url, 'moodle/site:config', true));
295 $ADMIN->add('portfoliosettings', new admin_externalpage('portfoliodelete', new lang_string('deleteportfolio', 'portfolio'), $url, 'moodle/site:config', true));
296 $ADMIN->add('portfoliosettings', new admin_externalpage('portfoliocontroller', new lang_string('manageportfolios', 'portfolio'), $url, 'moodle/site:config', true));
a50ef3d3 297
08d5e18b 298 foreach (portfolio_instances(false, false) as $portfolio) {
edf1fc35 299 require_once($CFG->dirroot . '/portfolio/' . $portfolio->get('plugin') . '/lib.php');
67a87e7d 300 $classname = 'portfolio_plugin_' . $portfolio->get('plugin');
a50ef3d3 301 $ADMIN->add(
302 'portfoliosettings',
08d5e18b 303 new admin_externalpage(
304 'portfoliosettings' . $portfolio->get('id'),
658837bb 305 $portfolio->get('name'),
6010eda2
MD
306 $url . '?action=edit&pf=' . $portfolio->get('id'),
307 'moodle/site:config'
0a94e4a9 308 )
a50ef3d3 309 );
67a87e7d 310 }
4a65c39a 311
312 // repository setting
313 require_once("$CFG->dirroot/repository/lib.php");
e106013f
SH
314 $catname =new lang_string('repositories', 'repository');
315 $managerepo = new lang_string('manage', 'repository');
04bd6d2d 316 $url = $CFG->wwwroot.'/'.$CFG->admin.'/repository.php';
4a65c39a 317 $ADMIN->add('modules', new admin_category('repositorysettings', $catname));
9d81733d
SM
318
319 // Add main page (with table)
320 $temp = new admin_page_managerepositories();
321 $ADMIN->add('repositorysettings', $temp);
322
323 // Add common settings page
e106013f 324 $temp = new admin_settingpage('managerepositoriescommon', new lang_string('commonrepositorysettings', 'repository'));
c1b3ac43
RT
325 $temp->add(new admin_setting_configtext('repositorycacheexpire', new lang_string('cacheexpire', 'repository'), new lang_string('configcacheexpire', 'repository'), 120, PARAM_INT));
326 $temp->add(new admin_setting_configtext('repositorygetfiletimeout', new lang_string('getfiletimeout', 'repository'), new lang_string('configgetfiletimeout', 'repository'), 30, PARAM_INT));
327 $temp->add(new admin_setting_configtext('repositorysyncfiletimeout', new lang_string('syncfiletimeout', 'repository'), new lang_string('configsyncfiletimeout', 'repository'), 1, PARAM_INT));
328 $temp->add(new admin_setting_configtext('repositorysyncimagetimeout', new lang_string('syncimagetimeout', 'repository'), new lang_string('configsyncimagetimeout', 'repository'), 3, PARAM_INT));
e106013f
SH
329 $temp->add(new admin_setting_configcheckbox('repositoryallowexternallinks', new lang_string('allowexternallinks', 'repository'), new lang_string('configallowexternallinks', 'repository'), 1));
330 $temp->add(new admin_setting_configcheckbox('legacyfilesinnewcourses', new lang_string('legacyfilesinnewcourses', 'admin'), new lang_string('legacyfilesinnewcourses_help', 'admin'), 0));
cc0bb815 331 $temp->add(new admin_setting_configcheckbox('legacyfilesaddallowed', new lang_string('legacyfilesaddallowed', 'admin'), new lang_string('legacyfilesaddallowed_help', 'admin'), 1));
4a65c39a 332 $ADMIN->add('repositorysettings', $temp);
4f2b9a4f 333 $ADMIN->add('repositorysettings', new admin_externalpage('repositorynew',
56aee7c2 334 new lang_string('addplugin', 'repository'), $url, 'moodle/site:config', true));
4a65c39a 335 $ADMIN->add('repositorysettings', new admin_externalpage('repositorydelete',
56aee7c2 336 new lang_string('deleterepository', 'repository'), $url, 'moodle/site:config', true));
4a65c39a 337 $ADMIN->add('repositorysettings', new admin_externalpage('repositorycontroller',
56aee7c2 338 new lang_string('manage', 'repository'), $url, 'moodle/site:config', true));
0d099914 339 $ADMIN->add('repositorysettings', new admin_externalpage('repositoryinstancenew',
56aee7c2 340 new lang_string('createrepository', 'repository'), $url, 'moodle/site:config', true));
0d099914 341 $ADMIN->add('repositorysettings', new admin_externalpage('repositoryinstanceedit',
56aee7c2 342 new lang_string('editrepositoryinstance', 'repository'), $url, 'moodle/site:config', true));
7025aeed
VD
343 $plugins = core_plugin_manager::instance()->get_plugins_of_type('repository');
344 core_collator::asort_objects_by_property($plugins, 'displayname');
345 foreach ($plugins as $plugin) {
e87214bd
PS
346 /** @var \core\plugininfo\repository $plugin */
347 $plugin->load_settings($ADMIN, 'repositorysettings', $hassiteconfig);
4a65c39a 348 }
bee4bce2 349
5ae9f539 350/// Web services
e106013f 351 $ADMIN->add('modules', new admin_category('webservicesettings', new lang_string('webservices', 'webservice')));
6b6deb8e 352
3e6161fb 353 /// overview page
e106013f 354 $temp = new admin_settingpage('webservicesoverview', new lang_string('webservicesoverview', 'webservice'));
3e6161fb 355 $temp->add(new admin_setting_webservicesoverview());
356 $ADMIN->add('webservicesettings', $temp);
cde291ed 357 //API documentation
e106013f 358 $ADMIN->add('webservicesettings', new admin_externalpage('webservicedocumentation', new lang_string('wsdocapi', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/documentation.php", 'moodle/site:config', false));
3e6161fb 359 /// manage service
e106013f 360 $temp = new admin_settingpage('externalservices', new lang_string('externalservices', 'webservice'));
e106013f 361 $temp->add(new admin_setting_heading('manageserviceshelpexplaination', new lang_string('information', 'webservice'), new lang_string('servicehelpexplanation', 'webservice')));
cc93c7da 362 $temp->add(new admin_setting_manageexternalservices());
363 $ADMIN->add('webservicesettings', $temp);
e106013f
SH
364 $ADMIN->add('webservicesettings', new admin_externalpage('externalservice', new lang_string('editaservice', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/service.php", 'moodle/site:config', true));
365 $ADMIN->add('webservicesettings', new admin_externalpage('externalservicefunctions', new lang_string('externalservicefunctions', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/service_functions.php", 'moodle/site:config', true));
366 $ADMIN->add('webservicesettings', new admin_externalpage('externalserviceusers', new lang_string('externalserviceusers', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/service_users.php", 'moodle/site:config', true));
367 $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 368 /// manage protocol page link
e106013f 369 $temp = new admin_settingpage('webserviceprotocols', new lang_string('manageprotocols', 'webservice'));
da124b5e 370 $temp->add(new admin_setting_managewebserviceprotocols());
cc93c7da 371 if (empty($CFG->enablewebservices)) {
e106013f 372 $temp->add(new admin_setting_heading('webservicesaredisabled', '', new lang_string('disabledwarning', 'webservice')));
cc93c7da 373 }
b4c91012
SH
374
375 // We cannot use $OUTPUT this early, doing so means that we lose the ability
376 // to set the page layout on all admin pages.
377 // $wsdoclink = $OUTPUT->doc_link('How_to_get_a_security_key');
378 $url = new moodle_url(get_docs_url('How_to_get_a_security_key'));
5e963820 379 $wsdoclink = html_writer::tag('a', new lang_string('supplyinfo', 'webservice'), array('href'=>$url));
e106013f
SH
380 $temp->add(new admin_setting_configcheckbox('enablewsdocumentation', new lang_string('enablewsdocumentation',
381 'admin'), new lang_string('configenablewsdocumentation', 'admin', $wsdoclink), false));
cc93c7da 382 $ADMIN->add('webservicesettings', $temp);
5ae9f539 383 /// links to protocol pages
7025aeed
VD
384 $plugins = core_plugin_manager::instance()->get_plugins_of_type('webservice');
385 core_collator::asort_objects_by_property($plugins, 'displayname');
386 foreach ($plugins as $plugin) {
e87214bd
PS
387 /** @var \core\plugininfo\webservice $plugin */
388 $plugin->load_settings($ADMIN, 'webservicesettings', $hassiteconfig);
cc93c7da 389 }
5ae9f539 390 /// manage token page link
e106013f
SH
391 $ADMIN->add('webservicesettings', new admin_externalpage('addwebservicetoken', new lang_string('managetokens', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/tokens.php", 'moodle/site:config', true));
392 $temp = new admin_settingpage('webservicetokens', new lang_string('managetokens', 'webservice'));
5ae9f539 393 $temp->add(new admin_setting_managewebservicetokens());
394 if (empty($CFG->enablewebservices)) {
e106013f 395 $temp->add(new admin_setting_heading('webservicesaredisabled', '', new lang_string('disabledwarning', 'webservice')));
5ae9f539 396 }
397 $ADMIN->add('webservicesettings', $temp);
2567584d 398}
df997f84 399
b6eb984a 400// Question type settings
78946b9b 401if ($hassiteconfig || has_capability('moodle/question:config', $systemcontext)) {
4125ded1 402
fde4560d 403 // Question behaviour settings.
e106013f 404 $ADMIN->add('modules', new admin_category('qbehavioursettings', new lang_string('questionbehaviours', 'admin')));
fde4560d
TH
405 $ADMIN->add('qbehavioursettings', new admin_page_manageqbehaviours());
406
bee4bce2 407 // Question type settings.
e106013f 408 $ADMIN->add('modules', new admin_category('qtypesettings', new lang_string('questiontypes', 'admin')));
bee4bce2 409 $ADMIN->add('qtypesettings', new admin_page_manageqtypes());
4125ded1
TH
410
411 // Question preview defaults.
412 $settings = new admin_settingpage('qdefaultsetting',
413 get_string('questionpreviewdefaults', 'question'),
414 'moodle/question:config');
415 $ADMIN->add('qtypesettings', $settings);
416
417 $settings->add(new admin_setting_heading('qdefaultsetting_preview_options',
418 '', get_string('questionpreviewdefaults_desc', 'question')));
419
420 // These keys are question_display_options::HIDDEN and VISIBLE.
421 $hiddenofvisible = array(
422 0 => get_string('notshown', 'question'),
423 1 => get_string('shown', 'question'),
424 );
425
426 $settings->add(new admin_setting_question_behaviour('question_preview/behaviour',
427 get_string('howquestionsbehave', 'question'), '',
428 'deferredfeedback'));
429
430 $settings->add(new admin_setting_configselect('question_preview/correctness',
431 get_string('whethercorrect', 'question'), '', 1, $hiddenofvisible));
432
433 // These keys are question_display_options::HIDDEN, MARK_ONLY and MARK_AND_MAX.
434 $marksoptions = array(
435 0 => get_string('notshown', 'question'),
436 1 => get_string('showmaxmarkonly', 'question'),
437 2 => get_string('showmarkandmax', 'question'),
438 );
439 $settings->add(new admin_setting_configselect('question_preview/marks',
96bdbe69 440 get_string('marks', 'question'), '', 2, $marksoptions));
4125ded1
TH
441
442 $settings->add(new admin_setting_configselect('question_preview/markdp',
443 get_string('decimalplacesingrades', 'question'), '', 2, array(0, 1, 2, 3, 4, 5, 6, 7)));
444
445 $settings->add(new admin_setting_configselect('question_preview/feedback',
446 get_string('specificfeedback', 'question'), '', 1, $hiddenofvisible));
447
448 $settings->add(new admin_setting_configselect('question_preview/generalfeedback',
449 get_string('generalfeedback', 'question'), '', 1, $hiddenofvisible));
450
451 $settings->add(new admin_setting_configselect('question_preview/rightanswer',
452 get_string('rightanswer', 'question'), '', 1, $hiddenofvisible));
453
454 $settings->add(new admin_setting_configselect('question_preview/history',
455 get_string('responsehistory', 'question'), '', 0, $hiddenofvisible));
456
457 // Settings for particular question types.
7025aeed
VD
458 $plugins = core_plugin_manager::instance()->get_plugins_of_type('qtype');
459 core_collator::asort_objects_by_property($plugins, 'displayname');
460 foreach ($plugins as $plugin) {
e87214bd
PS
461 /** @var \core\plugininfo\qtype $plugin */
462 $plugin->load_settings($ADMIN, 'qtypesettings', $hassiteconfig);
bee4bce2 463 }
220a90c5 464}
b6eb984a
TH
465
466// Plagiarism plugin settings
bce59524 467if ($hassiteconfig && !empty($CFG->enableplagiarism)) {
e106013f 468 $ADMIN->add('modules', new admin_category('plagiarism', new lang_string('plagiarism', 'plagiarism')));
760007a2
DM
469 $ADMIN->add('plagiarism', new admin_externalpage('manageplagiarismplugins', new lang_string('manageplagiarism', 'plagiarism'),
470 $CFG->wwwroot . '/' . $CFG->admin . '/plagiarism.php'));
471
7025aeed
VD
472 $plugins = core_plugin_manager::instance()->get_plugins_of_type('plagiarism');
473 core_collator::asort_objects_by_property($plugins, 'displayname');
474 foreach ($plugins as $plugin) {
e87214bd 475 /** @var \core\plugininfo\plagiarism $plugin */
d98305bd 476 $plugin->load_settings($ADMIN, 'plagiarism', $hassiteconfig);
bce59524
DM
477 }
478}
e106013f 479$ADMIN->add('reports', new admin_externalpage('comments', new lang_string('comments'), $CFG->wwwroot.'/comment/', 'moodle/site:viewreports'));
b63a6a63 480
b6eb984a
TH
481// Course reports settings
482if ($hassiteconfig) {
483 $pages = array();
bd3b3bba 484 foreach (core_component::get_plugin_list('coursereport') as $report => $path) {
b6eb984a
TH
485 $file = $CFG->dirroot . '/course/report/' . $report . '/settings.php';
486 if (file_exists($file)) {
487 $settings = new admin_settingpage('coursereport' . $report,
e106013f 488 new lang_string('pluginname', 'coursereport_' . $report), 'moodle/site:config');
b6eb984a
TH
489 // settings.php may create a subcategory or unset the settings completely
490 include($file);
491 if ($settings) {
492 $pages[] = $settings;
493 }
494 }
495 }
496 if (!empty($pages)) {
e106013f 497 $ADMIN->add('modules', new admin_category('coursereports', new lang_string('coursereports')));
7025aeed 498 core_collator::asort_objects_by_property($pages, 'visiblename');
b6eb984a
TH
499 foreach ($pages as $page) {
500 $ADMIN->add('coursereports', $page);
501 }
502 }
e30cc24c 503 unset($pages);
b6eb984a
TH
504}
505
506// Now add reports
e30cc24c 507$pages = array();
bd3b3bba 508foreach (core_component::get_plugin_list('report') as $report => $plugindir) {
17da2e6f 509 $settings_path = "$plugindir/settings.php";
b63a6a63 510 if (file_exists($settings_path)) {
e30cc24c 511 $settings = new admin_settingpage('report' . $report,
e106013f 512 new lang_string('pluginname', 'report_' . $report), 'moodle/site:config');
b63a6a63 513 include($settings_path);
e30cc24c
PS
514 if ($settings) {
515 $pages[] = $settings;
516 }
b63a6a63 517 }
e30cc24c 518}
e106013f
SH
519$ADMIN->add('modules', new admin_category('reportplugins', new lang_string('reports')));
520$ADMIN->add('reportplugins', new admin_externalpage('managereports', new lang_string('reportsmanage', 'admin'),
4f6bba20 521 $CFG->wwwroot . '/' . $CFG->admin . '/reports.php'));
7025aeed 522core_collator::asort_objects_by_property($pages, 'visiblename');
4f6bba20
PS
523foreach ($pages as $page) {
524 $ADMIN->add('reportplugins', $page);
b63a6a63 525}
526
46e944ae
DM
527if ($hassiteconfig) {
528 // Global Search engine plugins.
529 $ADMIN->add('modules', new admin_category('searchplugins', new lang_string('search', 'admin')));
530 $temp = new admin_settingpage('manageglobalsearch', new lang_string('globalsearchmanage', 'admin'));
db48207e 531
46e944ae
DM
532 $pages = array();
533 $engines = array();
534 foreach (core_component::get_plugin_list('search') as $engine => $plugindir) {
535 $engines[$engine] = new lang_string('pluginname', 'search_' . $engine);
536 $settingspath = "$plugindir/settings.php";
537 if (file_exists($settingspath)) {
538 $settings = new admin_settingpage('search' . $engine,
539 new lang_string('pluginname', 'search_' . $engine), 'moodle/site:config');
540 include($settingspath);
541 if ($settings) {
542 $pages[] = $settings;
543 }
db48207e
DM
544 }
545 }
db48207e 546
46e944ae
DM
547 // Setup status.
548 $temp->add(new admin_setting_searchsetupinfo());
549
550 // Search engine selection.
551 $temp->add(new admin_setting_heading('searchengineheading', new lang_string('searchengine', 'admin'), ''));
679e8d8b 552 $searchengineselect = new admin_setting_configselect('searchengine',
553 new lang_string('selectsearchengine', 'admin'), '', 'simpledb', $engines);
554 $searchengineselect->set_validate_function(function(string $value): string {
555 global $CFG;
556
557 // Check nobody's setting the indexing and query-only server to the same one.
558 if ($CFG->searchenginequeryonly === $value) {
559 return get_string('searchenginequeryonlysame', 'admin');
560 } else {
561 return '';
562 }
563 });
564 $temp->add($searchengineselect);
2d94d4ea 565 $temp->add(new admin_setting_heading('searchoptionsheading', new lang_string('searchoptions', 'admin'), ''));
67d64795 566 $temp->add(new admin_setting_configcheckbox('searchindexwhendisabled',
567 new lang_string('searchindexwhendisabled', 'admin'), new lang_string('searchindexwhendisabled_desc', 'admin'),
568 0));
569 $temp->add(new admin_setting_configduration('searchindextime',
570 new lang_string('searchindextime', 'admin'), new lang_string('searchindextime_desc', 'admin'),
571 600));
2085e860 572 $temp->add(new admin_setting_heading('searchcoursesheading', new lang_string('searchablecourses', 'admin'), ''));
2d94d4ea 573 $options = [
574 0 => new lang_string('searchallavailablecourses_off', 'admin'),
575 1 => new lang_string('searchallavailablecourses_on', 'admin')
576 ];
577 $temp->add(new admin_setting_configselect('searchallavailablecourses',
578 new lang_string('searchallavailablecourses', 'admin'),
2085e860 579 new lang_string('searchallavailablecoursesdesc', 'admin'),
2d94d4ea 580 0, $options));
2085e860
DM
581 $temp->add(new admin_setting_configcheckbox('searchincludeallcourses',
582 new lang_string('searchincludeallcourses', 'admin'), new lang_string('searchincludeallcourses_desc', 'admin'),
583 0));
46e944ae 584
e9074ee3
DM
585 // Search display options.
586 $temp->add(new admin_setting_heading('searchdisplay', new lang_string('searchdisplay', 'admin'), ''));
587 $temp->add(new admin_setting_configcheckbox('searchenablecategories',
588 new lang_string('searchenablecategories', 'admin'),
589 new lang_string('searchenablecategories_desc', 'admin'),
590 0));
591 $options = [];
592 foreach (\core_search\manager::get_search_area_categories() as $category) {
593 $options[$category->get_name()] = $category->get_visiblename();
594 }
595 $temp->add(new admin_setting_configselect('searchdefaultcategory',
596 new lang_string('searchdefaultcategory', 'admin'),
597 new lang_string('searchdefaultcategory_desc', 'admin'),
598 \core_search\manager::SEARCH_AREA_CATEGORY_ALL, $options));
599 $temp->add(new admin_setting_configcheckbox('searchhideallcategory',
600 new lang_string('searchhideallcategory', 'admin'),
601 new lang_string('searchhideallcategory_desc', 'admin'),
602 0));
603
679e8d8b 604 $temp->add(new admin_setting_heading('searchmanagement', new lang_string('searchmanagement', 'admin'),
605 new lang_string('searchmanagement_desc', 'admin')));
606
607 // Get list of search engines including those with alternate settings.
608 $searchenginequeryonlyselect = new admin_setting_configselect('searchenginequeryonly',
609 new lang_string('searchenginequeryonly', 'admin'),
610 new lang_string('searchenginequeryonly_desc', 'admin'), '', function() use($engines) {
611 $options = ['' => new lang_string('searchenginequeryonly_none', 'admin')];
612 foreach ($engines as $name => $display) {
613 $options[$name] = $display;
614
615 $classname = '\search_' . $name . '\engine';
616 $engine = new $classname;
617 if ($engine->has_alternate_configuration()) {
618 $options[$name . '-alternate'] =
619 new lang_string('searchenginealternatesettings', 'admin', $display);
620 }
621 }
622 return $options;
623 });
624 $searchenginequeryonlyselect->set_validate_function(function(string $value): string {
625 global $CFG;
626
627 // Check nobody's setting the indexing and query-only server to the same one.
628 if ($CFG->searchengine === $value) {
629 return get_string('searchenginequeryonlysame', 'admin');
630 } else {
631 return '';
632 }
633 });
634 $temp->add($searchenginequeryonlyselect);
635 $temp->add(new admin_setting_configcheckbox('searchbannerenable',
636 new lang_string('searchbannerenable', 'admin'), new lang_string('searchbannerenable_desc', 'admin'),
637 0));
638 $temp->add(new admin_setting_confightmleditor('searchbanner',
639 new lang_string('searchbanner', 'admin'), '', ''));
640
46e944ae 641 $ADMIN->add('searchplugins', $temp);
c3a95c28
DP
642 $ADMIN->add('searchplugins', new admin_externalpage('searchareas', new lang_string('searchareas', 'admin'),
643 new moodle_url('/admin/searchareas.php')));
db48207e 644
7025aeed 645 core_collator::asort_objects_by_property($pages, 'visiblename');
46e944ae
DM
646 foreach ($pages as $page) {
647 $ADMIN->add('searchplugins', $page);
648 }
db48207e
DM
649}
650
b33e6d8e
JG
651/// Add all admin tools
652if ($hassiteconfig) {
653 $ADMIN->add('modules', new admin_category('tools', new lang_string('tools', 'admin')));
654 $ADMIN->add('tools', new admin_externalpage('managetools', new lang_string('toolsmanage', 'admin'),
655 $CFG->wwwroot . '/' . $CFG->admin . '/tools.php'));
656}
657
e87214bd 658// Now add various admin tools.
7025aeed
VD
659$plugins = core_plugin_manager::instance()->get_plugins_of_type('tool');
660core_collator::asort_objects_by_property($plugins, 'displayname');
661foreach ($plugins as $plugin) {
e87214bd
PS
662 /** @var \core\plugininfo\tool $plugin */
663 $plugin->load_settings($ADMIN, null, $hassiteconfig);
11b24ce7 664}
17da2e6f 665
f23fbfd8
SH
666// Now add the Cache plugins
667if ($hassiteconfig) {
668 $ADMIN->add('modules', new admin_category('cache', new lang_string('caching', 'cache')));
669 $ADMIN->add('cache', new admin_externalpage('cacheconfig', new lang_string('cacheconfig', 'cache'), $CFG->wwwroot .'/cache/admin.php'));
670 $ADMIN->add('cache', new admin_externalpage('cachetestperformance', new lang_string('testperformance', 'cache'), $CFG->wwwroot . '/cache/testperformance.php'));
671 $ADMIN->add('cache', new admin_category('cachestores', new lang_string('cachestores', 'cache')));
7025aeed 672 $ADMIN->locate('cachestores')->set_sorting(true);
bd3b3bba 673 foreach (core_component::get_plugin_list('cachestore') as $plugin => $path) {
f23fbfd8
SH
674 $settingspath = $path.'/settings.php';
675 if (file_exists($settingspath)) {
6fec1820 676 $settings = new admin_settingpage('cachestore_'.$plugin.'_settings', new lang_string('pluginname', 'cachestore_'.$plugin), 'moodle/site:config');
f23fbfd8
SH
677 include($settingspath);
678 $ADMIN->add('cachestores', $settings);
679 }
680 }
681}
682
b404b1f4
AG
683// Add Calendar type settings.
684if ($hassiteconfig) {
685 $ADMIN->add('modules', new admin_category('calendartype', new lang_string('calendartypes', 'calendar')));
7025aeed
VD
686 $plugins = core_plugin_manager::instance()->get_plugins_of_type('calendartype');
687 core_collator::asort_objects_by_property($plugins, 'displayname');
688 foreach ($plugins as $plugin) {
49f3c893
MG
689 /** @var \core\plugininfo\calendartype $plugin */
690 $plugin->load_settings($ADMIN, 'calendartype', $hassiteconfig);
b404b1f4
AG
691 }
692}
693
33b8ca26
AA
694// Content bank content types.
695if ($hassiteconfig) {
061893d8 696 $ADMIN->add('modules', new admin_category('contentbanksettings', new lang_string('contentbank')));
33b8ca26
AA
697 $temp = new admin_settingpage('managecontentbanktypes', new lang_string('managecontentbanktypes'));
698 $temp->add(new admin_setting_managecontentbankcontenttypes());
061893d8 699 $ADMIN->add('contentbanksettings', $temp);
33b8ca26
AA
700 $plugins = core_plugin_manager::instance()->get_plugins_of_type('contenttype');
701 foreach ($plugins as $plugin) {
702 /** @var \core\plugininfo\contentbank $plugin */
061893d8 703 $plugin->load_settings($ADMIN, 'contentbanksettings', $hassiteconfig);
33b8ca26
AA
704 }
705}
706
17da2e6f 707/// Add all local plugins - must be always last!
1ed47309 708if ($hassiteconfig) {
e106013f
SH
709 $ADMIN->add('modules', new admin_category('localplugins', new lang_string('localplugins')));
710 $ADMIN->add('localplugins', new admin_externalpage('managelocalplugins', new lang_string('localpluginsmanage'),
1ed47309
DM
711 $CFG->wwwroot . '/' . $CFG->admin . '/localplugins.php'));
712}
17da2e6f 713
e87214bd
PS
714// Extend settings for each local plugin. Note that their settings may be in any part of the
715// settings tree and may be visible not only for administrators.
7025aeed
VD
716$plugins = core_plugin_manager::instance()->get_plugins_of_type('local');
717core_collator::asort_objects_by_property($plugins, 'displayname');
718foreach ($plugins as $plugin) {
e87214bd
PS
719 /** @var \core\plugininfo\local $plugin */
720 $plugin->load_settings($ADMIN, null, $hassiteconfig);
1bcb7eb5 721}