options.php 51 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 20

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

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

Nigel McNie's avatar
Nigel McNie committed
30 31 32
$yesno = array(true  => get_string('yes'),
               false => get_string('no'));

33 34
$searchpluginoptions = get_search_plugins();

35 36
$countries = getoptions_country();

37
$notificationelements = get_notification_settings_elements(null, true);
38

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

$siteoptionform['elements']['submit'] = array(
    'type'  => 'submit',
Naomi Guyer's avatar
Naomi Guyer committed
762
    'class' => 'btn btn-success mtm',
763 764 765 766
    'value' => get_string('updatesiteoptions', 'admin')
);

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

768
function siteoptions_fail(Pieform $form, $field) {
769 770 771 772
    $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
773 774
}

775
function siteoptions_submit(Pieform $form, $values) {
776
    $fields = array(
777
        'sitename','lang','theme', 'dropdownmenu',
778
        'defaultaccountlifetime', 'defaultregistrationexpirylifetime', 'defaultaccountinactiveexpire', 'defaultaccountinactivewarn',
779
        'defaultaccountlifetimeupdate', 'allowpublicviews', 'allowpublicprofiles', 'allowanonymouspages', 'generatesitemap',
780
        'registration_sendweeklyupdates', 'institutionexpirynotification', 'institutionautosuspend', 'requireregistrationconfirm',
781
        'showselfsearchsideblock', 'nousernames', 'searchplugin', 'showtagssideblock',
782
        'tagssideblockmaxtags', 'country', 'viewmicroheaders', 'userscanchooseviewthemes',
783 784
        'remoteavatars', 'userscanhiderealnames', 'antispam', 'spamhaus', 'surbl', 'anonymouscomments',
        'recaptchaonregisterform', 'recaptchapublickey', 'recaptchaprivatekey', 'loggedinprofileviewaccess', 'disableexternalresources',
785
        'proxyaddress', 'proxyauthmodel', 'proxyauthcredentials', 'smtphosts', 'smtpport', 'smtpuser', 'smtppass', 'smtpsecure',
786
        'noreplyaddress', 'homepageinfo', 'showprogressbar', 'showonlineuserssideblock', 'onlineuserssideblockmaxusers',
787
        'registerterms', 'licensemetadata', 'licenseallowcustom', 'allowmobileuploads', 'creategroups', 'createpublicgroups', 'allowgroupcategories', 'wysiwyg',
788
        'staffreports', 'staffstats', 'userscandisabledevicedetection', 'watchlistnotification_delay',
789
        'masqueradingreasonrequired', 'masqueradingnotified', 'searchuserspublic',
790
        'eventloglevel', 'eventlogexpiry', 'sitefilesaccess', 'exporttoqueue', 'defaultmultipleblogs',
791
    );
792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823