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

$siteoptionform['elements']['submit'] = array(
    'type'  => 'submit',
    'value' => get_string('updatesiteoptions', 'admin')
);

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

754
function siteoptions_fail(Pieform $form, $field) {
755
756
757
758
    $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
759
760
}

761
function siteoptions_submit(Pieform $form, $values) {
762
    $fields = array(
763
        'sitename','lang','theme', 'dropdownmenu',
764
        'defaultaccountlifetime', 'defaultregistrationexpirylifetime', 'defaultaccountinactiveexpire', 'defaultaccountinactivewarn',
765
        'defaultaccountlifetimeupdate', 'allowpublicviews', 'allowpublicprofiles', 'allowanonymouspages', 'generatesitemap',
766
        'registration_sendweeklyupdates', 'institutionexpirynotification', 'institutionautosuspend', 'requireregistrationconfirm',
767
        'showselfsearchsideblock', 'nousernames', 'searchplugin', 'showtagssideblock',
768
        'tagssideblockmaxtags', 'country', 'viewmicroheaders', 'userscanchooseviewthemes',
769
770
        'remoteavatars', 'userscanhiderealnames', 'antispam', 'spamhaus', 'surbl', 'anonymouscomments',
        'recaptchaonregisterform', 'recaptchapublickey', 'recaptchaprivatekey', 'loggedinprofileviewaccess', 'disableexternalresources',
771
        'proxyaddress', 'proxyauthmodel', 'proxyauthcredentials', 'smtphosts', 'smtpport', 'smtpuser', 'smtppass', 'smtpsecure',
772
        'noreplyaddress', 'homepageinfo', 'showprogressbar', 'showonlineuserssideblock', 'onlineuserssideblockmaxusers',
773
        'registerterms', 'licensemetadata', 'licenseallowcustom', 'allowmobileuploads', 'creategroups', 'createpublicgroups', 'allowgroupcategories', 'wysiwyg',
774
        'staffreports', 'staffstats', 'userscandisabledevicedetection', 'watchlistnotification_delay',
775
        'masqueradingreasonrequired', 'masqueradingnotified', 'searchuserspublic',
776
        'eventloglevel', 'eventlogexpiry', 'sitefilesaccess', 'exporttoqueue', 'defaultmultipleblogs',
777
    );
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
    $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();
        }
    }
814
815
816
817
    // if public views are disabled, sitemap generation must also be disabled.
    if ($values['allowpublicviews'] == false) {
        $values['generatesitemap'] = false;
    }
818
819
820
821
    else {
        // Ensure allowpublicprofiles is set as well
        $values['allowpublicprofiles'] = 1;
    }
822

823
    $oldsearchplugin = get_config('searchplugin');
824
    $oldlanguage = get_config('lang');
825
    $oldtheme = get_config('theme');
Nigel McNie's avatar
Nigel McNie committed
826
827
    foreach ($fields as $field) {
        if (!set_config($field, $values[$field])) {
828
            siteoptions_fail($form, $field);
Nigel McNie's avatar
Nigel McNie committed
829
830
        }
    }
831
832
833
834
    if ($oldlanguage != $values['lang']) {
        safe_require('artefact', 'file');
        ArtefactTypeFolder::change_public_folder_name($oldlanguage, $values['lang']);
    }
835

836
837
    save_notification_settings($values, null, true);

838
839
    if ($oldsearchplugin != $values['searchplugin']) {
        // Call the old search plugin's sitewide cleanup method
Aaron Wells's avatar
Aaron Wells committed
840
        safe_require('search', $oldsearchplugin);
841
842
843
        call_static_method(generate_class_name('search', $oldsearchplugin), 'cleanup_sitewide');
        // Call the new search plugin's sitewide initialize method
        safe_require('search', $values['searchplugin']);
844
845
846
        $initialize = call_static_method(generate_class_name('search', $values['searchplugin']), 'initialize_sitewide');
        if (!$initialize) {
            $form->reply(PIEFORM_ERR, array(
847
                'message' => get_string('searchconfigerror1', 'admin', $values['searchplugin']),
848
849
850
                'goto'    => '/admin/site/options.php',
            ));
        }
851
    }
852
853
854
855
856
857
858
859
860
    // 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',
        ));
    }
861

Nigel McNie's avatar
Nigel McNie committed
862
863
    // submitted sessionlifetime is in minutes; db entry session_timeout is in seconds
    if (!set_config('session_timeout', $values['sessionlifetime'] * 60)) {
864
        siteoptions_fail($form, 'sessionlifetime');
Nigel McNie's avatar
Nigel McNie committed
865
866
    }
    // Submitted value is on/off; database entry should be 1/0
867
868
869
870
    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
871
    }
872

873
874
    if ($values['viruschecking'] == 'on') {
        $pathtoclam = escapeshellcmd(trim(get_config('pathtoclam')));
875
876
877
878
879
880
881
        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)) {
882
883
884
885
886
887
888
            $form->reply(PIEFORM_ERR, array(
                'message' => get_string('clamlost', 'mahara', $pathtoclam),
                'goto'    => '/admin/site/options.php',
            ));
        }
    }

889
890
891
892
893
894
895
896
897
    if (get_config('recaptchaonregisterform')
            && !(
                    get_config('recaptchapublickey')
                    && get_config('recaptchaprivatekey')
            )
    ) {
        $form->reply(
            PIEFORM_ERR,
            array(
898
                'message' => get_string('recaptchakeysmissing1', 'admin'),
899
900
901
902
903
                'goto' => '/admin/site/options.php',
            )
        );
    }

904
905
    $message = get_string('siteoptionsset', 'admin');
    if ($oldtheme != $values['theme']) {
906
        global $USER;
907
        $message .= '  ' . get_string('usersseenewthemeonlogin', 'admin');
908
        $USER->reset_institutions();
909
    }
910
911
912
    if ($count) {
        $message .= ' ' . get_string('numberusersupdated','admin', $count);
    }
913
    $form->reply(PIEFORM_OK, array('message' => $message, 'goto' => '/admin/site/options.php'));
Nigel McNie's avatar
Nigel McNie committed
914
915
}

916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
$js = <<<EOF
jQuery(document).ready(function() {
    var j = jQuery.noConflict();
    var overrideuseraccountlifetime = j('#siteoptions input[name=defaultaccountlifetimeupdate]');
    var defaultaccountlifetime = j('#siteoptions_defaultaccountlifetime_units');
    function overrideuseraccountlife(v) {
        // if default account lifetime is set to 'noenddate' disable the override options
        if (v == 'noenddate') {
            var value = j('#siteoptions input[name=defaultaccountlifetimeupdate]:checked').val();
            j('#siteoptions input[name=defaultaccountlifetimeupdate][value=some]').attr('disabled',true);
            j('#siteoptions input[name=defaultaccountlifetimeupdate][value=some]').attr('checked', false);
            if (value != 'some') {
                j('#siteoptions input[name=defaultaccountlifetimeupdate][value=' + value + ']').attr('checked', true);
            }
        }
        else {
            // enable the radio buttons
            overrideuseraccountlifetime.attr('disabled',false);
            if (!j('#siteoptions input[name=defaultaccountlifetimeupdate]:checked').val()) {
                overrideuseraccountlifetime.each(function() {
                    if (typeof j(this).attr('checked') === 'undefined' || j(this).attr('checked') === false) {
                        // if no radio button already selected then choose the 'only for new users' option by default
                        if (j(this).val() == 'none') {
                            j(this).attr('checked',true);
                        }
                    }
                });
            }
        }
    }
    // when default account lifetime changes rerun the override account lifetime checks
    defaultaccountlifetime.change(function() {
        overrideuseraccountlife(defaultaccountlifetime.val());
    });
    // initial setup
    overrideuseraccountlife(defaultaccountlifetime.val());
});
EOF;

955
956
957
$thispage = json_encode(get_config('wwwroot') . 'admin/site/options.php');
$smarty = smarty(array('adminsiteoptions'));
$smarty->assign('siteoptionform', $siteoptionform);
958
$smarty->assign('PAGEHEADING', TITLE);
959
$smarty->assign('INLINEJAVASCRIPT', $js);
960
$smarty->display('admin/site/options.tpl');