From dd075e4bbc50371ae799059efa2356710d38aafb Mon Sep 17 00:00:00 2001 From: Stanislav Atanasov Date: Fri, 13 Jun 2014 23:58:22 +0300 Subject: [PATCH 1/3] [ticket/12701] Add events to user_add function Add two new events to user_add function in ./includes/functions_user.php. core.user_add_before - allow modification of submitted to function data. Returns: @var array $user_row - user_row array - User array @var array $cp_data - cp_data array - CPF array core.user_add_after - return user_id, user_row and cp_data after user registration Returns: @var int $user_id - user_id of the new user @var array $user_row - user_row array - User array @var array $cp_data - cp_data array - CPF array Justification: Allow extensions to parse data before and after creation of the user. PHPBB3-12701 --- phpBB/includes/functions_user.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) mode change 100644 => 100755 phpBB/includes/functions_user.php diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php old mode 100644 new mode 100755 index 5a10f9f411..0990eacc1c --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -180,6 +180,17 @@ function user_add($user_row, $cp_data = false) return false; } + /** + * Event to parse/modify data submited to user_add function + * + * @event core.user_add_before + * @var array user_row Array of user details submited to user_add + * @var array cp_data Array of Custom profile fields submited to user_add + * @since 3.1.0-b5 + */ + $vars = array('user_row', 'cp_data'); + extract($phpbb_dispatcher->trigger_event('core.user_add_before', compact($vars))); + $sql_ary = array( 'username' => $user_row['username'], 'username_clean' => $username_clean, @@ -344,6 +355,18 @@ function user_add($user_row, $cp_data = false) set_config('newest_user_colour', $row['group_colour'], true); } + /** + * Event that returns user id, user detals and user CPF of newly registared user + * + * @event core.user_add_after + * @var int user_id User id of newly registared user + * @var array user_row Array of user details submited to user_add + * @var array cp_data Array of Custom profile fields submited to user_add + * @since 3.1.0-b5 + */ + $vars = array('user_id', 'user_row', 'cp_data'); + extract($phpbb_dispatcher->trigger_event('core.user_add_after', compact($vars))); + return $user_id; } From 165c5f8f15c969c10f0ae5b2c1a0bc68947ce595 Mon Sep 17 00:00:00 2001 From: Stanislav Atanasov Date: Sat, 14 Jun 2014 11:47:41 +0300 Subject: [PATCH 2/3] [ticket/12701] Rmove before event and expand modify_data Removing core.user_add_before Adding $user_row and $cp_data to core.user_add_modify_data PHPBB3-12701 --- phpBB/includes/functions_user.php | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 0990eacc1c..b1e1742ef8 100755 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -180,17 +180,6 @@ function user_add($user_row, $cp_data = false) return false; } - /** - * Event to parse/modify data submited to user_add function - * - * @event core.user_add_before - * @var array user_row Array of user details submited to user_add - * @var array cp_data Array of Custom profile fields submited to user_add - * @since 3.1.0-b5 - */ - $vars = array('user_row', 'cp_data'); - extract($phpbb_dispatcher->trigger_event('core.user_add_before', compact($vars))); - $sql_ary = array( 'username' => $user_row['username'], 'username_clean' => $username_clean, @@ -272,10 +261,12 @@ 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 user_row Array of user details submited to user_add + * @var array cp_data Array of Custom profile fields submited to user_add * @var array sql_ary Array of data to be inserted when a user is added - * @since 3.1.0-a1 + * @since 3.1.0-b5 */ - $vars = array('sql_ary'); + $vars = array('user_row', 'cp_data', '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); From 152d5fc263a7f5a32e63c5b125e0b6a1cead71e7 Mon Sep 17 00:00:00 2001 From: Stanislav Atanasov Date: Sun, 22 Jun 2014 22:06:16 +0300 Subject: [PATCH 3/3] [ticket/12701] Add change Change back to since Add change PHPBB3-12701 --- phpBB/includes/functions_user.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index b1e1742ef8..f22f84ee97 100755 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -264,7 +264,8 @@ function user_add($user_row, $cp_data = false) * @var array user_row Array of user details submited to user_add * @var array cp_data Array of Custom profile fields submited to user_add * @var array sql_ary Array of data to be inserted when a user is added - * @since 3.1.0-b5 + * @since 3.1.0-a1 + * @change 3.1.0-b5 */ $vars = array('user_row', 'cp_data', 'sql_ary'); extract($phpbb_dispatcher->trigger_event('core.user_add_modify_data', compact($vars)));