options.php 51.2 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

30
31
$searchpluginoptions = get_search_plugins();

32
33
$countries = getoptions_country();

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

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

$siteoptionform['elements']['submit'] = array(
764
765
    'type'  => 'button',
    'usebuttontag' => true,
766
    'class' => 'btn-primary',
767
768
769
770
    'value' => get_string('updatesiteoptions', 'admin')
);

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

772
function siteoptions_fail(Pieform $form, $field) {
773
774
775
776
    $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
777
778
}

779
function siteoptions_submit(Pieform $form, $values) {
780
    $fields = array(
781
        'sitename','lang','theme', 'dropdownmenu',
782
        'defaultaccountlifetime', 'defaultregistrationexpirylifetime', 'defaultaccountinactiveexpire', 'defaultaccountinactivewarn',
783
        'defaultaccountlifetimeupdate', 'allowpublicviews', 'allowpublicprofiles', 'allowanonymouspages', 'generatesitemap',
784
        'registration_sendweeklyupdates', 'mathjax', 'institutionexpirynotification', 'institutionautosuspend', 'requireregistrationconfirm',
785
        'showselfsearchsideblock', 'nousernames', 'searchplugin', 'showtagssideblock',
786
        'tagssideblockmaxtags', 'country', 'userscanchooseviewthemes',
787
788
        'remoteavatars', 'userscanhiderealnames', 'antispam', 'spamhaus', 'surbl', 'anonymouscomments',
        'recaptchaonregisterform', 'recaptchapublickey', 'recaptchaprivatekey', 'loggedinprofileviewaccess', 'disableexternalresources',
789
        'proxyaddress', 'proxyauthmodel', 'proxyauthcredentials', 'smtphosts', 'smtpport', 'smtpuser', 'smtppass', 'smtpsecure',
790
        'noreplyaddress', 'homepageinfo', 'showprogressbar', 'showonlineuserssideblock', 'onlineuserssideblockmaxusers',
791
        'registerterms', 'licensemetadata', 'licenseallowcustom', 'allowmobileuploads', 'creategroups', 'createpublicgroups', 'allowgroupcategories', 'wysiwyg',
792
        'staffreports', 'staffstats', 'userscandisabledevicedetection', 'watchlistnotification_delay',
793
        'masqueradingreasonrequired', 'masqueradingnotified', 'searchuserspublic',
794
        'eventloglevel', 'eventlogexpiry', 'sitefilesaccess', 'exporttoqueue', 'defaultmultipleblogs',
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
824
825
826
827
828
829
830
831
    $count = 0;
    $where_sql = " WHERE admin = 0 AND id != 0";
    // if default account lifetime expiry has no end date
    if (empty($values['defaultaccountlifetime'])) {
        if ($values['defaultaccountlifetimeupdate'] == 'all') {
            // need to remove user expiry
            db_begin();
            $count = count_records_sql("SELECT COUNT(*) FROM {usr} $where_sql");
            execute_sql("UPDATE {usr} SET expiry = NULL $where_sql");
            db_commit();
        }
        else {
            // make the 'some' option the same as 'none' as it is meaningless to
            // update existing users without expiry date to having 'no end date'
            $values['defaultaccountlifetimeupdate'] = 'none';
        }
    }
    else {
        // fetch all the users that are not siteadmins
        $user_expiry = mktime(0, 0, 0, date('n'), date('j'), date('Y')) + (int)$values['defaultaccountlifetime'];
        if ($values['defaultaccountlifetimeupdate'] == 'some') {
            // and the user's expiry is not set
            $where_sql .= " AND expiry IS NULL";
            $count = count_records_sql("SELECT COUNT(*) FROM {usr} $where_sql");
            db_begin();
            execute_sql("UPDATE {usr} SET expiry = ? $where_sql", array(format_date($user_expiry)));
            db_commit();
        }
        else if ($values['defaultaccountlifetimeupdate'] == 'all') {
            // and the user's expiry is set
            db_begin();
            $count = count_records_sql("SELECT COUNT(*) FROM {usr} $where_sql");
            execute_sql("UPDATE {usr} SET expiry = ? $where_sql", array(format_date($user_expiry)));
            db_commit();
        }
    }
832
833
834
835
    // if public views are disabled, sitemap generation must also be disabled.
    if ($values['allowpublicviews'] == false) {
        $values['generatesitemap'] = false;
    }
836
837
838
839
    else {
        // Ensure allowpublicprofiles is set as well
        $values['allowpublicprofiles'] = 1;
    }
840

841
    $oldsearchplugin = get_config('searchplugin');
842
    $oldlanguage = get_config('lang');
843
    $oldtheme = get_config('theme');
Nigel McNie's avatar
Nigel McNie committed
844
845
    foreach ($fields as $field) {
        if (!set_config($field, $values[$field])) {
846
            siteoptions_fail($form, $field);
Nigel McNie's avatar
Nigel McNie committed
847
848
        }
    }
849
850
851
852
    if ($oldlanguage != $values['lang']) {
        safe_require('artefact', 'file');
        ArtefactTypeFolder::change_public_folder_name($oldlanguage, $values['lang']);
    }
853

854
855
    save_notification_settings($values, null, true);

856
857
    if ($oldsearchplugin != $values['searchplugin']) {
        // Call the old search plugin's sitewide cleanup method
Aaron Wells's avatar
Aaron Wells committed
858
        safe_require('search', $oldsearchplugin);
859
860
861
        call_static_method(generate_class_name('search', $oldsearchplugin), 'cleanup_sitewide');
        // Call the new search plugin's sitewide initialize method
        safe_require('search', $values['searchplugin']);
862
863
864
        $initialize = call_static_method(generate_class_name('search', $values['searchplugin']), 'initialize_sitewide');
        if (!$initialize) {
            $form->reply(PIEFORM_ERR, array(
865
                'message' => get_string('searchconfigerror1', 'admin', $values['searchplugin']),
866
867
868
                'goto'    => '/admin/site/options.php',
            ));
        }
869
    }
870
871
872
873
874
875
876
877
878
    // Call the new search plugin's can connect
    safe_require('search', $values['searchplugin']);
    $connect = call_static_method(generate_class_name('search', $values['searchplugin']), 'can_connect');
    if (!$connect) {
        $form->reply(PIEFORM_ERR, array(
            'message' => get_string('searchconfigerror1', 'admin', $values['searchplugin']),
            'goto'    => '/admin/site/options.php',
        ));
    }
879

Nigel McNie's avatar
Nigel McNie committed
880
881
    // submitted sessionlifetime is in minutes; db entry session_timeout is in seconds
    if (!set_config('session_timeout', $values['sessionlifetime'] * 60)) {
882
        siteoptions_fail($form, 'sessionlifetime');
Nigel McNie's avatar
Nigel McNie committed
883
884
    }
    // Submitted value is on/off; database entry should be 1/0
885
886
887
888
    foreach(array('viruschecking', 'usersallowedmultipleinstitutions') as $checkbox) {
        if (!set_config($checkbox, (int) ($values[$checkbox] == 'on'))) {
            siteoptions_fail($form, $checkbox);
        }
Nigel McNie's avatar
Nigel McNie committed
889
    }
890

891
892
    if ($values['viruschecking'] == 'on') {
        $pathtoclam = escapeshellcmd(trim(get_config('pathtoclam')));
893
894
895
896
897
898
899
        if (!$pathtoclam ) {
            $form->reply(PIEFORM_ERR, array(
                'message' => get_string('clamnotset', 'mahara', $pathtoclam),
                'goto'    => '/admin/site/options.php',
            ));
        }
        else if (!file_exists($pathtoclam) && !is_executable($pathtoclam)) {
900
901
902
903
904
905
906
            $form->reply(PIEFORM_ERR, array(
                'message' => get_string('clamlost', 'mahara', $pathtoclam),
                'goto'    => '/admin/site/options.php',
            ));
        }
    }

907
908
909
910
911
912
913
914
915
    if (get_config('recaptchaonregisterform')
            && !(
                    get_config('recaptchapublickey')
                    && get_config('recaptchaprivatekey')
            )
    ) {
        $form->reply(
            PIEFORM_ERR,
            array(
916
                'message' => get_string('recaptchakeysmissing1', 'admin'),
917
918
919
920
                'goto' => '/admin/site/options.php',
            )
        );
    }