Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
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
*/
26
 
27
if ($hassiteconfig) {
28
    /* @var admin_root $ADMIN */
29
    $ADMIN->locate('modules')->set_sorting(true);
30
 
31
    $ADMIN->add('modules', new admin_page_pluginsoverview());
32
 
33
    // activity modules
34
    $ADMIN->add('modules', new admin_category('modsettings', new lang_string('activitymodules')));
35
 
36
    $ADMIN->add('modsettings', new admin_page_managemods());
37
 
38
    $temp = new admin_settingpage('managemodulescommon', new lang_string('commonactivitysettings', 'admin'));
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
 
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) {
46
        /** @var \core\plugininfo\mod $plugin */
47
        $plugin->load_settings($ADMIN, 'modsettings', $hassiteconfig);
48
    }
49
 
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);
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) {
58
        /** @var \core\plugininfo\format $plugin */
59
        $plugin->load_settings($ADMIN, 'formatsettings', $hassiteconfig);
60
    }
61
 
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
 
74
    // blocks
75
    $ADMIN->add('modules', new admin_category('blocksettings', new lang_string('blocks')));
76
    $ADMIN->add('blocksettings', new admin_page_manageblocks());
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) {
80
        /** @var \core\plugininfo\block $plugin */
81
        $plugin->load_settings($ADMIN, 'blocksettings', $hassiteconfig);
82
    }
83
 
84
    // authentication plugins
85
    $ADMIN->add('modules', new admin_category('authsettings', new lang_string('authentication', 'admin')));
86
 
87
    $temp = new admin_settingpage('manageauths', new lang_string('authsettings', 'admin'));
88
    $temp->add(new admin_setting_manageauths());
89
    $temp->add(new admin_setting_heading('manageauthscommonheading', new lang_string('commonsettings', 'admin'), ''));
90
    $temp->add(new admin_setting_special_registerauth());
91
    $temp->add(new admin_setting_configcheckbox('authloginviaemail', new lang_string('authloginviaemail', 'core_auth'), new lang_string('authloginviaemail_desc', 'core_auth'), 0));
92
    $temp->add(new admin_setting_configcheckbox('allowaccountssameemail',
93
                    new lang_string('allowaccountssameemail', 'core_auth'),
94
                    new lang_string('allowaccountssameemail_desc', 'core_auth'), 0));
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'))));
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));
103
    $temp->add(new admin_setting_configtext('alternateloginurl', new lang_string('alternateloginurl', 'auth'),
104
                                            new lang_string('alternatelogin', 'auth', htmlspecialchars(get_login_url(), ENT_COMPAT)), ''));
105
    $temp->add(new admin_setting_configtext('forgottenpasswordurl', new lang_string('forgottenpasswordurl', 'auth'),
106
                                            new lang_string('forgottenpassword', 'auth'), '', PARAM_URL));
107
    $temp->add(new admin_setting_confightmleditor('auth_instructions', new lang_string('instructions', 'auth'),
108
                                                new lang_string('authinstructions', 'auth'), ''));
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);
117
    $temp->add(new admin_setting_configcheckbox('verifychangedemail', new lang_string('verifychangedemail', 'admin'), new lang_string('configverifychangedemail', 'admin'), 1));
118
 
119
    // ReCaptcha.
120
    $temp->add(new admin_setting_configselect('enableloginrecaptcha',
121
        new lang_string('auth_loginrecaptcha', 'auth'),
122
        new lang_string('auth_loginrecaptcha_desc', 'auth'),
123
        0,
124
        [
125
            new lang_string('no'),
126
            new lang_string('yes'),
127
        ],
128
    ));
129
 
130
    $setting = new admin_setting_configtext('recaptchapublickey', new lang_string('recaptchapublickey', 'admin'), new lang_string('configrecaptchapublickey', 'admin'), '', PARAM_NOTAGS);
131
    $setting->set_force_ltr(true);
132
    $temp->add($setting);
133
    $setting = new admin_setting_configtext('recaptchaprivatekey', new lang_string('recaptchaprivatekey', 'admin'), new lang_string('configrecaptchaprivatekey', 'admin'), '', PARAM_NOTAGS);
134
    $setting->set_force_ltr(true);
135
    $temp->add($setting);
136
    $ADMIN->add('authsettings', $temp);
137
 
138
    // Toggle password visiblity icon.
139
    $temp->add(new admin_setting_configselect('loginpasswordtoggle',
140
        new lang_string('auth_loginpasswordtoggle', 'auth'),
141
        new lang_string('auth_loginpasswordtoggle_desc', 'auth'),
142
        TOGGLE_SENSITIVE_SMALL_SCREENS_ONLY,
143
        [
144
            TOGGLE_SENSITIVE_DISABLED => get_string('disabled', 'admin'),
145
            TOGGLE_SENSITIVE_ENABLED => get_string('enabled', 'admin'),
146
            TOGGLE_SENSITIVE_SMALL_SCREENS_ONLY => get_string('smallscreensonly', 'admin'),
147
        ],
148
    ));
149
 
150
    $temp = new admin_externalpage('authtestsettings', get_string('testsettings', 'core_auth'), new moodle_url("/auth/test_settings.php"), 'moodle/site:config', true);
151
    $ADMIN->add('authsettings', $temp);
152
 
153
    $plugins = core_plugin_manager::instance()->get_plugins_of_type('auth');
154
    core_collator::asort_objects_by_property($plugins, 'displayname');
155
    foreach ($plugins as $plugin) {
156
        /** @var \core\plugininfo\auth $plugin */
157
        $plugin->load_settings($ADMIN, 'authsettings', $hassiteconfig);
158
    }
159
 
160
    // Enrolment plugins
161
    $ADMIN->add('modules', new admin_category('enrolments', new lang_string('enrolments', 'enrol')));
162
    $temp = new admin_settingpage('manageenrols', new lang_string('manageenrols', 'enrol'));
163
    $temp->add(new admin_setting_manageenrols());
164
    $ADMIN->add('enrolments', $temp);
165
 
166
    $temp = new admin_externalpage('enroltestsettings', get_string('testsettings', 'core_enrol'), new moodle_url("/enrol/test_settings.php"), 'moodle/site:config', true);
167
    $ADMIN->add('enrolments', $temp);
168
 
169
    $plugins = core_plugin_manager::instance()->get_plugins_of_type('enrol');
170
    core_collator::asort_objects_by_property($plugins, 'displayname');
171
    foreach ($plugins as $plugin) {
172
        /** @var \core\plugininfo\enrol $plugin */
173
        $plugin->load_settings($ADMIN, 'enrolments', $hassiteconfig);
174
    }
175
 
176
 
177
/// Editor plugins
178
    $ADMIN->add('modules', new admin_category('editorsettings', new lang_string('editors', 'editor')));
179
    $temp = new admin_settingpage('manageeditors', new lang_string('editorsettings', 'editor'));
180
    $temp->add(new \core_admin\admin\admin_setting_plugin_manager(
181
        'editor',
182
        \core_admin\table\editor_management_table::class,
183
        'editorsui',
184
        get_string('editorsettings', 'editor'),
185
    ));
186
    $ADMIN->add('editorsettings', $temp);
187
    $plugins = core_plugin_manager::instance()->get_plugins_of_type('editor');
188
    core_collator::asort_objects_by_property($plugins, 'displayname');
189
    foreach ($plugins as $plugin) {
190
        /** @var \core\plugininfo\editor $plugin */
191
        $plugin->load_settings($ADMIN, 'editorsettings', $hassiteconfig);
192
    }
193
 
194
    // Antivirus plugins.
195
    $ADMIN->add('modules', new admin_category('antivirussettings', new lang_string('antiviruses', 'antivirus')));
196
    $temp = new admin_settingpage('manageantiviruses', new lang_string('antivirussettings', 'antivirus'));
197
    $temp->add(new admin_setting_manageantiviruses());
198
 
199
    // Status check.
200
    $temp->add(new admin_setting_heading('antivirus/statuschecks', new lang_string('statuschecks'), ''));
201
    $temp->add(new admin_setting_check('antivirus/checkantivirus', new \core\check\environment\antivirus()));
202
 
203
    // Common settings.
204
    $temp->add(new admin_setting_heading('antiviruscommonsettings', new lang_string('antiviruscommonsettings', 'antivirus'), ''));
205
 
206
    // Alert email.
207
    $temp->add(
208
        new admin_setting_configtext(
209
            'antivirus/notifyemail',
210
            new lang_string('notifyemail', 'antivirus'),
211
            new lang_string('notifyemail_help', 'antivirus'),
212
            '',
213
            PARAM_EMAIL
214
        )
215
    );
216
 
217
    // Notify level.
218
    $temp->add(new admin_setting_configselect('antivirus/notifylevel',
219
        get_string('notifylevel', 'antivirus'), '', core\antivirus\scanner::SCAN_RESULT_ERROR, [
220
            core\antivirus\scanner::SCAN_RESULT_ERROR => get_string('notifylevelerror', 'antivirus'),
221
            core\antivirus\scanner::SCAN_RESULT_FOUND => get_string('notifylevelfound', 'antivirus')
222
        ]),
223
    );
224
 
225
    // Threshold for check displayed on the /report/status/index.php page.
226
    $url = new moodle_url('/report/status/index.php');
227
    $link = html_writer::link($url, get_string('pluginname', 'report_status'));
228
    $temp->add(
229
        new admin_setting_configduration(
230
            'antivirus/threshold',
231
            new lang_string('threshold', 'antivirus'),
232
            get_string('threshold_desc', 'antivirus', $link),
233
            20 * MINSECS
234
        )
235
    );
236
 
237
    // Enable quarantine.
238
    $temp->add(
239
        new admin_setting_configcheckbox(
240
            'antivirus/enablequarantine',
241
            new lang_string('enablequarantine', 'antivirus'),
242
            new lang_string('enablequarantine_help', 'antivirus',
243
            \core\antivirus\quarantine::DEFAULT_QUARANTINE_FOLDER),
244
 
245
        )
246
    );
247
 
248
    // Quarantine time.
249
    $temp->add(
250
        new admin_setting_configduration(
251
            'antivirus/quarantinetime',
252
            new lang_string('quarantinetime', 'antivirus'),
253
            new lang_string('quarantinetime_desc', 'antivirus'),
254
            \core\antivirus\quarantine::DEFAULT_QUARANTINE_TIME
255
        )
256
    );
257
 
258
    $ADMIN->add('antivirussettings', $temp);
259
    $plugins = core_plugin_manager::instance()->get_plugins_of_type('antivirus');
260
    core_collator::asort_objects_by_property($plugins, 'displayname');
261
    foreach ($plugins as $plugin) {
262
        /* @var \core\plugininfo\antivirus $plugin */
263
        $plugin->load_settings($ADMIN, 'antivirussettings', $hassiteconfig);
264
    }
265
 
266
    // Machine learning backend plugins.
267
    $ADMIN->add('modules', new admin_category('mlbackendsettings', new lang_string('mlbackendsettings', 'admin')));
268
    $plugins = core_plugin_manager::instance()->get_plugins_of_type('mlbackend');
269
    foreach ($plugins as $plugin) {
270
        $plugin->load_settings($ADMIN, 'mlbackendsettings', $hassiteconfig);
271
    }
272
 
273
/// Filter plugins
274
    $ADMIN->add('modules', new admin_category('filtersettings', new lang_string('managefilters')));
275
 
276
    $ADMIN->add('filtersettings', new admin_page_managefilters());
277
 
278
    // "filtersettings" settingpage
279
    $temp = new admin_settingpage('commonfiltersettings', new lang_string('commonfiltersettings', 'admin'));
280
    if ($ADMIN->fulltree) {
281
        $items = array();
282
        $items[] = new admin_setting_configselect('filteruploadedfiles', new lang_string('filteruploadedfiles', 'admin'), new lang_string('configfilteruploadedfiles', 'admin'), 0,
283
                array('0' => new lang_string('none'), '1' => new lang_string('allfiles'), '2' => new lang_string('htmlfilesonly')));
284
        $items[] = new admin_setting_configcheckbox('filtermatchoneperpage', new lang_string('filtermatchoneperpage', 'admin'), new lang_string('configfiltermatchoneperpage', 'admin'), 0);
285
        $items[] = new admin_setting_configcheckbox('filtermatchonepertext', new lang_string('filtermatchonepertext', 'admin'), new lang_string('configfiltermatchonepertext', 'admin'), 0);
286
        $items[] = new admin_setting_configcheckbox('filternavigationwithsystemcontext',
287
                new lang_string('filternavigationwithsystemcontext', 'admin'),
288
                new lang_string('configfilternavigationwithsystemcontext', 'admin'), 0);
289
        foreach ($items as $item) {
290
            $item->set_updatedcallback('reset_text_filters_cache');
291
            $temp->add($item);
292
        }
293
    }
294
    $ADMIN->add('filtersettings', $temp);
295
 
296
    $plugins = core_plugin_manager::instance()->get_plugins_of_type('filter');
297
    core_collator::asort_objects_by_property($plugins, 'displayname');
298
    foreach ($plugins as $plugin) {
299
        /** @var \core\plugininfo\filter $plugin */
300
        $plugin->load_settings($ADMIN, 'filtersettings', $hassiteconfig);
301
    }
302
 
303
    // Media players.
304
    $ADMIN->add('modules', new admin_category('mediaplayers', new lang_string('type_media_plural', 'plugin')));
305
    $temp = new admin_settingpage('managemediaplayers', new lang_string('managemediaplayers', 'media'));
306
    $temp->add(new admin_setting_heading('mediaformats', get_string('mediaformats', 'core_media'),
307
        format_text(get_string('mediaformats_desc', 'core_media'), FORMAT_MARKDOWN)));
308
    $temp->add(new \core_admin\admin\admin_setting_plugin_manager(
309
        'media',
310
        \core_admin\table\media_management_table::class,
311
        'managemediaplayers',
312
        new lang_string('managemediaplayers', 'core_media'),
313
    ));
314
    $temp->add(new admin_setting_heading('managemediaplayerscommonheading', new lang_string('commonsettings', 'admin'), ''));
315
    $temp->add(new admin_setting_configtext('media_default_width',
316
        new lang_string('defaultwidth', 'core_media'), new lang_string('defaultwidthdesc', 'core_media'),
317
        640, PARAM_INT, 10));
318
    $temp->add(new admin_setting_configtext('media_default_height',
319
        new lang_string('defaultheight', 'core_media'), new lang_string('defaultheightdesc', 'core_media'),
320
        360, PARAM_INT, 10));
321
    $ADMIN->add('mediaplayers', $temp);
322
 
323
    // Convert plugins.
324
    $ADMIN->add('modules', new admin_category('fileconverterplugins', new lang_string('type_fileconverter_plural', 'plugin')));
325
    $temp = new admin_settingpage('managefileconverterplugins', new lang_string('type_fileconvertermanage', 'plugin'));
326
    $temp->add(new admin_setting_manage_fileconverter_plugins());
327
    $ADMIN->add('fileconverterplugins', $temp);
328
 
329
    $plugins = core_plugin_manager::instance()->get_plugins_of_type('fileconverter');
330
    core_collator::asort_objects_by_property($plugins, 'displayname');
331
    foreach ($plugins as $plugin) {
332
        /** @var \core\plugininfo\media $plugin */
333
        $plugin->load_settings($ADMIN, 'fileconverterplugins', $hassiteconfig);
334
    }
335
 
336
    $plugins = core_plugin_manager::instance()->get_plugins_of_type('media');
337
    core_collator::asort_objects_by_property($plugins, 'displayname');
338
    foreach ($plugins as $plugin) {
339
        /** @var \core\plugininfo\media $plugin */
340
        $plugin->load_settings($ADMIN, 'mediaplayers', $hassiteconfig);
341
    }
342
 
343
    // Payment gateway plugins.
344
    $ADMIN->add('modules', new admin_category('paymentgateways', new lang_string('type_paygw_plural', 'plugin')));
345
    $temp = new admin_settingpage('managepaymentgateways', new lang_string('type_paygwmanage', 'plugin'));
346
    $temp->add(new \core_admin\local\settings\manage_payment_gateway_plugins());
347
    $temp->add(new admin_setting_description(
348
        'managepaymentgatewayspostfix',
349
        '',
350
        new lang_string('gotopaymentaccounts', 'payment',
351
            html_writer::link(new moodle_url('/payment/accounts.php'), get_string('paymentaccounts', 'payment')))
352
    ));
353
    $ADMIN->add('paymentgateways', $temp);
354
 
355
    $plugins = core_plugin_manager::instance()->get_plugins_of_type('paygw');
356
    core_collator::asort_objects_by_property($plugins, 'displayname');
357
    foreach ($plugins as $plugin) {
358
        /** @var \core\plugininfo\paygw $plugin */
359
        $plugin->load_settings($ADMIN, 'paymentgateways', $hassiteconfig);
360
    }
361
 
362
    // Data format settings.
363
    $ADMIN->add('modules', new admin_category('dataformatsettings', new lang_string('dataformats')));
364
    $temp = new admin_settingpage('managedataformats', new lang_string('managedataformats'));
365
    $temp->add(new admin_setting_managedataformats());
366
    $ADMIN->add('dataformatsettings', $temp);
367
 
368
    $plugins = core_plugin_manager::instance()->get_plugins_of_type('dataformat');
369
    core_collator::asort_objects_by_property($plugins, 'displayname');
370
    foreach ($plugins as $plugin) {
371
        /** @var \core\plugininfo\dataformat $plugin */
372
        $plugin->load_settings($ADMIN, 'dataformatsettings', $hassiteconfig);
373
    }
374
 
375
    //== Portfolio settings ==
376
    require_once($CFG->libdir. '/portfoliolib.php');
377
    $catname = new lang_string('portfolios', 'portfolio');
378
    $manage = new lang_string('manageportfolios', 'portfolio');
379
    $url = "$CFG->wwwroot/$CFG->admin/portfolio.php";
380
 
381
    $ADMIN->add('modules', new admin_category('portfoliosettings', $catname, empty($CFG->enableportfolios)));
382
 
383
    // Add manage page (with table)
384
    $temp = new admin_page_manageportfolios();
385
    $ADMIN->add('portfoliosettings', $temp);
386
 
387
    // Add common settings page
388
    $temp = new admin_settingpage('manageportfolioscommon', new lang_string('commonportfoliosettings', 'portfolio'));
389
    $temp->add(new admin_setting_heading('manageportfolioscommon', '', new lang_string('commonsettingsdesc', 'portfolio')));
390
    $fileinfo = portfolio_filesize_info(); // make sure this is defined in one place since its used inside portfolio too to detect insane settings
391
    $fileoptions = $fileinfo['options'];
392
    $temp->add(new admin_setting_configselect(
393
        'portfolio_moderate_filesize_threshold',
394
        new lang_string('moderatefilesizethreshold', 'portfolio'),
395
        new lang_string('moderatefilesizethresholddesc', 'portfolio'),
396
        $fileinfo['moderate'], $fileoptions));
397
    $temp->add(new admin_setting_configselect(
398
        'portfolio_high_filesize_threshold',
399
        new lang_string('highfilesizethreshold', 'portfolio'),
400
        new lang_string('highfilesizethresholddesc', 'portfolio'),
401
        $fileinfo['high'], $fileoptions));
402
 
403
    $temp->add(new admin_setting_configtext(
404
        'portfolio_moderate_db_threshold',
405
        new lang_string('moderatedbsizethreshold', 'portfolio'),
406
        new lang_string('moderatedbsizethresholddesc', 'portfolio'),
407
        20, PARAM_INT, 3));
408
 
409
    $temp->add(new admin_setting_configtext(
410
        'portfolio_high_db_threshold',
411
        new lang_string('highdbsizethreshold', 'portfolio'),
412
        new lang_string('highdbsizethresholddesc', 'portfolio'),
413
        50, PARAM_INT, 3));
414
 
415
    $ADMIN->add('portfoliosettings', $temp);
416
    $ADMIN->add('portfoliosettings', new admin_externalpage('portfolionew', new lang_string('addnewportfolio', 'portfolio'), $url, 'moodle/site:config', true));
417
    $ADMIN->add('portfoliosettings', new admin_externalpage('portfoliodelete', new lang_string('deleteportfolio', 'portfolio'), $url, 'moodle/site:config', true));
418
    $ADMIN->add('portfoliosettings', new admin_externalpage('portfoliocontroller', new lang_string('manageportfolios', 'portfolio'), $url, 'moodle/site:config', true));
419
 
420
    foreach (portfolio_instances(false, false) as $portfolio) {
421
        require_once($CFG->dirroot . '/portfolio/' . $portfolio->get('plugin') . '/lib.php');
422
        $classname = 'portfolio_plugin_' . $portfolio->get('plugin');
423
        $ADMIN->add(
424
            'portfoliosettings',
425
            new admin_externalpage(
426
                'portfoliosettings' . $portfolio->get('id'),
427
                $portfolio->get('name'),
428
                $url . '?action=edit&pf=' . $portfolio->get('id'),
429
                'moodle/site:config'
430
            )
431
        );
432
    }
433
 
434
    // repository setting
435
    require_once("$CFG->dirroot/repository/lib.php");
436
    $catname =new lang_string('repositories', 'repository');
437
    $managerepo = new lang_string('manage', 'repository');
438
    $url = $CFG->wwwroot.'/'.$CFG->admin.'/repository.php';
439
    $ADMIN->add('modules', new admin_category('repositorysettings', $catname));
440
 
441
    // Add main page (with table)
442
    $temp = new admin_page_managerepositories();
443
    $ADMIN->add('repositorysettings', $temp);
444
 
445
    // Add common settings page
446
    $temp = new admin_settingpage('managerepositoriescommon', new lang_string('commonrepositorysettings', 'repository'));
447
    $temp->add(new admin_setting_configtext('repositorycacheexpire', new lang_string('cacheexpire', 'repository'), new lang_string('configcacheexpire', 'repository'), 120, PARAM_INT));
448
    $temp->add(new admin_setting_configtext('repositorygetfiletimeout', new lang_string('getfiletimeout', 'repository'), new lang_string('configgetfiletimeout', 'repository'), 30, PARAM_INT));
449
    $temp->add(new admin_setting_configtext('repositorysyncfiletimeout', new lang_string('syncfiletimeout', 'repository'), new lang_string('configsyncfiletimeout', 'repository'), 1, PARAM_INT));
450
    $temp->add(new admin_setting_configtext('repositorysyncimagetimeout', new lang_string('syncimagetimeout', 'repository'), new lang_string('configsyncimagetimeout', 'repository'), 3, PARAM_INT));
451
    $temp->add(new admin_setting_configcheckbox('repositoryallowexternallinks', new lang_string('allowexternallinks', 'repository'), new lang_string('configallowexternallinks', 'repository'), 1));
452
    $temp->add(new admin_setting_configcheckbox('legacyfilesinnewcourses', new lang_string('legacyfilesinnewcourses', 'admin'), new lang_string('legacyfilesinnewcourses_help', 'admin'), 0));
453
    $temp->add(new admin_setting_configcheckbox('legacyfilesaddallowed', new lang_string('legacyfilesaddallowed', 'admin'), new lang_string('legacyfilesaddallowed_help', 'admin'), 1));
454
    $ADMIN->add('repositorysettings', $temp);
455
    $ADMIN->add('repositorysettings', new admin_externalpage('repositorynew',
456
        new lang_string('addplugin', 'repository'), $url, 'moodle/site:config', true));
457
    $ADMIN->add('repositorysettings', new admin_externalpage('repositorydelete',
458
        new lang_string('deleterepository', 'repository'), $url, 'moodle/site:config', true));
459
    $ADMIN->add('repositorysettings', new admin_externalpage('repositorycontroller',
460
        new lang_string('manage', 'repository'), $url, 'moodle/site:config', true));
461
    $ADMIN->add('repositorysettings', new admin_externalpage('repositoryinstancenew',
462
        new lang_string('createrepository', 'repository'), $url, 'moodle/site:config', true));
463
    $ADMIN->add('repositorysettings', new admin_externalpage('repositoryinstanceedit',
464
        new lang_string('editrepositoryinstance', 'repository'), $url, 'moodle/site:config', true));
465
    $plugins = core_plugin_manager::instance()->get_plugins_of_type('repository');
466
    core_collator::asort_objects_by_property($plugins, 'displayname');
467
    foreach ($plugins as $plugin) {
468
        /** @var \core\plugininfo\repository $plugin */
469
        $plugin->load_settings($ADMIN, 'repositorysettings', $hassiteconfig);
470
    }
471
}
472
 
473
// Question bank settings.
474
if ($hassiteconfig || has_capability('moodle/question:config', $systemcontext)) {
475
    $ADMIN->add('modules', new admin_category('qbanksettings',
476
            new lang_string('type_qbank_plural', 'plugin')));
477
    $temp = new admin_settingpage('manageqbanks', new lang_string('manageqbanks', 'admin'));
478
    $temp->add(new \core_question\admin\manage_qbank_plugins_page());
479
    $ADMIN->add('qbanksettings', $temp);
480
    $plugins = core_plugin_manager::instance()->get_plugins_of_type('qbank');
481
 
482
    foreach ($plugins as $plugin) {
483
        /** @var \core\plugininfo\qbank $plugin */
484
        $plugin->load_settings($ADMIN, 'qbanksettings', $hassiteconfig);
485
    }
486
}
487
 
488
// Question type settings
489
if ($hassiteconfig || has_capability('moodle/question:config', $systemcontext)) {
490
 
491
    // Question behaviour settings.
492
    $ADMIN->add('modules', new admin_category('qbehavioursettings', new lang_string('questionbehaviours', 'admin')));
493
    $ADMIN->add('qbehavioursettings', new admin_page_manageqbehaviours());
494
 
495
    // Question type settings.
496
    $ADMIN->add('modules', new admin_category('qtypesettings', new lang_string('questiontypes', 'admin')));
497
    $ADMIN->add('qtypesettings', new admin_page_manageqtypes());
498
 
499
    // Question preview defaults.
500
    $settings = new admin_settingpage('qdefaultsetting',
501
            get_string('questionpreviewdefaults', 'question'),
502
            'moodle/question:config');
503
    $ADMIN->add('qtypesettings', $settings);
504
 
505
    $settings->add(new admin_setting_heading('qdefaultsetting_preview_options',
506
            '', get_string('questionpreviewdefaults_desc', 'question')));
507
 
508
    // These keys are question_display_options::HIDDEN and VISIBLE.
509
    $hiddenofvisible = array(
510
 
511
        1 => get_string('shown', 'question'),
512
    );
513
 
514
    $settings->add(new admin_setting_question_behaviour('question_preview/behaviour',
515
            get_string('howquestionsbehave', 'question'), '',
516
                    'deferredfeedback'));
517
 
518
    $settings->add(new admin_setting_configselect('question_preview/correctness',
519
            get_string('whethercorrect', 'question'), '', 1, $hiddenofvisible));
520
 
521
    // These keys are question_display_options::HIDDEN, MARK_ONLY and MARK_AND_MAX.
522
    $marksoptions = array(
523
 
524
        1 => get_string('showmaxmarkonly', 'question'),
525
        2 => get_string('showmarkandmax', 'question'),
526
    );
527
    $settings->add(new admin_setting_configselect('question_preview/marks',
528
            get_string('marks', 'question'), '', 2, $marksoptions));
529
 
530
    $settings->add(new admin_setting_configselect('question_preview/markdp',
531
            get_string('decimalplacesingrades', 'question'), '', 2, array(0, 1, 2, 3, 4, 5, 6, 7)));
532
 
533
    $settings->add(new admin_setting_configselect('question_preview/feedback',
534
            get_string('specificfeedback', 'question'), '', 1, $hiddenofvisible));
535
 
536
    $settings->add(new admin_setting_configselect('question_preview/generalfeedback',
537
            get_string('generalfeedback', 'question'), '', 1, $hiddenofvisible));
538
 
539
    $settings->add(new admin_setting_configselect('question_preview/rightanswer',
540
            get_string('rightanswer', 'question'), '', 1, $hiddenofvisible));
541
 
542
    $settings->add(new admin_setting_configselect('question_preview/history',
543
            get_string('responsehistory', 'question'), '', 0, $hiddenofvisible));
544
 
545
    // Settings for particular question types.
546
    $plugins = core_plugin_manager::instance()->get_plugins_of_type('qtype');
547
    core_collator::asort_objects_by_property($plugins, 'displayname');
548
    foreach ($plugins as $plugin) {
549
        /** @var \core\plugininfo\qtype $plugin */
550
        $plugin->load_settings($ADMIN, 'qtypesettings', $hassiteconfig);
551
    }
552
}
553
 
554
// Plagiarism plugin settings
555
if ($hassiteconfig && !empty($CFG->enableplagiarism)) {
556
    $ADMIN->add('modules', new admin_category('plagiarism', new lang_string('plagiarism', 'plagiarism')));
557
    $ADMIN->add('plagiarism', new admin_externalpage('manageplagiarismplugins', new lang_string('manageplagiarism', 'plagiarism'),
558
        $CFG->wwwroot . '/' . $CFG->admin . '/plagiarism.php'));
559
 
560
    $plugins = core_plugin_manager::instance()->get_plugins_of_type('plagiarism');
561
    core_collator::asort_objects_by_property($plugins, 'displayname');
562
    foreach ($plugins as $plugin) {
563
        /** @var \core\plugininfo\plagiarism $plugin */
564
        $plugin->load_settings($ADMIN, 'plagiarism', $hassiteconfig);
565
    }
566
}
567
 
568
// Comments report, note this page is really just a means to delete comments so check that.
569
$ADMIN->add('reports', new admin_externalpage('comments', new lang_string('comments'), $CFG->wwwroot . '/comment/index.php',
570
    'moodle/comment:delete'));
571
 
572
// Course reports settings
573
if ($hassiteconfig) {
574
    $pages = array();
575
    foreach (core_component::get_plugin_list('coursereport') as $report => $path) {
576
        $file = $CFG->dirroot . '/course/report/' . $report . '/settings.php';
577
        if (file_exists($file)) {
578
            $settings = new admin_settingpage('coursereport' . $report,
579
                    new lang_string('pluginname', 'coursereport_' . $report), 'moodle/site:config');
580
            // settings.php may create a subcategory or unset the settings completely
581
            include($file);
582
            if ($settings) {
583
                $pages[] = $settings;
584
            }
585
        }
586
    }
587
    if (!empty($pages)) {
588
        $ADMIN->add('modules', new admin_category('coursereports', new lang_string('coursereports')));
589
        core_collator::asort_objects_by_property($pages, 'visiblename');
590
        foreach ($pages as $page) {
591
            $ADMIN->add('coursereports', $page);
592
        }
593
    }
594
    unset($pages);
595
}
596
 
597
// Now add reports
598
$pages = array();
599
foreach (core_component::get_plugin_list('report') as $report => $plugindir) {
600
    $settings_path = "$plugindir/settings.php";
601
    if (file_exists($settings_path)) {
602
        $settings = new admin_settingpage('report' . $report,
603
                new lang_string('pluginname', 'report_' . $report), 'moodle/site:config');
604
        include($settings_path);
605
        if ($settings) {
606
            $pages[] = $settings;
607
        }
608
    }
609
}
610
$ADMIN->add('modules', new admin_category('reportplugins', new lang_string('reports')));
611
$ADMIN->add('reportplugins', new admin_externalpage('managereports', new lang_string('reportsmanage', 'admin'),
612
                                                    $CFG->wwwroot . '/' . $CFG->admin . '/reports.php'));
613
core_collator::asort_objects_by_property($pages, 'visiblename');
614
foreach ($pages as $page) {
615
    $ADMIN->add('reportplugins', $page);
616
}
617
 
618
if ($hassiteconfig) {
619
    // Global Search engine plugins.
620
    $ADMIN->add('modules', new admin_category('searchplugins', new lang_string('search', 'admin')));
621
    $temp = new admin_settingpage('manageglobalsearch', new lang_string('globalsearchmanage', 'admin'));
622
 
623
    $pages = array();
624
    $engines = array();
625
    foreach (core_component::get_plugin_list('search') as $engine => $plugindir) {
626
        $engines[$engine] = new lang_string('pluginname', 'search_' . $engine);
627
        $settingspath = "$plugindir/settings.php";
628
        if (file_exists($settingspath)) {
629
            $settings = new admin_settingpage('search' . $engine,
630
                    new lang_string('pluginname', 'search_' . $engine), 'moodle/site:config');
631
            include($settingspath);
632
            if ($settings) {
633
                $pages[] = $settings;
634
            }
635
        }
636
    }
637
 
638
    // Setup status.
639
    $temp->add(new admin_setting_searchsetupinfo());
640
 
641
    // Search engine selection.
642
    $temp->add(new admin_setting_heading('searchengineheading', new lang_string('searchengine', 'admin'), ''));
643
    $searchengineselect = new admin_setting_configselect('searchengine',
644
            new lang_string('selectsearchengine', 'admin'), '', 'simpledb', $engines);
645
    $searchengineselect->set_validate_function(function(string $value): string {
646
        global $CFG;
647
 
648
        // Check nobody's setting the indexing and query-only server to the same one.
649
        if (isset($CFG->searchenginequeryonly) && $CFG->searchenginequeryonly === $value) {
650
            return get_string('searchenginequeryonlysame', 'admin');
651
        } else {
652
            return '';
653
        }
654
    });
655
    $temp->add($searchengineselect);
656
    $temp->add(new admin_setting_heading('searchoptionsheading', new lang_string('searchoptions', 'admin'), ''));
657
    $temp->add(new admin_setting_configcheckbox('searchindexwhendisabled',
658
            new lang_string('searchindexwhendisabled', 'admin'), new lang_string('searchindexwhendisabled_desc', 'admin'),
659
            0));
660
    $temp->add(new admin_setting_configduration('searchindextime',
661
            new lang_string('searchindextime', 'admin'), new lang_string('searchindextime_desc', 'admin'),
662
            600));
663
    $temp->add(new admin_setting_heading('searchcoursesheading', new lang_string('searchablecourses', 'admin'), ''));
664
    $options = [
665
 
666
        1 => new lang_string('searchallavailablecourses_on', 'admin')
667
    ];
668
    $temp->add(new admin_setting_configselect('searchallavailablecourses',
669
            new lang_string('searchallavailablecourses', 'admin'),
670
            new lang_string('searchallavailablecoursesdesc', 'admin'),
671
            0, $options));
672
    $temp->add(new admin_setting_configcheckbox('searchincludeallcourses',
673
        new lang_string('searchincludeallcourses', 'admin'), new lang_string('searchincludeallcourses_desc', 'admin'),
674
        0));
675
 
676
    // Search display options.
677
    $temp->add(new admin_setting_heading('searchdisplay', new lang_string('searchdisplay', 'admin'), ''));
678
    $temp->add(new admin_setting_configcheckbox('searchenablecategories',
679
        new lang_string('searchenablecategories', 'admin'),
680
        new lang_string('searchenablecategories_desc', 'admin'),
681
        0));
682
    $options = [];
683
    foreach (\core_search\manager::get_search_area_categories() as $category) {
684
        $options[$category->get_name()] = $category->get_visiblename();
685
    }
686
    $temp->add(new admin_setting_configselect('searchdefaultcategory',
687
        new lang_string('searchdefaultcategory', 'admin'),
688
        new lang_string('searchdefaultcategory_desc', 'admin'),
689
        \core_search\manager::SEARCH_AREA_CATEGORY_ALL, $options));
690
    $temp->add(new admin_setting_configcheckbox('searchhideallcategory',
691
        new lang_string('searchhideallcategory', 'admin'),
692
        new lang_string('searchhideallcategory_desc', 'admin'),
693
        0));
694
 
695
    // Top result options.
696
    $temp->add(new admin_setting_heading('searchtopresults', new lang_string('searchtopresults', 'admin'), ''));
697
    // Max Top results.
698
    $options = range(0, 10);
699
    $temp->add(new admin_setting_configselect('searchmaxtopresults',
700
        new lang_string('searchmaxtopresults', 'admin'),
701
        new lang_string('searchmaxtopresults_desc', 'admin'),
702
        3, $options));
703
    // Teacher roles.
704
    $options = [];
705
    foreach (role_get_names() as $role) {
706
        $options[$role->id] = $role->localname;
707
    }
708
    $temp->add(new admin_setting_configmultiselect('searchteacherroles',
709
        new lang_string('searchteacherroles', 'admin'),
710
        new lang_string('searchteacherroles_desc', 'admin'),
711
        [], $options));
712
 
713
    $temp->add(new admin_setting_heading('searchmanagement', new lang_string('searchmanagement', 'admin'),
714
            new lang_string('searchmanagement_desc', 'admin')));
715
 
716
    // Get list of search engines including those with alternate settings.
717
    $searchenginequeryonlyselect = new admin_setting_configselect('searchenginequeryonly',
718
            new lang_string('searchenginequeryonly', 'admin'),
719
            new lang_string('searchenginequeryonly_desc', 'admin'), '', function() use($engines) {
720
                $options = ['' => new lang_string('searchenginequeryonly_none', 'admin')];
721
                foreach ($engines as $name => $display) {
722
                    $options[$name] = $display;
723
 
724
                    $classname = '\search_' . $name . '\engine';
725
                    $engine = new $classname;
726
                    if ($engine->has_alternate_configuration()) {
727
                        $options[$name . '-alternate'] =
728
                                new lang_string('searchenginealternatesettings', 'admin', $display);
729
                    }
730
                }
731
                return $options;
732
            });
733
    $searchenginequeryonlyselect->set_validate_function(function(string $value): string {
734
        global $CFG;
735
 
736
        // Check nobody's setting the indexing and query-only server to the same one.
737
        if (isset($CFG->searchengine) && $CFG->searchengine === $value) {
738
            return get_string('searchenginequeryonlysame', 'admin');
739
        } else {
740
            return '';
741
        }
742
    });
743
    $temp->add($searchenginequeryonlyselect);
744
    $temp->add(new admin_setting_configcheckbox('searchbannerenable',
745
            new lang_string('searchbannerenable', 'admin'), new lang_string('searchbannerenable_desc', 'admin'),
746
            0));
747
    $temp->add(new admin_setting_confightmleditor('searchbanner',
748
            new lang_string('searchbanner', 'admin'), '', ''));
749
 
750
    $ADMIN->add('searchplugins', $temp);
751
    $ADMIN->add('searchplugins', new admin_externalpage('searchareas', new lang_string('searchareas', 'admin'),
752
        new moodle_url('/admin/searchareas.php')));
753
 
754
    core_collator::asort_objects_by_property($pages, 'visiblename');
755
    foreach ($pages as $page) {
756
        $ADMIN->add('searchplugins', $page);
757
    }
758
}
759
 
760
/// Add all admin tools
761
if ($hassiteconfig) {
762
    $ADMIN->add('modules', new admin_category('tools', new lang_string('tools', 'admin')));
763
    $settingspage = new admin_settingpage('toolsmanagement', new lang_string('toolsmanage', 'admin'));
764
    $ADMIN->add('tools', $settingspage);
765
    $settingspage->add(new \core_admin\admin\admin_setting_plugin_manager(
766
        'tool',
767
        \core_admin\table\tool_plugin_management_table::class,
768
        'managetools',
769
        new lang_string('toolsmanage', 'admin')
770
    ));
771
}
772
 
773
// Now add various admin tools.
774
$plugins = core_plugin_manager::instance()->get_plugins_of_type('tool');
775
core_collator::asort_objects_by_property($plugins, 'displayname');
776
foreach ($plugins as $plugin) {
777
    /** @var \core\plugininfo\tool $plugin */
778
    $plugin->load_settings($ADMIN, null, $hassiteconfig);
779
}
780
 
781
// Now add the Cache plugins
782
if ($hassiteconfig) {
783
    $ADMIN->add('modules', new admin_category('cache', new lang_string('caching', 'cache')));
784
    $ADMIN->add('cache', new admin_externalpage('cacheconfig', new lang_string('cacheconfig', 'cache'), $CFG->wwwroot .'/cache/admin.php'));
785
    $ADMIN->add('cache', new admin_externalpage('cachetestperformance', new lang_string('testperformance', 'cache'), $CFG->wwwroot . '/cache/testperformance.php'));
786
    $ADMIN->add('cache', new admin_externalpage('cacheusage',
787
            new lang_string('cacheusage', 'cache'), $CFG->wwwroot . '/cache/usage.php'));
788
    $ADMIN->add('cache', new admin_category('cachestores', new lang_string('cachestores', 'cache')));
789
    $ADMIN->locate('cachestores')->set_sorting(true);
790
    foreach (core_component::get_plugin_list('cachestore') as $plugin => $path) {
791
        $settingspath = $path.'/settings.php';
792
        if (file_exists($settingspath)) {
793
            $settings = new admin_settingpage('cachestore_'.$plugin.'_settings', new lang_string('pluginname', 'cachestore_'.$plugin), 'moodle/site:config');
794
            include($settingspath);
795
            $ADMIN->add('cachestores', $settings);
796
        }
797
    }
798
}
799
 
800
// Add Calendar type settings.
801
if ($hassiteconfig) {
802
    $ADMIN->add('modules', new admin_category('calendartype', new lang_string('calendartypes', 'calendar')));
803
    $plugins = core_plugin_manager::instance()->get_plugins_of_type('calendartype');
804
    core_collator::asort_objects_by_property($plugins, 'displayname');
805
    foreach ($plugins as $plugin) {
806
        /** @var \core\plugininfo\calendartype $plugin */
807
        $plugin->load_settings($ADMIN, 'calendartype', $hassiteconfig);
808
    }
809
}
810
 
811
// Communication plugins.
812
if ($hassiteconfig && core_communication\api::is_available()) {
813
    $ADMIN->add('modules', new admin_category('communicationsettings', new lang_string('communication', 'core_communication')));
814
    $temp = new admin_settingpage('managecommunicationproviders',
815
        new lang_string('managecommunicationproviders', 'core_communication'));
816
    $temp->add(new \core_communication\admin\manage_communication_providers_page());
817
    $ADMIN->add('communicationsettings', $temp);
818
    $plugins = core_plugin_manager::instance()->get_plugins_of_type('communication');
819
    foreach ($plugins as $plugin) {
820
        /** @var \core\plugininfo\communication $plugin */
821
        $plugin->load_settings($ADMIN, 'communicationsettings', $hassiteconfig);
822
    }
823
}
824
 
825
// Content bank content types.
826
if ($hassiteconfig) {
827
    $ADMIN->add('modules', new admin_category('contentbanksettings', new lang_string('contentbank')));
828
    $temp = new admin_settingpage('managecontentbanktypes', new lang_string('managecontentbanktypes'));
829
    $temp->add(new admin_setting_managecontentbankcontenttypes());
830
    $ADMIN->add('contentbanksettings', $temp);
831
    $plugins = core_plugin_manager::instance()->get_plugins_of_type('contenttype');
832
    foreach ($plugins as $plugin) {
833
        /** @var \core\plugininfo\contentbank $plugin */
834
        $plugin->load_settings($ADMIN, 'contentbanksettings', $hassiteconfig);
835
    }
836
}
837
 
838
/// Add all local plugins - must be always last!
839
if ($hassiteconfig) {
840
    $ADMIN->add('modules', new admin_category('localplugins', new lang_string('localplugins')));
841
    $ADMIN->add('localplugins', new admin_externalpage('managelocalplugins', new lang_string('localpluginsmanage'),
842
                                                        $CFG->wwwroot . '/' . $CFG->admin . '/localplugins.php'));
843
}
844
 
845
// Extend settings for each local plugin. Note that their settings may be in any part of the
846
// settings tree and may be visible not only for administrators.
847
$plugins = core_plugin_manager::instance()->get_plugins_of_type('local');
848
core_collator::asort_objects_by_property($plugins, 'displayname');
849
foreach ($plugins as $plugin) {
850
    /** @var \core\plugininfo\local $plugin */
851
    $plugin->load_settings($ADMIN, null, $hassiteconfig);
852
}