Beispiel #1
0
function reportUser($option, $form = 1, $uid = 0)
{
    global $_CB_framework, $ueConfig, $_PLUGINS, $_POST;
    if ($ueConfig['allowUserReports'] == 0) {
        $msg = CBTxt::Th('UE_FUNCTIONALITY_DISABLED', 'This functionality is currently disabled.');
    } elseif (!CBuser::getMyInstance()->authoriseView('profile', $uid)) {
        $msg = CBTxt::Th('UE_NOT_AUTHORIZED', 'You are not authorized to view this page!');
    } else {
        $msg = null;
    }
    $_PLUGINS->loadPluginGroup('user');
    $_PLUGINS->trigger('onBeforeReportUserRequest', array($uid, &$msg, $form));
    if ($msg) {
        $_CB_framework->enqueueMessage($msg, 'error');
        return;
    }
    $reportedByUser = CBuser::getUserDataInstance($_CB_framework->myId());
    $reportedUser = CBuser::getUserDataInstance($uid);
    if ($form == 1) {
        $results = $_PLUGINS->trigger('onBeforeReportUserForm', array($uid, &$reportedByUser, &$reportedUser));
        if ($_PLUGINS->is_errors()) {
            $_CB_framework->enqueueMessage($_PLUGINS->getErrorMSG('<br />'), 'error');
            return;
        }
        if (implode('', $results) != "") {
            $return = '<div class="cb_template cb_template_' . selectTemplate('dir') . '">' . '<div>' . implode('</div><div>', $results) . '</div>' . '</div>';
            echo $return;
            return;
        }
        HTML_comprofiler::reportUserForm($option, $uid, $reportedByUser, $reportedUser);
    } else {
        cbSpoofCheck('reportuser');
        $row = new UserReportTable();
        $_PLUGINS->trigger('onStartSaveReportUser', array(&$row, &$reportedByUser, &$reportedUser));
        if ($_PLUGINS->is_errors()) {
            cbRedirect($_CB_framework->viewUrl('reportuser', false), $_PLUGINS->getErrorMSG(), 'error');
            return;
        }
        if (!$row->bind($_POST)) {
            cbRedirect($_CB_framework->viewUrl('reportuser', false), $row->getError(), 'error');
            return;
        }
        $row->reportedondate = htmlspecialchars($row->reportedondate, ENT_QUOTES);
        //TBD: remove this: not urgent but isn't right
        $row->reportexplaination = htmlspecialchars($row->reportexplaination, ENT_QUOTES);
        //TBD: remove this: not urgent but isn't right
        $row->reportedondate = $_CB_framework->getUTCDate();
        if (!$row->check()) {
            cbRedirect($_CB_framework->viewUrl('reportuser', false), $row->getError(), 'error');
            return;
        }
        $_PLUGINS->trigger('onBeforeSaveReportUser', array(&$row, &$reportedByUser, &$reportedUser));
        if (!$row->store()) {
            cbRedirect($_CB_framework->viewUrl('reportuser', false), $row->getError(), 'error');
            return;
        }
        if ($ueConfig['moderatorEmail'] == 1) {
            $cbNotification = new cbNotification();
            $cbNotification->sendToModerators(CBTxt::T('UE_USERREPORT_SUB', 'User Report Pending Review'), CBTxt::T('UE_USERREPORT_MSG', 'A user has submitted a report regarding a user that requires your review. Please log in and take the appropriate action.'));
        }
        $_PLUGINS->trigger('onAfterSaveReportUser', array(&$row, &$reportedByUser, &$reportedUser));
        $_CB_framework->enqueueMessage(CBTxt::Th('UE_USERREPORT_SUCCESSFUL', 'User report submitted successfully.'));
    }
}