Hide reported content

From PunBB Resource Wiki

Jump to: navigation, search

Use the following code to display an error for users other than administrators or moderators when the number of users that have reported post(s) in a topic as objectionable totals 3 or more.

Open: viewtopic.php


if ($pid)
        $result = $db->query('SELECT topic_id FROM '.$db->prefix.'posts WHERE id='.$pid) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
        if (!$db->num_rows($result))
                message($lang_common['Bad request']);
        $id = $db->result($result);
        // Determine on what page the post is located (depending on $pun_user['disp_posts'])
        $result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id='.$id.' ORDER BY posted') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
        $num_posts = $db->num_rows($result);
        for ($i = 0; $i < $num_posts; ++$i)
                $cur_id = $db->result($result, $i);
                if ($cur_id == $pid)
        ++$i;        // we started at 0
        $_GET['p'] = ceil($i / $pun_user['disp_posts']);

After, add:

if ($pun_user['g_id'] > 2)
	$result = $db->query('SELECT DISTINCT reported_by FROM '.$db->prefix.'reports WHERE topic_id = '.$id.' AND zapped IS NULL') or error('Unable to fetch report info', __FILE__, __LINE__, $db->error());
	if ($db->num_rows($result) >= 3)
		message('Content contained in this topic has been marked as objectionable and is awaiting staff review. Please try again later.');

Special thanks to Smartys from the PunBB.org Forums for his guidance in using "zapped IS NULL" rather than "zapped = NULL".

--Pogenwurst 13:53, 4 June 2006 (GMT)

Personal tools