Esempio n. 1
0
 public function request()
 {
     if (is_null($this->getRequestVar('commentid'))) {
         $this->redirect('comments/list');
     }
     $this->comment = new \fpcm\model\comments\comment($this->getRequestVar('commentid'));
     if (!$this->comment->exists()) {
         $this->view->setNotFound('LOAD_FAILED_COMMENT', 'comments/list');
         return true;
     }
     if (!$this->comment->getEditPermission()) {
         $this->view = new \fpcm\model\view\error();
         $this->view->addErrorMessage('PERMISSIONS_REQUIRED');
         $this->view->render();
         return false;
     }
     if ($this->buttonClicked('commentSave') && $this->getRequestVar('comment')) {
         $commentData = $this->getRequestVar('comment', array(4, 7));
         $this->comment->setText($commentData['text']);
         unset($commentData['text']);
         foreach ($commentData as &$value) {
             $value = \fpcm\classes\http::filter($value, array(1, 3));
         }
         $this->comment->setName($commentData['name']);
         $this->comment->setEmail($commentData['email']);
         $this->comment->setWebsite($commentData['website']);
         if ($this->approve) {
             $this->comment->setApproved(isset($commentData['approved']) ? true : false);
             $this->comment->setSpammer(isset($commentData['spam']) ? true : false);
         }
         if ($this->private) {
             $this->comment->setPrivate(isset($commentData['private']) ? true : false);
         }
         $this->comment->setChangetime(time());
         $this->comment->setChangeuser($this->session->getUserId());
         if ($this->comment->update()) {
             $this->view->addNoticeMessage('SAVE_SUCCESS_COMMENT');
         } else {
             $this->view->addErrorMessage('SAVE_FAILED_COMMENT');
         }
     }
     return true;
 }