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