diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2013-02-25 21:03:34 +0100 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2013-02-25 21:03:34 +0100 |
commit | 8c6a1e50f502385c2d75920dd4914928d8311b80 (patch) | |
tree | 57a8e6af9ec0077323054aa93151e0a9c048dfb4 /phpBB/includes/functions_user.php | |
parent | 1d7b082a6fa05d5760ef15ef8bf78cd3a1d204cf (diff) | |
parent | 9b38c4579e80a9013b6ecad71fce38e930b67838 (diff) | |
download | forums-8c6a1e50f502385c2d75920dd4914928d8311b80.tar forums-8c6a1e50f502385c2d75920dd4914928d8311b80.tar.gz forums-8c6a1e50f502385c2d75920dd4914928d8311b80.tar.bz2 forums-8c6a1e50f502385c2d75920dd4914928d8311b80.tar.xz forums-8c6a1e50f502385c2d75920dd4914928d8311b80.zip |
Merge branch 'develop' of https://github.com/phpbb/phpbb3 into ticket/10411-2
* 'develop' of https://github.com/phpbb/phpbb3: (497 commits)
[ticket/10986] message.id fallback to SERVER_NAME or phpbb.generated
[ticket/11358] Changed the name of post parameter.
[ticket/11358] Changed the action parameter value to represent the link.
[ticket/11358] Enabled link making all users default for a group.
[ticket/11358] Removed redundant code and referred proper variable.
[ticket/11358] Success message even without selecting a user.
[ticket/11355] Referred proper variable when validating selection.
[ticket/11355] Wrong error message when no user is selected.
[ticket/10896] Add missing email validation lost in develop merge
[ticket/7262] Add note about set_config() not updating is_dynamic.
[ticket/7262] Add $is_dynamic example to set_config() and set_config_count().
[ticket/7262] Backport set_config() and set_config_count() docs from develop.
[ticket/11122] Move rxu to 'Former Contributors' section.
[ticket/11122] Add EXreaction to docs/AUTHORS.
[ticket/11298] Fix typo in language key; EXTENSIONS -> EXTENSION
[ticket/11361] Make sure that array passed to strtr() has the proper format.
[ticket/11342] Fix "unexpected token" syntax error
[ticket/11179] remove extra & in function call
[ticket/11179] correct start parameter in sphinx search
[ticket/11179] correct start parameter in native author search
...
Conflicts:
phpBB/config/services.yml
phpBB/includes/functions_user.php
phpBB/install/schemas/firebird_schema.sql
phpBB/install/schemas/mssql_schema.sql
phpBB/install/schemas/mysql_40_schema.sql
phpBB/install/schemas/mysql_41_schema.sql
phpBB/install/schemas/oracle_schema.sql
phpBB/install/schemas/postgres_schema.sql
phpBB/install/schemas/sqlite_schema.sql
Diffstat (limited to 'phpBB/includes/functions_user.php')
-rw-r--r-- | phpBB/includes/functions_user.php | 111 |
1 files changed, 70 insertions, 41 deletions
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 33b62fe8b8..379abe4d42 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -2676,12 +2676,12 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow } $db->sql_freeresult($result); - if (isset($sql_ary['group_avatar']) && !$sql_ary['group_avatar']) + if (isset($sql_ary['group_avatar'])) { remove_default_avatar($group_id, $user_ary); } - if (isset($sql_ary['group_rank']) && !$sql_ary['group_rank']) + if (isset($sql_ary['group_rank'])) { remove_default_rank($group_id, $user_ary); } @@ -2845,7 +2845,7 @@ function avatar_remove_db($avatar_name) */ function group_delete($group_id, $group_name = false) { - global $db, $user, $phpbb_root_path, $phpEx, $phpbb_dispatcher, $phpbb_container; + global $db, $cache, $auth, $user, $phpbb_root_path, $phpEx, $phpbb_dispatcher, $phpbb_container; if (!$group_name) { @@ -2917,12 +2917,12 @@ function group_delete($group_id, $group_name = false) extract($phpbb_dispatcher->trigger_event('core.delete_group_after', compact($vars))); // Re-cache moderators - if (!function_exists('cache_moderators')) + if (!function_exists('phpbb_cache_moderators')) { include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); } - cache_moderators(); + phpbb_cache_moderators($db, $cache, $auth); add_log('admin', 'LOG_GROUP_DELETE', $group_name); @@ -3212,8 +3212,8 @@ function remove_default_avatar($group_id, $user_ids) user_avatar_width = 0, user_avatar_height = 0 WHERE group_id = " . (int) $group_id . " - AND user_avatar = '" . $db->sql_escape($row['group_avatar']) . "' - AND " . $db->sql_in_set('user_id', $user_ids); + AND user_avatar = '" . $db->sql_escape($row['group_avatar']) . "' + AND " . $db->sql_in_set('user_id', $user_ids); $db->sql_query($sql); } @@ -3250,9 +3250,9 @@ function remove_default_rank($group_id, $user_ids) $sql = 'UPDATE ' . USERS_TABLE . ' SET user_rank = 0 WHERE group_id = ' . (int)$group_id . ' - AND user_rank <> 0 - AND user_rank = ' . (int)$row['group_rank'] . ' - AND ' . $db->sql_in_set('user_id', $user_ids); + AND user_rank <> 0 + AND user_rank = ' . (int)$row['group_rank'] . ' + AND ' . $db->sql_in_set('user_id', $user_ids); $db->sql_query($sql); } @@ -3281,7 +3281,8 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna case 'demote': case 'promote': - $sql = 'SELECT user_id FROM ' . USER_GROUP_TABLE . " + $sql = 'SELECT user_id + FROM ' . USER_GROUP_TABLE . " WHERE group_id = $group_id AND user_pending = 1 AND " . $db->sql_in_set('user_id', $user_id_ary); @@ -3379,7 +3380,8 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna return 'NO_USERS'; } - $sql = 'SELECT user_id, group_id FROM ' . USERS_TABLE . ' + $sql = 'SELECT user_id, group_id + FROM ' . USERS_TABLE . ' WHERE ' . $db->sql_in_set('user_id', $user_id_ary, false, true); $result = $db->sql_query($sql); @@ -3467,7 +3469,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, $phpbb_dispatcher; + global $phpbb_container, $db, $phpbb_dispatcher; if (empty($user_id_ary)) { @@ -3513,45 +3515,69 @@ function group_set_user_default($group_id, $user_id_ary, $group_attributes = fal } } - // Before we update the user attributes, we will make a list of those having now the group avatar assigned - if (isset($sql_ary['user_avatar'])) + $updated_sql_ary = $sql_ary; + + // Before we update the user attributes, we will update the rank for users that don't have a custom rank + if (isset($sql_ary['user_rank'])) { - // Ok, get the original avatar data from users having an uploaded one (we need to remove these from the filesystem) - $sql = 'SELECT user_id, group_id, user_avatar - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', $user_id_ary) . ' - AND user_avatar_type = ' . AVATAR_UPLOAD; - $result = $db->sql_query($sql); + $sql = 'UPDATE ' . USERS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', array('user_rank' => $sql_ary['user_rank'])) . ' + WHERE user_rank = 0 + AND ' . $db->sql_in_set('user_id', $user_id_ary); + $db->sql_query($sql); + unset($sql_ary['user_rank']); + } - while ($row = $db->sql_fetchrow($result)) + // Before we update the user attributes, we will update the avatar for users that don't have a custom avatar + $avatar_options = array('user_avatar', 'user_avatar_type', 'user_avatar_height', 'user_avatar_width'); + + if (isset($sql_ary['user_avatar'])) + { + $avatar_sql_ary = array(); + foreach ($avatar_options as $avatar_option) { - avatar_delete('user', $row); - } - $db->sql_freeresult($result); + if (isset($sql_ary[$avatar_option])) + { + $avatar_sql_ary[$avatar_option] = $sql_ary[$avatar_option]; + } + } + + $sql = 'UPDATE ' . USERS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $avatar_sql_ary) . " + WHERE user_avatar = '' + AND " . $db->sql_in_set('user_id', $user_id_ary); + $db->sql_query($sql); } - else + + // Remove the avatar options, as we already updated them + foreach ($avatar_options as $avatar_option) { - unset($sql_ary['user_avatar_type']); - unset($sql_ary['user_avatar_height']); - unset($sql_ary['user_avatar_width']); + unset($sql_ary[$avatar_option]); } - $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE ' . $db->sql_in_set('user_id', $user_id_ary); - $db->sql_query($sql); + if (!empty($sql_ary)) + { + $sql = 'UPDATE ' . USERS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' + WHERE ' . $db->sql_in_set('user_id', $user_id_ary); + $db->sql_query($sql); + } if (isset($sql_ary['user_colour'])) { // Update any cached colour information for these users - $sql = 'UPDATE ' . FORUMS_TABLE . " SET forum_last_poster_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "' + $sql = 'UPDATE ' . FORUMS_TABLE . " + SET forum_last_poster_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "' WHERE " . $db->sql_in_set('forum_last_poster_id', $user_id_ary); $db->sql_query($sql); - $sql = 'UPDATE ' . TOPICS_TABLE . " SET topic_first_poster_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "' + $sql = 'UPDATE ' . TOPICS_TABLE . " + SET topic_first_poster_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "' WHERE " . $db->sql_in_set('topic_poster', $user_id_ary); $db->sql_query($sql); - $sql = 'UPDATE ' . TOPICS_TABLE . " SET topic_last_poster_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "' + $sql = 'UPDATE ' . TOPICS_TABLE . " + SET topic_last_poster_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "' WHERE " . $db->sql_in_set('topic_last_poster_id', $user_id_ary); $db->sql_query($sql); @@ -3563,6 +3589,9 @@ function group_set_user_default($group_id, $user_id_ary, $group_attributes = fal } } + // Make all values available for the event + $sql_ary = $updated_sql_ary; + /** * Event when the default group is set for an array of users * @@ -3583,7 +3612,7 @@ function group_set_user_default($group_id, $user_id_ary, $group_attributes = fal } // Because some tables/caches use usercolour-specific data we need to purge this here. - $cache->destroy('sql', MODERATOR_CACHE_TABLE); + $phpbb_container->get('cache.driver')->destroy('sql', MODERATOR_CACHE_TABLE); } /** @@ -3682,7 +3711,7 @@ function group_memberships($group_id_ary = false, $user_id_ary = false, $return_ */ function group_update_listings($group_id) { - global $auth; + global $db, $cache, $auth; $hold_ary = $auth->acl_group_raw_data($group_id, array('a_', 'm_')); @@ -3724,22 +3753,22 @@ function group_update_listings($group_id) if ($mod_permissions) { - if (!function_exists('cache_moderators')) + if (!function_exists('phpbb_cache_moderators')) { global $phpbb_root_path, $phpEx; include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); } - cache_moderators(); + phpbb_cache_moderators($db, $cache, $auth); } if ($mod_permissions || $admin_permissions) { - if (!function_exists('update_foes')) + if (!function_exists('phpbb_update_foes')) { global $phpbb_root_path, $phpEx; include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); } - update_foes(array($group_id)); + phpbb_update_foes($db, $auth, array($group_id)); } } |