Ejemplo n.º 1
0
 /**
  * Save an entry
  *
  * @return    void
  */
 protected function _save()
 {
     // Ensure the user is logged in
     if (User::isGuest()) {
         return $this->_login();
     }
     // Check for request forgeries
     Request::checkToken();
     // Incoming
     $comment = Request::getVar('comment', array(), 'post', 'none', 2);
     // Instantiate a new comment object
     $row = new \Plugins\Hubzero\Comments\Models\Comment($comment['id']);
     // pass data to comment object
     if (!$row->bind($comment)) {
         App::redirect($this->url, $row->getError(), 'error');
         return;
     }
     $row->set('uploadDir', $this->params->get('comments_uploadpath', '/site/comments'));
     $row->set('created', Date::toSql());
     if ($row->exists() && !$this->params->get('access-edit-comment')) {
         App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($this->url)), Lang::txt('PLG_HUBZERO_COMMENTS_NOTAUTH'), 'warning');
         return;
     }
     // Store new content
     if (!$row->store(true)) {
         $key = 'failed_comment';
         $value = $row->content('raw');
         User::setState($key, $value);
         App::redirect($this->url, $row->getError(), 'error');
         return;
     }
     App::redirect($this->url, Lang::txt('PLG_HUBZERO_COMMENTS_SAVED'), 'message');
 }