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