예제 #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.'));
    }
}
예제 #2
0
 /**
  * Deletes this record (no checks)
  *
  * @param  int   $oid         Key id of row to delete (otherwise it's the one of $this)
  * @param  bool  $cbUserOnly  True: delete CB user only, False: delete CB and CMS user
  * @return boolean
  */
 public function delete($oid = null, $cbUserOnly = false)
 {
     global $_CB_framework, $_PLUGINS;
     $k = $this->_tbl_key;
     if ($oid) {
         $this->{$k} = (int) $oid;
     }
     $_PLUGINS->loadPluginGroup('user');
     $_PLUGINS->trigger('onBeforeDeleteUser', array($this));
     if ($_PLUGINS->is_errors()) {
         $this->setError($_PLUGINS->getErrorMSG());
         return false;
     } else {
         deleteAvatar($this->avatar);
         $reports = new UserReportTable();
         $reports->deleteUserReports($this->id);
         $views = new UserViewTable();
         $views->deleteUserViews($this->id);
         if (!$cbUserOnly) {
             $cmsUser = $_CB_framework->_getCmsUserObject($this->id);
             try {
                 $cmsUser->delete($this->id);
             } catch (\RuntimeException $e) {
                 $this->setError($e->getMessage());
                 return false;
             }
         }
         if (!parent::delete($oid)) {
             return false;
         }
         $query = 'DELETE' . "\n FROM " . $this->_db->NameQuote('#__session') . "\n WHERE " . $this->_db->NameQuote('userid') . " = " . (int) $this->id;
         $this->_db->setQuery($query);
         $this->_db->query();
         $_PLUGINS->trigger('onAfterDeleteUser', array($this, true));
     }
     return true;
 }