1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category frontend
|
5
|
* @package account
|
6
|
* @author WebsiteBaker Project
|
7
|
* @copyright 2009-2012, WebsiteBaker Org. e.V.
|
8
|
* @link http://www.websitebaker2.org/
|
9
|
* @license http://www.gnu.org/licenses/gpl.html
|
10
|
* @platform WebsiteBaker 2.8.x
|
11
|
* @requirements PHP 5.2.2 and higher
|
12
|
* @version $Id: preferences_form.php 1719 2012-08-29 14:59:35Z Luisehahne $
|
13
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/account/preferences_form.php $
|
14
|
* @lastmodified $Date: 2012-08-29 16:59:35 +0200 (Wed, 29 Aug 2012) $
|
15
|
*
|
16
|
*/
|
17
|
|
18
|
/* -------------------------------------------------------- */
|
19
|
// Must include code to stop this file being accessed directly
|
20
|
if(defined('WB_PATH') == false)
|
21
|
{
|
22
|
// Stop this file being access directly
|
23
|
die('<h2 style="color:red;margin:3em auto;text-align:center;">Cannot access this file directly</h2>');
|
24
|
}
|
25
|
/* -------------------------------------------------------- */
|
26
|
|
27
|
if($wb->is_authenticated() === false) {
|
28
|
// User needs to login first
|
29
|
header("Location: ".WB_URL."/account/login.php?redirect=".$wb->link);
|
30
|
exit(0);
|
31
|
}
|
32
|
|
33
|
// load module default language file (EN)
|
34
|
require_once(WB_PATH .'/account/languages/EN.php');
|
35
|
// check for user defined language file, load it and override EN-Settings with
|
36
|
if(file_exists(WB_PATH .'/account/languages/' .LANGUAGE .'.php')) {
|
37
|
require_once(WB_PATH .'/account/languages/' .LANGUAGE .'.php');
|
38
|
}
|
39
|
require_once(WB_PATH.'/framework/functions-utf8.php');
|
40
|
echo '<style type="text/css">';
|
41
|
include(WB_PATH .'/account/frontend.css');
|
42
|
echo "\n</style>\n";
|
43
|
$user_time = true;
|
44
|
require(ADMIN_PATH.'/interface/timezones.php');
|
45
|
require(ADMIN_PATH.'/interface/date_formats.php');
|
46
|
require(ADMIN_PATH.'/interface/time_formats.php');
|
47
|
$error = array();
|
48
|
$success = array();
|
49
|
$template = new Template(WB_PATH .'/account','keep');
|
50
|
|
51
|
switch($wb->get_post('action')):
|
52
|
case 'details':
|
53
|
require_once(WB_PATH .'/account/details.php');
|
54
|
break;
|
55
|
case 'email':
|
56
|
require_once(WB_PATH .'/account/email.php');
|
57
|
|
58
|
break;
|
59
|
case 'password':
|
60
|
require_once(WB_PATH .'/account/password.php');
|
61
|
break;
|
62
|
default:
|
63
|
// do nothing
|
64
|
endswitch; // switch
|
65
|
|
66
|
// show template
|
67
|
$template->set_file('page', 'preferences.htt');
|
68
|
$template->set_block('page', 'main_block', 'main');
|
69
|
// get existing values from database
|
70
|
$sql = "SELECT display_name,email FROM ".TABLE_PREFIX."users WHERE user_id = '".$wb->get_user_id()."'";
|
71
|
$rowset = $database->query($sql);
|
72
|
if($database->is_error()) $error[] = $database->get_error();
|
73
|
$row = $rowset->fetchRow();
|
74
|
// insert values into form
|
75
|
$template->set_var('DISPLAY_NAME', $row['display_name']);
|
76
|
$template->set_var('EMAIL', $row['email']);
|
77
|
|
78
|
// read available languages from table addons and assign it to the template
|
79
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'addons` ';
|
80
|
$sql .= 'WHERE `type` = \'language\' ORDER BY `directory`';
|
81
|
if( $res_lang = $database->query($sql) )
|
82
|
{
|
83
|
$template->set_block('main_block', 'language_list_block', 'language_list');
|
84
|
while( $rec_lang = $res_lang->fetchRow() )
|
85
|
{
|
86
|
$langIcons = (empty($rec_lang['directory'])) ? 'none' : strtolower($rec_lang['directory']);
|
87
|
$template->set_var('CODE', $rec_lang['directory']);
|
88
|
$template->set_var('NAME', $rec_lang['name']);
|
89
|
$template->set_var('FLAG', THEME_URL.'/images/flags/'.$langIcons);
|
90
|
$template->set_var('SELECTED', (LANGUAGE == $rec_lang['directory'] ? ' selected="selected"' : '') );
|
91
|
$template->parse('language_list', 'language_list_block', true);
|
92
|
}
|
93
|
}
|
94
|
// Insert default timezone values
|
95
|
$template->set_block('main_block', 'timezone_list_block', 'timezone_list');
|
96
|
foreach($TIMEZONES AS $hour_offset => $title) {
|
97
|
$template->set_var('VALUE', $hour_offset);
|
98
|
$template->set_var('NAME', $title);
|
99
|
if($wb->get_timezone() == $hour_offset*3600) {
|
100
|
$template->set_var('SELECTED', 'selected="selected"');
|
101
|
} else {
|
102
|
$template->set_var('SELECTED', '');
|
103
|
}
|
104
|
$template->parse('timezone_list', 'timezone_list_block', true);
|
105
|
}
|
106
|
|
107
|
// Insert date format list
|
108
|
$template->set_block('main_block', 'date_format_list_block', 'date_format_list');
|
109
|
foreach($DATE_FORMATS AS $format => $title) {
|
110
|
$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)
|
111
|
if($format != 'system_default') {
|
112
|
$template->set_var('VALUE', $format);
|
113
|
} else {
|
114
|
$template->set_var('VALUE', '');
|
115
|
}
|
116
|
$template->set_var('NAME', $title);
|
117
|
if(DATE_FORMAT == $format AND !isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) {
|
118
|
$template->set_var('SELECTED', 'selected="selected"');
|
119
|
} elseif($format == 'system_default' AND isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) {
|
120
|
$template->set_var('SELECTED', 'selected="selected"');
|
121
|
} else {
|
122
|
$template->set_var('SELECTED', '');
|
123
|
}
|
124
|
$template->parse('date_format_list', 'date_format_list_block', true);
|
125
|
}
|
126
|
|
127
|
// Insert time format list
|
128
|
$template->set_block('main_block', 'time_format_list_block', 'time_format_list');
|
129
|
foreach($TIME_FORMATS AS $format => $title) {
|
130
|
$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)
|
131
|
if($format != 'system_default') {
|
132
|
$template->set_var('VALUE', $format);
|
133
|
} else {
|
134
|
$template->set_var('VALUE', '');
|
135
|
}
|
136
|
$template->set_var('NAME', $title);
|
137
|
if(TIME_FORMAT == $format AND !isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) {
|
138
|
$template->set_var('SELECTED', 'selected="selected"');
|
139
|
} elseif($format == 'system_default' AND isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) {
|
140
|
$template->set_var('SELECTED', 'selected="selected"');
|
141
|
} else {
|
142
|
$template->set_var('SELECTED', '');
|
143
|
}
|
144
|
$template->parse('time_format_list', 'time_format_list_block', true);
|
145
|
}
|
146
|
// Insert language headings
|
147
|
$template->set_var(array(
|
148
|
'HEADING_MY_SETTINGS' => $HEADING['MY_SETTINGS'],
|
149
|
'HEADING_MY_EMAIL' => $HEADING['MY_EMAIL'],
|
150
|
'HEADING_MY_PASSWORD' => $HEADING['MY_PASSWORD']
|
151
|
)
|
152
|
);
|
153
|
// Insert language text and messages
|
154
|
$template->set_var(array(
|
155
|
'HTTP_REFERER' => $_SESSION['HTTP_REFERER'],
|
156
|
'TEXT_SAVE' => $TEXT['SAVE'],
|
157
|
'TEXT_RESET' => $TEXT['RESET'],
|
158
|
'TEXT_CANCEL' => $TEXT['CANCEL'],
|
159
|
'TEXT_DISPLAY_NAME' => $TEXT['DISPLAY_NAME'],
|
160
|
'TEXT_EMAIL' => $TEXT['EMAIL'],
|
161
|
'TEXT_LANGUAGE' => $TEXT['LANGUAGE'],
|
162
|
'TEXT_TIMEZONE' => $TEXT['TIMEZONE'],
|
163
|
'TEXT_DATE_FORMAT' => $TEXT['DATE_FORMAT'],
|
164
|
'TEXT_TIME_FORMAT' => $TEXT['TIME_FORMAT'],
|
165
|
'TEXT_CURRENT_PASSWORD' => $TEXT['CURRENT_PASSWORD'],
|
166
|
'TEXT_NEW_PASSWORD' => $TEXT['NEW_PASSWORD'],
|
167
|
'TEXT_RETYPE_NEW_PASSWORD' => $TEXT['RETYPE_NEW_PASSWORD']
|
168
|
)
|
169
|
);
|
170
|
|
171
|
// Insert module releated language text and messages
|
172
|
$template->set_var(array(
|
173
|
'MOD_PREFERENCE_PLEASE_SELECT' => $MOD_PREFERENCE['PLEASE_SELECT'],
|
174
|
'MOD_PREFERENCE_SAVE_SETTINGS' => $MOD_PREFERENCE['SAVE_SETTINGS'],
|
175
|
'MOD_PREFERENCE_SAVE_EMAIL' => $MOD_PREFERENCE['SAVE_EMAIL'],
|
176
|
'MOD_PREFERENCE_SAVE_PASSWORD' => $MOD_PREFERENCE['SAVE_PASSWORD'],
|
177
|
)
|
178
|
);
|
179
|
// Insert error and/or success messages
|
180
|
$template->set_block('main_block', 'error_block', 'error_list');
|
181
|
$template->set_var('ERROR_VALUE', '');
|
182
|
if(sizeof($error)>0){
|
183
|
foreach($error AS $value){
|
184
|
$template->set_var('ERROR_VALUE', $value);
|
185
|
$template->parse('error_list', 'error_block', true);
|
186
|
}
|
187
|
} else {
|
188
|
$template->parse('error_list', '');
|
189
|
}
|
190
|
|
191
|
$template->set_block('main_block', 'success_block', 'success_list');
|
192
|
$template->set_var('SUCCESS_VALUE', '');
|
193
|
if(sizeof($success)!=0){
|
194
|
foreach($success AS $value){
|
195
|
$template->set_var('SUCCESS_VALUE', $value);
|
196
|
$template->parse('success_list', 'success_block', true);
|
197
|
}
|
198
|
} else {
|
199
|
$template->parse('success_list', '');
|
200
|
}
|
201
|
// Parse template for preferences form
|
202
|
$template->parse('main', 'main_block', false);
|
203
|
$template->pparse('output', 'page');
|