Пример #1
0
/**
* Recalculates the members of an infraction group based on changes to it.
* Specifying the (required) override group ID allows removal of users from the group.
* Specifying the point level and applicable group allows addition of users to the group.
*
* @param	integer	Usergroup ID users are placed in
* @param	integer	Point level when this infraction group kicks in
* @param	integer	User group that this infraction group applies to
*/
function check_infraction_group_change($override_groupid, $point_level = null, $applies_groupid = -1)
{
    global $vbulletin;
    $users = array();
    if ($point_level === null) {
        $user_sql = $vbulletin->db->query_read("\n\t\t\tSELECT userid\n\t\t\tFROM " . TABLE_PREFIX . "user\n\t\t\tWHERE FIND_IN_SET('" . intval($override_groupid) . "', infractiongroupids)\n\t\t");
    } else {
        $user_sql = $vbulletin->db->query_read("\n\t\t\tSELECT userid\n\t\t\tFROM " . TABLE_PREFIX . "user\n\t\t\tWHERE FIND_IN_SET('" . intval($override_groupid) . "', infractiongroupids)\n\t\t\t\tOR (ipoints >= " . intval($point_level) . "\n\t\t\t\t\t" . ($applies_groupid != -1 ? "AND usergroupid = " . intval($applies_groupid) : '') . "\n\t\t\t\t)\n\t\t");
    }
    while ($user = $vbulletin->db->fetch_array($user_sql)) {
        $users[] = $user['userid'];
    }
    if ($users) {
        build_infractiongroupids($users);
    }
}
Пример #2
0
$warningarray = array();
$infractionarray = array();
$ipointsarray = array();
$userids = array();
$usernames = array();
while ($infraction = $vbulletin->db->fetch_array($infractions)) {
    $vbulletin->db->query_write("\n\t\tUPDATE " . TABLE_PREFIX . "infraction\n\t\tSET action = 1, actiondateline = " . TIMENOW . "\n\t\tWHERE infractionid = {$infraction['infractionid']}\n\t\t\tAND action = 0\n\t");
    // enforce atomic update so that related records are only updated at most one time, in the event this task is executed more than one time
    if ($vbulletin->db->affected_rows()) {
        $userids["{$infraction['userid']}"] = $infraction['username'];
        if ($infraction['points']) {
            $infractionarray["{$infraction['userid']}"]++;
            $ipointsarray["{$infraction['userid']}"] += $infraction['points'];
        } else {
            $warningarray["{$infraction['userid']}"]++;
        }
    }
}
// ############################ MAGIC ###################################
if (!empty($userids) and build_user_infractions($ipointsarray, $infractionarray, $warningarray)) {
    build_infractiongroupids(array_keys($userids));
}
if (!empty($userids)) {
    log_cron_action(implode(', ', $userids), $nextitem, 1);
}
/*======================================================================*\
|| ####################################################################
|| # Downloaded: 03:13, Sat Sep 7th 2013
|| # CVS: $RCSfile$ - $Revision: 32878 $
|| ####################################################################
\*======================================================================*/