Php code needed to confirm mod should be seeing report


Well-known member
Howdy i am working email report mod

basically so far i have it so it sends emails on new reports to all mods (global and forum) and admins

however it means sometimes forum/content mods get reports they shouldn't

what would i need to do with below code to get it so global mods and admins get all reports but forum/content mods just get their own section reports in email notices?

class EmailReport_Report extends XenForo_Model_Report
    public function reportContent($contentType, array $content, $message, array $viewingUser = null)
        $reportId = parent::reportContent($contentType, $content, $message, $viewingUser);
        if ($reportId == 0)
            return false;
      $users = $this->fetchAllKeyed('SELECT * FROM xf_user WHERE is_admin = 1 OR is_moderator = 1', 'user_id');
        $report = $this->getReportById($reportId);
        $userModel = $this->getModelFromCache('XenForo_Model_User');
        // Fetching the owner of reported content
        $reportedUser = $userModel->getUserById($report['content_user_id']);
        foreach ($users as $user)
            $params = array(
        // User whose email will be sent
                'user' => $user['username'],
        // User who reported the content
                'reportingUser' => $report['last_modified_username'],
                'reportId' => $report['report_id'],
        // The message of the report - very useful indeed ;)
                'reportMessage' => $message,
        // Username of the content owner
                'reportedUser' => $reportedUser['username']
            $mail = new XenForo_Mail('new_item_reported', $params, $user['language_id']);
            $mail->send($user['email'], $user['username']);