options.php 36 KB
Newer Older
Nigel McNie's avatar
Nigel McNie committed
1
2
<?php
/**
Francois Marier's avatar
Francois Marier committed
3
 * Mahara: Electronic portfolio, weblog, resume builder and social networking
4
5
 * Copyright (C) 2006-2009 Catalyst IT Ltd and others; see:
 *                         http://wiki.mahara.org/Contributors
Nigel McNie's avatar
Nigel McNie committed
6
 *
Francois Marier's avatar
Francois Marier committed
7
8
9
10
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
Nigel McNie's avatar
Nigel McNie committed
11
 *
Francois Marier's avatar
Francois Marier committed
12
13
14
15
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
Nigel McNie's avatar
Nigel McNie committed
16
 *
Francois Marier's avatar
Francois Marier committed
17
18
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
Nigel McNie's avatar
Nigel McNie committed
19
20
21
 *
 * @package    mahara
 * @subpackage admin
22
 * @author     Catalyst IT Ltd
Nigel McNie's avatar
Nigel McNie committed
23
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
24
 * @copyright  (C) 2006-2009 Catalyst IT Ltd http://catalyst.net.nz
Nigel McNie's avatar
Nigel McNie committed
25
26
27
 *
 */

28
29
define('INTERNAL', 1);
define('ADMIN', 1);
30
define('MENUITEM', 'configsite/siteoptions');
31
32
33
define('SECTION_PLUGINTYPE', 'core');
define('SECTION_PLUGINNAME', 'admin');
define('SECTION_PAGE', 'siteoptions');
Nigel McNie's avatar
Nigel McNie committed
34
35
36

require(dirname(dirname(dirname(__FILE__))) . '/init.php');
require_once('pieforms/pieform.php');
37
require_once('searchlib.php');
38
require_once('antispam.php');
Nigel McNie's avatar
Nigel McNie committed
39
define('TITLE', get_string('siteoptions', 'admin'));
Nigel McNie's avatar
Nigel McNie committed
40
41

$langoptions = get_languages();
42
$themeoptions = get_all_themes();
43
44
unset($themeoptions['custom']); // Only available for institution configurable themes

Nigel McNie's avatar
Nigel McNie committed
45
46
47
$yesno = array(true  => get_string('yes'),
               false => get_string('no'));

48
49
$searchpluginoptions = get_search_plugins();

50
51
$countries = getoptions_country();

52
53
54
55
56
57
58
59
$notificationmethods = array();
foreach (array_keys(plugins_installed('notification')) as $n) {
    $notificationmethods[$n] = get_string('name', 'notification.' . $n);
}
if (!$notificationdefault = get_config('defaultnotificationmethod')) {
    $notificationdefault = isset($notificationmethods['email']) ? 'email' : 'internal';
}

60
$spamtraps = available_spam_traps();
61
$siteoptionform = array(
Penny Leach's avatar
Penny Leach committed
62
63
64
65
66
    'name'       => 'siteoptions',
    'jsform'     => true,
    'renderer'   => 'table',
    'plugintype' => 'core',
    'pluginname' => 'admin',
67
    'jssuccesscallback' => 'checkReload',
Penny Leach's avatar
Penny Leach committed
68
    'elements'   => array(
69
70
71
        'sitesettings' => array(
            'type'         => 'fieldset',
            'collapsible'  => true,
72
            'collapsed'    => true,
73
74
75
76
77
78
79
80
            '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,
81
                    'disabled'     => in_array('sitename', $OVERRIDDEN),
82
83
84
85
86
87
88
89
90
                ),
                'lang' => array(
                    'type'         => 'select',
                    'title'        => get_string('language', 'admin'),
                    'description'  => get_string('sitelanguagedescription', 'admin'),
                    'defaultvalue' => get_config('lang'),
                    'collapseifoneoption' => true,
                    'options'      => $langoptions,
                    'help'         => true,
91
                    'disabled'     => in_array('lang', $OVERRIDDEN),
92
93
94
95
96
97
98
99
                ),
                '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,
100
                    'disabled'     => in_array('country', $OVERRIDDEN),
101
102
103
104
105
106
107
108
109
                ),
                'theme' => array(
                    'type'         => 'select',
                    'title'        => get_string('theme'),
                    'description'  => get_string('sitethemedescription', 'admin'),
                    'defaultvalue' => get_config('theme'),
                    'collapseifoneoption' => true,
                    'options'      => $themeoptions,
                    'help'         => true,
110
                    'disabled'     => in_array('theme', $OVERRIDDEN),
111
                ),
112
113
114
115
116
117
118
                'dropdownmenu' => array(
                    'type'         => 'checkbox',
                    'title'        => get_string('dropdownmenu', 'admin'),
                    'description'  => get_string('dropdownmenudescription', 'admin'),
                    'defaultvalue' => get_config('dropdownmenu'),
                    'disabled'     => in_array('dropdownmenu', $OVERRIDDEN),
                ),
119
120
121
122
123
                'homepageinfo' => array(
                    'type'         => 'checkbox',
                    'title'        => get_string('homepageinfo', 'admin'),
                    'description'  => get_string('homepageinfodescription', 'admin'),
                    'defaultvalue' => get_config('homepageinfo'),
124
                    'disabled'     => in_array('homepageinfo', $OVERRIDDEN),
125
126
127
128
129
130
131
                ),
                'registration_sendweeklyupdates' => array(
                    'type'         => 'checkbox',
                    'title'        => get_string('sendweeklyupdates', 'admin'),
                    'description'  => get_string('sendweeklyupdatesdescription', 'admin'),
                    'defaultvalue' => get_config('registration_sendweeklyupdates'),
                    'help'         => true,
132
                    'disabled'     => in_array('registration_sendweeklyupdates', $OVERRIDDEN),
133
                ),
134
135
            ),
        ),
136
137
138
        'usersettings' => array(
            'type'         => 'fieldset',
            'collapsible'  => true,
139
            'collapsed'    => true,
140
141
142
143
144
145
146
            'legend'       => get_string('usersettingslegend', 'admin'),
            'elements'     => array(
                'userscanchooseviewthemes' => array(
                    'type'         => 'checkbox',
                    'title'        => get_string('userscanchooseviewthemes', 'admin'),
                    'description'  => get_string('userscanchooseviewthemesdescription', 'admin'),
                    'defaultvalue' => get_config('userscanchooseviewthemes'),
147
                    'disabled'     => in_array('userscanchooseviewthemes', $OVERRIDDEN),
148
149
150
151
152
153
154
                ),
                'remoteavatars' => array(
                    'type'         => 'checkbox',
                    'title'        => get_string('remoteavatars', 'admin'),
                    'description'  => get_string('remoteavatarsdescription', 'admin'),
                    'defaultvalue' => get_config('remoteavatars'),
                    'help'         => true,
155
                    'disabled'     => in_array('remoteavatars', $OVERRIDDEN),
156
157
158
159
160
161
                ),
                'userscanhiderealnames' => array(
                    'type'         => 'checkbox',
                    'title'        => get_string('userscanhiderealnames', 'admin'),
                    'description'  => get_string('userscanhiderealnamesdescription', 'admin'),
                    'defaultvalue' => get_config('userscanhiderealnames'),
162
                    'disabled'     => in_array('userscanhiderealnames', $OVERRIDDEN),
163
                ),
164
165
166
167
168
169
170
                'searchusernames' => array(
                    'type'         => 'checkbox',
                    'title'        => get_string('searchusernames', 'admin'),
                    'description'  => get_string('searchusernamesdescription', 'admin'),
                    'defaultvalue' => get_config('searchusernames'),
                    'disabled'     => in_array('searchusernames', $OVERRIDDEN),
                ),
171
172
173
174
175
                'anonymouscomments' => array(
                    'type'         => 'checkbox',
                    'title'        => get_string('anonymouscomments', 'admin'),
                    'description'  => get_string('anonymouscommentsdescription', 'admin'),
                    'defaultvalue' => get_config('anonymouscomments'),
176
                    'disabled'     => in_array('anonymouscomments', $OVERRIDDEN),
177
                ),
178
179
180
181
182
183
                'loggedinprofileviewaccess' => array(
                    'type'         => 'checkbox',
                    'title'        => get_string('loggedinprofileviewaccess', 'admin'),
                    'description'  => get_string('loggedinprofileviewaccessdescription', 'admin'),
                    'defaultvalue' => get_config('loggedinprofileviewaccess'),
                    'disabled'     => in_array('loggedinprofileviewaccess', $OVERRIDDEN),
184
                    'help'         => true,
185
                ),
186
187
188
189
190
191
192
                'staffreports' => array(
                    'type'         => 'checkbox',
                    'title'        => get_string('staffuserreports', 'admin'),
                    'description'  => get_string('staffuserreportsdescription', 'admin'),
                    'defaultvalue' => get_config('staffreports'),
                    'disabled'     => in_array('staffreports', $OVERRIDDEN),
                ),
Hugh Davenport's avatar
Hugh Davenport committed
193
194
195
196
197
198
199
                'staffstats' => array(
                    'type'         => 'checkbox',
                    'title'        => get_string('staffuserstats', 'admin'),
                    'description'  => get_string('staffuserstatsdescription', 'admin'),
                    'defaultvalue' => get_config('staffstats'),
                    'disabled'     => in_array('staffstats', $OVERRIDDEN),
                ),
200
201
202
203
204
205
206
                'userscandisabledevicedetection' => array(
                    'type'         => 'checkbox',
                    'title'        => get_string('userscandisabledevicedetection', 'admin'),
                    'description'  => get_string('userscandisabledevicedetectiondescription', 'admin'),
                    'defaultvalue' => get_config('userscandisabledevicedetection'),
                    'disabled'     => in_array('userscandisabledevicedetection', $OVERRIDDEN),
                ),
207
            ),
208
        ),
209
        'searchsettings' => array(
210
211
            'type'         => 'fieldset',
            'collapsible'  => true,
212
            'collapsed'    => true,
213
214
215
216
217
218
219
220
221
222
            '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,
223
                    'disabled'     => in_array('searchplugin', $OVERRIDDEN),
224
                ),
225
            ),
226
        ),
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
        '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'),
                    ),
243
                    'disabled'     => in_array('creategroups', $OVERRIDDEN),
244
245
246
247
248
249
250
251
252
253
254
                ),
                '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,
255
                    'disabled'     => in_array('createpublicgroups', $OVERRIDDEN),
256
257
                ),
                'allowgroupcategories' => array(
258
                    'type'         => 'checkbox',
259
260
261
                    'title'        => get_string('allowgroupcategories', 'admin'),
                    'description'  => get_string('allowgroupcategoriesdescription', 'admin'),
                    'defaultvalue' => get_config('allowgroupcategories'),
262
                    'disabled'     => in_array('allowgroupcategories', $OVERRIDDEN),
263
264
                ),
            ),
265
        ),
266
267
268
        'institutionsettings' => array(
            'type'         => 'fieldset',
            'collapsible'  => true,
269
            'collapsed'    => true,
270
271
272
273
274
275
276
277
            'legend'       => get_string('institutionsettingslegend', 'admin'),
            'elements'     => array(
                'usersallowedmultipleinstitutions' => array(
                    'type'         => 'checkbox',
                    'title'        => get_string('usersallowedmultipleinstitutions', 'admin'),
                    'description'  => get_string('usersallowedmultipleinstitutionsdescription', 'admin'),
                    'defaultvalue' => get_config('usersallowedmultipleinstitutions'),
                    'help'         => true,
278
                    'disabled'     => in_array('usersallowedmultipleinstitutions', $OVERRIDDEN),
279
280
281
282
                ),
                'institutionexpirynotification' => array(
                    'type'         => 'expiry',
                    'title'        => get_string('institutionexpirynotification', 'admin'),
283
                    'description'  => get_string('institutionexpirynotificationdescriptioninfo', 'admin'),
284
285
                    'defaultvalue' => get_config('institutionexpirynotification'),
                    'help'         => true,
286
                    'disabled'     => in_array('institutionexpirynotification', $OVERRIDDEN),
287
288
289
290
291
292
293
                ),
                'institutionautosuspend' => array(
                    'type'         => 'checkbox',
                    'title'        => get_string('institutionautosuspend', 'admin'),
                    'description'  => get_string('institutionautosuspenddescription', 'admin'),
                    'defaultvalue' => get_config('institutionautosuspend'),
                    'help'         => true,
294
                    'disabled'     => in_array('institutionautosuspend', $OVERRIDDEN),
295
296
                ),
            ),
297
        ),
298
299
300
        'accountsettings' => array(
            'type'         => 'fieldset',
            'collapsible'  => true,
301
            'collapsed'    => true,
302
303
304
305
306
307
308
309
310
311
            '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,
312
                    'disabled'     => in_array('session_timeout', $OVERRIDDEN),
313
314
315
316
317
318
319
                ),
                'defaultaccountlifetime' => array(
                    'type'         => 'expiry',
                    'title'        => get_string('defaultaccountlifetime', 'admin'),
                    'description'  => get_string('defaultaccountlifetimedescription', 'admin'),
                    'defaultvalue' => get_config('defaultaccountlifetime'),
                    'help'         => true,
320
                    'disabled'     => in_array('defaultaccountlifetime', $OVERRIDDEN),
321
322
323
324
325
326
327
                ),
                'defaultaccountinactiveexpire' => array(
                    'type'         => 'expiry',
                    'title'        => get_string('defaultaccountinactiveexpire', 'admin'),
                    'description'  => get_string('defaultaccountinactiveexpiredescription', 'admin'),
                    'defaultvalue' => get_config('defaultaccountinactiveexpire'),
                    'help'         => true,
328
                    'disabled'     => in_array('defaultaccountinactiveexpire', $OVERRIDDEN),
329
330
331
332
333
334
335
                ),
                'defaultaccountinactivewarn' => array(
                    'type'         => 'expiry',
                    'title'        => get_string('defaultaccountinactivewarn', 'admin'),
                    'description'  => get_string('defaultaccountinactivewarndescription', 'admin'),
                    'defaultvalue' => get_config('defaultaccountinactivewarn'),
                    'help'         => true,
336
                    'disabled'     => in_array('defaultaccountinactivewarn', $OVERRIDDEN),
337
338
                ),
            ),
339
        ),
340
341
342
        'securitysettings' => array(
            'type'         => 'fieldset',
            'collapsible'  => true,
343
            'collapsed'    => true,
344
345
346
347
348
349
350
351
            'legend'       => get_string('securitysettingslegend', 'admin'),
            'elements'     => array(
                'viruschecking' => array(
                    'type'         => 'checkbox',
                    'title'        => get_string('viruschecking', 'admin'),
                    'description'  => get_string('viruscheckingdescription', 'admin'),
                    'defaultvalue' => get_config('viruschecking'),
                    'help'         => true,
352
                    'disabled'     => in_array('viruschecking', $OVERRIDDEN),
353
354
355
356
357
358
359
                ),
                'pathtoclam' => array(
                    'type'         => 'text',
                    'title'        => get_string('pathtoclam', 'admin'),
                    'description'  => get_string('pathtoclamdescription', 'admin'),
                    'defaultvalue' => get_config('pathtoclam'),
                    'help'         => true,
360
                    'disabled'     => in_array('pathtoclam', $OVERRIDDEN),
361
362
363
364
365
366
367
368
                ),
                'antispam' => array(
                    'type'         => 'select',
                    'title'        => get_string('antispam', 'admin'),
                    'description'  => get_string('antispamdescription', 'admin'),
                    'defaultvalue' => get_config('antispam'),
                    'options'      => $spamtraps,
                    'help'         => true,
369
                    'disabled'     => in_array('antispam', $OVERRIDDEN),
370
371
372
373
374
375
376
                ),
                'spamhaus' => array(
                    'type'         => 'checkbox',
                    'title'        => get_string('spamhaus', 'admin'),
                    'description'  => get_string('spamhausdescription', 'admin'),
                    'defaultvalue' => get_config('spamhaus'),
                    'help'         => true,
377
                    'disabled'     => in_array('spamhaus', $OVERRIDDEN),
378
379
380
381
382
383
384
                ),
                'surbl' => array(
                    'type'         => 'checkbox',
                    'title'        => get_string('surbl', 'admin'),
                    'description'  => get_string('surbldescription', 'admin'),
                    'defaultvalue' => get_config('surbl'),
                    'help'         => true,
385
                    'disabled'     => in_array('surbl', $OVERRIDDEN),
386
                ),
387
388
389
390
391
392
393
394
                'disableexternalresources' => array(
                    'type'         => 'checkbox',
                    'title'        => get_string('disableexternalresources', 'admin'),
                    'description'  => get_string('disableexternalresourcesdescription', 'admin'),
                    'defaultvalue' => get_config('disableexternalresources'),
                    'help'         => true,
                    'disabled'     => in_array('disableexternalresources', $OVERRIDDEN),
                ),
395
            ),
396
        ),
397
398
399
400
401
402
403
404
405
406
407
408
        # 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'),
409
                   'disabled'      => in_array('proxyaddress', $OVERRIDDEN),
410
411
412
413
414
415
416
                ),
                'proxyauthmodel' => array(
                    'type'          => 'select',
                    'title'         => get_string('proxyauthmodel', 'admin'),
                    'description'   => get_string('proxyauthmodeldescription', 'admin'),
                    'defaultvalue'  => get_config('proxyauthmodel'),
                    'options'       => array(
417
418
                                        '' => get_string('none', 'admin'),
                                        'basic' => get_string('proxyauthmodelbasic', 'admin'),
419
                                    ),
420
                    'disabled'      => in_array('proxyauthmodel', $OVERRIDDEN),
421
422
423
424
425
426
                ),
                'proxyauthcredentials' => array(
                    'type'          => 'text',
                    'title'         => get_string('proxyauthcredentials', 'admin'),
                    'description'   => get_string('proxyauthcredentialsdescription', 'admin'),
                    'defaultvalue'  => get_config('proxyauthcredentials'),
427
                    'disabled'      => in_array('proxyauthcredentials', $OVERRIDDEN),
428
429
430
                ),
            ),
        ),
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
        '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,
                ),
479
480
481
482
483
484
485
486
                '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,
                ),
487
488
489
490
491
492
493
494
495
                'defaultnotificationmethod' => array(
                    'type'          => 'select',
                    'title'         => get_string('defaultnotificationmethod', 'admin'),
                    'description'   => get_string('defaultnotificationmethoddescription', 'admin'),
                    'defaultvalue'  => $notificationdefault,
                    'disabled'      => in_array('defaultnotificationmethod', $OVERRIDDEN),
                    'options'       => $notificationmethods,
                    'help'          => true,
                ),
496
497
            ),
        ),
498
499
500
        'generalsettings' => array(
            'type'         => 'fieldset',
            'collapsible'  => true,
501
            'collapsed'    => true,
502
503
504
            'legend'       => get_string('generalsettingslegend', 'admin'),
            'elements'     => array(
                'allowpublicviews' => array(
505
                    'type'         => 'checkbox',
506
507
508
509
                    'title'        => get_string('allowpublicviews', 'admin'),
                    'description'  => get_string('allowpublicviewsdescription', 'admin'),
                    'defaultvalue' => get_config('allowpublicviews'),
                    'help'         => true,
510
                    'disabled'     => in_array('allowpublicviews', $OVERRIDDEN),
511
512
                ),
                'allowpublicprofiles' => array(
513
                    'type'         => 'checkbox',
514
515
516
517
                    'title'        => get_string('allowpublicprofiles', 'admin'),
                    'description'  => get_string('allowpublicprofilesdescription', 'admin'),
                    'defaultvalue' => get_config('allowpublicprofiles'),
                    'help'         => true,
518
                    'disabled'     => in_array('allowpublicprofiles', $OVERRIDDEN) || get_config('allowpublicviews'),
519
                ),
520
521
522
523
524
525
526
527
                'generatesitemap' => array(
                    'type'         => 'checkbox',
                    'title'        => get_string('generatesitemap', 'admin'),
                    'description'  => get_string('generatesitemapdescription', 'admin'),
                    'defaultvalue' => get_config('generatesitemap'),
                    'help'         => true,
                    'disabled'     => in_array('generatesitemap', $OVERRIDDEN) || !get_config('allowpublicviews'),
                ),
528
529
530
                'showselfsearchsideblock' => array(
                    'type'         => 'checkbox',
                    'title'        => get_string('showselfsearchsideblock', 'admin'),
531
                    'description'  => get_string('showselfsearchsideblockdescription1', 'admin'),
532
533
534
                    'defaultvalue' => get_config('showselfsearchsideblock'),
                    'disabled'     => in_array('showselfsearchsideblock', $OVERRIDDEN),
                ),
535
536
537
                'showtagssideblock' => array(
                    'type'         => 'checkbox',
                    'title'        => get_string('showtagssideblock', 'admin'),
538
                    'description'  => get_string('showtagssideblockdescription1', 'admin'),
539
                    'defaultvalue' => get_config('showtagssideblock'),
540
                    'disabled'     => in_array('showtagssideblock', $OVERRIDDEN),
541
542
543
544
545
546
547
548
                ),
                '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),
549
                    'disabled'     => in_array('tagssideblockmaxtags', $OVERRIDDEN),
550
551
552
553
554
555
                ),
                'viewmicroheaders' => array(
                    'type'         => 'checkbox',
                    'title'        => get_string('smallviewheaders', 'admin'),
                    'description'  => get_string('smallviewheadersdescription', 'admin'),
                    'defaultvalue' => get_config('viewmicroheaders'),
556
557
558
559
560
                    'disabled'     => in_array('viewmicroheaders', $OVERRIDDEN),
                ),
                'showonlineuserssideblock' => array(
                    'type'         => 'checkbox',
                    'title'        => get_string('showonlineuserssideblock', 'admin'),
561
                    'description'  => get_string('showonlineuserssideblockdescriptionmessage', 'admin'),
562
563
                    'defaultvalue' => get_config('showonlineuserssideblock'),
                    'disabled'     => in_array('showonlineuserssideblock', $OVERRIDDEN),
564
                ),
565
566
567
568
569
570
571
572
573
                '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),
                ),
574
575
576
577
578
579
580
                'registerterms' => array(
                    'type'         => 'checkbox',
                    'title'        => get_string('registerterms', 'admin'),
                    'description'  => get_string('registertermsdescription', 'admin'),
                    'defaultvalue' => get_config('registerterms'),
                    'disabled'     => in_array('registerterms', $OVERRIDDEN),
                ),
581
582
583
584
585
586
587
                'allowmobileuploads' => array(
                    'type'         => 'checkbox',
                    'title'        => get_string('allowmobileuploads', 'admin'),
                    'description'  => get_string('allowmobileuploadsdescription', 'admin'),
                    'defaultvalue' => get_config('allowmobileuploads'),
                    'disabled'     => in_array('allowmobileuploads', $OVERRIDDEN),
                ),
588
589
590
591
592
593
594
595
596
597
598
                '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,
599
                    'disabled'     => in_array('wysiwyg', $OVERRIDDEN),
600
                ),
601
            ),
602
        ),
Nigel McNie's avatar
Nigel McNie committed
603
    )
604
605
606
607
608
609
610
611
);

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

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

613
function siteoptions_fail(Pieform $form, $field) {
614
615
616
617
    $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
618
619
}

620
function siteoptions_submit(Pieform $form, $values) {
621
    $fields = array(
622
        'sitename','lang','theme', 'pathtoclam', 'dropdownmenu',
623
        'defaultaccountlifetime', 'defaultaccountinactiveexpire', 'defaultaccountinactivewarn',
624
        'allowpublicviews', 'allowpublicprofiles', 'generatesitemap',
625
        'registration_sendweeklyupdates', 'institutionexpirynotification', 'institutionautosuspend',
626
        'showselfsearchsideblock', 'searchusernames', 'searchplugin', 'showtagssideblock',
627
        'tagssideblockmaxtags', 'country', 'viewmicroheaders', 'userscanchooseviewthemes',
628
        'remoteavatars', 'userscanhiderealnames', 'antispam', 'spamhaus', 'surbl', 'anonymouscomments', 'loggedinprofileviewaccess', 'disableexternalresources',
629
        'proxyaddress', 'proxyauthmodel', 'proxyauthcredentials', 'smtphosts', 'smtpport', 'smtpuser', 'smtppass', 'smtpsecure',
630
631
        'noreplyaddress', 'defaultnotificationmethod', 'homepageinfo', 'showonlineuserssideblock', 'onlineuserssideblockmaxusers',
        'registerterms', 'allowmobileuploads', 'creategroups', 'createpublicgroups', 'allowgroupcategories', 'wysiwyg',
632
        'staffreports', 'staffstats', 'userscandisabledevicedetection',
633
    );
634
635
636
637
638

    // if public views are disabled, sitemap generation must also be disabled.
    if ($values['allowpublicviews'] == false) {
        $values['generatesitemap'] = false;
    }
639
640
641
642
    else {
        // Ensure allowpublicprofiles is set as well
        $values['allowpublicprofiles'] = 1;
    }
643

644
    $oldlanguage = get_config('lang');
645
    $oldtheme = get_config('theme');
Nigel McNie's avatar
Nigel McNie committed
646
647
    foreach ($fields as $field) {
        if (!set_config($field, $values[$field])) {
648
            siteoptions_fail($form, $field);
Nigel McNie's avatar
Nigel McNie committed
649
650
        }
    }
651
652
653
654
655
    if ($oldlanguage != $values['lang']) {
        safe_require('artefact', 'file');
        ArtefactTypeFolder::change_public_folder_name($oldlanguage, $values['lang']);
    }
    
Nigel McNie's avatar
Nigel McNie committed
656
657
    // submitted sessionlifetime is in minutes; db entry session_timeout is in seconds
    if (!set_config('session_timeout', $values['sessionlifetime'] * 60)) {
658
        siteoptions_fail($form, 'sessionlifetime');
Nigel McNie's avatar
Nigel McNie committed
659
660
    }
    // Submitted value is on/off; database entry should be 1/0
661
662
663
664
    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
665
    }
666

667
668
669
670
671
672
673
674
675
676
    if ($values['viruschecking'] == 'on') {
        $pathtoclam = escapeshellcmd(trim(get_config('pathtoclam')));
        if (!$pathtoclam || !file_exists($pathtoclam) && !is_executable($pathtoclam)) {
            $form->reply(PIEFORM_ERR, array(
                'message' => get_string('clamlost', 'mahara', $pathtoclam),
                'goto'    => '/admin/site/options.php',
            ));
        }
    }

677
678
    $message = get_string('siteoptionsset', 'admin');
    if ($oldtheme != $values['theme']) {
679
        global $USER;
680
        $message .= '  ' . get_string('usersseenewthemeonlogin', 'admin');
681
        $USER->reset_institutions();
682
683
    }
    $form->reply(PIEFORM_OK, array('message' => $message, 'goto' => '/admin/site/options.php'));
Nigel McNie's avatar
Nigel McNie committed
684
685
}

686
687
688
$thispage = json_encode(get_config('wwwroot') . 'admin/site/options.php');
$smarty = smarty(array('adminsiteoptions'));
$smarty->assign('siteoptionform', $siteoptionform);
689
$smarty->assign('PAGEHEADING', TITLE);
690
$smarty->display('admin/site/options.tpl');