1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category frontend
|
5
|
* @package account
|
6
|
* @author WebsiteBaker Project
|
7
|
* @copyright Ryan Djurovich
|
8
|
* @copyright WebsiteBaker Org. e.V.
|
9
|
* @link http://websitebaker.org/
|
10
|
* @license http://www.gnu.org/licenses/gpl.html
|
11
|
* @platform WebsiteBaker 2.8.3
|
12
|
* @requirements PHP 5.3.6 and higher
|
13
|
* @version $Id: preferences_form.php 2 2017-07-02 15:14:29Z Manuela $
|
14
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb/2.10.x/branches/main/account/preferences_form.php $
|
15
|
* @lastmodified $Date: 2017-07-02 17:14:29 +0200 (Sun, 02 Jul 2017) $
|
16
|
*
|
17
|
*/
|
18
|
// prevent this file from being accesses directly
|
19
|
if(defined('WB_PATH') == false) { exit("Cannot access this file directly"); }
|
20
|
$sCallingScript = WB_URL;
|
21
|
|
22
|
$redirect_url = (isset($_SESSION['HTTP_REFERER']) && ($_SESSION['HTTP_REFERER'] != '') ? $_SESSION['HTTP_REFERER'] : $sCallingScript );
|
23
|
$redirect_url = (isset($redirect) && ($redirect!='') ? $redirect : $redirect_url);
|
24
|
/*
|
25
|
print '<pre class="mod-pre rounded">function <span>'.__FUNCTION__.'( '.$page_id.' );</span> filename: <span>'.basename(__FILE__).'</span> line: '.__LINE__.' -> <br />';
|
26
|
print_r( $redirect_url ); print '</pre>'; flush (); // ob_flush();;sleep(10); die();
|
27
|
*/
|
28
|
if($wb->is_authenticated() === false) {
|
29
|
// User needs to login first
|
30
|
header("Location: ".WB_URL."/account/login.php?redirect=".$wb->link);
|
31
|
exit(0);
|
32
|
}
|
33
|
// load module default language file (EN)
|
34
|
$sAddonName = basename(__DIR__);
|
35
|
$oTrans = Translate::getInstance();
|
36
|
$oTrans->enableAddon('account');
|
37
|
|
38
|
//require(WB_PATH .'/'.$sAddonName.'/languages/EN.php');
|
39
|
//if(file_exists(WB_PATH .'/'.$sAddonName.'/languages/'.LANGUAGE .'.php')) {
|
40
|
// require(WB_PATH .'/'.$sAddonName.'/languages/'.LANGUAGE .'.php');
|
41
|
//}
|
42
|
require_once(WB_PATH.'/framework/functions-utf8.php');
|
43
|
/*
|
44
|
echo '<style type="text/css">';
|
45
|
include(WB_PATH .'/account/frontend.css');
|
46
|
echo "\n</style>\n";
|
47
|
*/
|
48
|
|
49
|
$user_time = true;
|
50
|
require(ADMIN_PATH.'/interface/timezones.php');
|
51
|
require(ADMIN_PATH.'/interface/date_formats.php');
|
52
|
require(ADMIN_PATH.'/interface/time_formats.php');
|
53
|
$error = array();
|
54
|
$success = array();
|
55
|
$template = new Template(WB_PATH .'/account','remove');
|
56
|
switch($wb->get_post('action')):
|
57
|
case 'details':
|
58
|
require_once(WB_PATH .'/account/details.php');
|
59
|
break;
|
60
|
case 'email':
|
61
|
require_once(WB_PATH .'/account/email.php');
|
62
|
break;
|
63
|
case 'password':
|
64
|
require_once(WB_PATH .'/account/password.php');
|
65
|
break;
|
66
|
default:
|
67
|
// do nothing
|
68
|
endswitch; // switch
|
69
|
// show template
|
70
|
$template->set_file('page', 'template.htt');
|
71
|
$template->set_block('page', 'main_block', 'main');
|
72
|
// get existing values from database
|
73
|
$sql = "SELECT `display_name`,`email` FROM `".TABLE_PREFIX."users` WHERE `user_id` = '".$wb->get_user_id()."'";
|
74
|
$rowset = $database->query($sql);
|
75
|
if($database->is_error()) { $error[] = $database->get_error(); }
|
76
|
$row = $rowset->fetchRow(MYSQLI_ASSOC);
|
77
|
// insert values into form
|
78
|
$template->set_var('DISPLAY_NAME', $row['display_name']);
|
79
|
$template->set_var('EMAIL', $row['email']);
|
80
|
// read available languages from table addons and assign it to the template
|
81
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'addons` ';
|
82
|
$sql .= 'WHERE `type` = \'language\' ORDER BY `directory`';
|
83
|
if( $res_lang = $database->query($sql) ) {
|
84
|
$template->set_block('main_block', 'language_list_block', 'language_list');
|
85
|
$iCurrentLanguage = (@$_SESSION['LANGUAGE'] ? : LANGUAGE);
|
86
|
while( $rec_lang = $res_lang->fetchRow(MYSQLI_ASSOC) )
|
87
|
{
|
88
|
$langIcons = (empty($rec_lang['directory'])) ? 'none' : strtolower($rec_lang['directory']);
|
89
|
$template->set_var('CODE', $rec_lang['directory']);
|
90
|
$template->set_var('NAME', $rec_lang['name']);
|
91
|
$template->set_var('FLAG', THEME_URL.'/images/flags/'.$langIcons);
|
92
|
$template->set_var('SELECTED', ($iCurrentLanguage == $rec_lang['directory'] ? ' selected="selected"' : '') );
|
93
|
$template->parse('language_list', 'language_list_block', true);
|
94
|
}
|
95
|
}
|
96
|
// Insert default timezone values
|
97
|
$template->set_block('main_block', 'timezone_list_block', 'timezone_list');
|
98
|
if( isset($_SESSION['TIMEZONE'])) {
|
99
|
$actual_time = time()+ $_SESSION['TIMEZONE'];
|
100
|
foreach($TIME_FORMATS as $key => &$val) {
|
101
|
if($key == "system_default") {
|
102
|
if(isset($oTrans->TEXT_SYSTEM_DEFAULT)) {
|
103
|
$TIME_FORMATS['system_default'] = gmdate(DEFAULT_TIME_FORMAT, $actual_time).' ('.$oTrans->TEXT_SYSTEM_DEFAULT.')';
|
104
|
} else {
|
105
|
$TIME_FORMATS['system_default'] = gmdate(DEFAULT_TIME_FORMAT, $actual_time).' (System Default)';
|
106
|
}
|
107
|
} else {
|
108
|
$format = str_replace("|", " ", $key);
|
109
|
$TIME_FORMATS[ $key ] = gmdate( $format, $actual_time);
|
110
|
}
|
111
|
}
|
112
|
// Keep in mind we've also update the Date! (± one day)
|
113
|
foreach($DATE_FORMATS as $key => &$val) {
|
114
|
if($key == "system_default") {
|
115
|
if(isset($oTrans->TEXT_SYSTEM_DEFAULT)) {
|
116
|
$DATE_FORMATS['system_default'] = gmdate(DEFAULT_DATE_FORMAT, $actual_time).' ('.$oTrans->TEXT_SYSTEM_DEFAULT.')';
|
117
|
} else {
|
118
|
$DATE_FORMATS['system_default'] = gmdate(DEFAULT_DATE_FORMAT, $actual_time).' (System Default)';
|
119
|
}
|
120
|
} else {
|
121
|
$format = str_replace("|", " ", $key);
|
122
|
$DATE_FORMATS[ $key ] = gmdate( $format, $actual_time);
|
123
|
}
|
124
|
}
|
125
|
}
|
126
|
|
127
|
$iActualTimezone = ((DEFAULT_TIMEZONE <> 0) ? DEFAULT_TIMEZONE : 0);
|
128
|
$iActualTimezone = (($iActualTimezone == $wb->get_timezone())? 'system_default':$wb->get_timezone());
|
129
|
$iCurrentTimeZone = intval(@$_SESSION['TIMEZONE'] ? : $iActualTimezone);
|
130
|
foreach($TIMEZONES AS $hour_offset => $title) {
|
131
|
$iTmpOffset = (is_numeric($hour_offset)?$hour_offset*3600:$hour_offset);
|
132
|
$template->set_var('VALUE', $hour_offset);
|
133
|
$template->set_var('NAME', $title);
|
134
|
$template->set_var('SELECTED', (($iTmpOffset === $iActualTimezone) ? ' selected="selected"' : ''));
|
135
|
/*
|
136
|
$template->set_var('VALUE', $hour_offset);
|
137
|
$template->set_var('NAME', $title);
|
138
|
if($iCurrentTimeZone == $hour_offset*3600) {
|
139
|
$template->set_var('SELECTED', 'selected="selected"');
|
140
|
} else {
|
141
|
$template->set_var('SELECTED', '');
|
142
|
}
|
143
|
*/
|
144
|
$template->parse('timezone_list', 'timezone_list_block', true);
|
145
|
}
|
146
|
// Insert date format list
|
147
|
$template->set_block('main_block', 'date_format_list_block', 'date_format_list');
|
148
|
$sTempDateFormat = (@$_SESSION['DATE_FORMAT'] ?: DATE_FORMAT);
|
149
|
foreach($DATE_FORMATS AS $format => $title) {
|
150
|
$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)
|
151
|
if($format != 'system_default') {
|
152
|
$template->set_var('VALUE', $format);
|
153
|
} else {
|
154
|
$template->set_var('VALUE', '');
|
155
|
}
|
156
|
$template->set_var('NAME', $title);
|
157
|
if($sTempDateFormat == $format AND !isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) {
|
158
|
$template->set_var('SELECTED', 'selected="selected"');
|
159
|
} elseif($format == 'system_default' AND isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) {
|
160
|
$template->set_var('SELECTED', 'selected="selected"');
|
161
|
} else {
|
162
|
$template->set_var('SELECTED', '');
|
163
|
}
|
164
|
$template->parse('date_format_list', 'date_format_list_block', true);
|
165
|
}
|
166
|
// Insert time format list
|
167
|
$template->set_block('main_block', 'time_format_list_block', 'time_format_list');
|
168
|
$sTimeFormat = (@$_SESSION['TIME_FORMAT'] ? : TIME_FORMAT );
|
169
|
foreach($TIME_FORMATS AS $format => $title) {
|
170
|
$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)
|
171
|
if($format != 'system_default') {
|
172
|
$template->set_var('VALUE', $format);
|
173
|
} else {
|
174
|
$template->set_var('VALUE', '');
|
175
|
}
|
176
|
$template->set_var('NAME', $title);
|
177
|
if($sTimeFormat == $format AND !isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) {
|
178
|
$template->set_var('SELECTED', 'selected="selected"');
|
179
|
} elseif($format == 'system_default' AND isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) {
|
180
|
$template->set_var('SELECTED', 'selected="selected"');
|
181
|
} else {
|
182
|
$template->set_var('SELECTED', '');
|
183
|
}
|
184
|
$template->parse('time_format_list', 'time_format_list_block', true);
|
185
|
}
|
186
|
// insert all translations
|
187
|
$template->set_var($oTrans->getLangArray());
|
188
|
$template->set_var('HTTP_REFERER', $redirect_url); //$_SESSION['HTTP_REFERER'],
|
189
|
// Insert language headings
|
190
|
// $template->set_var(array(
|
191
|
// 'HEADING_MY_SETTINGS' => $oTrans->HEADING_MY_SETTINGS,
|
192
|
// 'HEADING_MY_EMAIL' => $oTrans->HEADING_MY_EMAIL,
|
193
|
// 'HEADING_MY_PASSWORD' => $oTrans->HEADING_MY_PASSWORD
|
194
|
// )
|
195
|
// );
|
196
|
//// Insert language text and messages
|
197
|
// $template->set_var(array(
|
198
|
// 'TEXT_SAVE' => $oTrans->TEXT_SAVE,
|
199
|
// 'TEXT_RESET' => $oTrans->TEXT_RESET,
|
200
|
// 'TEXT_CANCEL' => $oTrans->TEXT_CANCEL,
|
201
|
// 'TEXT_DISPLAY_NAME' => $oTrans->TEXT_DISPLAY_NAME,
|
202
|
// 'TEXT_EMAIL' => $oTrans->TEXT_EMAIL,
|
203
|
// 'TEXT_LANGUAGE' => $oTrans->TEXT_LANGUAGE,
|
204
|
// 'TEXT_TIMEZONE' => $oTrans->TEXT_TIMEZONE,
|
205
|
// 'TEXT_DATE_FORMAT' => $oTrans->TEXT_DATE_FORMAT,
|
206
|
// 'TEXT_TIME_FORMAT' => $oTrans->TEXT_TIME_FORMAT,
|
207
|
// 'TEXT_CURRENT_PASSWORD' => $oTrans->TEXT_CURRENT_PASSWORD,
|
208
|
// 'TEXT_NEW_PASSWORD' => $oTrans->TEXT_NEW_PASSWORD,
|
209
|
// 'TEXT_RETYPE_NEW_PASSWORD' => $oTrans->TEXT_RETYPE_NEW_PASSWORD
|
210
|
// )
|
211
|
// );
|
212
|
//// Insert module releated language text and messages
|
213
|
// $template->set_var(array(
|
214
|
// 'MOD_PREFERENCE_PLEASE_SELECT' => $oTrans->MOD_PREFERENCE_PLEASE_SELECT,
|
215
|
// 'MOD_PREFERENCE_SAVE_SETTINGS' => $oTrans->MOD_PREFERENCE_SAVE_SETTINGS,
|
216
|
// 'MOD_PREFERENCE_SAVE_EMAIL' => $oTrans->MOD_PREFERENCE_SAVE_EMAIL,
|
217
|
// 'MOD_PREFERENCE_SAVE_PASSWORD' => $oTrans->MOD_PREFERENCE_SAVE_PASSWORD,
|
218
|
// )
|
219
|
// );
|
220
|
// Insert error and/or success messages
|
221
|
$template->set_block('main_block', 'error_block', 'error_list');
|
222
|
if(sizeof($error)>0){
|
223
|
foreach($error AS $value){
|
224
|
$template->set_var('ERROR_VALUE', $value);
|
225
|
$template->parse('error_list', 'error_block', true);
|
226
|
}
|
227
|
}
|
228
|
$template->set_block('main_block', 'success_block', 'success_list');
|
229
|
if(sizeof($success)!=0){
|
230
|
foreach($success AS $value){
|
231
|
$template->set_var('SUCCESS_VALUE', $value);
|
232
|
$template->parse('success_list', 'success_block', true);
|
233
|
}
|
234
|
}
|
235
|
// Parse template for preferences form
|
236
|
$template->parse('main', 'main_block', false);
|
237
|
$template->pparse('output', 'page');
|