Automatic Group Assignment By Posts Number. How Does It Work?


Subject: Automatic Group Assignment By Posts Number. How Does It Work?
Hi all,

I am wondering to know how does the system makes the group change when you activate it by user posts number. Is it checking it on any post the user writes? or maybe is a cron script? could you tellme where in the code is this feature?

Thank you so much.

Profile PM  
Subject: Re: Automatic Group Assignment By Posts Number. How Does It Work?
Hi,
the function is in this file includes/functions_post.php

function update_post_stats(&$mode, &$post_data, &$forum_id, &$topic_id, &$post_id, &$user_id)


Here is the portion of the code:
Code: [Download] [Hide] [Select]
$sql = "SELECT ug.user_id, g.group_id as g_id, u.user_posts, u.user_color_group, u.user_color, g.group_count, g.group_color, g.group_count_max FROM (" . GROUPS_TABLE . " g, " . USERS_TABLE . " u)
LEFT JOIN ". USER_GROUP_TABLE." ug ON g.group_id = ug.group_id AND ug.user_id = '" . $user_id . "'
WHERE u.user_id = '" . $user_id . "'
AND g.group_single_user = '0'
AND g.group_count_enable = '1'
AND g.group_moderator <> '" . $user_id . "'";
$result = $db->sql_query($sql);

while ($group_data = $db->sql_fetchrow($result))
{
$user_already_added = (empty($group_data['user_id'])) ? false : true;
$user_add = (($group_data['group_count'] == $group_data['user_posts']) && ($user_id != ANONYMOUS)) ? true : false;
$user_remove = ($group_data['group_count'] > $group_data['user_posts'] || $group_data['group_count_max'] < $group_data['user_posts']) ? true : false;
if ($user_add && !$user_already_added)
{
update_user_color($user_id, $group_data['group_color'], $group_data['g_id'], false, false);
update_user_posts_details($user_id, $group_data['group_color'], '', false, false);
empty_cache_folders(USERS_CACHE_FOLDER);
//user join a autogroup
$sql = "INSERT INTO " . USER_GROUP_TABLE . " (group_id, user_id, user_pending)
VALUES (" . $group_data['g_id'] . ", $user_id, '0')";
$db->sql_query($sql);
}
elseif ($user_already_added && $user_remove)
{
update_user_color($user_id, $config['active_users_color'], 0);
update_user_posts_details($user_id, '', '', false, false);
empty_cache_folders(USERS_CACHE_FOLDER);
//remove user from auto group
$sql = "DELETE FROM " . USER_GROUP_TABLE . "
WHERE group_id = '" . $group_data['g_id'] . "'
AND user_id = '" . $user_id . "'";
$db->sql_query($sql);
}
}
}


Page 1 of 1


  
You cannot post new topics
You cannot reply to topics
You cannot edit your posts
You cannot delete your posts
You cannot vote in polls
You cannot attach files
You can download files
You cannot post calendar events

   

This is a "Lo-Fi" version of our main content. To view the full version with more information, formatting and images, please click here.

Powered by Icy Phoenix based on phpBB
Generation Time: 0.3307s (PHP: 5% SQL: 95%)
SQL queries: 29 - Debug Off - GZIP Enabled