/** * Mark an answer as accepted * * @return void */ public function acceptTask() { // Login required if (User::isGuest()) { $this->setError(Lang::txt('COM_ANSWERS_PLEASE_LOGIN')); $this->loginTask(); return; } // Incoming $id = Request::getInt('id', 0); $rid = Request::getInt('rid', 0); $question = new Question($id); // verify the orignial poster is the only one accepting the answer if ($question->get('created_by') != User::get('id')) { App::redirect(Route::url($question->link()), Lang::txt('COM_ANSWERS_ERROR_MUST_BE_ASKER'), 'error'); } // Check changes if (!$question->accept($rid)) { $this->setError($question->getError()); } // Call the plugin if (!Event::trigger('xmessage.onTakeAction', array('answers_reply_submitted', array(User::get('id')), $this->_option, $rid))) { $this->setError(Lang::txt('COM_ANSWERS_ACTION_FAILED')); } // Redirect to the question App::redirect(Route::url($question->link() . '¬e=10'), Lang::txt('COM_ANSWERS_NOTICE_QUESTION_CLOSED'), 'success'); }