Okay, this is what I had in mind:
PHP Code:
$pinfract_this_year = $vbulletin->db->query_read("
SELECT infraction.*
FROM " . TABLE_PREFIX . "infraction AS infraction
WHERE dateline >= " . (TIMENOW - 365*86400) . "
AND expires = 0
");
$userlist = '';
while ($infract = $vbulletin->db->fetch_array($pinfract_this_year))
{
$userlist .= ($infract['userid'] . ',');
}
$userlist = rtrim($userlist, ',');
$vbulletin->db->query_write("
UPDATE " . TABLE_PREFIX . "user
SET new_column = CASE
WHEN userid IN (" . $userlist . ") THEN 1
ELSE 0
END
");
edit: I just now saw you posted "I also want to now count the number of permanent infractions the user has had in the past year and set it in the new column in the user table." That will require some recoding, which I will have to put off for now as it's getting late.
edit 2: I corrected a small typo in the code.