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 |
|
|
* @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$
|
13 |
|
|
* @filesource $HeadURL$
|
14 |
|
|
* @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 |
1777
|
Luisehahne
|
if($wb->is_authenticated() === false) {
|
27 |
1508
|
Luisehahne
|
// User needs to login first
|
28 |
1777
|
Luisehahne
|
header("Location: ".WB_URL."/account/login.php?redirect=".$wb->link);
|
29 |
|
|
exit(0);
|
30 |
|
|
}
|
31 |
1420
|
Luisehahne
|
|
32 |
1508
|
Luisehahne
|
// load module default language file (EN)
|
33 |
1777
|
Luisehahne
|
require_once(WB_PATH .'/account/languages/EN.php');
|
34 |
1508
|
Luisehahne
|
// check for user defined language file, load it and override EN-Settings with
|
35 |
1777
|
Luisehahne
|
if(file_exists(WB_PATH .'/account/languages/' .LANGUAGE .'.php')) {
|
36 |
|
|
require_once(WB_PATH .'/account/languages/' .LANGUAGE .'.php');
|
37 |
|
|
}
|
38 |
|
|
require_once(WB_PATH.'/framework/functions-utf8.php');
|
39 |
1773
|
Luisehahne
|
|
40 |
|
|
// echo '<style type="text/css">';
|
41 |
|
|
// include(WB_PATH .'/account/frontend.css');
|
42 |
|
|
// echo "\n</style>\n";
|
43 |
|
|
|
44 |
1777
|
Luisehahne
|
$user_time = true;
|
45 |
|
|
require(ADMIN_PATH.'/interface/timezones.php');
|
46 |
|
|
require(ADMIN_PATH.'/interface/date_formats.php');
|
47 |
|
|
require(ADMIN_PATH.'/interface/time_formats.php');
|
48 |
|
|
$error = array();
|
49 |
|
|
$success = array();
|
50 |
|
|
$template = new Template(WB_PATH .'/account/htt','keep');
|
51 |
1420
|
Luisehahne
|
|
52 |
1777
|
Luisehahne
|
switch($wb->get_post('action')):
|
53 |
|
|
case 'details':
|
54 |
|
|
require_once(WB_PATH .'/account/details.php');
|
55 |
|
|
break;
|
56 |
|
|
case 'email':
|
57 |
|
|
require_once(WB_PATH .'/account/email.php');
|
58 |
1420
|
Luisehahne
|
|
59 |
1777
|
Luisehahne
|
break;
|
60 |
|
|
case 'password':
|
61 |
|
|
require_once(WB_PATH .'/account/password.php');
|
62 |
|
|
break;
|
63 |
|
|
default:
|
64 |
|
|
// do nothing
|
65 |
|
|
endswitch; // switch
|
66 |
1420
|
Luisehahne
|
|
67 |
1508
|
Luisehahne
|
// show template
|
68 |
1777
|
Luisehahne
|
$template->set_file('page', 'preferences.htt');
|
69 |
|
|
$template->set_block('page', 'main_block', 'main');
|
70 |
1508
|
Luisehahne
|
// get existing values from database
|
71 |
1777
|
Luisehahne
|
$sql = "SELECT `display_name`,`email` FROM ".TABLE_PREFIX."users WHERE `user_id` = '".$wb->get_user_id()."'";
|
72 |
|
|
$rowset = $database->query($sql);
|
73 |
|
|
if($database->is_error()) $error[] = $database->get_error();
|
74 |
|
|
$row = $rowset->fetchRow();
|
75 |
1508
|
Luisehahne
|
// insert values into form
|
76 |
1777
|
Luisehahne
|
$template->set_var('DISPLAY_NAME', $row['display_name']);
|
77 |
|
|
$template->set_var('EMAIL', $row['email']);
|
78 |
|
|
$template->set_var('ACTION_URL', WB_URL.'/account/preferences.php');
|
79 |
1508
|
Luisehahne
|
|
80 |
1509
|
Luisehahne
|
// read available languages from table addons and assign it to the template
|
81 |
1777
|
Luisehahne
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'addons` ';
|
82 |
|
|
$sql .= 'WHERE `type` = \'language\' ORDER BY `directory`';
|
83 |
|
|
if( $res_lang = $database->query($sql) )
|
84 |
|
|
{
|
85 |
|
|
$template->set_block('main_block', 'language_list_block', 'language_list');
|
86 |
|
|
while( $rec_lang = $res_lang->fetchRow() )
|
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', ($wb->get_session('LANGUAGE') == $rec_lang['directory'] ? ' selected="selected"' : '') );
|
93 |
|
|
$template->parse('language_list', 'language_list_block', true);
|
94 |
|
|
}
|
95 |
|
|
}
|
96 |
1508
|
Luisehahne
|
// Insert default timezone values
|
97 |
1777
|
Luisehahne
|
$template->set_block('main_block', 'timezone_list_block', 'timezone_list');
|
98 |
|
|
foreach($TIMEZONES AS $hour_offset => $title) {
|
99 |
|
|
$template->set_var('VALUE', $hour_offset);
|
100 |
|
|
$template->set_var('NAME', $title);
|
101 |
|
|
if($wb->get_timezone() == $hour_offset*3600) {
|
102 |
|
|
$template->set_var('SELECTED', 'selected="selected"');
|
103 |
|
|
} else {
|
104 |
|
|
$template->set_var('SELECTED', '');
|
105 |
|
|
}
|
106 |
|
|
$template->parse('timezone_list', 'timezone_list_block', true);
|
107 |
|
|
}
|
108 |
1420
|
Luisehahne
|
|
109 |
1508
|
Luisehahne
|
// Insert date format list
|
110 |
1777
|
Luisehahne
|
$template->set_block('main_block', 'date_format_list_block', 'date_format_list');
|
111 |
|
|
foreach($DATE_FORMATS AS $format => $title)
|
112 |
|
|
{
|
113 |
|
|
$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)
|
114 |
|
|
if($format != 'system_default') {
|
115 |
|
|
$template->set_var('VALUE', $format);
|
116 |
|
|
} else {
|
117 |
|
|
$template->set_var('VALUE', '');
|
118 |
|
|
}
|
119 |
|
|
$template->set_var('NAME', $title);
|
120 |
|
|
if($wb->get_session('DATE_FORMAT') == $format AND !isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) {
|
121 |
|
|
$template->set_var('SELECTED', 'selected="selected"');
|
122 |
|
|
} elseif($format == 'system_default' AND isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) {
|
123 |
|
|
$template->set_var('SELECTED', 'selected="selected"');
|
124 |
|
|
} else {
|
125 |
|
|
$template->set_var('SELECTED', '');
|
126 |
|
|
}
|
127 |
|
|
$template->parse('date_format_list', 'date_format_list_block', true);
|
128 |
|
|
}
|
129 |
1420
|
Luisehahne
|
|
130 |
1508
|
Luisehahne
|
// Insert time format list
|
131 |
1777
|
Luisehahne
|
$template->set_block('main_block', 'time_format_list_block', 'time_format_list');
|
132 |
|
|
foreach($TIME_FORMATS AS $format => $title)
|
133 |
|
|
{
|
134 |
|
|
$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)
|
135 |
|
|
if($format != 'system_default') {
|
136 |
|
|
$template->set_var('VALUE', $format);
|
137 |
|
|
} else {
|
138 |
|
|
$template->set_var('VALUE', '');
|
139 |
|
|
}
|
140 |
|
|
$template->set_var('NAME', $title);
|
141 |
|
|
if($wb->get_session('TIME_FORMAT') == $format AND !isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) {
|
142 |
|
|
$template->set_var('SELECTED', 'selected="selected"');
|
143 |
|
|
} elseif($format == 'system_default' AND isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) {
|
144 |
|
|
$template->set_var('SELECTED', 'selected="selected"');
|
145 |
|
|
} else {
|
146 |
|
|
$template->set_var('SELECTED', '');
|
147 |
|
|
}
|
148 |
|
|
$template->parse('time_format_list', 'time_format_list_block', true);
|
149 |
|
|
}
|
150 |
1508
|
Luisehahne
|
// Insert language headings
|
151 |
1777
|
Luisehahne
|
$template->set_var(array(
|
152 |
|
|
'HEADING_MY_SETTINGS' => $HEADING['MY_SETTINGS'],
|
153 |
|
|
'HEADING_MY_EMAIL' => $HEADING['MY_EMAIL'],
|
154 |
|
|
'HEADING_MY_PASSWORD' => $HEADING['MY_PASSWORD']
|
155 |
|
|
)
|
156 |
|
|
);
|
157 |
1508
|
Luisehahne
|
// Insert language text and messages
|
158 |
1777
|
Luisehahne
|
$template->set_var(array(
|
159 |
|
|
'HTTP_REFERER' => $_SESSION['HTTP_REFERER'],
|
160 |
|
|
'TEXT_SAVE' => $TEXT['SAVE'],
|
161 |
|
|
'TEXT_RESET' => $TEXT['RESET'],
|
162 |
|
|
'TEXT_CANCEL' => $TEXT['CANCEL'],
|
163 |
|
|
'TEXT_DISPLAY_NAME' => $TEXT['DISPLAY_NAME'],
|
164 |
|
|
'TEXT_EMAIL' => $TEXT['EMAIL'],
|
165 |
|
|
'TEXT_LANGUAGE' => $TEXT['LANGUAGE'],
|
166 |
|
|
'TEXT_TIMEZONE' => $TEXT['TIMEZONE'],
|
167 |
|
|
'TEXT_DATE_FORMAT' => $TEXT['DATE_FORMAT'],
|
168 |
|
|
'TEXT_TIME_FORMAT' => $TEXT['TIME_FORMAT'],
|
169 |
|
|
'TEXT_CURRENT_PASSWORD' => $TEXT['CURRENT_PASSWORD'],
|
170 |
|
|
'TEXT_NEW_PASSWORD' => $TEXT['NEW_PASSWORD'],
|
171 |
|
|
'TEXT_RETYPE_NEW_PASSWORD' => $TEXT['RETYPE_NEW_PASSWORD']
|
172 |
|
|
)
|
173 |
|
|
);
|
174 |
1420
|
Luisehahne
|
|
175 |
1508
|
Luisehahne
|
// Insert module releated language text and messages
|
176 |
1777
|
Luisehahne
|
$template->set_var(array(
|
177 |
|
|
'MOD_PREFERENCE_PLEASE_SELECT' => $MOD_PREFERENCE['PLEASE_SELECT'],
|
178 |
|
|
'MOD_PREFERENCE_SAVE_SETTINGS' => $MOD_PREFERENCE['SAVE_SETTINGS'],
|
179 |
|
|
'MOD_PREFERENCE_SAVE_EMAIL' => $MOD_PREFERENCE['SAVE_EMAIL'],
|
180 |
|
|
'MOD_PREFERENCE_SAVE_PASSWORD' => $MOD_PREFERENCE['SAVE_PASSWORD'],
|
181 |
|
|
)
|
182 |
|
|
);
|
183 |
1508
|
Luisehahne
|
// Insert error and/or success messages
|
184 |
1777
|
Luisehahne
|
$template->set_block('main_block', 'error_block', 'error_list');
|
185 |
|
|
$template->set_var('ERROR_VALUE', '');
|
186 |
|
|
if(sizeof($error)>0){
|
187 |
|
|
$template->set_var('ERROR_VALUE', $wb->format_message(implode('<br />',$error),'error'));
|
188 |
|
|
$template->parse('error_list', 'error_block', true);
|
189 |
|
|
} else {
|
190 |
|
|
$template->parse('error_list', '');
|
191 |
|
|
}
|
192 |
1420
|
Luisehahne
|
|
193 |
1777
|
Luisehahne
|
$template->set_block('main_block', 'success_block', 'success_list');
|
194 |
|
|
$template->set_var('SUCCESS_VALUE', '');
|
195 |
|
|
if(sizeof($success)!=0){
|
196 |
|
|
$template->set_var('SUCCESS_VALUE', $wb->format_message(implode('<br />',$success),'ok'));
|
197 |
|
|
$template->parse('success_list', 'success_block', true);
|
198 |
|
|
} else {
|
199 |
|
|
$template->parse('success_list', '');
|
200 |
|
|
}
|
201 |
1508
|
Luisehahne
|
// Parse template for preferences form
|
202 |
1777
|
Luisehahne
|
$template->parse('main', 'main_block', false);
|
203 |
|
|
$template->pparse('output', 'page');
|