index.php 5.44 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
/**
 * This program is part of Mahara
 *
 *  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 2 of the License, or
 *  (at your option) any later version.
 *
 *  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.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 *
 * @package    mahara
Penny Leach's avatar
Penny Leach committed
20
21
 * @subpackage admin
 * @author     Nigel McNie <nigel@catalyst.net.nz>
22
23
24
25
26
27
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
 * @copyright  (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
 *
 */

define('INTERNAL',1);
28
29
30
define('ADMIN',1);
define('MENUITEM','siteoptions');

31
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
32
require_once('form.php');
33

34
35
36
37
$langoptions = get_languages();
$themeoptions = get_themes();
$yesno = array(true  => get_string('yes'),
               false => get_string('no'));
38

39
40
41
42
$siteoptionform = form(array(
    'name'     => 'siteoptions',
    'ajaxpost' => true,
    'elements' => array(
43
44
        'sitename' => array(
            'type'         => 'text',
45
46
            'title'        => get_string('sitename','admin'),
            'description'  => get_string('sitenamedescription','admin'),
47
48
            'defaultvalue' => get_config('sitename'),
        ),
49
50
        'language' => array(
            'type'         => 'select',
51
52
            'title'        => get_string('language','admin'),
            'description'  => get_string('sitelanguagedescription','admin'),
53
            'defaultvalue' => get_config('language'),
54
            'collapseifoneoption' => true,
55
56
57
58
            'options'      => $langoptions,
        ),
        'theme' => array(
            'type'         => 'select',
59
60
            'title'        => get_string('theme','admin'),
            'description'  => get_string('sitethemedescription','admin'),
61
            'defaultvalue' => get_config('theme'),
62
            'collapseifoneoption' => true,
63
64
65
66
            'options'      => $themeoptions,
        ),
        'viruschecking' => array(
            'type'         => 'checkbox',
67
68
            'title'        => get_string('viruschecking','admin'),
            'description'  => get_string('viruscheckingdescription','admin'),
69
70
71
72
            'defaultvalue' => get_config('viruschecking'),
        ),
        'pathtoclam' => array(
            'type'         => 'text',
73
74
            'title'        => get_string('pathtoclam','admin'),
            'description'  => get_string('pathtoclamdescription','admin'),
75
76
77
78
79
            'defaultvalue' => get_config('pathtoclam'),
        ),
        'sessionlifetime' => array(
            'type'         => 'text',
            'size'         => 4,
80
81
            'title'        => get_string('sessionlifetime','admin'),
            'description'  => get_string('sessionlifetimedescription','admin'),
82
83
84
85
            'defaultvalue' => get_config('session_timeout') / 60,
        ),
        'allowpublicviews' => array(
            'type'         => 'select',
86
87
            'title'        => get_string('allowpublicviews','admin'),
            'description'  => get_string('allowpublicviewsdescription','admin'),
88
89
90
91
92
            'defaultvalue' => get_config('allowpublicviews'),
            'options'      => $yesno,
        ),
        'artefactviewinactivitytime' => array(
            'type'         => 'expiry',
93
94
            'title'        => get_string('artefactviewinactivitytime','admin'),
            'description'  => get_string('artefactviewinactivitytimedescription','admin'),
95
96
97
98
            'defaultvalue' => get_config('artefactviewinactivitytime'),
        ),
        'contactaddress' => array(
            'type'         => 'text',
99
100
            'title'        => get_string('contactaddress','admin'),
            'description'  => get_string('contactaddressdescription','admin'),
101
102
103
104
105
106
107
            'defaultvalue' => get_config('contactaddress'),
            'rules'        => array(
                'email' => true
            )
        ),
        'submit' => array(
            'type'  => 'submit',
108
            'value' => get_string('updatesiteoptions','admin')
109
110
111
112
113
        ),
    )
));

function siteoptions_fail($field) {
114
    json_reply('local', get_string('setsiteoptionsfailed','admin', get_string($field)));
115
}
Richard Mansfield's avatar
Richard Mansfield committed
116

117
function siteoptions_submit($values) {
118
    $fields = array('sitename','language','theme','pathtoclam',
119
120
121
122
123
124
125
                    'allowpublicviews','artefactviewinactivitytime',
                    'contactaddress');
    foreach ($fields as $field) {
        if (!set_config($field, $values[$field])) {
            siteoptions_fail($field);
        }
    }
Richard Mansfield's avatar
Richard Mansfield committed
126
    // submitted sessionlifetime is in minutes; db entry session_timeout is in seconds
127
    if (!set_config('session_timeout', $values['sessionlifetime'] * 60)) {
128
        siteoptions_fail('sessionlifetime');
129
    }
Richard Mansfield's avatar
Richard Mansfield committed
130
    // Submitted value is on/off; database entry should be 1/0
131
    if (!set_config('viruschecking', (int) ($values['viruschecking'] == 'on'))) {
132
        siteoptions_fail('viruschecking');
133
    }
134
    json_reply(false, get_string('siteoptionsset','admin'));
135
136
}

137
$smarty = smarty();
138
$smarty->assign('SITEOPTIONFORM',$siteoptionform);
139
140
141
$smarty->display('admin/options/index.tpl');

?>