options.php 53.7 KB
Newer Older
Nigel McNie's avatar
Nigel McNie committed
1 2 3 4 5
<?php
/**
 *
 * @package    mahara
 * @subpackage admin
6
 * @author     Catalyst IT Ltd
7 8
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
 * @copyright  For copyright information on Mahara, please see the README file distributed with this software.
Nigel McNie's avatar
Nigel McNie committed
9 10 11
 *
 */

12 13
define('INTERNAL', 1);
define('ADMIN', 1);
14
define('MENUITEM', 'configsite/siteoptions');
15 16 17
define('SECTION_PLUGINTYPE', 'core');
define('SECTION_PLUGINNAME', 'admin');
define('SECTION_PAGE', 'siteoptions');
Nigel McNie's avatar
Nigel McNie committed
18 19

require(dirname(dirname(dirname(__FILE__))) . '/init.php');
20
require_once('searchlib.php');
21
require_once('antispam.php');
22
require_once(get_config('libroot') . 'activity.php');
Nigel McNie's avatar
Nigel McNie committed
23
define('TITLE', get_string('siteoptions', 'admin'));
Nigel McNie's avatar
Nigel McNie committed
24 25

$langoptions = get_languages();
26
$themeoptions = get_all_themes();
27 28
unset($themeoptions['custom']); // Only available for institution configurable themes

29 30
$searchpluginoptions = get_search_plugins();

31 32
$countries = getoptions_country();

33
$notificationelements = get_notification_settings_elements(null, true);
34

35 36
validate_theme(get_config('theme'));

37
$spamtraps = available_spam_traps();
38
$siteoptionform = array(
Penny Leach's avatar
Penny Leach committed
39 40
    'name'       => 'siteoptions',
    'jsform'     => true,
Naomi Guyer's avatar
Naomi Guyer committed
41
    'renderer'   => 'div',
Penny Leach's avatar
Penny Leach committed
42 43
    'plugintype' => 'core',
    'pluginname' => 'admin',
44
    'jssuccesscallback' => 'checkReload',
Penny Leach's avatar
Penny Leach committed
45
    'elements'   => array(
46
        'sitesettings' => array(
Naomi Guyer's avatar
Naomi Guyer committed
47
            'iconclass' => 'globe',
48 49
            'type'         => 'fieldset',
            'collapsible'  => true,
50
            'collapsed'    => true,
51 52 53 54 55 56 57 58
            'legend'       => get_string('sitesettingslegend', 'admin'),
            'elements'     => array(
                'sitename' => array(
                    'type'         => 'text',
                    'title'        => get_string('sitename', 'admin'),
                    'description'  => get_string('sitenamedescription', 'admin'),
                    'defaultvalue' => get_config('sitename'),
                    'help'         => true,
59
                    'disabled'     => in_array('sitename', $OVERRIDDEN),
60 61 62 63 64 65 66 67 68
                ),
                'lang' => array(
                    'type'         => 'select',
                    'title'        => get_string('language', 'admin'),
                    'description'  => get_string('sitelanguagedescription', 'admin'),
                    'defaultvalue' => get_config('lang'),
                    'collapseifoneoption' => true,
                    'options'      => $langoptions,
                    'help'         => true,
69
                    'disabled'     => in_array('lang', $OVERRIDDEN),
70 71 72 73 74 75 76 77
                ),
                'country' => array(
                    'type'         => 'select',
                    'title'        => get_string('country', 'admin'),
                    'description'  => get_string('sitecountrydescription', 'admin'),
                    'defaultvalue' => get_config('country'),
                    'options'      => array('' => get_string('nocountryselected')) + $countries,
                    'help'         => true,
78
                    'disabled'     => in_array('country', $OVERRIDDEN),
79 80 81 82 83 84 85 86 87
                ),
                'theme' => array(
                    'type'         => 'select',
                    'title'        => get_string('theme'),
                    'description'  => get_string('sitethemedescription', 'admin'),
                    'defaultvalue' => get_config('theme'),
                    'collapseifoneoption' => true,
                    'options'      => $themeoptions,
                    'help'         => true,
88
                    'disabled'     => in_array('theme', $OVERRIDDEN),
89 90
                ),
                'homepageinfo' => array(
91
                    'type'         => 'switchbox',
92
                    'title'        => get_string('homepageinfo1', 'admin'),
93
                    'description'  => get_string('homepageinfodescription3', 'admin'),
94
                    'defaultvalue' => get_config('homepageinfo'),
95
                    'disabled'     => in_array('homepageinfo', $OVERRIDDEN),
96 97
                ),
                'registration_sendweeklyupdates' => array(
98
                    'type'         => 'switchbox',
99
                    'title'        => get_string('sendweeklyupdates', 'admin'),
100
                    'description'  => get_string('sendweeklyupdatesdescription2', 'admin'),
101 102
                    'defaultvalue' => get_config('registration_sendweeklyupdates'),
                    'help'         => true,
103
                    'disabled'     => in_array('registration_sendweeklyupdates', $OVERRIDDEN),
104
                ),
105 106
            ),
        ),
107
        'usersettings' => array(
Naomi Guyer's avatar
Naomi Guyer committed
108
            'iconclass' => 'user',
109 110
            'type'         => 'fieldset',
            'collapsible'  => true,
111
            'collapsed'    => true,
112 113 114
            'legend'       => get_string('usersettingslegend', 'admin'),
            'elements'     => array(
                'userscanchooseviewthemes' => array(
115
                    'type'         => 'switchbox',
116
                    'title'        => get_string('userscanchooseviewthemes', 'admin'),
117
                    'description'  => get_string('userscanchooseviewthemesdescription1', 'admin'),
118
                    'defaultvalue' => get_config('userscanchooseviewthemes'),
119
                    'disabled'     => in_array('userscanchooseviewthemes', $OVERRIDDEN),
120 121
                ),
                'remoteavatars' => array(
122
                    'type'         => 'switchbox',
123
                    'title'        => get_string('remoteavatars', 'admin'),
124
                    'description'  => get_string('remoteavatarsdescription1', 'admin'),
125 126
                    'defaultvalue' => get_config('remoteavatars'),
                    'help'         => true,
127
                    'disabled'     => in_array('remoteavatars', $OVERRIDDEN),
128 129
                ),
                'userscanhiderealnames' => array(
130
                    'type'         => 'switchbox',
131
                    'title'        => get_string('userscanhiderealnames', 'admin'),
132
                    'description'  => get_string('userscanhiderealnamesdescription1', 'admin'),
133
                    'defaultvalue' => get_config('userscanhiderealnames'),
134
                    'disabled'     => in_array('userscanhiderealnames', $OVERRIDDEN),
135
                ),
136
                'nousernames' => array(
137
                    'type'         => 'switchbox',
138
                    'title'        => get_string('nousernames', 'admin'),
139
                    'description'  => get_string('nousernamesdescription1', 'admin'),
140 141 142
                    'defaultvalue' => get_config('nousernames'),
                    'disabled'     => in_array('nousernames', $OVERRIDDEN),
                ),
143
                'searchuserspublic' => array(
144
                    'type'         => 'switchbox',
145 146 147 148 149
                    'title'        => get_string('searchuserspublic', 'admin'),
                    'description'  => get_string('searchuserspublicdescription', 'admin'),
                    'defaultvalue' => get_config('searchuserspublic'),
                    'disabled'     => in_array('searchuserspublic', $OVERRIDDEN),
                ),
150
                'anonymouscomments' => array(
151
                    'type'         => 'switchbox',
152
                    'title'        => get_string('anonymouscomments', 'admin'),
153
                    'description'  => get_string('anonymouscommentsdescription1', 'admin'),
154
                    'defaultvalue' => get_config('anonymouscomments'),
155
                    'disabled'     => in_array('anonymouscomments', $OVERRIDDEN),
156
                ),
157
                'loggedinprofileviewaccess' => array(
158
                    'type'         => 'switchbox',
159
                    'title'        => get_string('loggedinprofileviewaccess1', 'admin'),
160
                    'description'  => get_string('loggedinprofileviewaccessdescription1', 'admin'),
161 162
                    'defaultvalue' => get_config('loggedinprofileviewaccess'),
                    'disabled'     => in_array('loggedinprofileviewaccess', $OVERRIDDEN),
163
                    'help'         => true,
164
                ),
165
                'staffreports' => array(
166
                    'type'         => 'switchbox',
167
                    'title'        => get_string('staffaccessreports', 'admin'),
168
                    'description'  => get_string('staffaccessreportsdescription1', 'admin'),
169 170 171
                    'defaultvalue' => get_config('staffreports'),
                    'disabled'     => in_array('staffreports', $OVERRIDDEN),
                ),
Hugh Davenport's avatar
Hugh Davenport committed
172
                'staffstats' => array(
173
                    'type'         => 'switchbox',
174 175
                    'title'        => get_string('institutionstaffallreports', 'admin'),
                    'description'  => get_string('institutionstaffallreportsdescription', 'admin'),
Hugh Davenport's avatar
Hugh Davenport committed
176 177 178
                    'defaultvalue' => get_config('staffstats'),
                    'disabled'     => in_array('staffstats', $OVERRIDDEN),
                ),
179
                'userscandisabledevicedetection' => array(
180
                    'type'         => 'switchbox',
181
                    'title'        => get_string('userscandisabledevicedetection', 'admin'),
182
                    'description'  => get_string('userscandisabledevicedetectiondescription1', 'admin'),
183 184 185
                    'defaultvalue' => get_config('userscandisabledevicedetection'),
                    'disabled'     => in_array('userscandisabledevicedetection', $OVERRIDDEN),
                ),
186
                'masqueradingreasonrequired' => array(
187
                    'type'         => 'switchbox',
188
                    'title'        => get_string('masqueradingreasonrequired', 'admin'),
189
                    'description'  => get_string('masqueradingreasonrequireddescription3', 'admin'),
190 191 192 193
                    'defaultvalue' => get_config('masqueradingreasonrequired'),
                    'disabled'     => in_array('masqueradingreasonrequired', $OVERRIDDEN),
                ),
                'masqueradingnotified' => array(
194
                    'type'         => 'switchbox',
195
                    'title'        => get_string('masqueradingnotified', 'admin'),
196
                    'description'  => get_string('masqueradingnotifielddescription', 'admin'),
197 198 199
                    'defaultvalue' => get_config('masqueradingnotified'),
                    'disabled'     => in_array('masqueradingnotified', $OVERRIDDEN),
                ),
200
                'showprogressbar' => array(
201
                    'type'         => 'switchbox',
202
                    'title'        => get_string('showprogressbar', 'admin'),
203
                    'description'  => get_string('showprogressbardescription1', 'admin'),
204 205 206
                    'defaultvalue' => get_config('showprogressbar'),
                    'disabled'     => in_array('showprogressbar', $OVERRIDDEN),
                ),
207
                'exporttoqueue' => array(
208
                    'type'         => 'switchbox',
209
                    'title'        => get_string('exporttoqueue', 'admin'),
210
                    'description'  => get_string('exporttoqueuedescription2', 'admin'),
211 212 213
                    'defaultvalue' => get_config('exporttoqueue'),
                    'disabled'     => in_array('exporttoqueue', $OVERRIDDEN),
                ),
214
                'defaultmultipleblogs' => array(
215
                    'type'         => 'switchbox',
216
                    'title'        => get_string('defaultmultipleblogs', 'admin'),
217
                    'description'  => get_string('defaultmultipleblogsdescription1', 'admin'),
218 219 220
                    'defaultvalue' => get_config('defaultmultipleblogs'),
                    'disabled'     => in_array('defaultmultipleblogs', $OVERRIDDEN),
                ),
221
            ),
222
        ),
223
        'searchsettings' => array(
Naomi Guyer's avatar
Naomi Guyer committed
224
            'iconclass' => 'search',
225 226
            'type'         => 'fieldset',
            'collapsible'  => true,
227
            'collapsed'    => true,
228 229 230 231 232 233 234 235 236 237
            'legend'       => get_string('searchsettingslegend', 'admin'),
            'elements'     => array(
                'searchplugin' => array(
                    'type'         => 'select',
                    'title'        => get_string('searchplugin', 'admin'),
                    'description'  => get_string('searchplugindescription', 'admin'),
                    'defaultvalue' => get_config('searchplugin'),
                    'collapseifoneoption' => true,
                    'options'      => $searchpluginoptions,
                    'help'         => true,
238
                    'disabled'     => in_array('searchplugin', $OVERRIDDEN),
239
                ),
240
            ),
241
        ),
242
        'groupsettings' => array(
Naomi Guyer's avatar
Naomi Guyer committed
243
            'iconclass' => 'users',
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
            'type'         => 'fieldset',
            'collapsible'  => true,
            'collapsed'    => true,
            'legend'       => get_string('groupsettingslegend', 'admin'),
            'elements'     => array(
                'creategroups' => array(
                    'type'         => 'select',
                    'title'        => get_string('whocancreategroups', 'admin'),
                    'description'  => get_string('whocancreategroupsdescription', 'admin'),
                    'defaultvalue' => get_config('creategroups'),
                    'options'      => array(
                        'admins' => get_string('adminsonly', 'admin'),
                        'staff'  => get_string('adminsandstaffonly', 'admin'),
                        'all'    => get_string('Everyone', 'admin'),
                    ),
259
                    'disabled'     => in_array('creategroups', $OVERRIDDEN),
260 261 262 263 264 265 266 267 268 269 270
                ),
                'createpublicgroups' => array(
                    'type'         => 'select',
                    'title'        => get_string('whocancreatepublicgroups', 'admin'),
                    'description'  => get_string('whocancreatepublicgroupsdescription', 'admin'),
                    'defaultvalue' => get_config('createpublicgroups'),
                    'options'      => array(
                        'admins' => get_string('adminsonly', 'admin'),
                        'all' => get_string('Everyone', 'admin'),
                    ),
                    'help'         => true,
271
                    'disabled'     => in_array('createpublicgroups', $OVERRIDDEN),
272 273
                ),
                'allowgroupcategories' => array(
274
                    'type'         => 'switchbox',
275
                    'title'        => get_string('allowgroupcategories', 'admin'),
276
                    'description'  => get_string('allowgroupcategoriesdescription1', 'admin'),
277
                    'defaultvalue' => get_config('allowgroupcategories'),
278
                    'disabled'     => in_array('allowgroupcategories', $OVERRIDDEN),
279 280
                ),
            ),
281
        ),
282
        'institutionsettings' => array(
Naomi Guyer's avatar
Naomi Guyer committed
283
            'iconclass' => 'university',
284 285
            'type'         => 'fieldset',
            'collapsible'  => true,
286
            'collapsed'    => true,
287 288
            'legend'       => get_string('institutionsettingslegend', 'admin'),
            'elements'     => array(
289
                'institutionstrictprivacy' => array(
290
                    'type'         => 'switchbox',
291 292 293
                    'title'        => get_string('institutionstrictprivacy', 'admin'),
                    'description'  => get_string('institutionstrictprivacydescription', 'admin'),
                    'defaultvalue' => get_config('institutionstrictprivacy'),
294
                    'help'         => true,
295
                    'disabled'     => users_in_multiple_institutions() || get_config('usersallowedmultipleinstitutions'),
296
                ),
297
                'usersallowedmultipleinstitutions' => array(
298
                    'type'         => 'switchbox',
299
                    'title'        => get_string('usersallowedmultipleinstitutions', 'admin'),
300
                    'description'  => get_string('usersallowedmultipleinstitutionsdescription1', 'admin'),
301 302
                    'defaultvalue' => get_config('usersallowedmultipleinstitutions'),
                    'help'         => true,
303
                    'disabled'     => in_array('usersallowedmultipleinstitutions', $OVERRIDDEN),
304
                ),
305 306 307 308 309 310 311
                'requireregistrationconfirm' => array(
                  'type'         => 'switchbox',
                  'title'        => get_string('requireregistrationconfirm', 'admin'),
                  'description'  => get_string('requireregistrationconfirmdescription1', 'admin'),
                  'defaultvalue' => get_config('requireregistrationconfirm'),
                  'help'         => true,
                ),
312 313 314
                'institutionexpirynotification' => array(
                    'type'         => 'expiry',
                    'title'        => get_string('institutionexpirynotification', 'admin'),
315
                    'description'  => get_string('institutionexpirynotificationdescriptioninfo', 'admin'),
316 317
                    'defaultvalue' => get_config('institutionexpirynotification'),
                    'help'         => true,
318
                    'disabled'     => in_array('institutionexpirynotification', $OVERRIDDEN),
Naomi Guyer's avatar
Naomi Guyer committed
319
                    'class'        => 'double'
320 321
                ),
                'institutionautosuspend' => array(
322
                    'type'         => 'switchbox',
323
                    'title'        => get_string('institutionautosuspend', 'admin'),
324
                    'description'  => get_string('institutionautosuspenddescription1', 'admin'),
325 326
                    'defaultvalue' => get_config('institutionautosuspend'),
                    'help'         => true,
327
                    'disabled'     => in_array('institutionautosuspend', $OVERRIDDEN),
328 329
                ),
            ),
330
        ),
331
        'accountsettings' => array(
Naomi Guyer's avatar
Naomi Guyer committed
332
            'iconclass'=>'clock-o',
333 334
            'type'         => 'fieldset',
            'collapsible'  => true,
335
            'collapsed'    => true,
336 337 338 339 340 341 342 343
            'legend'       => get_string('accountsettingslegend', 'admin'),
            'elements'     => array(
                'sessionlifetime' => array(
                    'type'         => 'text',
                    'size'         => 4,
                    'title'        => get_string('sessionlifetime', 'admin'),
                    'description'  => get_string('sessionlifetimedescription', 'admin'),
                    'defaultvalue' => get_config('session_timeout') / 60,
344 345
                    // Largest amount allowed is 30 days.
                    'rules'        => array('integer' => true, 'minvalue' => 1, 'maxvalue' => (30 * 24 * 60)),
346
                    'help'         => true,
347
                    'disabled'     => in_array('session_timeout', $OVERRIDDEN),
348
                ),
349 350 351 352 353 354 355
                'defaultregistrationexpirylifetime' => array(
                    'type'         => 'expiry',
                    'title'        => get_string('defaultregistrationexpirylifetime', 'admin'),
                    'description'  => get_string('defaultregistrationexpirylifetimedescription', 'admin'),
                    'defaultvalue' => get_config('defaultregistrationexpirylifetime'),
                    'help'         => false,
                    'disabled'     => in_array('defaultregistrationexpirylifetime', $OVERRIDDEN),
Naomi Guyer's avatar
Naomi Guyer committed
356
                    'class'        => 'double'
357
                ),
358 359 360 361 362 363
                'defaultaccountlifetime' => array(
                    'type'         => 'expiry',
                    'title'        => get_string('defaultaccountlifetime', 'admin'),
                    'description'  => get_string('defaultaccountlifetimedescription', 'admin'),
                    'defaultvalue' => get_config('defaultaccountlifetime'),
                    'help'         => true,
364
                    'disabled'     => in_array('defaultaccountlifetime', $OVERRIDDEN),
Naomi Guyer's avatar
Naomi Guyer committed
365
                    'class'        => 'double'
366
                ),
367 368 369 370 371 372 373 374 375 376 377 378
                'defaultaccountlifetimeupdate' => array(
                    'type'         => 'radio',
                    'title'        => get_string('defaultaccountlifetimeupdate', 'admin'),
                    'description'  => get_string('defaultaccountlifetimeupdatedescription', 'admin'),
                    'defaultvalue' => get_config('defaultaccountlifetimeupdate'),
                    'options'      => array(
                        'none'     => get_string('defaultaccountlifetimeupdatenone', 'admin'),
                        'some'     => get_string('defaultaccountlifetimeupdatesome', 'admin'),
                        'all'      => get_string('defaultaccountlifetimeupdateall', 'admin')
                    ),
                    'help'         => true,
                ),
379 380 381 382 383 384
                'defaultaccountinactiveexpire' => array(
                    'type'         => 'expiry',
                    'title'        => get_string('defaultaccountinactiveexpire', 'admin'),
                    'description'  => get_string('defaultaccountinactiveexpiredescription', 'admin'),
                    'defaultvalue' => get_config('defaultaccountinactiveexpire'),
                    'help'         => true,
385
                    'disabled'     => in_array('defaultaccountinactiveexpire', $OVERRIDDEN),
Naomi Guyer's avatar
Naomi Guyer committed
386
                    'class'        => 'double'
387 388 389 390 391 392 393
                ),
                'defaultaccountinactivewarn' => array(
                    'type'         => 'expiry',
                    'title'        => get_string('defaultaccountinactivewarn', 'admin'),
                    'description'  => get_string('defaultaccountinactivewarndescription', 'admin'),
                    'defaultvalue' => get_config('defaultaccountinactivewarn'),
                    'help'         => true,
394
                    'disabled'     => in_array('defaultaccountinactivewarn', $OVERRIDDEN),
Naomi Guyer's avatar
Naomi Guyer committed
395
                    'class'        => 'double'
396 397
                ),
            ),
398
        ),
399
        'securitysettings' => array(
Naomi Guyer's avatar
Naomi Guyer committed
400
            'iconclass'=>'lock',
401 402
            'type'         => 'fieldset',
            'collapsible'  => true,
403
            'collapsed'    => true,
404 405 406
            'legend'       => get_string('securitysettingslegend', 'admin'),
            'elements'     => array(
                'viruschecking' => array(
407
                    'type'         => 'switchbox',
408
                    'title'        => get_string('viruschecking', 'admin'),
409
                    'description'  => get_string('viruscheckingdescription1', 'admin'),
410 411
                    'defaultvalue' => get_config('viruschecking'),
                    'help'         => true,
412
                    'disabled'     => in_array('viruschecking', $OVERRIDDEN),
413
                ),
414 415 416 417 418 419 420
                'pathtoclam' => array(
                    'type' => 'html',
                    'title' => get_string('pathtoclam', 'admin'),
                    'description' => get_string('pathtoclamdescription', 'admin'),
                    'value' => (get_config('pathtoclam') ? get_config('pathtoclam') : get_string('pathtoclamnotset', 'admin')),
                    'help' => true,
                ),
421 422 423 424 425 426 427
                'antispam' => array(
                    'type'         => 'select',
                    'title'        => get_string('antispam', 'admin'),
                    'description'  => get_string('antispamdescription', 'admin'),
                    'defaultvalue' => get_config('antispam'),
                    'options'      => $spamtraps,
                    'help'         => true,
428
                    'disabled'     => in_array('antispam', $OVERRIDDEN),
429 430
                ),
                'spamhaus' => array(
431 432 433
                    'type'         => 'switchbox',
                    'title'        => get_string('spamhaus1', 'admin'),
                    'description'  => get_string('spamhausdescription1', 'admin'),
434 435
                    'defaultvalue' => get_config('spamhaus'),
                    'help'         => true,
436
                    'disabled'     => in_array('spamhaus', $OVERRIDDEN),
437 438
                ),
                'surbl' => array(
439 440 441
                    'type'         => 'switchbox',
                    'title'        => get_string('surbl1', 'admin'),
                    'description'  => get_string('surbldescription1', 'admin'),
442 443
                    'defaultvalue' => get_config('surbl'),
                    'help'         => true,
444
                    'disabled'     => in_array('surbl', $OVERRIDDEN),
445
                ),
446
                'disableexternalresources' => array(
447
                    'type'         => 'switchbox',
448
                    'title'        => get_string('disableexternalresources', 'admin'),
449
                    'description'  => get_string('disableexternalresourcesdescription1', 'admin'),
450 451 452 453
                    'defaultvalue' => get_config('disableexternalresources'),
                    'help'         => true,
                    'disabled'     => in_array('disableexternalresources', $OVERRIDDEN),
                ),
454
                'recaptchaonregisterform' => array(
455
                    'type' => 'switchbox',
456
                    'title' => get_string('recaptchaonregisterform', 'admin'),
457
                    'description' => get_string('recaptchaonregisterformdesc1', 'admin'),
458
                    'defaultvalue' => get_config('recaptchaonregisterform'),
459 460 461 462 463
                    'help' => true,
                    'disabled' => in_array('recaptchaonregisterform', $OVERRIDDEN)
                ),
                'recaptchapublickey' => array(
                    'type' => 'text',
464 465
                    'title' => get_string('recaptchapublickey1', 'admin'),
                    'description' => get_string('recaptchapublickeydesc1', 'admin'),
466 467 468 469 470
                    'defaultvalue' => get_config('recaptchapublickey'),
                    'disabled' => in_array('recaptchapublickey', $OVERRIDDEN)
                ),
                'recaptchaprivatekey' => array(
                    'type' => 'text',
471 472
                    'title' => get_string('recaptchaprivatekey1', 'admin'),
                    'description' => get_string('recaptchaprivatekeydesc1', 'admin'),
473 474 475
                    'defaultvalue' => get_config('recaptchaprivatekey'),
                    'disabled' => in_array('recaptchaprivatekey', $OVERRIDDEN)
                ),
476
            ),
477
        ),
478 479
        # TODO: this should become "Network Settings" at some point
        'proxysettings' => array(
Naomi Guyer's avatar
Naomi Guyer committed
480
            'iconclass'=>'exchange',
481 482 483 484 485 486 487 488 489 490
            'type'         => 'fieldset',
            'collapsible'  => true,
            'collapsed'    => true,
            'legend'       => get_string('proxysettings', 'admin'),
            'elements'     => array(
                'proxyaddress' => array(
                   'type'          => 'text',
                   'title'         => get_string('proxyaddress', 'admin'),
                   'description'   => get_string('proxyaddressdescription', 'admin'),
                   'defaultvalue'  => get_config('proxyaddress'),
491
                   'disabled'      => in_array('proxyaddress', $OVERRIDDEN),
492 493 494 495 496 497 498
                ),
                'proxyauthmodel' => array(
                    'type'          => 'select',
                    'title'         => get_string('proxyauthmodel', 'admin'),
                    'description'   => get_string('proxyauthmodeldescription', 'admin'),
                    'defaultvalue'  => get_config('proxyauthmodel'),
                    'options'       => array(
499 500
                                        '' => get_string('none', 'admin'),
                                        'basic' => get_string('proxyauthmodelbasic', 'admin'),
501
                                    ),
502
                    'disabled'      => in_array('proxyauthmodel', $OVERRIDDEN),
503 504 505 506 507 508
                ),
                'proxyauthcredentials' => array(
                    'type'          => 'text',
                    'title'         => get_string('proxyauthcredentials', 'admin'),
                    'description'   => get_string('proxyauthcredentialsdescription', 'admin'),
                    'defaultvalue'  => get_config('proxyauthcredentials'),
509
                    'disabled'      => in_array('proxyauthcredentials', $OVERRIDDEN),
510 511 512
                ),
            ),
        ),
513
        'emailsettings' => array(
Naomi Guyer's avatar
Naomi Guyer committed
514
            'iconclass'=>'envelope',
515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543
            'type'         => 'fieldset',
            'collapsible'  => true,
            'collapsed'    => true,
            'legend'       => get_string('emailsettings', 'admin'),
            'elements'     => array(
                'smtphosts' => array(
                   'type'           => 'text',
                   'title'          => get_string('emailsmtphosts', 'admin'),
                   'description'    => get_string('emailsmtphostsdescription', 'admin'),
                   'defaultvalue'   => get_config('smtphosts'),
                   'disabled'       => in_array('smtphosts', $OVERRIDDEN),
                   'help'           => true,
                ),
                'smtpport' => array(
                    'type'          => 'text',
                    'title'         => get_string('emailsmtpport', 'admin'),
                    'description'   => get_string('emailsmtpportdescription', 'admin'),
                    'defaultvalue'  => get_config('smtpport'),
                    'disabled'      => in_array('smtpport', $OVERRIDDEN),
                    'help'          => true,
                ),
                'smtpuser' => array(
                    'type'          => 'text',
                    'title'         => get_string('emailsmtpuser', 'admin'),
                    'description'   => get_string('emailsmtpuserdescription', 'admin'),
                    'defaultvalue'  => get_config('smtpuser'),
                    'disabled'      => in_array('smtpuser', $OVERRIDDEN),
                ),
                'smtppass' => array(
544
                    'type'          => 'password',
545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561
                    'title'         => get_string('emailsmtppass', 'admin'),
                    'defaultvalue'  => get_config('smtppass'),
                    'disabled'      => in_array('smtppass', $OVERRIDDEN),
                ),
                'smtpsecure' => array(
                    'type'          => 'select',
                    'title'         => get_string('emailsmtpsecure', 'admin'),
                    'description'   => get_string('emailsmtpsecuredescription', 'admin'),
                    'defaultvalue'  => get_config('smtpsecure'),
                    'disabled'      => in_array('smtpsecure', $OVERRIDDEN),
                    'options'       => array(
                        '' => get_string('none', 'admin'),
                        'ssl' => get_string('emailsmtpsecuressl', 'admin'),
                        'tls' => get_string('emailsmtpsecuretls', 'admin'),
                        ),
                    'help'          => true,
                ),
562 563 564 565 566 567 568 569
                'noreplyaddress' => array(
                    'type'          => 'text',
                    'title'         => get_string('emailnoreplyaddress', 'admin'),
                    'description'   => get_string('emailnoreplyaddressdescription', 'admin'),
                    'defaultvalue'  => get_config('noreplyaddress'),
                    'disabled'      => in_array('noreplyaddress', $OVERRIDDEN),
                    'help'          => true,
                ),
570 571
            ),
        ),
572
        'notificationsettings' => array(
Naomi Guyer's avatar
Naomi Guyer committed
573
            'iconclass'=>'bell',
574 575 576 577
            'type'         => 'fieldset',
            'collapsible'  => true,
            'collapsed'    => true,
            'legend'       => get_string('notificationsettings', 'admin'),
578 579
            'elements'     => array_merge(
                array(
580 581 582 583 584 585 586 587
                    'internalnotificationexpire' => array(
                        'type' => 'text',
                        'size'         => 4,
                        'title'         => get_string('internalnotificationexpire', 'admin'),
                        'description'   => get_string('internalnotificationexpiredescription', 'admin'),
                        'defaultvalue'  => get_config('internalnotificationexpire') ? get_config('internalnotificationexpire') : 182,
                        'help'          => true,
                    ),
588 589 590 591 592 593 594
                    'activitydescription' => array(
                        'type' => 'html',
                        'class' => 'description',
                        'value' => get_string('notificationsettingsdescription', 'admin'),
                    )
                ),
                $notificationelements),
595
        ),
596
        'generalsettings' => array(
Naomi Guyer's avatar
Naomi Guyer committed
597
            'iconclass'=>'cog',
598 599
            'type'         => 'fieldset',
            'collapsible'  => true,
600
            'collapsed'    => true,
601 602 603
            'legend'       => get_string('generalsettingslegend', 'admin'),
            'elements'     => array(
                'allowpublicviews' => array(
604
                    'type'         => 'switchbox',
605
                    'title'        => get_string('allowpublicviews', 'admin'),
606
                    'description'  => get_string('allowpublicviewsdescription1', 'admin'),
607 608
                    'defaultvalue' => get_config('allowpublicviews'),
                    'help'         => true,
609
                    'disabled'     => in_array('allowpublicviews', $OVERRIDDEN),
610 611
                ),
                'allowpublicprofiles' => array(
612
                    'type'         => 'switchbox',
613
                    'title'        => get_string('allowpublicprofiles', 'admin'),
614
                    'description'  => get_string('allowpublicprofilesdescription1', 'admin'),
615 616
                    'defaultvalue' => get_config('allowpublicprofiles'),
                    'help'         => true,
617
                    'disabled'     => in_array('allowpublicprofiles', $OVERRIDDEN) || get_config('allowpublicviews'),
618
                ),
619
                'allowanonymouspages' => array(
620
                    'type'         => 'switchbox',
621
                    'title'        => get_string('allowanonymouspages', 'admin'),
622
                    'description'  => get_string('allowanonymouspagesdescription1', 'admin'),
623 624 625 626
                    'defaultvalue' => get_config('allowanonymouspages'),
                    'help'         => true,
                    'disabled'     => in_array('allowanonymouspages', $OVERRIDDEN),
                ),
627
                'generatesitemap' => array(
628 629
                    'type'         => 'switchbox',
                    'title'        => get_string('generatesitemap1', 'admin'),
630 631 632 633 634
                    'description'  => get_string('generatesitemapdescription', 'admin'),
                    'defaultvalue' => get_config('generatesitemap'),
                    'help'         => true,
                    'disabled'     => in_array('generatesitemap', $OVERRIDDEN) || !get_config('allowpublicviews'),
                ),
635
                'showselfsearchsideblock' => array(
636 637
                    'type'         => 'switchbox',
                    'title'        => get_string('showselfsearchsideblock1', 'admin'),
638
                    'description'  => get_string('showselfsearchsideblockdescription1', 'admin'),
639 640 641
                    'defaultvalue' => get_config('showselfsearchsideblock'),
                    'disabled'     => in_array('showselfsearchsideblock', $OVERRIDDEN),
                ),
642
                'showtagssideblock' => array(
643 644 645
                    'type'         => 'switchbox',
                    'title'        => get_string('showtagssideblock1', 'admin'),
                    'description'  => get_string('showtagssideblockdescription2', 'admin'),
646
                    'defaultvalue' => get_config('showtagssideblock'),
647
                    'disabled'     => in_array('showtagssideblock', $OVERRIDDEN),
648 649 650 651 652 653 654 655
                ),
                'tagssideblockmaxtags' => array(
                    'type'         => 'text',
                    'size'         => 4,
                    'title'        => get_string('tagssideblockmaxtags', 'admin'),
                    'description'  => get_string('tagssideblockmaxtagsdescription', 'admin'),
                    'defaultvalue' => get_config('tagssideblockmaxtags'),
                    'rules'        => array('integer' => true, 'minvalue' => 0, 'maxvalue' => 1000),
656
                    'disabled'     => in_array('tagssideblockmaxtags', $OVERRIDDEN),
657
                ),
658
                'showonlineuserssideblock' => array(
659
                    'type'         => 'switchbox',
660
                    'title'        => get_string('showonlineuserssideblock', 'admin'),
661
                    'description'  => get_string('showonlineuserssideblockdescriptionmessage1', 'admin'),
662 663
                    'defaultvalue' => get_config('showonlineuserssideblock'),
                    'disabled'     => in_array('showonlineuserssideblock', $OVERRIDDEN),
664
                ),
665 666 667 668 669 670 671 672 673
                'onlineuserssideblockmaxusers' => array(
                    'type'         => 'text',
                    'size'         => 4,
                    'title'        => get_string('onlineuserssideblockmaxusers', 'admin'),
                    'description'  => get_string('onlineuserssideblockmaxusersdescription', 'admin'),
                    'defaultvalue' => get_config('onlineuserssideblockmaxusers'),
                    'rules'        => array('integer' => true, 'minvalue' => 0, 'maxvalue' => 100),
                    'disabled'     => in_array('onlineuserssideblockmaxusers', $OVERRIDDEN),
                ),
674
                'registerterms' => array(
675
                    'type'         => 'switchbox',
676 677 678 679 680
                    'title'        => get_string('registerterms', 'admin'),
                    'description'  => get_string('registertermsdescription', 'admin'),
                    'defaultvalue' => get_config('registerterms'),
                    'disabled'     => in_array('registerterms', $OVERRIDDEN),
                ),
681
                'licensemetadata' => array(
682
                    'type'         => 'switchbox',
683 684 685 686 687 688 689
                    'title'        => get_string('licensemetadata', 'admin'),
                    'description'  => get_string('licensemetadatadescription', 'admin'),
                    'defaultvalue' => get_config('licensemetadata'),
                    'help'         => true,
                    'disabled'     => in_array('licensemetadata', $OVERRIDDEN),
                ),
                'licenseallowcustom' => array(
690 691
                    'type'         => 'switchbox',
                    'title'        => get_string('licenseallowcustom1', 'admin'),
692 693 694 695
                    'description'  => get_string('licenseallowcustomdescription', 'admin'),
                    'defaultvalue' => get_config('licenseallowcustom'),
                    'disabled'     => in_array('licenseallowcustom', $OVERRIDDEN),
                ),
696 697 698 699 700 701 702 703 704 705 706
                'wysiwyg' => array(
                    'type'         => 'select',
                    'title'        => get_string('wysiwyg', 'admin'),
                    'description'  => get_string('wysiwygdescription', 'admin'),
                    'defaultvalue' => get_config('wysiwyg'),
                    'options'      => array(
                                        '' => get_string('wysiwyguserdefined', 'admin'),
                                        'disable' => get_string('disable'),
                                        'enable' => get_string('enable'),
                                    ),
                    'help'         => true,
707
                    'disabled'     => in_array('wysiwyg', $OVERRIDDEN),
708
                ),
709 710 711 712 713 714 715 716
                'mathjax' => array(
                    'type'         => 'switchbox',
                    'title'        => get_string('mathjax', 'admin'),
                    'description'  => get_string('mathjaxdescription', 'admin'),
                    'defaultvalue' => get_config('mathjax'),
                    'help'         => true,
                    'disabled'     => in_array('mathjax', $OVERRIDDEN),
                ),
717
                'sitefilesaccess' => array(
718
                    'type'         => 'switchbox',
719
                    'title'        => get_string('sitefilesaccess', 'admin'),
720
                    'description'  => get_string('sitefilesaccessdescription1', 'admin'),
721 722 723
                    'defaultvalue' => get_config('sitefilesaccess'),
                    'disabled'     => in_array('sitefilesaccess', $OVERRIDDEN),
                ),
724 725 726 727 728 729 730
                'watchlistnotification_delay' => array(
                    'type'         => 'text',
                    'title'        => get_string('watchlistdelaytitle', 'admin'),
                    'description'  => get_string('watchlistdelaydescription', 'admin'),
                    'defaultvalue' => get_config('watchlistnotification_delay'),
                    'disabled'     => in_array('watchlistnotification_delay', $OVERRIDDEN),
                ),
731
            ),
732
        ),
733
        'loggingsettings' => array(
Naomi Guyer's avatar
Naomi Guyer committed
734
            'iconclass'=>'exclamation-triangle',
735
            'class' => 'last',
736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760
            'type'         => 'fieldset',
            'collapsible'  => true,
            'collapsed'    => true,
            'legend'       => get_string('loggingsettingslegend', 'admin'),
            'elements'     => array(
                'eventloglevel' => array(
                    'type'         => 'select',
                    'title'        => get_string('eventloglevel', 'admin'),
                    'description'  => get_string('eventlogleveldescription', 'admin'),
                    'defaultvalue' => get_config('eventloglevel'),
                    'options'      => array(
                        'none' => get_string('eventloglevelnone', 'admin'),
                        'masq' => get_string('eventloglevelmasq', 'admin'),
                        'all' => get_string('eventloglevelall', 'admin'),
                    ),
                    'help'         => true,
                    'disabled'     => in_array('eventloglevel', $OVERRIDDEN),
                ),
                'eventlogexpiry' => array(
                    'type'         => 'expiry',
                    'title'        => get_string('eventlogexpiry', 'admin'),
                    'description'  => get_string('eventlogexpirydescription', 'admin'),
                    'defaultvalue' => get_config('eventlogexpiry'),
                    'help'         => false,
                    'disabled'     => in_array('eventlogexpiry', $OVERRIDDEN),
Naomi Guyer's avatar
Naomi Guyer committed
761
                    'class'        => 'double'
762
                ),
763 764 765
                'eventlogenhancedsearch' => array(
                    'type'         => 'switchbox',
                    'title'        => get_string('eventlogenhancedsearch', 'admin'),
766
                    'description'  => get_string('eventlogenhancedsearchdescription1', 'admin'),
767 768 769 770
                    'defaultvalue' => get_config('eventlogenhancedsearch'),
                    'help'         => true,
                    'disabled'     => (get_config('searchplugin') != 'elasticsearch' || in_array('eventlogenhancedsearch', $OVERRIDDEN)),
                ),
771 772
            ),
        ),
Nigel McNie's avatar
Nigel McNie committed
773
    )
774 775
);

776 777 778 779 780 781 782 783 784 785
if (get_config('dropdownmenuenabled')) {
    $siteoptionform['elements']['sitesettings']['elements']['dropdownmenu'] = array(
        'type'         => 'switchbox',
        'title'        => get_string('dropdownmenu', 'admin'),
        'description'  => get_string('dropdownmenudescription2', 'admin'),
        'defaultvalue' => get_config('dropdownmenu'),
        'disabled'     => in_array('dropdownmenu', $OVERRIDDEN),
    );
}

786
$siteoptionform['elements']['submit'] = array(
787 788
    'type'  => 'button',
    'usebuttontag' => true,
789
    'class' => 'btn-primary',
790 791 792 793
    'value' => get_string('updatesiteoptions', 'admin')
);

$siteoptionform = pieform($siteoptionform);
Nigel McNie's avatar
Nigel McNie committed
794

795
function siteoptions_fail(Pieform $form, $field) {
796 797 798 799
    $form->reply(PIEFORM_ERR, array(
        'message' => get_string('setsiteoptionsfailed', 'admin', get_string($field, 'admin')),
        'goto'    => '/admin/site/options.php',
    ));
Nigel McNie's avatar
Nigel McNie committed
800 801
}

802
function siteoptions_submit(Pieform $form, $values) {
803
    $fields = array(
804
        'sitename','lang','theme',
805
        'defaultaccountlifetime', 'defaultregistrationexpirylifetime', 'defaultaccountinactiveexpire', 'defaultaccountinactivewarn',
806
        'defaultaccountlifetimeupdate', 'allowpublicviews', 'allowpublicprofiles', 'allowanonymouspages', 'generatesitemap',
807
        'registration_sendweeklyupdates', 'mathjax', 'institutionexpirynotification', 'institutionautosuspend', 'requireregistrationconfirm',
808
        'institutionstrictprivacy',
809
        'showselfsearchsideblock', 'nousernames', 'searchplugin', 'showtagssideblock',
810
        'tagssideblockmaxtags', 'country', 'userscanchooseviewthemes', 'internalnotificationexpire',
811 812
        'remoteavatars', 'userscanhiderealnames', 'antispam', 'spamhaus', 'surbl', 'anonymouscomments',
        'recaptchaonregisterform', 'recaptchapublickey', 'recaptchaprivatekey', 'loggedinprofileviewaccess', 'disableexternalresources',
813
        'proxyaddress', 'proxyauthmodel', 'proxyauthcredentials', 'smtphosts', 'smtpport', 'smtpuser', 'smtppass', 'smtpsecure',
814
        'noreplyaddress', 'homepageinfo', 'showprogressbar', 'showonlineuserssideblock', 'onlineuserssideblockmaxusers',
815
        'registerterms', 'licensemetadata', 'licenseallowcustom', 'creategroups', 'createpublicgroups', 'allowgroupcategories', 'wysiwyg',
816
        'staffreports', 'staffstats', 'userscandisabledevicedetection', 'watchlistnotification_delay',
817
        'masqueradingreasonrequired', 'masqueradingnotified', 'searchuserspublic',
818
        'eventloglevel', 'eventlogexpiry', 'eventlogenhancedsearch', 'sitefilesaccess', 'exporttoqueue', 'defaultmultipleblogs',
819
    );
820 821 822
    if (get_config('dropdownmenuenabled')) {
      $fields = array_merge($fields, array('dropdownmenu'));
    }
823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842