diff options
author | Marc Alexander <admin@m-a-styles.de> | 2019-01-05 16:12:29 +0100 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2019-01-05 16:12:29 +0100 |
commit | 537ff0c567de293763226390ab9d968ab73d77d5 (patch) | |
tree | 7480cd41593deff17963ed12ef1a21804f3d8422 /phpBB/includes/functions_user.php | |
parent | 409bfafbf088b4ac194c4cc1b89c9c07e3f5ef99 (diff) | |
parent | 08968bdb60c9ff286cb71901718500c7720f1da4 (diff) | |
download | forums-537ff0c567de293763226390ab9d968ab73d77d5.tar forums-537ff0c567de293763226390ab9d968ab73d77d5.tar.gz forums-537ff0c567de293763226390ab9d968ab73d77d5.tar.bz2 forums-537ff0c567de293763226390ab9d968ab73d77d5.tar.xz forums-537ff0c567de293763226390ab9d968ab73d77d5.zip |
Merge pull request #5457 from battye/ticket/15883
[ticket/15883] New error message for when users try adding invalid usernames to a group
Diffstat (limited to 'phpBB/includes/functions_user.php')
-rw-r--r-- | phpBB/includes/functions_user.php | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 26bb987561..5372a28d18 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -26,8 +26,10 @@ if (!defined('IN_PHPBB')) * @param array &$user_id_ary The user ids to check or empty if usernames used * @param array &$username_ary The usernames to check or empty if user ids used * @param mixed $user_type Array of user types to check, false if not restricting by user type +* @param boolean $update_references If false, the supplied array is unset and appears unchanged from where it was called +* @return boolean|string Returns false on success, error string on failure */ -function user_get_id_name(&$user_id_ary, &$username_ary, $user_type = false) +function user_get_id_name(&$user_id_ary, &$username_ary, $user_type = false, $update_references = false) { global $db; @@ -50,7 +52,13 @@ function user_get_id_name(&$user_id_ary, &$username_ary, $user_type = false) } $sql_in = ($which_ary == 'user_id_ary') ? array_map('intval', ${$which_ary}) : array_map('utf8_clean_string', ${$which_ary}); - unset(${$which_ary}); + + // By unsetting the array here, the values passed in at the point user_get_id_name() was called will be retained. + // Otherwise, if we don't unset (as the array was passed by reference) the original array will be updated below. + if ($update_references === false) + { + unset(${$which_ary}); + } $user_id_ary = $username_ary = array(); @@ -2698,6 +2706,13 @@ function group_user_add($group_id, $user_id_ary = false, $username_ary = false, return 'NO_USER'; } + // Because the item that gets passed into the previous function is unset, the reference is lost and our original + // array is retained - so we know there's a problem if there's a different number of ids to usernames now. + if (count($user_id_ary) != count($username_ary)) + { + return 'GROUP_USERS_INVALID'; + } + // Remove users who are already members of this group $sql = 'SELECT user_id, group_leader FROM ' . USER_GROUP_TABLE . ' |