diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html index 1864012a5a..1cd539348e 100644 --- a/phpBB/docs/CHANGELOG.html +++ b/phpBB/docs/CHANGELOG.html @@ -118,6 +118,7 @@
  • [Fix] Delete drafts and bookmarks when deleting an user. (#27585, thanks Schumi for the fix)
  • [Fix] Set last_post_subject for new topics. (#23945)
  • [Fix] Allow moving posts to invisible forums. (#27325)
  • +
  • [Fix] Don't allow promoting unapproved group members (#16124)
  • 1.ii. Changes since 3.0.0

    diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index eb785ced23..6d789fb5ff 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -87,24 +87,32 @@ class acp_groups // Approve, demote or promote $group_name = ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name']; - group_user_attributes($action, $group_id, $mark_ary, false, $group_name); - - switch ($action) + $error = group_user_attributes($action, $group_id, $mark_ary, false, $group_name); + + if (!$error) { - case 'demote': - $message = 'GROUP_MODS_DEMOTED'; - break; + switch ($action) + { + case 'demote': + $message = 'GROUP_MODS_DEMOTED'; + break; - case 'promote': - $message = 'GROUP_MODS_PROMOTED'; - break; + case 'promote': + $message = 'GROUP_MODS_PROMOTED'; + break; - case 'approve': - $message = 'USERS_APPROVED'; - break; + case 'approve': + $message = 'USERS_APPROVED'; + break; + } + + trigger_error($user->lang[$message] . adm_back_link($this->u_action . '&action=list&g=' . $group_id)); } - - trigger_error($user->lang[$message] . adm_back_link($this->u_action . '&action=list&g=' . $group_id)); + else + { + trigger_error($user->lang[$error] . adm_back_link($this->u_action . '&action=list&g=' . $group_id), E_USER_WARNING); + } + break; case 'default': diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 7188ebeb52..daa571a790 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -2911,7 +2911,7 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna if (!sizeof($user_id_ary) || $result !== false) { - return false; + return 'NO_USERS'; } if (!$group_name) @@ -2923,9 +2923,23 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna { case 'demote': case 'promote': + + $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); + $result = $db->sql_query_limit($sql, 1); + $not_empty = ($db->sql_fetchrow($result)); + $db->sql_freeresult($result); + if ($not_empty) + { + return 'NO_VALID_USERS'; + } + $sql = 'UPDATE ' . USER_GROUP_TABLE . ' SET group_leader = ' . (($action == 'promote') ? 1 : 0) . " WHERE group_id = $group_id + AND user_pending = 0 AND " . $db->sql_in_set('user_id', $user_id_ary); $db->sql_query($sql); @@ -3019,7 +3033,7 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna group_update_listings($group_id); - return true; + return false; } /** diff --git a/phpBB/language/en/acp/groups.php b/phpBB/language/en/acp/groups.php index 714cbe7f0d..f74110a7d3 100644 --- a/phpBB/language/en/acp/groups.php +++ b/phpBB/language/en/acp/groups.php @@ -108,6 +108,7 @@ $lang = array_merge($lang, array( 'NO_PERMISSIONS' => 'Do not copy permissions', 'NO_USERS' => 'You haven’t entered any users.', 'NO_USERS_ADDED' => 'No users were added to the group.', + 'NO_VALID_USERS' => 'You haven’t entered any users eligible for that action.', 'SPECIAL_GROUPS' => 'Pre-defined groups', 'SPECIAL_GROUPS_EXPLAIN' => 'Pre-defined groups are special groups, they cannot be deleted or directly modified. However you can still add users and alter basic settings.',