/** * Save a comment * * @return string */ public function savecommentTask() { // Check for request forgeries Request::checkToken(); // Ensure the user is logged in if (User::isGuest()) { return $this->loginTask(); } // Incoming $comment = Request::getVar('comment', array(), 'post', 'none', 2); // Instantiate a new comment object and pass it the data $row = new Comment($this->database); if (!$row->bind($comment)) { $this->setError($row->getError()); return $this->displayTask(); } // Check content if (!$row->check()) { $this->setError($row->getError()); return $this->displayTask(); } // Store new content if (!$row->store()) { $this->setError($row->getError()); return $this->displayTask(); } $this->displayTask(); }
/** * 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($this->database); if (!$row->bind($fields)) { $this->setMessage($row->getError(), 'error'); $this->editTask($row); return; } $row->anonymous = isset($fields['anonymous']) && $fields['anonymous'] ? 1 : 0; // Check content if (!$row->check()) { $this->setError($row->getError()); $this->editTask($row); return; } // Store new content if (!$row->store()) { $this->setError($row->getError()); $this->editTask($row); return; } Notify::success(Lang::txt('COM_WISHLIST_COMMENT_SAVED')); if ($this->getTask() == 'apply') { return $this->editTask($row); } // Redirect App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&wish=' . $row->item_id, false)); }