MyBB Community Forums

Full Version: moderation.php - inherited moderator can't mark reports read
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Inherited moderator (from parent forum) can't mark reports read - nothing happens after selecting some reports and clicking "mark selected as read" (there is no error - message is "ok - marked as read").


In file moderation.php in section "do_reports" we have SQL:
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."moderators WHERE uid='".$mybb->user[uid]."'");
which is probably bad because it does not include inherited moderators.


Fix - I do not know any simple solution... maybe use function ismod()? But it will be rather slow... :/
Anybody thats a moderator is in the moderators table, weather or not they're inherited, so I'm not sure what the problem is coming from. Can you please post the url to your board
The problem is in selecting forums for UPDATE query when marking reports read.:
while($forum = $db->fetch_array($query))
{
   $flist .= ",'".$forum['fid']."'";
}

Inherited moderator and its forum is not in mybb_moderators. For example:
- forum fid=10 is moderated by 'X';
- forum fid=11 is a subforum of 10 (parent id=10, so 'X' inherits it);
in mybb_moderators we will only see record like: fid=10,uid=X. There will not be record for forum fid 11. So the effect is that the SQL query (in first post) does not select forum fids for inherited moderators.

I do not know if it is real problem since normal moderators do not see post reports...


P.S. I can post the URL but you will not find anything usefull there for that problem because this inheriting forums are not visible for everyone Smile.
I just made a test board, with 2 users. 1 is an admin, and one is a normal forum moderator. I created a subforum to another forum, and then I assigned the moderator to the parent forum. I then reported a post in the subforum, and logged into the moderator account. After logging into the moderator account, i went to the reported posts (yes, it showed up), and I was able to check the reported post succesfully, and it didn't show up next time in the reported posts.

So... I don't know whats wrong :\
Also, this block of code is not used (dunno why not):

$flist = "";
		if($mybb->usergroup['issupermod'] != "yes")
		{
			$query = $db->query("SELECT * FROM ".TABLE_PREFIX."moderators WHERE uid='".$mybb->user['uid']."'");
			while($forum = $db->fetch_array($query))
			{
				$flist .= ",'".$forum['fid']."'";
			}
		}
		if($flist)
		{
			$flist = "AND fid IN (0$flist)";
		}

I don't see it used anywhere, so I guess the problem doesn't lay there
Oh yes, I remember now Smile. I have made modification to use this code (actually the variable $flist):
FIND:
		$db->query("UPDATE ".TABLE_PREFIX."reportedposts SET reportstatus='1' WHERE rid IN ($rids)");
		$cache->updatereportedposts();
REPLACE WITH:
		$db->query("UPDATE ".TABLE_PREFIX."reportedposts SET reportstatus='1' WHERE rid IN ($rids) $flist");
		$cache->updatereportedposts();
and in my board each moderator can mark only his reports (reports from his forum).

So actually I have created that problem in my board while solving another...

Anyway thanks for your time Smile.