1 |
1420
|
Luisehahne
|
<?php
|
2 |
|
|
/**
|
3 |
1777
|
Luisehahne
|
*
|
4 |
|
|
* @category frontend
|
5 |
|
|
* @package account
|
6 |
|
|
* @author WebsiteBaker Project
|
7 |
|
|
* @copyright 2009-2012, WebsiteBaker Org. e.V.
|
8 |
1792
|
Luisehahne
|
* @link http://www.websitebaker2.org/
|
9 |
1777
|
Luisehahne
|
* @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$
|
13 |
1849
|
Luisehahne
|
* @filesource $HeadURL$
|
14 |
1777
|
Luisehahne
|
* @lastmodified $Date$
|
15 |
|
|
*
|
16 |
|
|
*/
|
17 |
1420
|
Luisehahne
|
|
18 |
1719
|
Luisehahne
|
/* -------------------------------------------------------- */
|
19 |
|
|
// Must include code to stop this file being accessed directly
|
20 |
1777
|
Luisehahne
|
if(!defined('WB_PATH')) {
|
21 |
|
|
require_once(dirname(dirname(__FILE__)).'/framework/globalExceptionHandler.php');
|
22 |
|
|
throw new IllegalFileException();
|
23 |
1719
|
Luisehahne
|
}
|
24 |
|
|
/* -------------------------------------------------------- */
|
25 |
1420
|
Luisehahne
|
|
26 |
1987
|
Luisehahne
|
$oReg = WbAdaptor::getInstance();
|
27 |
|
|
$mLang = Translate::getinstance();
|
28 |
|
|
|
29 |
1777
|
Luisehahne
|
if($wb->is_authenticated() === false) {
|
30 |
1508
|
Luisehahne
|
// User needs to login first
|
31 |
1792
|
Luisehahne
|
header("Location: ".WB_URL."/account/login.php?redirect=".$wb->link);
|
32 |
|
|
exit(0);
|
33 |
1777
|
Luisehahne
|
}
|
34 |
1420
|
Luisehahne
|
|
35 |
1792
|
Luisehahne
|
/**
|
36 |
|
|
*
|
37 |
|
|
*/
|
38 |
|
|
$sUserLanguage = LANGUAGE;
|
39 |
|
|
// Check existing language
|
40 |
|
|
$sql = 'SELECT `language` ';
|
41 |
|
|
$sql .= 'FROM `'.TABLE_PREFIX.'users` ';
|
42 |
|
|
$sql .= 'WHERE `user_id` = '.$wb->get_user_id();
|
43 |
2051
|
darkviper
|
if (($sUserLanguage = $database->get_one($sql))) {
|
44 |
1792
|
Luisehahne
|
$_SESSION['LANGUAGE'] = $sUserLanguage;
|
45 |
|
|
}
|
46 |
|
|
|
47 |
|
|
$sDefaultLanguage = DEFAULT_LANGUAGE;
|
48 |
|
|
//$sLang = $wb->get_session('LANGUAGE');
|
49 |
|
|
$sLanguage = LANGUAGE.'.php';
|
50 |
|
|
|
51 |
|
|
$LanguageDir = WB_PATH .'/account/languages/';
|
52 |
2051
|
darkviper
|
$sLanguageFile = ( is_readable($LanguageDir.$sUserLanguage.'.php') ? $LanguageDir.$sUserLanguage.'.php' : $LanguageDir.$sLanguage);
|
53 |
1792
|
Luisehahne
|
$sLanguageFile = ( is_readable($sLanguageFile) ? $sLanguageFile : $LanguageDir.$sDefaultLanguage.'.php' );
|
54 |
1508
|
Luisehahne
|
// load module default language file (EN)
|
55 |
2051
|
darkviper
|
if (is_readable($sLanguageFile)) { require_once($sLanguageFile); }
|
56 |
1792
|
Luisehahne
|
|
57 |
1845
|
Luisehahne
|
if(!function_exists('utf8_check')) { require(WB_PATH.'/framework/functions-utf8.php'); }
|
58 |
1792
|
Luisehahne
|
|
59 |
|
|
$sIncludeHeadLinkCss = '';
|
60 |
|
|
if( is_readable(WB_PATH .'/account/frontend.css')) {
|
61 |
|
|
$sIncludeHeadLinkCss .= '<link href="'.WB_URL.'/account/frontend.css"';
|
62 |
|
|
$sIncludeHeadLinkCss .= ' rel="stylesheet" type="text/css" media="screen" />'."\n";
|
63 |
1777
|
Luisehahne
|
}
|
64 |
1773
|
Luisehahne
|
|
65 |
1777
|
Luisehahne
|
$error = array();
|
66 |
|
|
$success = array();
|
67 |
1792
|
Luisehahne
|
|
68 |
1777
|
Luisehahne
|
$template = new Template(WB_PATH .'/account/htt','keep');
|
69 |
1420
|
Luisehahne
|
|
70 |
1792
|
Luisehahne
|
// show template
|
71 |
|
|
$template->set_file('page', 'preferences.htt');
|
72 |
|
|
$template->set_block('page', 'main_block', 'main');
|
73 |
|
|
|
74 |
|
|
/**
|
75 |
|
|
*
|
76 |
|
|
*/
|
77 |
1777
|
Luisehahne
|
switch($wb->get_post('action')):
|
78 |
1792
|
Luisehahne
|
case 'details':
|
79 |
|
|
require_once(WB_PATH .'/account/details.php');
|
80 |
|
|
break;
|
81 |
|
|
case 'email':
|
82 |
|
|
require_once(WB_PATH .'/account/email.php');
|
83 |
|
|
break;
|
84 |
|
|
case 'password':
|
85 |
|
|
require_once(WB_PATH .'/account/password.php');
|
86 |
|
|
break;
|
87 |
|
|
default:
|
88 |
1777
|
Luisehahne
|
// do nothing
|
89 |
|
|
endswitch; // switch
|
90 |
1987
|
Luisehahne
|
|
91 |
1792
|
Luisehahne
|
// get existing values from database
|
92 |
|
|
$sql = "SELECT `display_name`,`email`,`language`,`timezone`,`date_format`,`time_format` ";
|
93 |
|
|
$sql .= "FROM `".TABLE_PREFIX."users` ";
|
94 |
|
|
$sql .= "WHERE `user_id` = '".$wb->get_user_id()."'";
|
95 |
1420
|
Luisehahne
|
|
96 |
1792
|
Luisehahne
|
if($rowset = $database->query($sql)) {
|
97 |
|
|
$row = $rowset->fetchRow();
|
98 |
|
|
$_SESSION['LANGUAGE'] = $row['language'];
|
99 |
|
|
$_SESSION['EMAIL'] = $row['email'];
|
100 |
|
|
$_SESSION['DISPLAY_NAME'] = $row['display_name'];
|
101 |
|
|
$_SESSION['TIMEZONE'] = $row['timezone'];
|
102 |
|
|
$_SESSION['DATE_FORMAT'] = $row['date_format'];
|
103 |
|
|
$_SESSION['TIME_FORMAT'] = $row['time_format'];
|
104 |
|
|
}
|
105 |
1777
|
Luisehahne
|
if($database->is_error()) $error[] = $database->get_error();
|
106 |
1508
|
Luisehahne
|
// insert values into form
|
107 |
1777
|
Luisehahne
|
$template->set_var('DISPLAY_NAME', $row['display_name']);
|
108 |
|
|
$template->set_var('EMAIL', $row['email']);
|
109 |
|
|
$template->set_var('ACTION_URL', WB_URL.'/account/preferences.php');
|
110 |
1508
|
Luisehahne
|
|
111 |
1792
|
Luisehahne
|
$_SESSION['HTTP_REFERER'] =( ($_SESSION['LANGUAGE'] != LANGUAGE ) ? WB_URL.'?lang='.$_SESSION['LANGUAGE'] : $_SESSION['HTTP_REFERER']);
|
112 |
|
|
$template->set_block('main_block', 'show_detail_send_block', 'show_detail_send');
|
113 |
|
|
$template->set_block('main_block', 'show_email_send_block', 'show_email_send');
|
114 |
|
|
$template->set_block('main_block', 'show_password_send_block', 'show_password_send');
|
115 |
|
|
|
116 |
1987
|
Luisehahne
|
$aLangAddons = array();
|
117 |
|
|
$aLangBrowser = array();
|
118 |
|
|
// default, if no information from client available
|
119 |
|
|
$sAutoLanguage = DEFAULT_LANGUAGE;
|
120 |
|
|
|
121 |
|
|
// read available languages from table addons
|
122 |
|
|
$aLangAddons = $admin->getAvailableLanguages();
|
123 |
|
|
|
124 |
|
|
$aLangUsed = array_flip(explode(',',$wb->getLanguagesInUsed()));
|
125 |
|
|
$aLangUsed = array_intersect_key($aLangAddons, $aLangUsed);
|
126 |
|
|
if( (sizeof($aLangUsed)<2) || !($oReg->PageLanguages) ){
|
127 |
|
|
$aLangUsed = $aLangAddons;
|
128 |
|
|
}
|
129 |
|
|
|
130 |
|
|
if( !(array_key_exists($sUserLanguage, $aLangUsed)) ) {
|
131 |
1792
|
Luisehahne
|
$template->parse('show_detail_send', '');
|
132 |
|
|
$template->parse('show_email_send', '');
|
133 |
|
|
$template->parse('show_password_send', '');
|
134 |
|
|
} else {
|
135 |
|
|
$template->parse('show_detail_send', 'show_detail_send_block');
|
136 |
|
|
$template->parse('show_email_send', 'show_email_send_block');
|
137 |
|
|
$template->parse('show_password_send', 'show_password_send_block');
|
138 |
|
|
}
|
139 |
|
|
|
140 |
1845
|
Luisehahne
|
// Insert language text and messages visibilty="hidden"
|
141 |
1987
|
Luisehahne
|
// WB_URL.'/account/preferences.php'
|
142 |
1792
|
Luisehahne
|
$template->set_var(array(
|
143 |
1987
|
Luisehahne
|
'REFERER_ID' => ( $wb->get_session('HTTP_REFERER')!='' ? $_SESSION['HTTP_REFERER'] : WB_URL),
|
144 |
|
|
'HTTP_REFERER' => (!(array_key_exists($sUserLanguage, $aLangUsed)) ?WB_URL.'/account/preferences.php':( $wb->get_session('HTTP_REFERER')!='' ? $_SESSION['HTTP_REFERER'] : WB_URL)),
|
145 |
1792
|
Luisehahne
|
'CSS_BLOCK' => $sIncludeHeadLinkCss,
|
146 |
|
|
'TEXT_SAVE' => $TEXT['SAVE'],
|
147 |
|
|
'TEXT_RESET' => $TEXT['RESET'],
|
148 |
1987
|
Luisehahne
|
'SUBMIT_BUTTON' => (!(array_key_exists($sUserLanguage, $aLangUsed)) ?'submit':'button'),
|
149 |
|
|
'VALUE_BUTTON' => (!(array_key_exists($sUserLanguage, $aLangUsed)) ?'details':'cancel'),
|
150 |
|
|
'TEXT_CANCEL' => (!(array_key_exists($sUserLanguage, $aLangUsed)) ? $MOD_PREFERENCE['SAVE_LANGUAGE']:$TEXT['CANCEL']),
|
151 |
|
|
'MOD_PREFERENCE_SET_PREFERENCES_LANGUAGE' => !(array_key_exists($sUserLanguage, $aLangUsed)) ? $MOD_PREFERENCE['SET_PREFERENCES_LANGUAGE']:'',
|
152 |
|
|
'DISPLAY_PREFERENCES_LANGUAGE' => !(array_key_exists($sUserLanguage, $aLangUsed)) ? '':'display:none',
|
153 |
1845
|
Luisehahne
|
'TEXT_DISPLAY_NAME' => $TEXT['DISPLAY_NAME'],
|
154 |
1792
|
Luisehahne
|
'TEXT_EMAIL' => $TEXT['EMAIL'],
|
155 |
|
|
'TEXT_LANGUAGE' => $TEXT['LANGUAGE'],
|
156 |
|
|
'TEXT_TIMEZONE' => $TEXT['TIMEZONE'],
|
157 |
|
|
'TEXT_DATE_FORMAT' => $TEXT['DATE_FORMAT'],
|
158 |
|
|
'TEXT_TIME_FORMAT' => $TEXT['TIME_FORMAT'],
|
159 |
|
|
'TEXT_CURRENT_PASSWORD' => $TEXT['CURRENT_PASSWORD'],
|
160 |
|
|
'TEXT_NEW_PASSWORD' => $TEXT['NEW_PASSWORD'],
|
161 |
|
|
'TEXT_RETYPE_NEW_PASSWORD' => $TEXT['RETYPE_NEW_PASSWORD']
|
162 |
|
|
)
|
163 |
|
|
);
|
164 |
|
|
|
165 |
|
|
// read available languages from table addons and assign it to the template
|
166 |
|
|
$template->set_block('main_block', 'language_list_block', 'language_list');
|
167 |
|
|
foreach( $aLangUsed as $sDirectory => $sName )
|
168 |
|
|
{
|
169 |
1872
|
Luisehahne
|
$langIcons = ( empty($sDirectory) ? 'none' : strtolower($sDirectory));
|
170 |
1792
|
Luisehahne
|
|
171 |
1872
|
Luisehahne
|
$template->set_var('CODE', $sDirectory);
|
172 |
|
|
$template->set_var('NAME', $sName);
|
173 |
|
|
$template->set_var('FLAG', THEME_URL.'/images/flags/'.$langIcons);
|
174 |
|
|
$template->set_var('SELECTED', ( $_SESSION['LANGUAGE'] == $sDirectory ? ' selected="selected"' : '') );
|
175 |
1792
|
Luisehahne
|
|
176 |
1872
|
Luisehahne
|
$template->parse('language_list', 'language_list_block', true);
|
177 |
1792
|
Luisehahne
|
}
|
178 |
|
|
|
179 |
1508
|
Luisehahne
|
// Insert default timezone values
|
180 |
1872
|
Luisehahne
|
$user_time = true;
|
181 |
|
|
require(ADMIN_PATH.'/interface/timezones.php');
|
182 |
1777
|
Luisehahne
|
$template->set_block('main_block', 'timezone_list_block', 'timezone_list');
|
183 |
|
|
foreach($TIMEZONES AS $hour_offset => $title) {
|
184 |
1872
|
Luisehahne
|
$template->set_var('VALUE', $hour_offset);
|
185 |
|
|
$template->set_var('NAME', $title);
|
186 |
|
|
$template->set_var('SELECTED', ($wb->get_timezone() == ($hour_offset * 3600) ? ' selected="selected"' : '') );
|
187 |
|
|
$template->parse('timezone_list', 'timezone_list_block', true);
|
188 |
1777
|
Luisehahne
|
}
|
189 |
1508
|
Luisehahne
|
// Insert date format list
|
190 |
1872
|
Luisehahne
|
$user_time = true;
|
191 |
|
|
require(ADMIN_PATH.'/interface/date_formats.php');
|
192 |
1777
|
Luisehahne
|
$template->set_block('main_block', 'date_format_list_block', 'date_format_list');
|
193 |
|
|
foreach($DATE_FORMATS AS $format => $title)
|
194 |
|
|
{
|
195 |
1872
|
Luisehahne
|
$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)
|
196 |
|
|
if($format != 'system_default') {
|
197 |
|
|
$template->set_var('VALUE', $format);
|
198 |
|
|
} else {
|
199 |
|
|
$template->set_var('VALUE', '');
|
200 |
|
|
}
|
201 |
|
|
$template->set_var('NAME', $title);
|
202 |
|
|
if($wb->get_session('DATE_FORMAT') == $format AND !isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) {
|
203 |
|
|
$template->set_var('SELECTED', 'selected="selected"');
|
204 |
|
|
} elseif($format == 'system_default' AND isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) {
|
205 |
|
|
$template->set_var('SELECTED', 'selected="selected"');
|
206 |
|
|
} else {
|
207 |
|
|
$template->set_var('SELECTED', '');
|
208 |
|
|
}
|
209 |
|
|
$template->parse('date_format_list', 'date_format_list_block', true);
|
210 |
1777
|
Luisehahne
|
}
|
211 |
1420
|
Luisehahne
|
|
212 |
1872
|
Luisehahne
|
// Insert time format list
|
213 |
1849
|
Luisehahne
|
$user_time = true;
|
214 |
1872
|
Luisehahne
|
require(ADMIN_PATH.'/interface/time_formats.php');
|
215 |
1777
|
Luisehahne
|
$template->set_block('main_block', 'time_format_list_block', 'time_format_list');
|
216 |
|
|
foreach($TIME_FORMATS AS $format => $title)
|
217 |
|
|
{
|
218 |
1872
|
Luisehahne
|
$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)
|
219 |
|
|
if($format != 'system_default') {
|
220 |
|
|
$template->set_var('VALUE', $format);
|
221 |
|
|
} else {
|
222 |
|
|
$template->set_var('VALUE', '');
|
223 |
|
|
}
|
224 |
|
|
$template->set_var('NAME', $title);
|
225 |
|
|
if($wb->get_session('TIME_FORMAT') == $format AND !isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) {
|
226 |
|
|
$template->set_var('SELECTED', 'selected="selected"');
|
227 |
|
|
} elseif($format == 'system_default' AND isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) {
|
228 |
|
|
$template->set_var('SELECTED', 'selected="selected"');
|
229 |
|
|
} else {
|
230 |
|
|
$template->set_var('SELECTED', '');
|
231 |
|
|
}
|
232 |
|
|
$template->parse('time_format_list', 'time_format_list_block', true);
|
233 |
1777
|
Luisehahne
|
}
|
234 |
1508
|
Luisehahne
|
// Insert language headings
|
235 |
1777
|
Luisehahne
|
$template->set_var(array(
|
236 |
1792
|
Luisehahne
|
'HEADING_MY_SETTINGS' => $HEADING['MY_SETTINGS'],
|
237 |
|
|
'HEADING_MY_EMAIL' => $HEADING['MY_EMAIL'],
|
238 |
|
|
'HEADING_MY_PASSWORD' => $HEADING['MY_PASSWORD']
|
239 |
1777
|
Luisehahne
|
)
|
240 |
|
|
);
|
241 |
1420
|
Luisehahne
|
|
242 |
1508
|
Luisehahne
|
// Insert module releated language text and messages
|
243 |
1777
|
Luisehahne
|
$template->set_var(array(
|
244 |
|
|
'MOD_PREFERENCE_PLEASE_SELECT' => $MOD_PREFERENCE['PLEASE_SELECT'],
|
245 |
|
|
'MOD_PREFERENCE_SAVE_SETTINGS' => $MOD_PREFERENCE['SAVE_SETTINGS'],
|
246 |
|
|
'MOD_PREFERENCE_SAVE_EMAIL' => $MOD_PREFERENCE['SAVE_EMAIL'],
|
247 |
|
|
'MOD_PREFERENCE_SAVE_PASSWORD' => $MOD_PREFERENCE['SAVE_PASSWORD'],
|
248 |
|
|
)
|
249 |
|
|
);
|
250 |
1508
|
Luisehahne
|
// Insert error and/or success messages
|
251 |
1777
|
Luisehahne
|
$template->set_block('main_block', 'error_block', 'error_list');
|
252 |
|
|
$template->set_var('ERROR_VALUE', '');
|
253 |
|
|
if(sizeof($error)>0){
|
254 |
|
|
$template->set_var('ERROR_VALUE', $wb->format_message(implode('<br />',$error),'error'));
|
255 |
|
|
$template->parse('error_list', 'error_block', true);
|
256 |
|
|
} else {
|
257 |
|
|
$template->parse('error_list', '');
|
258 |
|
|
}
|
259 |
1420
|
Luisehahne
|
|
260 |
1777
|
Luisehahne
|
$template->set_block('main_block', 'success_block', 'success_list');
|
261 |
|
|
$template->set_var('SUCCESS_VALUE', '');
|
262 |
|
|
if(sizeof($success)!=0){
|
263 |
|
|
$template->set_var('SUCCESS_VALUE', $wb->format_message(implode('<br />',$success),'ok'));
|
264 |
|
|
$template->parse('success_list', 'success_block', true);
|
265 |
|
|
} else {
|
266 |
|
|
$template->parse('success_list', '');
|
267 |
|
|
}
|
268 |
1508
|
Luisehahne
|
// Parse template for preferences form
|
269 |
1777
|
Luisehahne
|
$template->parse('main', 'main_block', false);
|
270 |
|
|
$template->pparse('output', 'page');
|