Not that this really matters, but technically a redundant query is made once a post has enough reports and gets unapproved.
I've updated my plugin code to the following:
PHP Code:
if ($_POST['do'] == 'sendemail' AND !empty($_POST['reason']))
{
$reports = $vbulletin->db->query_first("SELECT reports FROM " . TABLE_PREFIX . "post WHERE postid = " . $postinfo['postid']);
if ($reports['reports'] + 1 >= $vbulletin->options['unapprove_reported_posts_num_reports'] OR is_member_of($vbulletin->userinfo, unserialize($vbulletin->options['unapprove_reported_posts_bypass_usergroups'])))
{
$modinfo = fetch_userinfo($postinfo['userid']);
$uglist = $modinfo['usergroupid'] . iif(trim($modinfo['membergroupids']), ",$modinfo[membergroupids]");
if (!can_moderate(0, '', $modinfo['userid'], $uglist) OR ($permissions['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel']))
{
require_once(DIR. '/includes/functions_databuild.php');
unapprove_post($postinfo['postid'], ($foruminfo['countposts'] AND !$postinfo['skippostcount']), true, $postinfo, $threadinfo, false);
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "post SET reports = 0 WHERE postid = " . $postinfo['postid']);
}
else
{
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "post SET reports = reports + 1 WHERE postid = " . $postinfo['postid']);
}
}
else
{
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "post SET reports = reports + 1 WHERE postid = " . $postinfo['postid']);
}
}