-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.php
60 lines (49 loc) · 2.04 KB
/
user.php
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
32
33
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
<?php
/**
* user preferences and user creation
*/
require('./inc/config.php');
// No $_POST data or not logged -> display the blank form
if (!count($_POST) && (empty($_SESSION['strUserId']))) {
$smarty->assign( 'booDisplayMenu', false); // no need to display the menu (we're not logged)
$smarty->assign('arrTemplate', $sillaj->getTemplate()); // get default template
$smarty->assign('arrLanguage', $sillaj->getLanguage(true)); // get default language
$smarty->display('user.tpl');
}
// else $_GET data -> edit the account -> pre-fill the form
elseif (!count($_POST) && (!empty($_SESSION['strUserId']))) {
// Allowed to edit ?
$user->checkAuthent();
// if no user info concerning language and theme (old accounts), use session info
$arrUser = $user->get($_SESSION['strUserId']);
if ($arrUser['strLanguage'] == '') {
$arrUser['strLanguage'] = $_SESSION['strLocale'];
}
if ($arrUser['strTemplate'] == '') {
$arrUser['strTemplate'] = $_SESSION['strThemeName'];
}
$smarty->assign( 'booEdit', true); // to fill the fields
$smarty->assign_by_ref( 'arrUser', $arrUser);
$smarty->assign('arrTemplate', $sillaj->getTemplate());
$smarty->assign('arrLanguage', $sillaj->getLanguage(true));
$smarty->display('user.tpl');
}
// else $_POST data -> validate the form
elseif (count($_POST)) {
if (empty($_POST['booEdit'])) { // we're creating a new user
$smarty->assign('strMessage', $user->add());
$user->execAuthent(false); // Authentication without redirect
header('Location: ./');
}
else {
// Allowed to edit ?
// We must be authenticated...
$user->checkAuthent();
// ... and the user in the session must match the account to edit
if ($_SESSION['strUserId'] != $_REQUEST['strUserId']) {
raiseError(STR_EDIT_ACCOUNT_NOT_ALLOWED_SILLAJ);
}
displayMessage($user->set());
}
}
?>