Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 296 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
ucp_prefs | |
0.00% |
0 / 294 |
|
0.00% |
0 / 1 |
2450 | |
0.00% |
0 / 1 |
main | |
0.00% |
0 / 294 |
|
0.00% |
0 / 1 |
2450 |
1 | <?php |
2 | /** |
3 | * |
4 | * This file is part of the phpBB Forum Software package. |
5 | * |
6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
7 | * @license GNU General Public License, version 2 (GPL-2.0) |
8 | * |
9 | * For full copyright and license information, please see |
10 | * the docs/CREDITS.txt file. |
11 | * |
12 | */ |
13 | |
14 | /** |
15 | * @ignore |
16 | */ |
17 | if (!defined('IN_PHPBB')) |
18 | { |
19 | exit; |
20 | } |
21 | |
22 | /** |
23 | * ucp_prefs |
24 | * Changing user preferences |
25 | */ |
26 | class ucp_prefs |
27 | { |
28 | var $u_action; |
29 | |
30 | function main($id, $mode) |
31 | { |
32 | global $config, $db, $user, $auth, $template, $phpbb_dispatcher, $request; |
33 | |
34 | $submit = (isset($_POST['submit'])) ? true : false; |
35 | $error = $data = array(); |
36 | $s_hidden_fields = ''; |
37 | |
38 | switch ($mode) |
39 | { |
40 | case 'personal': |
41 | add_form_key('ucp_prefs_personal'); |
42 | $data = array( |
43 | 'notifymethod' => $request->variable('notifymethod', $user->data['user_notify_type']), |
44 | 'dateformat' => $request->variable('dateformat', $user->data['user_dateformat'], true), |
45 | 'lang' => basename($request->variable('lang', $user->data['user_lang'])), |
46 | 'user_style' => $request->variable('user_style', (int) $user->data['user_style']), |
47 | 'tz' => $request->variable('tz', $user->data['user_timezone']), |
48 | |
49 | 'viewemail' => $request->variable('viewemail', (bool) $user->data['user_allow_viewemail']), |
50 | 'massemail' => $request->variable('massemail', (bool) $user->data['user_allow_massemail']), |
51 | 'hideonline' => $request->variable('hideonline', (bool) !$user->data['user_allow_viewonline']), |
52 | 'allowpm' => $request->variable('allowpm', (bool) $user->data['user_allow_pm']), |
53 | ); |
54 | |
55 | if ($data['notifymethod'] == NOTIFY_IM && (!$config['jab_enable'] || !$user->data['user_jabber'] || !@extension_loaded('xml'))) |
56 | { |
57 | // Jabber isnt enabled, or no jabber field filled in. Update the users table to be sure its correct. |
58 | $data['notifymethod'] = NOTIFY_BOTH; |
59 | } |
60 | |
61 | /** |
62 | * Add UCP edit global settings data before they are assigned to the template or submitted |
63 | * |
64 | * To assign data to the template, use $template->assign_vars() |
65 | * |
66 | * @event core.ucp_prefs_personal_data |
67 | * @var bool submit Do we display the form only |
68 | * or did the user press submit |
69 | * @var array data Array with current ucp options data |
70 | * @var array error Array with list of errors |
71 | * @since 3.1.0-a1 |
72 | * @changed 3.1.4-RC1 Added error variable to the event |
73 | */ |
74 | $vars = array('submit', 'data', 'error'); |
75 | extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_personal_data', compact($vars))); |
76 | |
77 | if ($submit) |
78 | { |
79 | if ($config['override_user_style']) |
80 | { |
81 | $data['user_style'] = (int) $config['default_style']; |
82 | } |
83 | else if (!phpbb_style_is_active($data['user_style'])) |
84 | { |
85 | $data['user_style'] = (int) $user->data['user_style']; |
86 | } |
87 | |
88 | $error = array_merge(validate_data($data, array( |
89 | 'dateformat' => array('string', false, 1, 64), |
90 | 'lang' => array('language_iso_name'), |
91 | 'tz' => array('timezone'), |
92 | )), $error); |
93 | |
94 | if (!check_form_key('ucp_prefs_personal')) |
95 | { |
96 | $error[] = 'FORM_INVALID'; |
97 | } |
98 | |
99 | if (!count($error)) |
100 | { |
101 | $sql_ary = array( |
102 | 'user_allow_pm' => $data['allowpm'], |
103 | 'user_allow_viewemail' => $data['viewemail'], |
104 | 'user_allow_massemail' => $data['massemail'], |
105 | 'user_allow_viewonline' => ($auth->acl_get('u_hideonline')) ? !$data['hideonline'] : $user->data['user_allow_viewonline'], |
106 | 'user_notify_type' => $data['notifymethod'], |
107 | 'user_options' => $user->data['user_options'], |
108 | |
109 | 'user_dateformat' => $data['dateformat'], |
110 | 'user_lang' => $data['lang'], |
111 | 'user_timezone' => $data['tz'], |
112 | 'user_style' => $data['user_style'], |
113 | ); |
114 | |
115 | /** |
116 | * Update UCP edit global settings data on form submit |
117 | * |
118 | * @event core.ucp_prefs_personal_update_data |
119 | * @var array data Submitted display options data |
120 | * @var array sql_ary Display options data we update |
121 | * @since 3.1.0-a1 |
122 | */ |
123 | $vars = array('data', 'sql_ary'); |
124 | extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_personal_update_data', compact($vars))); |
125 | |
126 | $sql = 'UPDATE ' . USERS_TABLE . ' |
127 | SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' |
128 | WHERE user_id = ' . $user->data['user_id']; |
129 | $db->sql_query($sql); |
130 | |
131 | meta_refresh(3, $this->u_action); |
132 | $message = $user->lang['PREFERENCES_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); |
133 | trigger_error($message); |
134 | } |
135 | |
136 | // Replace "error" strings with their real, localised form |
137 | $error = array_map(array($user, 'lang'), $error); |
138 | } |
139 | |
140 | $dateformat_options = ''; |
141 | |
142 | foreach ($user->lang['dateformats'] as $format => $null) |
143 | { |
144 | $dateformat_options .= '<option value="' . $format . '"' . (($format == $data['dateformat']) ? ' selected="selected"' : '') . '>'; |
145 | $dateformat_options .= $user->format_date(time(), $format, false) . ((strpos($format, '|') !== false) ? $user->lang['VARIANT_DATE_SEPARATOR'] . $user->format_date(time(), $format, true) : ''); |
146 | $dateformat_options .= '</option>'; |
147 | } |
148 | |
149 | $s_custom = false; |
150 | |
151 | $dateformat_options .= '<option value="custom"'; |
152 | if (!isset($user->lang['dateformats'][$data['dateformat']])) |
153 | { |
154 | $dateformat_options .= ' selected="selected"'; |
155 | $s_custom = true; |
156 | } |
157 | $dateformat_options .= '>' . $user->lang['CUSTOM_DATEFORMAT'] . '</option>'; |
158 | |
159 | $timezone_select = phpbb_timezone_select($user, $data['tz'], true); |
160 | |
161 | // check if there are any user-selectable languages |
162 | $sql = 'SELECT lang_iso, lang_local_name |
163 | FROM ' . LANG_TABLE . ' |
164 | ORDER BY lang_english_name'; |
165 | $result = $db->sql_query($sql); |
166 | $lang_row = (array) $db->sql_fetchrowset($result); |
167 | $db->sql_freeresult($result); |
168 | $s_more_languages = count($lang_row) > 1; |
169 | |
170 | // check if there are any user-selectable styles |
171 | $sql = 'SELECT style_id, style_name |
172 | FROM ' . STYLES_TABLE . ' |
173 | WHERE style_active = 1 |
174 | ORDER BY style_name'; |
175 | $result = $db->sql_query($sql); |
176 | $styles_row = (array) $db->sql_fetchrowset($result); |
177 | $db->sql_freeresult($result); |
178 | $s_more_styles = count($styles_row) > 1; |
179 | |
180 | $lang_options = phpbb_language_select($db, $data['lang'], $lang_row); |
181 | |
182 | $template->assign_vars([ |
183 | 'ERROR' => (count($error)) ? implode('<br />', $error) : '', |
184 | |
185 | 'S_NOTIFY_EMAIL' => ($data['notifymethod'] == NOTIFY_EMAIL) ? true : false, |
186 | 'S_NOTIFY_IM' => ($data['notifymethod'] == NOTIFY_IM) ? true : false, |
187 | 'S_NOTIFY_BOTH' => ($data['notifymethod'] == NOTIFY_BOTH) ? true : false, |
188 | 'S_VIEW_EMAIL' => $data['viewemail'], |
189 | 'S_MASS_EMAIL' => $data['massemail'], |
190 | 'S_ALLOW_PM' => $data['allowpm'], |
191 | 'S_HIDE_ONLINE' => $data['hideonline'], |
192 | |
193 | 'DATE_FORMAT' => $data['dateformat'], |
194 | 'A_DATE_FORMAT' => addslashes($data['dateformat']), |
195 | 'S_DATEFORMAT_OPTIONS' => $dateformat_options, |
196 | 'S_CUSTOM_DATEFORMAT' => $s_custom, |
197 | 'DEFAULT_DATEFORMAT' => $config['default_dateformat'], |
198 | 'A_DEFAULT_DATEFORMAT' => addslashes($config['default_dateformat']), |
199 | |
200 | 'S_MORE_LANGUAGES' => $s_more_languages, |
201 | 'S_MORE_STYLES' => $s_more_styles, |
202 | |
203 | 'LANG_OPTIONS' => [ |
204 | 'id' => 'lang', |
205 | 'name' => 'lang', |
206 | 'options' => $lang_options, |
207 | ], |
208 | 'S_STYLE_OPTIONS' => ($config['override_user_style']) ? '' : [ |
209 | 'id' => 'user_style', |
210 | 'name' => 'user_style', |
211 | 'options' => style_select($data['user_style'], false, $styles_row) |
212 | ], |
213 | 'TIMEZONE_OPTIONS' => [ |
214 | 'tag' => 'select', |
215 | 'name' => 'tz', |
216 | 'options' => $timezone_select, |
217 | ], |
218 | 'S_CAN_HIDE_ONLINE' => (bool) $auth->acl_get('u_hideonline'), |
219 | 'S_SELECT_NOTIFY' => (bool) ($config['jab_enable'] && $user->data['user_jabber'] && @extension_loaded('xml')), |
220 | ]); |
221 | |
222 | break; |
223 | |
224 | case 'view': |
225 | |
226 | add_form_key('ucp_prefs_view'); |
227 | |
228 | $data = array( |
229 | 'topic_sk' => $request->variable('topic_sk', (!empty($user->data['user_topic_sortby_type'])) ? $user->data['user_topic_sortby_type'] : 't'), |
230 | 'topic_sd' => $request->variable('topic_sd', (!empty($user->data['user_topic_sortby_dir'])) ? $user->data['user_topic_sortby_dir'] : 'd'), |
231 | 'topic_st' => $request->variable('topic_st', (!empty($user->data['user_topic_show_days'])) ? (int) $user->data['user_topic_show_days'] : 0), |
232 | |
233 | 'post_sk' => $request->variable('post_sk', (!empty($user->data['user_post_sortby_type'])) ? $user->data['user_post_sortby_type'] : 't'), |
234 | 'post_sd' => $request->variable('post_sd', (!empty($user->data['user_post_sortby_dir'])) ? $user->data['user_post_sortby_dir'] : 'a'), |
235 | 'post_st' => $request->variable('post_st', (!empty($user->data['user_post_show_days'])) ? (int) $user->data['user_post_show_days'] : 0), |
236 | |
237 | 'images' => $request->variable('images', (bool) $user->optionget('viewimg')), |
238 | 'smilies' => $request->variable('smilies', (bool) $user->optionget('viewsmilies')), |
239 | 'sigs' => $request->variable('sigs', (bool) $user->optionget('viewsigs')), |
240 | 'avatars' => $request->variable('avatars', (bool) $user->optionget('viewavatars')), |
241 | 'wordcensor' => $request->variable('wordcensor', (bool) $user->optionget('viewcensors')), |
242 | ); |
243 | |
244 | /** |
245 | * Add UCP edit display options data before they are assigned to the template or submitted |
246 | * |
247 | * To assign data to the template, use $template->assign_vars() |
248 | * |
249 | * @event core.ucp_prefs_view_data |
250 | * @var bool submit Do we display the form only |
251 | * or did the user press submit |
252 | * @var array data Array with current ucp options data |
253 | * @since 3.1.0-a1 |
254 | */ |
255 | $vars = array('submit', 'data'); |
256 | extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_view_data', compact($vars))); |
257 | |
258 | if ($submit) |
259 | { |
260 | $error = validate_data($data, array( |
261 | 'topic_sk' => array( |
262 | array('string', false, 1, 1), |
263 | array('match', false, '#(a|r|s|t|v)#'), |
264 | ), |
265 | 'topic_sd' => array( |
266 | array('string', false, 1, 1), |
267 | array('match', false, '#(a|d)#'), |
268 | ), |
269 | 'post_sk' => array( |
270 | array('string', false, 1, 1), |
271 | array('match', false, '#(a|s|t)#'), |
272 | ), |
273 | 'post_sd' => array( |
274 | array('string', false, 1, 1), |
275 | array('match', false, '#(a|d)#'), |
276 | ), |
277 | )); |
278 | |
279 | if (!check_form_key('ucp_prefs_view')) |
280 | { |
281 | $error[] = 'FORM_INVALID'; |
282 | } |
283 | |
284 | if (!count($error)) |
285 | { |
286 | $user->optionset('viewimg', $data['images']); |
287 | $user->optionset('viewsmilies', $data['smilies']); |
288 | $user->optionset('viewsigs', $data['sigs']); |
289 | $user->optionset('viewavatars', $data['avatars']); |
290 | |
291 | if ($auth->acl_get('u_chgcensors')) |
292 | { |
293 | $user->optionset('viewcensors', $data['wordcensor']); |
294 | } |
295 | |
296 | $sql_ary = array( |
297 | 'user_options' => $user->data['user_options'], |
298 | 'user_topic_sortby_type' => $data['topic_sk'], |
299 | 'user_post_sortby_type' => $data['post_sk'], |
300 | 'user_topic_sortby_dir' => $data['topic_sd'], |
301 | 'user_post_sortby_dir' => $data['post_sd'], |
302 | |
303 | 'user_topic_show_days' => $data['topic_st'], |
304 | 'user_post_show_days' => $data['post_st'], |
305 | ); |
306 | |
307 | /** |
308 | * Update UCP edit display options data on form submit |
309 | * |
310 | * @event core.ucp_prefs_view_update_data |
311 | * @var array data Submitted display options data |
312 | * @var array sql_ary Display options data we update |
313 | * @since 3.1.0-a1 |
314 | */ |
315 | $vars = array('data', 'sql_ary'); |
316 | extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_view_update_data', compact($vars))); |
317 | |
318 | $sql = 'UPDATE ' . USERS_TABLE . ' |
319 | SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' |
320 | WHERE user_id = ' . $user->data['user_id']; |
321 | $db->sql_query($sql); |
322 | |
323 | meta_refresh(3, $this->u_action); |
324 | $message = $user->lang['PREFERENCES_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); |
325 | trigger_error($message); |
326 | } |
327 | |
328 | // Replace "error" strings with their real, localised form |
329 | $error = array_map(array($user, 'lang'), $error); |
330 | } |
331 | |
332 | $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']); |
333 | |
334 | // Topic ordering options |
335 | $limit_topic_days = array(0 => $user->lang['ALL_TOPICS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); |
336 | |
337 | $sort_by_topic_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 'r' => $user->lang['REPLIES'], 's' => $user->lang['SUBJECT'], 'v' => $user->lang['VIEWS']); |
338 | $sort_by_topic_sql = array('a' => 't.topic_first_poster_name', 't' => array('t.topic_last_post_time', 't.topic_last_post_id'), 'r' => 't.topic_posts_approved', 's' => 't.topic_title', 'v' => 't.topic_views'); |
339 | |
340 | // Post ordering options |
341 | $limit_post_days = array(0 => $user->lang['ALL_POSTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); |
342 | |
343 | $sort_by_post_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']); |
344 | $sort_by_post_sql = array('a' => 'u.username_clean', 't' => 'p.post_id', 's' => 'p.post_subject'); |
345 | |
346 | $_options = array('topic', 'post'); |
347 | foreach ($_options as $sort_option) |
348 | { |
349 | ${'s_limit_' . $sort_option . '_days'} = '<select name="' . $sort_option . '_st">'; |
350 | foreach (${'limit_' . $sort_option . '_days'} as $day => $text) |
351 | { |
352 | $selected = ($data[$sort_option . '_st'] == $day) ? ' selected="selected"' : ''; |
353 | ${'s_limit_' . $sort_option . '_days'} .= '<option value="' . $day . '"' . $selected . '>' . $text . '</option>'; |
354 | } |
355 | ${'s_limit_' . $sort_option . '_days'} .= '</select>'; |
356 | |
357 | ${'s_sort_' . $sort_option . '_key'} = '<select name="' . $sort_option . '_sk">'; |
358 | foreach (${'sort_by_' . $sort_option . '_text'} as $key => $text) |
359 | { |
360 | $selected = ($data[$sort_option . '_sk'] == $key) ? ' selected="selected"' : ''; |
361 | ${'s_sort_' . $sort_option . '_key'} .= '<option value="' . $key . '"' . $selected . '>' . $text . '</option>'; |
362 | } |
363 | ${'s_sort_' . $sort_option . '_key'} .= '</select>'; |
364 | |
365 | ${'s_sort_' . $sort_option . '_dir'} = '<select name="' . $sort_option . '_sd">'; |
366 | foreach ($sort_dir_text as $key => $value) |
367 | { |
368 | $selected = ($data[$sort_option . '_sd'] == $key) ? ' selected="selected"' : ''; |
369 | ${'s_sort_' . $sort_option . '_dir'} .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; |
370 | } |
371 | ${'s_sort_' . $sort_option . '_dir'} .= '</select>'; |
372 | } |
373 | |
374 | /** |
375 | * Run code before view form is displayed |
376 | * |
377 | * @event core.ucp_prefs_view_after |
378 | * @var bool submit Do we display the form only |
379 | * or did the user press submit |
380 | * @var array data Array with current ucp options data |
381 | * @var array sort_dir_text Array with sort dir language strings |
382 | * @var array limit_topic_days Topic ordering options |
383 | * @var array sort_by_topic_text Topic ordering language strings |
384 | * @var array sort_by_topic_sql Topic ordering sql |
385 | * @var array limit_post_days Post ordering options |
386 | * @var array sort_by_post_text Post ordering language strings |
387 | * @var array sort_by_post_sql Post ordering sql |
388 | * @var array _options Sort options |
389 | * @var string s_limit_topic_days Sort limit topic by days select box |
390 | * @var string s_sort_topic_key Sort topic key select box |
391 | * @var string s_sort_topic_dir Sort topic dir select box |
392 | * @var string s_limit_post_days Sort limit post by days select box |
393 | * @var string s_sort_post_key Sort post key select box |
394 | * @var string s_sort_post_dir Sort post dir select box |
395 | * @since 3.1.8-RC1 |
396 | */ |
397 | $vars = array( |
398 | 'submit', |
399 | 'data', |
400 | 'sort_dir_text', |
401 | 'limit_topic_days', |
402 | 'sort_by_topic_text', |
403 | 'sort_by_topic_sql', |
404 | 'limit_post_days', |
405 | 'sort_by_post_text', |
406 | 'sort_by_post_sql', |
407 | '_options', |
408 | 's_limit_topic_days', |
409 | 's_sort_topic_key', |
410 | 's_sort_topic_dir', |
411 | 's_limit_post_days', |
412 | 's_sort_post_key', |
413 | 's_sort_post_dir', |
414 | ); |
415 | extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_view_after', compact($vars))); |
416 | |
417 | $template->assign_vars(array( |
418 | 'ERROR' => (count($error)) ? implode('<br />', $error) : '', |
419 | |
420 | 'S_IMAGES' => $data['images'], |
421 | 'S_SMILIES' => $data['smilies'], |
422 | 'S_SIGS' => $data['sigs'], |
423 | 'S_AVATARS' => $data['avatars'], |
424 | 'S_DISABLE_CENSORS' => $data['wordcensor'], |
425 | |
426 | 'S_CHANGE_CENSORS' => ($auth->acl_get('u_chgcensors') && $config['allow_nocensors']) ? true : false, |
427 | |
428 | 'S_TOPIC_SORT_DAYS' => $s_limit_topic_days, |
429 | 'S_TOPIC_SORT_KEY' => $s_sort_topic_key, |
430 | 'S_TOPIC_SORT_DIR' => $s_sort_topic_dir, |
431 | 'S_POST_SORT_DAYS' => $s_limit_post_days, |
432 | 'S_POST_SORT_KEY' => $s_sort_post_key, |
433 | 'S_POST_SORT_DIR' => $s_sort_post_dir) |
434 | ); |
435 | |
436 | break; |
437 | |
438 | case 'post': |
439 | |
440 | $data = array( |
441 | 'bbcode' => $request->variable('bbcode', $user->optionget('bbcode')), |
442 | 'smilies' => $request->variable('smilies', $user->optionget('smilies')), |
443 | 'sig' => $request->variable('sig', $user->optionget('attachsig')), |
444 | 'notify' => $request->variable('notify', (bool) $user->data['user_notify']), |
445 | ); |
446 | add_form_key('ucp_prefs_post'); |
447 | |
448 | /** |
449 | * Add UCP edit posting defaults data before they are assigned to the template or submitted |
450 | * |
451 | * To assign data to the template, use $template->assign_vars() |
452 | * |
453 | * @event core.ucp_prefs_post_data |
454 | * @var bool submit Do we display the form only |
455 | * or did the user press submit |
456 | * @var array data Array with current ucp options data |
457 | * @since 3.1.0-a1 |
458 | */ |
459 | $vars = array('submit', 'data'); |
460 | extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_post_data', compact($vars))); |
461 | |
462 | if ($submit) |
463 | { |
464 | if (check_form_key('ucp_prefs_post')) |
465 | { |
466 | $user->optionset('bbcode', $data['bbcode']); |
467 | $user->optionset('smilies', $data['smilies']); |
468 | $user->optionset('attachsig', $data['sig']); |
469 | |
470 | $sql_ary = array( |
471 | 'user_options' => $user->data['user_options'], |
472 | 'user_notify' => $data['notify'], |
473 | ); |
474 | |
475 | /** |
476 | * Update UCP edit posting defaults data on form submit |
477 | * |
478 | * @event core.ucp_prefs_post_update_data |
479 | * @var array data Submitted display options data |
480 | * @var array sql_ary Display options data we update |
481 | * @since 3.1.0-a1 |
482 | */ |
483 | $vars = array('data', 'sql_ary'); |
484 | extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_post_update_data', compact($vars))); |
485 | |
486 | $sql = 'UPDATE ' . USERS_TABLE . ' |
487 | SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' |
488 | WHERE user_id = ' . $user->data['user_id']; |
489 | $db->sql_query($sql); |
490 | |
491 | $msg = $user->lang['PREFERENCES_UPDATED']; |
492 | } |
493 | else |
494 | { |
495 | $msg = $user->lang['FORM_INVALID']; |
496 | } |
497 | meta_refresh(3, $this->u_action); |
498 | $message = $msg . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); |
499 | trigger_error($message); |
500 | } |
501 | |
502 | $template->assign_vars(array( |
503 | 'S_SIG_ALLOWED' => $config['allow_sig'] && $auth->acl_get('u_sig'), |
504 | |
505 | 'S_BBCODE' => $data['bbcode'], |
506 | 'S_SMILIES' => $data['smilies'], |
507 | 'S_SIG' => $data['sig'], |
508 | 'S_NOTIFY' => $data['notify']) |
509 | ); |
510 | break; |
511 | } |
512 | |
513 | /** |
514 | * Modify UCP preferences data before the page load |
515 | * |
516 | * @event core.ucp_prefs_modify_common |
517 | * @var array data Array with current/submitted UCP options data |
518 | * @var array error Errors data |
519 | * @var string mode UCP prefs operation mode |
520 | * @var string s_hidden_fields Hidden fields data |
521 | * @since 3.1.0-RC3 |
522 | */ |
523 | $vars = array( |
524 | 'data', |
525 | 'error', |
526 | 'mode', |
527 | 's_hidden_fields', |
528 | ); |
529 | extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_modify_common', compact($vars))); |
530 | |
531 | $template->assign_vars(array( |
532 | 'L_TITLE' => $user->lang['UCP_PREFS_' . strtoupper($mode)], |
533 | |
534 | 'S_HIDDEN_FIELDS' => $s_hidden_fields, |
535 | 'S_UCP_ACTION' => $this->u_action) |
536 | ); |
537 | |
538 | $this->tpl_name = 'ucp_prefs_' . $mode; |
539 | $this->page_title = 'UCP_PREFS_' . strtoupper($mode); |
540 | } |
541 | } |