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