From ac11806bf449b1ca1b69eae023b5ec318a10547d Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sun, 21 Aug 2011 14:33:40 +0200 Subject: [ticket/10329] Add phpbb_ prefix to new pcre_utf8_support() function. Introduced by 6b4d0a254218e8d40151ca1bdff8c439f89502e9. PHPBB3-10329 --- phpBB/includes/functions_user.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 124aac18be..930cd4625f 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1477,7 +1477,7 @@ function validate_username($username, $allowed_username = false) $mbstring = $pcre = false; // generic UTF-8 character types supported? - if (pcre_utf8_support()) + if (phpbb_pcre_utf8_support()) { $pcre = true; } @@ -1614,7 +1614,7 @@ function validate_password($password) $pcre = $mbstring = false; // generic UTF-8 character types supported? - if (pcre_utf8_support()) + if (phpbb_pcre_utf8_support()) { $upp = '\p{Lu}'; $low = '\p{Ll}'; -- cgit v1.2.1 From 179662e949967090724c5e14ea4d4d399886a38a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 20 Sep 2011 01:33:33 +0200 Subject: [ticket/10345] Use the plural function in some more places. I added two function avatar_explanation_string() and avatar_error_wrong_size() for easier handling of the "pixels"-languages, as they are used quite often. PHPBB3-10345 --- phpBB/includes/functions_user.php | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 930cd4625f..e3537fe328 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -2039,7 +2039,7 @@ function avatar_remote($data, &$error) { if ($width > $config['avatar_max_width'] || $height > $config['avatar_max_height']) { - $error[] = sprintf($user->lang['AVATAR_WRONG_SIZE'], $config['avatar_min_width'], $config['avatar_min_height'], $config['avatar_max_width'], $config['avatar_max_height'], $width, $height); + $error[] = avatar_error_wrong_size($width, $height); return false; } } @@ -2048,7 +2048,7 @@ function avatar_remote($data, &$error) { if ($width < $config['avatar_min_width'] || $height < $config['avatar_min_height']) { - $error[] = sprintf($user->lang['AVATAR_WRONG_SIZE'], $config['avatar_min_width'], $config['avatar_min_height'], $config['avatar_max_width'], $config['avatar_max_height'], $width, $height); + $error[] = avatar_error_wrong_size($width, $height); return false; } } @@ -2388,7 +2388,7 @@ function avatar_process_user(&$error, $custom_userdata = false, $can_upload = nu { if ($data['width'] > $config['avatar_max_width'] || $data['height'] > $config['avatar_max_height']) { - $error[] = sprintf($user->lang['AVATAR_WRONG_SIZE'], $config['avatar_min_width'], $config['avatar_min_height'], $config['avatar_max_width'], $config['avatar_max_height'], $data['width'], $data['height']); + $error[] = avatar_error_wrong_size($data['width'], $data['height']); } } @@ -2398,7 +2398,7 @@ function avatar_process_user(&$error, $custom_userdata = false, $can_upload = nu { if ($data['width'] < $config['avatar_min_width'] || $data['height'] < $config['avatar_min_height']) { - $error[] = sprintf($user->lang['AVATAR_WRONG_SIZE'], $config['avatar_min_width'], $config['avatar_min_height'], $config['avatar_max_width'], $config['avatar_max_height'], $data['width'], $data['height']); + $error[] = avatar_error_wrong_size($data['width'], $data['height']); } } } @@ -2444,6 +2444,29 @@ function avatar_process_user(&$error, $custom_userdata = false, $can_upload = nu return (sizeof($error)) ? false : true; } +function avatar_error_wrong_size($width, $height) +{ + global $config, $user; + + return $user->lang('AVATAR_WRONG_SIZE', + $user->lang('PIXELS', (int) $config['avatar_min_width']), + $user->lang('PIXELS', (int) $config['avatar_min_height']), + $user->lang('PIXELS', (int) $config['avatar_max_width']), + $user->lang('PIXELS', (int) $config['avatar_max_height']), + $user->lang('PIXELS', (int) $width), + $user->lang('PIXELS', (int) $height)); +} + +function avatar_explanation_string() +{ + global $config, $user; + + return $user->lang('AVATAR_EXPLAIN', + $user->lang('PIXELS', (int) $config['avatar_max_width']), + $user->lang('PIXELS', (int) $config['avatar_max_height']), + round($config['avatar_filesize'] / 1024)); +} + // // Usergroup functions // -- cgit v1.2.1 From b790d2e2839850c053b6fecc4f5d767746c47f20 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 30 Nov 2011 21:03:29 +0100 Subject: [ticket/10345] Add documentation and phpbb_ prefix to the new avatar functions PHPBB3-10345 --- phpBB/includes/functions_user.php | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index e3537fe328..5631928f96 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -2039,7 +2039,7 @@ function avatar_remote($data, &$error) { if ($width > $config['avatar_max_width'] || $height > $config['avatar_max_height']) { - $error[] = avatar_error_wrong_size($width, $height); + $error[] = phpbb_avatar_error_wrong_size($width, $height); return false; } } @@ -2048,7 +2048,7 @@ function avatar_remote($data, &$error) { if ($width < $config['avatar_min_width'] || $height < $config['avatar_min_height']) { - $error[] = avatar_error_wrong_size($width, $height); + $error[] = phpbb_avatar_error_wrong_size($width, $height); return false; } } @@ -2388,7 +2388,7 @@ function avatar_process_user(&$error, $custom_userdata = false, $can_upload = nu { if ($data['width'] > $config['avatar_max_width'] || $data['height'] > $config['avatar_max_height']) { - $error[] = avatar_error_wrong_size($data['width'], $data['height']); + $error[] = phpbb_avatar_error_wrong_size($data['width'], $data['height']); } } @@ -2398,7 +2398,7 @@ function avatar_process_user(&$error, $custom_userdata = false, $can_upload = nu { if ($data['width'] < $config['avatar_min_width'] || $data['height'] < $config['avatar_min_height']) { - $error[] = avatar_error_wrong_size($data['width'], $data['height']); + $error[] = phpbb_avatar_error_wrong_size($data['width'], $data['height']); } } } @@ -2444,7 +2444,14 @@ function avatar_process_user(&$error, $custom_userdata = false, $can_upload = nu return (sizeof($error)) ? false : true; } -function avatar_error_wrong_size($width, $height) +/** +* Returns a language string with the avatar size of the new avatar and the allowed maximum and minimum +* +* @param $width int The width of the new uploaded/selected avatar +* @param $height int The height of the new uploaded/selected avatar +* @return string +*/ +function phpbb_avatar_error_wrong_size($width, $height) { global $config, $user; @@ -2457,7 +2464,12 @@ function avatar_error_wrong_size($width, $height) $user->lang('PIXELS', (int) $height)); } -function avatar_explanation_string() +/** +* Returns an explanation string with maximum avatar settings +* +* @return string +*/ +function phpbb_avatar_explanation_string() { global $config, $user; -- cgit v1.2.1 From 7a04c9048c110f0bd21ea3e9e869e17b408d640e Mon Sep 17 00:00:00 2001 From: Unknown Date: Sat, 31 Dec 2011 13:32:52 +0000 Subject: [ticket/9916] Updating header license and removing Version $Id$ PHPBB3-9916 --- phpBB/includes/functions_user.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 5631928f96..509e1a953c 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -2,9 +2,8 @@ /** * * @package phpBB3 -* @version $Id$ * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ -- cgit v1.2.1 From 17f5c6bf71f560be2f4e2ecabae83ab2973bec47 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 18 Feb 2012 12:00:12 +0100 Subject: [ticket/10605] Check for orphan privmsgs when deleting a user Also moved the hole code into a new function. PHPBB3-10605 --- phpBB/includes/functions_user.php | 58 +++------------------------------------ 1 file changed, 4 insertions(+), 54 deletions(-) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 6b5cca8abb..20923ea495 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -528,62 +528,12 @@ function user_delete($mode, $user_id, $post_username = false) WHERE session_user_id = ' . $user_id; $db->sql_query($sql); - // Remove any undelivered mails... - $sql = 'SELECT msg_id, user_id - FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE author_id = ' . $user_id . ' - AND folder_id = ' . PRIVMSGS_NO_BOX; - $result = $db->sql_query($sql); - - $undelivered_msg = $undelivered_user = array(); - while ($row = $db->sql_fetchrow($result)) - { - $undelivered_msg[] = $row['msg_id']; - $undelivered_user[$row['user_id']][] = true; - } - $db->sql_freeresult($result); - - if (sizeof($undelivered_msg)) + // Clean the private messages tables from the user + if (!function_exists('delete_user_pms')) { - $sql = 'DELETE FROM ' . PRIVMSGS_TABLE . ' - WHERE ' . $db->sql_in_set('msg_id', $undelivered_msg); - $db->sql_query($sql); - } - - $sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE author_id = ' . $user_id . ' - AND folder_id = ' . PRIVMSGS_NO_BOX; - $db->sql_query($sql); - - // Delete all to-information - $sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE user_id = ' . $user_id; - $db->sql_query($sql); - - // Set the remaining author id to anonymous - this way users are still able to read messages from users being removed - $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . ' - SET author_id = ' . ANONYMOUS . ' - WHERE author_id = ' . $user_id; - $db->sql_query($sql); - - $sql = 'UPDATE ' . PRIVMSGS_TABLE . ' - SET author_id = ' . ANONYMOUS . ' - WHERE author_id = ' . $user_id; - $db->sql_query($sql); - - foreach ($undelivered_user as $_user_id => $ary) - { - if ($_user_id == $user_id) - { - continue; - } - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_new_privmsg = user_new_privmsg - ' . sizeof($ary) . ', - user_unread_privmsg = user_unread_privmsg - ' . sizeof($ary) . ' - WHERE user_id = ' . $_user_id; - $db->sql_query($sql); + include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx); } + delete_user_pms($user_id); $db->sql_transaction('commit'); -- cgit v1.2.1 From 025de9ee191654825f6ba09a4804e6ef3633b8cb Mon Sep 17 00:00:00 2001 From: rxu Date: Thu, 8 Mar 2012 14:57:47 +0800 Subject: [ticket/10684] Send notifications for users with stale bans PHPBB3-10684 --- phpBB/includes/functions_user.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 6b5cca8abb..aea94a0d34 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -3587,4 +3587,33 @@ function remove_newly_registered($user_id, $user_data = false) return $user_data['group_id']; } +/** +* Get a list of banned users' ids, ignoring stale buns which were not wiped yet. +* +* @return array Array of banned users' ids if any, empty array otherwise +*/ +function phpbb_get_banned_users_ids() +{ + global $db; + + // Get banned User ID's + // Ignore stale bans which were not wiped yet + $banned_ids_list = array(); + $sql = 'SELECT ban_userid + FROM ' . BANLIST_TABLE . ' + WHERE ban_userid <> 0 + AND ban_exclude <> 1 + AND (ban_end > ' . time() . ' + OR ban_end = 0)'; + $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) + { + $user_id = (int) $row['ban_userid']; + $banned_ids_list[$user_id] = $user_id; + } + $db->sql_freeresult($result); + + return $banned_ids_list; +} + ?> \ No newline at end of file -- cgit v1.2.1 From ee6783109ad7af70665c98d6bbc12d170bc0f892 Mon Sep 17 00:00:00 2001 From: rxu Date: Fri, 9 Mar 2012 16:41:49 +0800 Subject: [ticket/10684] Fix 2 typos in comment lines. PHPBB3-10684 --- phpBB/includes/functions_user.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index aea94a0d34..dec8d09082 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -3588,7 +3588,7 @@ function remove_newly_registered($user_id, $user_data = false) } /** -* Get a list of banned users' ids, ignoring stale buns which were not wiped yet. +* Get a list of banned users' ids, ignoring stale bans which were not wiped yet. * * @return array Array of banned users' ids if any, empty array otherwise */ -- cgit v1.2.1 From 321d0d9b56011e049b245b6d54975b6c67b3b15b Mon Sep 17 00:00:00 2001 From: rxu Date: Mon, 12 Mar 2012 01:44:00 +0800 Subject: [ticket/10684] Adjust pm_notifications() to handle stale bans - Add parameter (array) to the function phpbb_get_banned_users_ids() - Fix function pm_notification() to handle users with stale bans PHPBB3-10684 --- phpBB/includes/functions_user.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index dec8d09082..8f40401f0b 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -3588,22 +3588,26 @@ function remove_newly_registered($user_id, $user_data = false) } /** -* Get a list of banned users' ids, ignoring stale bans which were not wiped yet. +* Get a list of banned users' ids, ignoring stale bans which were not cleaned yet. * +* @param array $users_ids_array Array of users' ids to check for banning, +* leave empty to get complete list of banned ids * @return array Array of banned users' ids if any, empty array otherwise */ -function phpbb_get_banned_users_ids() +function phpbb_get_banned_users_ids($users_ids_array = array()) { global $db; + $sql_users_ids = (!empty($users_ids_array)) ? $db->sql_in_set('ban_userid', $users_ids_array) : 'ban_userid <> 0'; + // Get banned User ID's // Ignore stale bans which were not wiped yet $banned_ids_list = array(); $sql = 'SELECT ban_userid - FROM ' . BANLIST_TABLE . ' - WHERE ban_userid <> 0 + FROM ' . BANLIST_TABLE . " + WHERE $sql_users_ids AND ban_exclude <> 1 - AND (ban_end > ' . time() . ' + AND (ban_end > " . time() . ' OR ban_end = 0)'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) -- cgit v1.2.1 From ff8d5237688beee9ea36848e1ac49565e538c2cd Mon Sep 17 00:00:00 2001 From: rxu Date: Mon, 12 Mar 2012 01:57:51 +0800 Subject: [ticket/10684] Rename function phpbb_get_banned_users_ids() parameter PHPBB3-10684 --- phpBB/includes/functions_user.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 8f40401f0b..8c42a5bb42 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -3590,15 +3590,15 @@ function remove_newly_registered($user_id, $user_data = false) /** * Get a list of banned users' ids, ignoring stale bans which were not cleaned yet. * -* @param array $users_ids_array Array of users' ids to check for banning, -* leave empty to get complete list of banned ids +* @param array $users_ids Array of users' ids to check for banning, +* leave empty to get complete list of banned ids * @return array Array of banned users' ids if any, empty array otherwise */ -function phpbb_get_banned_users_ids($users_ids_array = array()) +function phpbb_get_banned_users_ids($users_ids = array()) { global $db; - $sql_users_ids = (!empty($users_ids_array)) ? $db->sql_in_set('ban_userid', $users_ids_array) : 'ban_userid <> 0'; + $sql_users_ids = (!empty($users_ids)) ? $db->sql_in_set('ban_userid', $users_ids) : 'ban_userid <> 0'; // Get banned User ID's // Ignore stale bans which were not wiped yet -- cgit v1.2.1 From ba6943a6a0ea50af772dc6e94f13b56292cd9f37 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 12 Mar 2012 10:11:52 +0100 Subject: [ticket/10605] Prefix function with phpbb_ and use true instead of 1 PHPBB3-10605 --- phpBB/includes/functions_user.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 20923ea495..92a7b8e0e9 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -529,11 +529,11 @@ function user_delete($mode, $user_id, $post_username = false) $db->sql_query($sql); // Clean the private messages tables from the user - if (!function_exists('delete_user_pms')) + if (!function_exists('phpbb_delete_user_pms')) { include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx); } - delete_user_pms($user_id); + phpbb_delete_user_pms($user_id); $db->sql_transaction('commit'); -- cgit v1.2.1 From 5a9dd1994fc20aaebe3145540b630826d7333998 Mon Sep 17 00:00:00 2001 From: rxu Date: Thu, 22 Mar 2012 21:19:01 +0800 Subject: [ticket/10684] Adjust function and parameter name, minor changes. PHPBB3-10684 --- phpBB/includes/functions_user.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 8c42a5bb42..10fb57ea97 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -3588,24 +3588,24 @@ function remove_newly_registered($user_id, $user_data = false) } /** -* Get a list of banned users' ids, ignoring stale bans which were not cleaned yet. +* Gets user ids of currently banned registered users. * -* @param array $users_ids Array of users' ids to check for banning, +* @param array $user_ids Array of users' ids to check for banning, * leave empty to get complete list of banned ids * @return array Array of banned users' ids if any, empty array otherwise */ -function phpbb_get_banned_users_ids($users_ids = array()) +function phpbb_get_banned_user_ids($user_ids = array()) { global $db; - $sql_users_ids = (!empty($users_ids)) ? $db->sql_in_set('ban_userid', $users_ids) : 'ban_userid <> 0'; + $sql_user_ids = (!empty($user_ids)) ? $db->sql_in_set('ban_userid', $user_ids) : 'ban_userid <> 0'; // Get banned User ID's // Ignore stale bans which were not wiped yet $banned_ids_list = array(); $sql = 'SELECT ban_userid FROM ' . BANLIST_TABLE . " - WHERE $sql_users_ids + WHERE $sql_user_ids AND ban_exclude <> 1 AND (ban_end > " . time() . ' OR ban_end = 0)'; -- cgit v1.2.1 From 018419b36cf4d81cf2fa3f82d85f9bc8580c9c19 Mon Sep 17 00:00:00 2001 From: Hari Sankar R Date: Thu, 5 Apr 2012 19:31:18 +0530 Subject: [ticket/10561] Moved and renamed the funtion validate_style(). Fixed minor changes as suggested by @bantu. PHPBB3-10561 --- phpBB/includes/functions_user.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 10fb57ea97..7313844955 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1948,6 +1948,25 @@ function validate_jabber($jid) return false; } +/** +* @param int $style_id The style_id of a style which should be checked if activated or not. +* @return boolean +*/ +function phpbb_validate_style($style_id) +{ + global $db; + + $sql = 'SELECT style_active + FROM ' . STYLES_TABLE . ' + WHERE style_id = '. (int) $style_id; + $result = $db->sql_query($sql); + + $style_is_active = (bool) $db->sql_fetchfield('style_active'); + $db->sql_freeresult($result); + + return $style_is_active; +} + /** * Remove avatar */ -- cgit v1.2.1 From 03a35581c4b0dcb7c20885d4ca807ea7117872cb Mon Sep 17 00:00:00 2001 From: Hari Sankar R Date: Sat, 7 Apr 2012 23:15:12 +0530 Subject: [ticket/10561] Reverted to phpbb_style_is_active() Changes made to function name, reverted to old. PHPBB3-10561 --- phpBB/includes/functions_user.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 7313844955..770eab48d5 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1952,7 +1952,7 @@ function validate_jabber($jid) * @param int $style_id The style_id of a style which should be checked if activated or not. * @return boolean */ -function phpbb_validate_style($style_id) +function phpbb_style_is_active($style_id) { global $db; -- cgit v1.2.1 From 9bce716081f55f209afbfb3ecf1a097b47292da4 Mon Sep 17 00:00:00 2001 From: Hari Sankar R Date: Mon, 9 Apr 2012 00:57:29 +0530 Subject: [ticket/10561] Added function desc for phpbb_style_is_active() PHPBB3-10561 --- phpBB/includes/functions_user.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 770eab48d5..83316be2a3 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1949,6 +1949,8 @@ function validate_jabber($jid) } /** +* Verifies whether a style ID corresponds to an active style. +* * @param int $style_id The style_id of a style which should be checked if activated or not. * @return boolean */ -- cgit v1.2.1 From 50936cb2eff3f80d99390c76ef6ac535e73f6cc3 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 4 Jun 2012 19:06:46 +0200 Subject: [feature/new-tz-handling] Fix selecting and validating of timezone in UCP PHPBB3-9558 --- phpBB/includes/functions_user.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 9b102b7387..3a77407c20 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1395,6 +1395,22 @@ function validate_language_iso_name($lang_iso) return ($lang_id) ? false : 'WRONG_DATA'; } +/** +* Validate Timezone Name +* +* Tests whether a timezone name is valid +* +* @param string $timezone The timezone string to test +* +* @return bool|string Either false if validation succeeded or +* a string which will be used as the error message +* (with the variable name appended) +*/ +function validate_timezone($timezone) +{ + return (in_array($timezone, DateTimeZone::listIdentifiers())) ? false : 'TIMEZONE_INVALID'; +} + /** * Check to see if the username has been taken, or if it is disallowed. * Also checks if it includes the " character, which we don't allow in usernames. -- cgit v1.2.1 From 963d4afc2cf5fb2903ed02ada20cdbf0188d57db Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 4 Jun 2012 23:14:41 +0200 Subject: [feature/new-tz-handling] Replace gmmktime() and mktime() with phpbb_datetime PHPBB3-9558 --- phpBB/includes/functions_user.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 3a77407c20..f235b2be55 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -197,7 +197,6 @@ function user_add($user_row, $cp_data = false) 'user_lastpost_time' => 0, 'user_lastpage' => '', 'user_posts' => 0, - 'user_dst' => (int) $config['board_dst'], 'user_colour' => '', 'user_occ' => '', 'user_interests' => '', @@ -677,8 +676,10 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas if (sizeof($ban_other) == 3 && ((int)$ban_other[0] < 9999) && (strlen($ban_other[0]) == 4) && (strlen($ban_other[1]) == 2) && (strlen($ban_other[2]) == 2)) { - $time_offset = (isset($user->timezone) && isset($user->dst)) ? (int) $user->timezone + (int) $user->dst : 0; - $ban_end = max($current_time, gmmktime(0, 0, 0, (int)$ban_other[1], (int)$ban_other[2], (int)$ban_other[0]) - $time_offset); + $ban_end = max($current_time, $user->create_datetime() + ->setDate((int) $ban_other[0], (int) $ban_other[1], (int) $ban_other[2]) + ->setTime(0, 0, 0) + ->getTimestamp() + $user->tz->getOffset(new DateTime('UTC'))); } else { -- cgit v1.2.1 From b61ac43abecafdd4e9597022fe8b09323854aac9 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 16 Jul 2012 18:41:30 +0200 Subject: [feature/new-tz-handling] Allow phpbb prefix for user data validation functions PHPBB3-9558 --- phpBB/includes/functions_user.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index f235b2be55..27f4b60189 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1248,10 +1248,21 @@ function validate_data($data, $val_ary) $function = array_shift($validate); array_unshift($validate, $data[$var]); - if ($result = call_user_func_array('validate_' . $function, $validate)) + if (function_exists('phpbb_validate_' . $function)) { - // Since errors are checked later for their language file existence, we need to make sure custom errors are not adjusted. - $error[] = (empty($user->lang[$result . '_' . strtoupper($var)])) ? $result : $result . '_' . strtoupper($var); + if ($result = call_user_func_array('phpbb_validate_' . $function, $validate)) + { + // Since errors are checked later for their language file existence, we need to make sure custom errors are not adjusted. + $error[] = (empty($user->lang[$result . '_' . strtoupper($var)])) ? $result : $result . '_' . strtoupper($var); + } + } + else + { + if ($result = call_user_func_array('validate_' . $function, $validate)) + { + // Since errors are checked later for their language file existence, we need to make sure custom errors are not adjusted. + $error[] = (empty($user->lang[$result . '_' . strtoupper($var)])) ? $result : $result . '_' . strtoupper($var); + } } } } @@ -1407,7 +1418,7 @@ function validate_language_iso_name($lang_iso) * a string which will be used as the error message * (with the variable name appended) */ -function validate_timezone($timezone) +function phpbb_validate_timezone($timezone) { return (in_array($timezone, DateTimeZone::listIdentifiers())) ? false : 'TIMEZONE_INVALID'; } -- cgit v1.2.1 From a71e60cdbd3e47c62a565dd777a28aec6832fb88 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 18 Jul 2012 16:52:52 +0200 Subject: [feature/new-tz-handling] Rename $user->tz back to $user->timezone PHPBB3-9558 --- phpBB/includes/functions_user.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 27f4b60189..9bc72cbaa6 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -679,7 +679,7 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas $ban_end = max($current_time, $user->create_datetime() ->setDate((int) $ban_other[0], (int) $ban_other[1], (int) $ban_other[2]) ->setTime(0, 0, 0) - ->getTimestamp() + $user->tz->getOffset(new DateTime('UTC'))); + ->getTimestamp() + $user->timezone->getOffset(new DateTime('UTC'))); } else { -- cgit v1.2.1 From 6de222065e737bdab4ecdd010773fb70c415fb3b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 19 Jul 2012 14:36:20 +0200 Subject: [feature/new-tz-handling] Add previous selected value to validation if valid We also add the selected timezone if we can create an object with it. DateTimeZone::listIdentifiers seems to not add all identifiers to the list, because some are only kept for backward compatible reasons. If the user has a deprecated value, we add it here, so it can still be kept. Once the user changed his value, there is no way back to deprecated values. PHPBB3-9558 --- phpBB/includes/functions_user.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 9bc72cbaa6..6e658b4ef4 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1420,7 +1420,7 @@ function validate_language_iso_name($lang_iso) */ function phpbb_validate_timezone($timezone) { - return (in_array($timezone, DateTimeZone::listIdentifiers())) ? false : 'TIMEZONE_INVALID'; + return (in_array($timezone, phpbb_get_timezone_identifiers($timezone))) ? false : 'TIMEZONE_INVALID'; } /** -- cgit v1.2.1 From 77845c147818b4199005363a3168bbb44dc46641 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 15 Mar 2012 20:55:17 +0100 Subject: [feature/events] Adding ledge user_update_name Used by phpBB Gallery PHPBB3-9550 --- phpBB/includes/functions_user.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 6e658b4ef4..b50dcac49c 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -112,7 +112,7 @@ function update_last_username() */ function user_update_name($old_name, $new_name) { - global $config, $db, $cache; + global $config, $db, $cache, $phpbb_dispatcher; $update_ary = array( FORUMS_TABLE => array('forum_last_poster_name'), @@ -137,6 +137,11 @@ function user_update_name($old_name, $new_name) set_config('newest_username', $new_name, true); } + $vars = array('old_name', 'new_name'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.user_update_name', $event); + extract($event->get_data_filtered($vars)); + // Because some tables/caches use username-specific data we need to purge this here. $cache->destroy('sql', MODERATOR_CACHE_TABLE); } -- cgit v1.2.1 From 5b226c400280588349eb3a4cab9780ae98d20c0f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 15 Mar 2012 20:58:22 +0100 Subject: [feature/events] Adding ledges user_delete Used by phpBB Gallery PHPBB3-9550 --- phpBB/includes/functions_user.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index b50dcac49c..32529ec308 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -336,7 +336,7 @@ function user_add($user_row, $cp_data = false) */ function user_delete($mode, $user_id, $post_username = false) { - global $cache, $config, $db, $user, $auth; + global $cache, $config, $db, $user, $auth, $phpbb_dispatcher; global $phpbb_root_path, $phpEx; $sql = 'SELECT * @@ -540,6 +540,11 @@ function user_delete($mode, $user_id, $post_username = false) $db->sql_transaction('commit'); + $vars = array('mode', 'user_id', 'post_username'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.user_delete', $event); + extract($event->get_data_filtered($vars)); + // Reset newest user info if appropriate if ($config['newest_user_id'] == $user_id) { -- cgit v1.2.1 From ae49d6dca2fd17b2b4735c2026871d1a9250b4ad Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 15 Mar 2012 20:59:15 +0100 Subject: [feature/events] Adding ledge group_delete Used by phpBB Gallery PHPBB3-9550 --- phpBB/includes/functions_user.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 32529ec308..0e751ba890 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -2769,7 +2769,7 @@ function avatar_remove_db($avatar_name) */ function group_delete($group_id, $group_name = false) { - global $db, $phpbb_root_path, $phpEx; + global $db, $phpbb_root_path, $phpEx, $phpbb_dispatcher; if (!$group_name) { @@ -2818,6 +2818,11 @@ function group_delete($group_id, $group_name = false) $teampage->delete_group($group_id); unset($teampage); + $vars = array('group_id', 'group_name'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.group_delete', $event); + extract($event->get_data_filtered($vars)); + // Delete group $sql = 'DELETE FROM ' . GROUPS_TABLE . " WHERE group_id = $group_id"; -- cgit v1.2.1 From d4ace75370febea0f9a18ed2f744bee8caecedb2 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 15 Mar 2012 21:00:20 +0100 Subject: [feature/events] Adding ledge group_user_del Used by phpBB Gallery PHPBB3-9550 --- phpBB/includes/functions_user.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 0e751ba890..a32f14e48f 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -2955,7 +2955,7 @@ function group_user_add($group_id, $user_id_ary = false, $username_ary = false, */ function group_user_del($group_id, $user_id_ary = false, $username_ary = false, $group_name = false) { - global $db, $auth, $config; + global $db, $auth, $config, $phpbb_dispatcher; if ($config['coppa_enable']) { @@ -3054,6 +3054,11 @@ function group_user_del($group_id, $user_id_ary = false, $username_ary = false, } unset($special_group_data); + $vars = array('group_id', 'user_id_ary', 'username_ary', 'group_name'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.group_user_del', $event); + extract($event->get_data_filtered($vars)); + $sql = 'DELETE FROM ' . USER_GROUP_TABLE . " WHERE group_id = $group_id AND " . $db->sql_in_set('user_id', $user_id_ary); -- cgit v1.2.1 From 4d87b2254c7762db129b2706b372538451279d13 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 15 Mar 2012 21:01:49 +0100 Subject: [feature/events] Adding ledge group_set_user_default Used by phpBB Gallery PHPBB3-9550 --- phpBB/includes/functions_user.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index a32f14e48f..82400de932 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -3376,7 +3376,7 @@ function group_validate_groupname($group_id, $group_name) */ function group_set_user_default($group_id, $user_id_ary, $group_attributes = false, $update_listing = false) { - global $cache, $db; + global $cache, $db, $phpbb_dispatcher; if (empty($user_id_ary)) { @@ -3472,6 +3472,11 @@ function group_set_user_default($group_id, $user_id_ary, $group_attributes = fal } } + $vars = array('group_id', 'user_id_ary', 'group_attributes', 'update_listing', 'sql_ary'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.group_set_user_default', $event); + extract($event->get_data_filtered($vars)); + if ($update_listing) { group_update_listings($group_id); -- cgit v1.2.1 From 8af7d225ef481cd26e6fd7862847183d25727117 Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Tue, 20 Mar 2012 11:23:03 +0000 Subject: [feature/events] Change to use the new method of adding events PHPBB3-9550 --- phpBB/includes/functions_user.php | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 82400de932..761ce6436a 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -138,9 +138,7 @@ function user_update_name($old_name, $new_name) } $vars = array('old_name', 'new_name'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.user_update_name', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.user_update_name', compact($vars), $vars)); // Because some tables/caches use username-specific data we need to purge this here. $cache->destroy('sql', MODERATOR_CACHE_TABLE); @@ -541,9 +539,7 @@ function user_delete($mode, $user_id, $post_username = false) $db->sql_transaction('commit'); $vars = array('mode', 'user_id', 'post_username'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.user_delete', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.user_delete', compact($vars), $vars)); // Reset newest user info if appropriate if ($config['newest_user_id'] == $user_id) @@ -2819,9 +2815,7 @@ function group_delete($group_id, $group_name = false) unset($teampage); $vars = array('group_id', 'group_name'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.group_delete', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.group_delete', compact($vars), $vars)); // Delete group $sql = 'DELETE FROM ' . GROUPS_TABLE . " @@ -3055,9 +3049,7 @@ function group_user_del($group_id, $user_id_ary = false, $username_ary = false, unset($special_group_data); $vars = array('group_id', 'user_id_ary', 'username_ary', 'group_name'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.group_user_del', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.group_user_del', compact($vars), $vars)); $sql = 'DELETE FROM ' . USER_GROUP_TABLE . " WHERE group_id = $group_id @@ -3473,9 +3465,7 @@ function group_set_user_default($group_id, $user_id_ary, $group_attributes = fal } $vars = array('group_id', 'user_id_ary', 'group_attributes', 'update_listing', 'sql_ary'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.group_set_user_default', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.group_set_user_default', compact($vars), $vars)); if ($update_listing) { -- cgit v1.2.1 From 3f1b4e83aef7f7344cd551463b59de71bb4bd6fe Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Sat, 31 Mar 2012 13:39:41 +0100 Subject: [feature/events] Removing the third trigger_event parameter PHPBB3-9550 --- phpBB/includes/functions_user.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 761ce6436a..cf6a99c2b7 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -138,7 +138,7 @@ function user_update_name($old_name, $new_name) } $vars = array('old_name', 'new_name'); - extract($phpbb_dispatcher->trigger_event('core.user_update_name', compact($vars), $vars)); + extract($phpbb_dispatcher->trigger_event('core.user_update_name', compact($vars))); // Because some tables/caches use username-specific data we need to purge this here. $cache->destroy('sql', MODERATOR_CACHE_TABLE); @@ -539,7 +539,7 @@ function user_delete($mode, $user_id, $post_username = false) $db->sql_transaction('commit'); $vars = array('mode', 'user_id', 'post_username'); - extract($phpbb_dispatcher->trigger_event('core.user_delete', compact($vars), $vars)); + extract($phpbb_dispatcher->trigger_event('core.user_delete', compact($vars))); // Reset newest user info if appropriate if ($config['newest_user_id'] == $user_id) @@ -2815,7 +2815,7 @@ function group_delete($group_id, $group_name = false) unset($teampage); $vars = array('group_id', 'group_name'); - extract($phpbb_dispatcher->trigger_event('core.group_delete', compact($vars), $vars)); + extract($phpbb_dispatcher->trigger_event('core.group_delete', compact($vars))); // Delete group $sql = 'DELETE FROM ' . GROUPS_TABLE . " @@ -3049,7 +3049,7 @@ function group_user_del($group_id, $user_id_ary = false, $username_ary = false, unset($special_group_data); $vars = array('group_id', 'user_id_ary', 'username_ary', 'group_name'); - extract($phpbb_dispatcher->trigger_event('core.group_user_del', compact($vars), $vars)); + extract($phpbb_dispatcher->trigger_event('core.group_user_del', compact($vars))); $sql = 'DELETE FROM ' . USER_GROUP_TABLE . " WHERE group_id = $group_id @@ -3465,7 +3465,7 @@ function group_set_user_default($group_id, $user_id_ary, $group_attributes = fal } $vars = array('group_id', 'user_id_ary', 'group_attributes', 'update_listing', 'sql_ary'); - extract($phpbb_dispatcher->trigger_event('core.group_set_user_default', compact($vars), $vars)); + extract($phpbb_dispatcher->trigger_event('core.group_set_user_default', compact($vars))); if ($update_listing) { -- cgit v1.2.1 From c903b1512c9926dfbc54e4e48233904385c137c6 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 28 Jul 2012 16:53:20 +0200 Subject: [feature/php-events] Fix docs and naming of core.update_username PHPBB3-9550 --- phpBB/includes/functions_user.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index cf6a99c2b7..eef75b8430 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -137,8 +137,16 @@ function user_update_name($old_name, $new_name) set_config('newest_username', $new_name, true); } + /** + * Update username when it is changed + * + * @event core.update_username + * @var string old_name The old username that is replaced + * @var string new_name The new username + * @since 3.1-A1 + */ $vars = array('old_name', 'new_name'); - extract($phpbb_dispatcher->trigger_event('core.user_update_name', compact($vars))); + extract($phpbb_dispatcher->trigger_event('core.update_username', compact($vars))); // Because some tables/caches use username-specific data we need to purge this here. $cache->destroy('sql', MODERATOR_CACHE_TABLE); -- cgit v1.2.1 From ec957350c14c8b0bb6dc4768b5ad363a39715cab Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 28 Jul 2012 17:02:18 +0200 Subject: [feature/php-events] Fix docs and naming of core.delete_user_after PHPBB3-9550 --- phpBB/includes/functions_user.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index eef75b8430..de65d86e3f 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -546,8 +546,17 @@ function user_delete($mode, $user_id, $post_username = false) $db->sql_transaction('commit'); + /** + * Event after an user is deleted + * + * @event core.delete_user_after + * @var string mode Mode of deletion (retain/delete posts) + * @var int user_id ID of the deleted user + * @var mixed post_username Guest username that is being used or false + * @since 3.1-A1 + */ $vars = array('mode', 'user_id', 'post_username'); - extract($phpbb_dispatcher->trigger_event('core.user_delete', compact($vars))); + extract($phpbb_dispatcher->trigger_event('core.delete_user_after', compact($vars))); // Reset newest user info if appropriate if ($config['newest_user_id'] == $user_id) -- cgit v1.2.1 From 3affe7f229f4c8a3bb4ddb1abd79aca0dc0c15a9 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 28 Jul 2012 17:03:04 +0200 Subject: [feature/php-events] Fix docs and naming of core.delete_user_before PHPBB3-9550 --- phpBB/includes/functions_user.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index de65d86e3f..8f91a66549 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -357,6 +357,18 @@ function user_delete($mode, $user_id, $post_username = false) return false; } + /** + * Event before an user is deleted + * + * @event core.delete_user_before + * @var string mode Mode of deletion (retain/delete posts) + * @var int user_id ID of the deleted user + * @var mixed post_username Guest username that is being used or false + * @since 3.1-A1 + */ + $vars = array('mode', 'user_id', 'post_username'); + extract($phpbb_dispatcher->trigger_event('core.delete_user_before', compact($vars))); + // Before we begin, we will remove the reports the user issued. $sql = 'SELECT r.post_id, p.topic_id FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p -- cgit v1.2.1 From 8d3389448bf65f1bfc78efbfc80d0b658661f3da Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 28 Jul 2012 18:54:00 +0200 Subject: [feature/php-events] Fix docs and naming of core.delete_group_after PHPBB3-9550 --- phpBB/includes/functions_user.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 8f91a66549..c78c74bd76 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -2843,9 +2843,6 @@ function group_delete($group_id, $group_name = false) $teampage->delete_group($group_id); unset($teampage); - $vars = array('group_id', 'group_name'); - extract($phpbb_dispatcher->trigger_event('core.group_delete', compact($vars))); - // Delete group $sql = 'DELETE FROM ' . GROUPS_TABLE . " WHERE group_id = $group_id"; @@ -2856,6 +2853,17 @@ function group_delete($group_id, $group_name = false) WHERE group_id = $group_id"; $db->sql_query($sql); + /** + * Event after a group is deleted + * + * @event core.delete_group_after + * @var int group_id ID of the deleted group + * @var string group_name Name of the deleted group + * @since 3.1-A1 + */ + $vars = array('group_id', 'group_name'); + extract($phpbb_dispatcher->trigger_event('core.delete_group_after', compact($vars))); + // Re-cache moderators if (!function_exists('cache_moderators')) { -- cgit v1.2.1 From 3ced9f58ea5493e13796766d55059b70bc6d6a3e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 28 Jul 2012 19:27:58 +0200 Subject: [feature/php-events] Fix docs and naming of core.group_delete_user_before PHPBB3-9550 --- phpBB/includes/functions_user.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index c78c74bd76..d65d59f6c5 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -3085,8 +3085,18 @@ function group_user_del($group_id, $user_id_ary = false, $username_ary = false, } unset($special_group_data); - $vars = array('group_id', 'user_id_ary', 'username_ary', 'group_name'); - extract($phpbb_dispatcher->trigger_event('core.group_user_del', compact($vars))); + /** + * Event before users are removed from a group + * + * @event core.group_delete_user_before + * @var int group_id ID of the group from which users are deleted + * @var string group_name Name of the group + * @var array user_id_ary IDs of the users which are removed + * @var array username_ary names of the users which are removed + * @since 3.1-A1 + */ + $vars = array('group_id', 'group_name', 'user_id_ary', 'username_ary'); + extract($phpbb_dispatcher->trigger_event('core.group_delete_user_before', compact($vars))); $sql = 'DELETE FROM ' . USER_GROUP_TABLE . " WHERE group_id = $group_id -- cgit v1.2.1 From a05cd6d837ad9d2202561ded9c100a9b1350c0c2 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 28 Jul 2012 19:50:58 +0200 Subject: [feature/php-events] Fix docs and naming of core.user_set_default_group PHPBB3-9550 --- phpBB/includes/functions_user.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index d65d59f6c5..733a6fd9bd 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -3511,8 +3511,19 @@ function group_set_user_default($group_id, $user_id_ary, $group_attributes = fal } } + /** + * Event when the default group is set for an array of user + * + * @event core.user_set_default_group + * @var int group_id ID of the group + * @var array user_id_ary IDs of the users + * @var array group_attributes Group attributes which were changed + * @var array update_listing Update the list of moderators and foes + * @var array sql_ary User attributes which were changed + * @since 3.1-A1 + */ $vars = array('group_id', 'user_id_ary', 'group_attributes', 'update_listing', 'sql_ary'); - extract($phpbb_dispatcher->trigger_event('core.group_set_user_default', compact($vars))); + extract($phpbb_dispatcher->trigger_event('core.user_set_default_group', compact($vars))); if ($update_listing) { -- cgit v1.2.1 From aea60f9323e8753535d0dbf5ffa1ffa09ff3c02e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 20 Aug 2012 10:08:28 +0200 Subject: [feature/php-events] Fix doc of core.update_username PHPBB3-9550 --- phpBB/includes/functions_user.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 733a6fd9bd..a561daa334 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -138,7 +138,7 @@ function user_update_name($old_name, $new_name) } /** - * Update username when it is changed + * Update a username when it is changed * * @event core.update_username * @var string old_name The old username that is replaced -- cgit v1.2.1 From 74d9ef0becb1558d12a7372ba68553421963ccbe Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 20 Aug 2012 10:08:59 +0200 Subject: [feature/php-events] Fix doc of core.delete_user_before PHPBB3-9550 --- phpBB/includes/functions_user.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index a561daa334..1a75e96dd6 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -358,7 +358,7 @@ function user_delete($mode, $user_id, $post_username = false) } /** - * Event before an user is deleted + * Event before a user is deleted * * @event core.delete_user_before * @var string mode Mode of deletion (retain/delete posts) -- cgit v1.2.1 From 48b54ed1e0e5b354618fb92f9559b653e61fb530 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 20 Aug 2012 10:09:29 +0200 Subject: [feature/php-events] Fix doc of core.delete_user_after PHPBB3-9550 --- phpBB/includes/functions_user.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 1a75e96dd6..3de7b5d7c7 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -559,7 +559,7 @@ function user_delete($mode, $user_id, $post_username = false) $db->sql_transaction('commit'); /** - * Event after an user is deleted + * Event after a user is deleted * * @event core.delete_user_after * @var string mode Mode of deletion (retain/delete posts) -- cgit v1.2.1 From 365d95c1fee2b5e73dd16d0d741df6cc64956ed7 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 20 Aug 2012 10:11:52 +0200 Subject: [feature/php-events] Fix doc of core.user_set_default_group PHPBB3-9550 --- phpBB/includes/functions_user.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 3de7b5d7c7..9e33a5122e 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -3512,7 +3512,7 @@ function group_set_user_default($group_id, $user_id_ary, $group_attributes = fal } /** - * Event when the default group is set for an array of user + * Event when the default group is set for an array of users * * @event core.user_set_default_group * @var int group_id ID of the group -- cgit v1.2.1 From 4f6f0c08979d420a47f5cc4bcab2709d27853222 Mon Sep 17 00:00:00 2001 From: David King Date: Tue, 21 Aug 2012 17:04:16 -0400 Subject: [feature/add_events] Event to modify the data array for when a user is added PHPBB3-9550 --- phpBB/includes/functions_user.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 9e33a5122e..f4ecb7cdc3 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -255,6 +255,16 @@ function user_add($user_row, $cp_data = false) } } + /** + * Use this event to modify the values to be inserted when a user is added + * + * @event core.user_add_modify_data + * @var array sql_ary Array of data to be inserted when a user is added + * @since 3.1-A1 + */ + $vars = array('sql_ary'); + extract($phpbb_dispatcher->trigger_event('core.user_add_modify_data', compact($vars))); + $sql = 'INSERT INTO ' . USERS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); $db->sql_query($sql); -- cgit v1.2.1 From 46597be1a372f1215ffc18cfd645c1e977b44d84 Mon Sep 17 00:00:00 2001 From: David King Date: Wed, 22 Aug 2012 08:37:33 -0400 Subject: [feature/add_events] Globalize event dispatcher object in some functions PHPBB3-9550 --- phpBB/includes/functions_user.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index f4ecb7cdc3..f843902dd5 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -162,6 +162,7 @@ function user_update_name($old_name, $new_name) function user_add($user_row, $cp_data = false) { global $db, $user, $auth, $config, $phpbb_root_path, $phpEx; + global $phpbb_dispatcher; if (empty($user_row['username']) || !isset($user_row['group_id']) || !isset($user_row['user_email']) || !isset($user_row['user_type'])) { -- cgit v1.2.1