Revision 1508
Added by Dietmar almost 13 years ago
preferences_form.php | ||
---|---|---|
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 |
// Must include code to stop this file being access directly
|
|
20 |
if(defined('WB_PATH') == false) { die("Cannot access this file directly"); }
|
|
19 |
// prevent this file from being accesses directly
|
|
20 |
if(defined('WB_PATH') == false) { exit("Cannot access this file directly"); }
|
|
21 | 21 |
|
22 |
?> |
|
22 |
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 |
} |
|
23 | 27 |
|
24 |
<h2> <?php print $HEADING['MY_SETTINGS']; ?></h2> |
|
28 |
$_SESSION['PAGE_LINK'] = get_page_link( $_SESSION['PAGE_ID'] ); |
|
29 |
$_SESSION['HTTP_REFERER'] = page_link($_SESSION['PAGE_LINK']); |
|
25 | 30 |
|
26 |
<form name="user" action="<?php print WB_URL.'/account/preferences.php'; ?>" method="post" style="margin-bottom: 5px;"> |
|
27 |
<input type="hidden" name="user_id" value="{USER_ID}" /> |
|
28 |
<table cellpadding="5" cellspacing="0" border="0" width="97%"> |
|
29 |
<tr> |
|
30 |
<td width="140"><?php print $TEXT['DISPLAY_NAME']; ?>:</td> |
|
31 |
<td class="value_input"> |
|
32 |
<input type="text" name="display_name" style="width: 380px;" maxlength="255" value="<?php print $wb->get_display_name(); ?>" /> |
|
33 |
</td> |
|
34 |
</tr> |
|
35 |
<tr> |
|
36 |
<td><?php print $TEXT['LANGUAGE']; ?>:</td> |
|
37 |
<td> |
|
38 |
<select name="language" style="width: 380px;"> |
|
39 |
<?php |
|
40 |
/** |
|
41 |
* |
|
42 |
* Getting the languages from the database. (addons) |
|
43 |
* It's a little bit corious, but the language-shortform is |
|
44 |
* storred in the field "directory" ... |
|
45 |
* |
|
46 |
*/ |
|
47 |
$query = 'SELECT * FROM `'.TABLE_PREFIX.'addons` '; |
|
48 |
$query .= 'WHERE `type` = \'language\' ORDER BY `directory`'; |
|
49 |
$result = $database->query($query); |
|
50 |
if ($result) { |
|
51 |
$options_html = ""; |
|
52 |
while($data = $result->fetchRow()) { |
|
53 |
$sel = ($data['directory'] == LANGUAGE) ? " selected=\"selected\" " : ""; |
|
54 |
// $options_html .= "<option value=\"".$data['directory']."\" ".$sel.">".$data['name']." (".$data['directory'].")</option>\n"; |
|
55 |
$options_html .= "<option value=\"".$data['directory']."\" ".$sel." style=\"background: url(".THEME_URL.'/images/flags/'.strtolower($data['directory']).".png) no-repeat center left; padding-left: 20px;\">".$data['name']." (".$data['directory'].")</option>\n"; |
|
56 |
} |
|
57 |
echo $options_html; |
|
58 |
} |
|
59 |
?> |
|
60 |
</select> |
|
61 |
</td> |
|
62 |
</tr> |
|
63 |
<tr> |
|
64 |
<td><?php print $TEXT['TIMEZONE']; ?>:</td> |
|
65 |
<td> |
|
66 |
<select name="timezone" style="width: 380px;"> |
|
67 |
<option value="-20"><?php print $TEXT['PLEASE_SELECT']; ?>...</option> |
|
68 |
<?php |
|
69 |
// Insert default timezone values |
|
70 |
require_once(ADMIN_PATH.'/interface/timezones.php'); |
|
71 |
$test_time = $wb->get_timezone(); |
|
72 |
$options_html = ""; |
|
73 |
foreach($TIMEZONES as $hour_offset => $title) { |
|
74 |
$sel = ($test_time == $hour_offset*60*60) ? " selected=\"selected\" " : ""; |
|
75 |
$options_html .= "<option value=\"".$hour_offset."\" ".$sel.">".$title."</option>\n"; |
|
76 |
} |
|
77 |
print $options_html; |
|
78 |
?> |
|
31 |
// load module default language file (EN) |
|
32 |
require_once(WB_PATH .'/account/languages/EN.php'); |
|
33 |
// check for user defined language file, load it and override EN-Settings with |
|
34 |
if(file_exists(WB_PATH .'/account/languages/' .LANGUAGE .'.php')) { |
|
35 |
require_once(WB_PATH .'/account/languages/' .LANGUAGE .'.php'); |
|
36 |
} |
|
37 |
require_once(WB_PATH.'/framework/functions-utf8.php'); |
|
38 |
echo '<style type="text/css">'; |
|
39 |
include(WB_PATH .'/account/frontend.css'); |
|
40 |
echo "\n</style>\n"; |
|
41 |
$user_time = true; |
|
42 |
require(ADMIN_PATH.'/interface/timezones.php'); |
|
43 |
require(ADMIN_PATH.'/interface/date_formats.php'); |
|
44 |
require(ADMIN_PATH.'/interface/time_formats.php'); |
|
45 |
$error = array(); |
|
46 |
$success = array(); |
|
47 |
$template = new Template(WB_PATH .'/account','remove'); |
|
79 | 48 |
|
80 |
</select> |
|
81 |
</td> |
|
82 |
</tr> |
|
83 |
<tr> |
|
84 |
<td><?php print $TEXT['DATE_FORMAT']; ?>:</td> |
|
85 |
<td> |
|
86 |
<select name="date_format" style="width: 98%;"> |
|
87 |
<option value=""><?php print $TEXT['PLEASE_SELECT']; ?>...</option> |
|
88 |
<?php |
|
89 |
// Insert date format list |
|
90 |
$user_time = true; |
|
91 |
require_once(ADMIN_PATH.'/interface/date_formats.php'); |
|
92 |
foreach($DATE_FORMATS AS $format => $title) { |
|
93 |
$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key) |
|
94 |
if($format != 'system_default') { |
|
95 |
$value = $format; |
|
96 |
} else { |
|
97 |
$value = ''; |
|
98 |
} |
|
99 |
if(DATE_FORMAT == $format AND !isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) { |
|
100 |
$selected = ' selected="selected"'; |
|
101 |
} elseif($format == 'system_default' AND isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) { |
|
102 |
$selected = ' selected="selected"'; |
|
103 |
} else { |
|
104 |
$selected = ''; |
|
105 |
} |
|
106 |
print '<option value="'.$value.'"'.$selected.'>'.$title.'</option>'."\n"; |
|
107 |
} |
|
108 |
?> |
|
109 |
</select> |
|
110 |
</td> |
|
111 |
</tr> |
|
112 |
<tr> |
|
113 |
<td><?php print $TEXT['TIME_FORMAT']; ?>:</td> |
|
114 |
<td> |
|
115 |
<select name="time_format" style="width: 98%;"> |
|
116 |
<option value=""><?php print $TEXT['PLEASE_SELECT']; ?>...</option> |
|
117 |
<?php |
|
118 |
// Insert time format list |
|
119 |
$user_time = true; |
|
120 |
require_once(ADMIN_PATH.'/interface/time_formats.php'); |
|
121 |
foreach($TIME_FORMATS AS $format => $title) |
|
122 |
{ |
|
123 |
$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key) |
|
124 |
$value = ($format != 'system_default') ? $format : ''; |
|
49 |
switch($wb->get_post('action')): |
|
50 |
case 'details': |
|
51 |
require_once(WB_PATH .'/account/details.php'); |
|
52 |
break; |
|
53 |
case 'email': |
|
54 |
require_once(WB_PATH .'/account/email.php'); |
|
125 | 55 |
|
126 |
$selected = ((TIME_FORMAT == $format AND ! isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) |
|
127 |
OR ($format == 'system_default' AND isset($_SESSION['USE_DEFAULT_TIME_FORMAT']))) |
|
128 |
? ' selected="selected"' : ''; |
|
56 |
break; |
|
57 |
case 'password': |
|
58 |
require_once(WB_PATH .'/account/password.php'); |
|
59 |
break; |
|
60 |
default: |
|
61 |
// do nothing |
|
62 |
endswitch; // switch |
|
129 | 63 |
|
130 |
print '<option value="'.$value.'"'.$selected.'>'.$title.'</option>'; |
|
64 |
// show template |
|
65 |
$template->set_file('page', 'template.html'); |
|
66 |
$template->set_block('page', 'main_block', 'main'); |
|
67 |
// get existing values from database |
|
68 |
$sql = "SELECT display_name,email FROM ".TABLE_PREFIX."users WHERE user_id = '".$wb->get_user_id()."'"; |
|
69 |
$rowset = $database->query($sql); |
|
70 |
if($database->is_error()) $error[] = $database->get_error(); |
|
71 |
$row = $rowset->fetchRow(); |
|
72 |
// insert values into form |
|
73 |
$template->set_var('DISPLAY_NAME', $row['display_name']); |
|
74 |
$template->set_var('EMAIL', $row['email']); |
|
75 |
|
|
76 |
// Insert language values |
|
77 |
$template->set_block('main_block', 'language_list_block', 'language_list'); |
|
78 |
$sql = "SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'language' order by name"; |
|
79 |
$rowset = $database->query($sql); |
|
80 |
if($rowset->numRows() > 0) { |
|
81 |
while($row = $rowset->fetchRow()) { |
|
82 |
$l_codes[$row['name']] = $row['directory']; |
|
83 |
$l_names[$row['name']] = entities_to_7bit($row['name']); // sorting-problem workaround |
|
84 |
} |
|
85 |
asort($l_names); |
|
86 |
foreach($l_names as $l_name=>$v) { |
|
87 |
// Insert code and name |
|
88 |
$template->set_var(array( 'CODE' => $l_codes[$l_name], 'NAME' => $l_name )); |
|
89 |
// Check if it is selected |
|
90 |
if(LANGUAGE == $l_codes[$l_name]) { |
|
91 |
$template->set_var('SELECTED', ' selected="selected"'); |
|
92 |
} else { |
|
93 |
$template->set_var('SELECTED', ''); |
|
131 | 94 |
} |
132 |
?> |
|
133 |
</select> |
|
134 |
</td> |
|
135 |
</tr> |
|
136 |
<tr> |
|
137 |
<td> </td> |
|
138 |
<td> |
|
139 |
<input type="submit" name="submit" value="<?php print $TEXT['SAVE']; ?>" /> |
|
140 |
<input type="reset" name="reset" value="<?php print $TEXT['RESET']; ?>" /> |
|
141 |
</td> |
|
142 |
</tr> |
|
143 |
</table> |
|
95 |
$template->parse('language_list', 'language_list_block', true); |
|
96 |
} |
|
97 |
} |
|
144 | 98 |
|
145 |
</form> |
|
99 |
// Insert default timezone values |
|
100 |
$template->set_block('main_block', 'timezone_list_block', 'timezone_list'); |
|
101 |
foreach($TIMEZONES AS $hour_offset => $title) { |
|
102 |
$template->set_var('VALUE', $hour_offset); |
|
103 |
$template->set_var('NAME', $title); |
|
104 |
if($wb->get_timezone() == $hour_offset*3600) { |
|
105 |
$template->set_var('SELECTED', 'selected="selected"'); |
|
106 |
} else { |
|
107 |
$template->set_var('SELECTED', ''); |
|
108 |
} |
|
109 |
$template->parse('timezone_list', 'timezone_list_block', true); |
|
110 |
} |
|
146 | 111 |
|
147 |
<h2> <?php print $HEADING['MY_EMAIL']; ?></h2> |
|
112 |
// Insert date format list |
|
113 |
$template->set_block('main_block', 'date_format_list_block', 'date_format_list'); |
|
114 |
foreach($DATE_FORMATS AS $format => $title) { |
|
115 |
$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key) |
|
116 |
if($format != 'system_default') { |
|
117 |
$template->set_var('VALUE', $format); |
|
118 |
} else { |
|
119 |
$template->set_var('VALUE', ''); |
|
120 |
} |
|
121 |
$template->set_var('NAME', $title); |
|
122 |
if(DATE_FORMAT == $format AND !isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) { |
|
123 |
$template->set_var('SELECTED', 'selected="selected"'); |
|
124 |
} elseif($format == 'system_default' AND isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) { |
|
125 |
$template->set_var('SELECTED', 'selected="selected"'); |
|
126 |
} else { |
|
127 |
$template->set_var('SELECTED', ''); |
|
128 |
} |
|
129 |
$template->parse('date_format_list', 'date_format_list_block', true); |
|
130 |
} |
|
148 | 131 |
|
149 |
<form name="email" action="<?php print WB_URL.'/account/preferences.php'; ?>" method="post" style="margin-bottom: 5px;"> |
|
150 |
<input type="hidden" name="user_id" value="{USER_ID}" /> |
|
151 |
<table cellpadding="5" cellspacing="0" border="0" width="97%"> |
|
152 |
<tr> |
|
153 |
<td width="140"><?php print $TEXT['CURRENT_PASSWORD']; ?>:</td> |
|
154 |
<td> |
|
155 |
<input type="password" name="current_password" style="width: 380px;" /> |
|
156 |
</td> |
|
157 |
</tr> |
|
158 |
<tr> |
|
159 |
<td><?php print $TEXT['EMAIL']; ?>:</td> |
|
160 |
<td class="value_input"> |
|
161 |
<input type="text" name="email" style="width: 380px;" maxlength="255" value="<?php print $wb->get_email(); ?>" /> |
|
162 |
</td> |
|
163 |
</tr> |
|
164 |
<tr> |
|
165 |
<td> </td> |
|
166 |
<td> |
|
167 |
<input type="submit" name="submit" value="<?php print $TEXT['SAVE']; ?>" /> |
|
168 |
<input type="reset" name="reset" value="<?php print $TEXT['RESET']; ?>" /> |
|
169 |
</td> |
|
170 |
</tr> |
|
171 |
</table> |
|
132 |
// Insert time format list |
|
133 |
$template->set_block('main_block', 'time_format_list_block', 'time_format_list'); |
|
134 |
foreach($TIME_FORMATS AS $format => $title) { |
|
135 |
$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key) |
|
136 |
if($format != 'system_default') { |
|
137 |
$template->set_var('VALUE', $format); |
|
138 |
} else { |
|
139 |
$template->set_var('VALUE', ''); |
|
140 |
} |
|
141 |
$template->set_var('NAME', $title); |
|
142 |
if(TIME_FORMAT == $format AND !isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) { |
|
143 |
$template->set_var('SELECTED', 'selected="selected"'); |
|
144 |
} elseif($format == 'system_default' AND isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) { |
|
145 |
$template->set_var('SELECTED', 'selected="selected"'); |
|
146 |
} else { |
|
147 |
$template->set_var('SELECTED', ''); |
|
148 |
} |
|
149 |
$template->parse('time_format_list', 'time_format_list_block', true); |
|
150 |
} |
|
151 |
// Insert language headings |
|
152 |
$template->set_var(array( |
|
153 |
'HEADING_MY_SETTINGS' => $HEADING['MY_SETTINGS'], |
|
154 |
'HEADING_MY_EMAIL' => $HEADING['MY_EMAIL'], |
|
155 |
'HEADING_MY_PASSWORD' => $HEADING['MY_PASSWORD'] |
|
156 |
) |
|
157 |
); |
|
158 |
// Insert language text and messages |
|
159 |
$template->set_var(array( |
|
160 |
'HTTP_REFERER' => $_SESSION['HTTP_REFERER'], |
|
161 |
'TEXT_SAVE' => $TEXT['SAVE'], |
|
162 |
'TEXT_RESET' => $TEXT['RESET'], |
|
163 |
'TEXT_CANCEL' => $TEXT['CANCEL'], |
|
164 |
'TEXT_DISPLAY_NAME' => $TEXT['DISPLAY_NAME'], |
|
165 |
'TEXT_EMAIL' => $TEXT['EMAIL'], |
|
166 |
'TEXT_LANGUAGE' => $TEXT['LANGUAGE'], |
|
167 |
'TEXT_TIMEZONE' => $TEXT['TIMEZONE'], |
|
168 |
'TEXT_DATE_FORMAT' => $TEXT['DATE_FORMAT'], |
|
169 |
'TEXT_TIME_FORMAT' => $TEXT['TIME_FORMAT'], |
|
170 |
'TEXT_CURRENT_PASSWORD' => $TEXT['CURRENT_PASSWORD'], |
|
171 |
'TEXT_NEW_PASSWORD' => $TEXT['NEW_PASSWORD'], |
|
172 |
'TEXT_RETYPE_NEW_PASSWORD' => $TEXT['RETYPE_NEW_PASSWORD'] |
|
173 |
) |
|
174 |
); |
|
172 | 175 |
|
173 |
</form> |
|
176 |
// Insert module releated language text and messages |
|
177 |
$template->set_var(array( |
|
178 |
'MOD_PREFERENCE_PLEASE_SELECT' => $MOD_PREFERENCE['PLEASE_SELECT'], |
|
179 |
'MOD_PREFERENCE_SAVE_SETTINGS' => $MOD_PREFERENCE['SAVE_SETTINGS'], |
|
180 |
'MOD_PREFERENCE_SAVE_EMAIL' => $MOD_PREFERENCE['SAVE_EMAIL'], |
|
181 |
'MOD_PREFERENCE_SAVE_PASSWORD' => $MOD_PREFERENCE['SAVE_PASSWORD'], |
|
182 |
) |
|
183 |
); |
|
184 |
// Insert error and/or success messages |
|
185 |
$template->set_block('main_block', 'error_block', 'error_list'); |
|
186 |
if(sizeof($error)>0){ |
|
187 |
foreach($error AS $value){ |
|
188 |
$template->set_var('ERROR_VALUE', $value); |
|
189 |
$template->parse('error_list', 'error_block', true); |
|
190 |
} |
|
191 |
} |
|
174 | 192 |
|
175 |
|
|
176 |
<h2> <?php print $HEADING['MY_PASSWORD']; ?></h2> |
|
177 |
|
|
178 |
<form name="user" action="<?php print WB_URL.'/account/preferences.php'; ?>" method="post"> |
|
179 |
<input type="hidden" name="user_id" value="{USER_ID}" /> |
|
180 |
<table cellpadding="5" cellspacing="0" border="0" width="97%"> |
|
181 |
<tr> |
|
182 |
<td width="140"><?php print $TEXT['CURRENT_PASSWORD']; ?>:</td> |
|
183 |
<td> |
|
184 |
<input type="password" name="current_password" style="width: 380px;" /> |
|
185 |
</td> |
|
186 |
</tr> |
|
187 |
<tr> |
|
188 |
<td><?php print $TEXT['NEW_PASSWORD']; ?>:</td> |
|
189 |
<td> |
|
190 |
<input type="password" name="new_password" style="width: 380px;" /> |
|
191 |
</td> |
|
192 |
</tr> |
|
193 |
<tr> |
|
194 |
<td><?php print $TEXT['RETYPE_NEW_PASSWORD']; ?>:</td> |
|
195 |
<td> |
|
196 |
<input type="password" name="new_password2" style="width: 380px;" /> |
|
197 |
</td> |
|
198 |
</tr> |
|
199 |
<tr> |
|
200 |
<td> </td> |
|
201 |
<td> |
|
202 |
<input type="submit" name="submit" value="<?php print $TEXT['SAVE']; ?>" /> |
|
203 |
<input type="reset" name="reset" value="<?php print $TEXT['RESET']; ?>" /> |
|
204 |
</td> |
|
205 |
</tr> |
|
206 |
</table> |
|
207 |
|
|
208 |
</form> |
|
193 |
$template->set_block('main_block', 'success_block', 'success_list'); |
|
194 |
if(sizeof($success)!=0){ |
|
195 |
foreach($success AS $value){ |
|
196 |
$template->set_var('SUCCESS_VALUE', $value); |
|
197 |
$template->parse('success_list', 'success_block', true); |
|
198 |
} |
|
199 |
} |
|
200 |
// Parse template for preferences form |
|
201 |
$template->parse('main', 'main_block', false); |
|
202 |
$template->pparse('output', 'page'); |
Also available in: Unified diff
fixed print_error exit in frontend account