index.php 3.45 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?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
 * @subpackage core
 * @author     Penny Leach <penny@catalyst.net.nz>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
 * @copyright  (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
 *
 */

define('INTERNAL', 1);
define('MENUITEM', 'account');
define('SUBMENUITEM', 'accountprefs');

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

Penny Leach's avatar
Penny Leach committed
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// load up user preferences
$prefs = (object)($SESSION->get('accountprefs'));

$prefsform = array(
    'name'        => 'accountprefs',
    'method'      => 'post',
    'ajaxpost'    => true,
    'plugintype ' => 'core',
    'pluginname'  => 'account',
    'elements'    => array(
        'friendscontrol' => array(
            'type' => 'radio',
            'value' => $prefs->friendscontrol, 
            'title'  => get_string('friendsdescr', 'account'),
            'separator' => HTML_BR,
            'options' => array(
                'nobody' => get_string('friendsnobody', 'account'),
                'auth'   => get_string('friendsauth', 'account'),
                'auto'   => get_string('friendsauto', 'account')
            ),
           'rules' => array(
                'required' => true
            )
        ),
        'wysiwyg' => array(
            'type' => 'radio',
            'value' => $prefs->wysiwyg,
            'title' => get_string('wysiwygdescr', 'account'),
            'options' => array(
                1 => get_string('on', 'account'),
                0 => get_string('off', 'account'),
            ),
           'rules' => array(
                'required' => true
            )
        ),
        'messages' => array(
            'type' => 'radio',
            'value' => $prefs->messages,
            'title' => get_string('messagesdescr', 'account'),
74
            'separator' => HTML_BR,
Penny Leach's avatar
Penny Leach committed
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
            'options' => array(
                'nobody' => get_string('messagesnobody', 'account'),
                'friends' => get_string('messagesfriends', 'account'),
                'allow' => get_string('messagesallow', 'account'),
            ),
           'rules' => array(
                'required' => true
            )
        ),
        'submit' => array(
            'type' => 'submit',
            'value' => get_string('save'),
        ),
    ),
);
90

Penny Leach's avatar
Penny Leach committed
91
92
93

$smarty = smarty();
$smarty->assign('form', form($prefsform));
94
95
$smarty->display('account/index.tpl');

Penny Leach's avatar
Penny Leach committed
96
function accountprefs_submit($values) {
97
98
99
100
101
102
103
104
    // use this as looping through values is not safe.
    $expectedprefs = expected_account_preferences(); 
    try {
        foreach (array_keys($expectedprefs) as $pref) {
            set_account_preference($SESSION->get('id'), $pref, $expectedprefs[$pref]);
        }
    } 
    catch (Exception $e) {
Penny Leach's avatar
Penny Leach committed
105

106
    }
Penny Leach's avatar
Penny Leach committed
107
108
109
}


110
?>