Permalink
Browse files

#647: Promote user to new group after posting, if enabled.

  • Loading branch information...
1 parent 98678f3 commit b7f3c0ec69d494629a2d2a909a8bc4acef3ed11e @franzliedke franzliedke committed Mar 27, 2012
Showing with 9 additions and 1 deletion.
  1. +9 −1 post.php
View
@@ -152,7 +152,7 @@
$hide_smilies = isset($_POST['hide_smilies']) ? '1' : '0';
$subscribe = isset($_POST['subscribe']) ? '1' : '0';
$stick_topic = isset($_POST['stick_topic']) && $is_admmod ? '1' : '0';
-
+
// Replace four-byte characters (MySQL cannot handle them)
$message = strip_bad_multibyte_chars($message);
@@ -418,6 +418,14 @@
{
$db->query('UPDATE '.$db->prefix.'users SET num_posts=num_posts+1, last_post='.$now.' WHERE id='.$pun_user['id']) or error('Unable to update user', __FILE__, __LINE__, $db->error());
+ // Promote this user to a new group if enabled
+ if ($pun_user['g_promote_next_group'] != 0 && $pun_user['num_posts'] + 1 >= $pun_user['g_promote_min_posts'])
+ {
+ $new_group_id = $pun_user['g_promote_next_group'];
+ $db->query('UPDATE '.$db->prefix.'users SET group_id='.$new_group_id) or error('Unable to promote user to new group', __FILE__, __LINE__, $db->error());
+ }
+
+ // Topic tracking stuff...
$tracked_topics = get_tracked_topics();
$tracked_topics['topics'][$new_tid] = time();
set_tracked_topics($tracked_topics);

2 comments on commit b7f3c0e

@Quy
Member
Quy commented on b7f3c0e Mar 29, 2012

This promotes all users. It needs to specify the user ID to update.

@franzliedke
Member

Whoops, that is kind of embarrassing. Will fix it in a few minutes.

Please sign in to comment.