Skip to content
Permalink
Browse files

#935: Add backend action to promote a user if he is ready.

  • Loading branch information...
franzliedke committed Feb 26, 2014
1 parent be95b6f commit a1d9b6feedc47c07357abcb3ee6afb4e2998a1ae
Showing with 20 additions and 0 deletions.
  1. +20 −0 profile.php
@@ -567,6 +567,26 @@
}
else if (isset($_POST['promote']))
{
if ($pun_user['g_id'] != PUN_ADMIN && ($pun_user['g_moderator'] != '1' || $pun_user['g_mod_promote_users'] == '0'))
message($lang_common['No permission'], false, '403 Forbidden');
confirm_referrer('profile.php');
$sql = 'SELECT gg.g_promote_next_group FROM '.$db->prefix.'groups AS g INNER JOIN '.$db->prefix.'groups AS gg ON g.g_id = gg.g_promote_next_group INNER JOIN '.$db->prefix.'users AS u ON u.group_id = gg.g_id WHERE u.id = '.$id.' AND u.num_posts >= gg.g_promote_min_posts';

This comment has been minimized.

Copy link
@Quy

Quy Feb 26, 2014

Member

How about changing as follows since user's number of posts may be less than the required number of posts to be promoted?

    $result = $db->query('SELECT g.g_promote_next_group FROM '.$db->prefix.'users AS u INNER JOIN '.$db->prefix.'groups AS g ON (g.g_id=u.group_id) WHERE g.g_promote_next_group>0 AND u.id='.$id) or error('Unable to fetch group', __FILE__, __LINE__, $db->error());

This comment has been minimized.

Copy link
@franzliedke

franzliedke Feb 26, 2014

Author Member

Yeah, makes sense. Thanks for the heads-up. And thanks @askelon for the code, I forgot to mention you in the commit message.

$result = $db->query($sql) or error('Unable to fetch promotion information', __FILE__, __LINE__, $db->error());
if (!$db->num_rows($result))
message($lang_common['Bad request'], false, '404 Not Found');
$next_group_id = $db->result($result);
$db->query('UPDATE '.$db->prefix.'users SET group_id = '.$next_group_id.' WHERE id = '.$id) or error('Unable to promote user', __FILE__, __LINE__, $db->error());
redirect('profile.php?section=admin&id='.$id, $lang_profile['User promote redirect']);
}
else if (isset($_POST['delete_user']) || isset($_POST['delete_user_comply']))
{
if ($pun_user['g_id'] > PUN_ADMIN)

0 comments on commit a1d9b6f

Please sign in to comment.
You can’t perform that action at this time.