コード例 #1
0
ファイル: comments.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Save a comment
  *
  * @return  void
  */
 public function saveTask()
 {
     // Check for request forgeries
     Request::checkToken();
     $fields = Request::getVar('comment', array(), 'post');
     // Bind the form data to our object
     $comment = new Comment($fields['id']);
     if (!$comment->bind($fields)) {
         $this->setError($comment->getError());
         $this->displayTask();
         return;
     }
     // Parse the wikitext and set some values
     $comment->set('chtml', NULL);
     $comment->set('chtml', $comment->content('parsed'));
     $comment->set('anonymous', $comment->get('anonymous') ? 1 : 0);
     $comment->set('created', $comment->get('created') ? $comment->get('created') : Date::toSql());
     // Save the data
     if (!$comment->store(true)) {
         $this->setError($comment->getError());
         $this->displayTask();
         return;
     }
     // Did they rate the page?
     // If so, update the page with the new average rating
     if ($comment->get('rating')) {
         $this->page->calculateRating();
         if (!$this->page->store()) {
             $this->setError($this->page->getError());
         }
     }
     // Redirect to Comments page
     App::redirect(Route::url($this->page->link('comments')));
 }
コード例 #2
0
ファイル: comments.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Save an entry
  *
  * @return  void
  */
 public function saveTask()
 {
     // Check for request forgeries
     Request::checkToken();
     // Incoming
     $fields = Request::getVar('fields', array(), 'post', 'none', 2);
     $fields = array_map('trim', $fields);
     // Initiate extended database class
     $row = new Comment($fields['id']);
     if (!$row->bind($fields)) {
         $this->setError($row->getError());
         $this->editTask($row);
         return;
     }
     // Store new content
     if (!$row->store(true)) {
         $this->setError($row->getError());
         $this->editTask($row);
         return;
     }
     if ($this->getTask() == 'apply') {
         return $this->editTask($row);
     }
     // Set the redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&pageid=' . $fields['pageid'], false), Lang::txt('COM_WIKI_COMMENT_SAVED'));
 }