Пример #1
0
 public function __construct()
 {
     parent::__construct();
     $oCommentModel = new CommentModel();
     $sComment = $this->httpRequest->post('comment');
     $sCurrentTime = $this->dateTime->get()->dateTime('Y-m-d H:i:s');
     $iTimeDelay = (int) DbConfig::getSetting('timeDelaySendComment');
     $sTable = $this->httpRequest->get('table');
     $iRecipientId = $this->httpRequest->get('recipient', 'int');
     $iSenderId = (int) $this->session->get('member_id');
     if (!$oCommentModel->idExists($iRecipientId, $sTable)) {
         \PFBC\Form::setError('form_comment', t('The comment recipient does not exists.'));
     } elseif (!$oCommentModel->checkWaitSend($iSenderId, $iTimeDelay, $sCurrentTime, $sTable)) {
         \PFBC\Form::setError('form_comment', Form::waitWriteMsg($iTimeDelay));
     } elseif ($oCommentModel->isDuplicateContent($iSenderId, $sComment, $sTable)) {
         \PFBC\Form::setError('form_comment', Form::duplicateContentMsg());
     } else {
         if (!$oCommentModel->add($sComment, $iRecipientId, $iSenderId, 1, $sCurrentTime, $sTable)) {
             \PFBC\Form::setError('form_comment', t('Oops! Error when adding comment.'));
         } else {
             /* Clean All Data of CommentModel Cache */
             (new Framework\Cache\Cache())->start(CommentCoreModel::CACHE_GROUP, null, null)->clear();
             HeaderUrl::redirect(Uri::get('comment', 'comment', 'read', $sTable . ',' . $iRecipientId), t('The comment has been sent successfully!'));
         }
     }
     unset($oCommentModel);
 }
 public function __construct()
 {
     parent::__construct();
     $oCommentModel = new CommentModel();
     $sTable = $this->httpRequest->get('table');
     $iCommentId = $this->httpRequest->get('id', 'int');
     $iMemberId = (int) $this->session->get('member_id');
     $iRecipientId = $this->httpRequest->get('recipient', 'int');
     $iSenderId = $this->httpRequest->get('sender', 'int');
     if (!$oCommentModel->idExists($iRecipientId, $sTable)) {
         \PFBC\Form::setError('form_comment', t('The comment recipient does not exists.'));
     } else {
         if ($iMemberId == $iRecipientId || $iMemberId == $iSenderId) {
             if ($oCommentModel->update($iCommentId, $iRecipientId, $iSenderId, $this->httpRequest->post('comment'), 1, $this->dateTime->get()->dateTime('Y-m-d H:i:s'), $sTable)) {
                 /* Clean All Data of CommentModel Cache */
                 (new Framework\Cache\Cache())->start(CommentCoreModel::CACHE_GROUP, null, null)->clear();
                 Header::redirect(Uri::get('comment', 'comment', 'read', $sTable . ',' . $iRecipientId), t('The comment has been updated successfully!'));
             } else {
                 \PFBC\Form::setError('form_comment', t('Oops! Error when updated comment.'));
             }
         }
     }
     unset($oCommentModel);
 }