MyBB Community Forums

Full Version: [TuT] Forum Mods See Only Reported Posts From Their Forum
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Alright, I will show you a quick fix so that Forum Moderators see ONLY their forum reports.

Part 1
Only show our forum reports.

First change you will want is in modcp.php at root.

Search for the following, it should be around line 104.
if($mybb->input['action'] == "reports")

Once you are there, scroll down until you see the following:

$trow = alt_trow();
		if(is_moderator($report['fid']))
		{
			$trow = 'trow_shaded';
		}

This is what we are altering. We will be adding an 'else' statement after this. Now the above should look like:

$trow = alt_trow();
		if(is_moderator($report['fid']))
		{
			$trow = 'trow_shaded';
		}
        else {
                continue;
        }

--

Part 2
Adjust global unreadreports message.

Now we will need to edit global.php at root. We need to only display how many reports are in your section.

So open up global.php and look for the following:

$unreadreports = '';

There should only be one instance.

Alright, now that you are at the mark, we need to change the following:

$unreadreports = '';
// This user is a moderator, super moderator or administrator
if($mybb->usergroup['cancp'] == 1 || $mybb->user['ismoderator'] && $mybb->usergroup['canmodcp'])
{
	// Read the reported posts cache
	$reported = $cache->read("reportedposts");

	// 0 or more reported posts currently exist
	if($reported['unread'] > 0)
	{
		if($reported['unread'] == 1)
		{
			$lang->unread_reports = $lang->unread_report;
		}
		else
		{
			$lang->unread_reports = $lang->sprintf($lang->unread_reports, $reported['unread']);
		}
		eval("\$unreadreports = \"".$templates->get("global_unreadreports")."\";");
	}
}

to..

$unreadreports = '';
// This user is a moderator, super moderator or administrator
if($mybb->usergroup['cancp'] == 1 || $mybb->user['ismoderator'] && $mybb->usergroup['canmodcp'])
{
	if($mybb->usergroup['cancp'] || $mybb->usergroup['issupermod'])
	{
		 // Read the reported posts cache
		$reported = $cache->read("reportedposts");

		// 0 or more reported posts currently exist
		if($reported['unread'] > 0)
		{
			if($reported['unread'] == 1)
			{
				$lang->unread_reports = $lang->unread_report;
			}
			else
			{
				$lang->unread_reports = $lang->sprintf($lang->unread_reports, $reported['unread']);
			}
			eval("\$unreadreports = \"".$templates->get("global_unreadreports")."\";");
		}
	}
	else {
		$query = $db->simple_select("reportedposts", "reportstatus,fid", "reportstatus='0'");
		
		$reportsleft = 0;
		
		while($report = $db->fetch_array($query))
		{
			if(is_moderator($report['fid']))
			{
				$reportsleft +=1;
			}
		}
		
		// 0 or more reported posts currently exist
		if($reportsleft > 0)
		{
			if($reportsleft == 1)
			{
				$lang->unread_reports = $lang->unread_report;
			}
			else
			{
				$lang->unread_reports = $lang->sprintf($lang->unread_reports, $reportsleft);
			}
			eval("\$unreadreports = \"".$templates->get("global_unreadreports")."\";");
		}
	}
}

The difference with this, is that it checks if the user is an Admin or Super Moderator first, and handle the reports notice as normal.

However, if the person is a normal mod, it will continue to the next part of the script, the 'else' statement.

The else statement grabs the number of reports from the reportedposts table (using simple_select only taking the columns 'reportstatus' and 'fid') and checks to see if the user is the moderator of that forum area. It then displays the results as normal.

--

Well guys, that is pretty much it, please leave some feedback and criticism Smile
You have an error in your code:my bad you dont
-> Good tutorial hit that rep button!
Is this xerotic from HF?
Can anyone confirm that this is safe and works? I can't take any chances.
(2011-08-30, 01:22 PM)HybridForum Wrote: [ -> ]You have an error in your code:my bad you dont
-> Good tutorial hit that rep button!
Is this xerotic from HF?

Yes, but that does not matter.

(2011-08-30, 04:22 PM)Everett777 Wrote: [ -> ]Can anyone confirm that this is safe and works? I can't take any chances.

I would like confirmation that this is 100% safe to use as well. I think it is.
Yes, this is 100% safe, Everett777.
(2011-08-31, 12:05 PM)Irreligious Wrote: [ -> ]Yes, this is 100% safe, Everett777.

Thanks, glad to see you enjoy it Smile
Sorry for bumping, though this does not work. Anyone know why? I kinda need this for my forum. :3
(2012-02-15, 04:53 AM)ZouX Wrote: [ -> ]Sorry for bumping, though this does not work. Anyone know why? I kinda need this for my forum. :3

What error are you getting?