/** * Delete an entry * * @return void */ public function deleteTask() { $section = Request::getVar('section', ''); $category = Request::getVar('category', ''); // Is the user logged in? if (User::isGuest()) { App::redirect(Route::url('index.php?option=' . $this->_option . '§ion=' . $section . '&category=' . $category), Lang::txt('COM_FORUM_LOGIN_NOTICE'), 'warning'); return; } // Incoming $id = Request::getInt('thread', 0); // Load the post $model = new Tables\Post($this->database); $model->load($id); // Make the sure the category exist if (!$model->id) { App::redirect(Route::url('index.php?option=' . $this->_option . '§ion=' . $section . '&category=' . $category), Lang::txt('COM_FORUM_MISSING_ID'), 'error'); return; } // Check if user is authorized to delete entries $this->_authorize('thread', $id); if (!$this->config->get('access-delete-thread')) { App::redirect(Route::url('index.php?option=' . $this->_option . '§ion=' . $section . '&category=' . $category), Lang::txt('COM_FORUM_NOT_AUTHORIZED'), 'warning'); return; } // Update replies if this is a parent (thread starter) if (!$model->parent) { if (!$model->updateReplies(array('state' => 2), $model->id)) { $this->setError($model->getError()); } } // Delete the topic itself $model->state = 2; /* 0 = unpublished, 1 = published, 2 = deleted */ if (!$model->store()) { App::redirect(Route::url('index.php?option=' . $this->_option . '§ion=' . $section . '&category=' . $category), $model->getError(), 'error'); return; } // Delete the attachment associated with the post $this->markForDelete($id); // Redirect to main listing App::redirect(Route::url('index.php?option=' . $this->_option . '§ion=' . $section . '&category=' . $category), Lang::txt('COM_FORUM_THREAD_DELETED'), 'message'); }
/** * Sets the state of one or more entries * * @return void */ public function accessTask() { // Check for request forgeries Request::checkToken(['get', 'post']); // Incoming $category = Request::getInt('category_id', 0); $state = Request::getInt('access', 0); $ids = Request::getVar('id', array()); $ids = !is_array($ids) ? array($ids) : $ids; // Check for an ID if (count($ids) < 1) { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&category_id=' . $category, false), Lang::txt('COM_FORUM_SELECT_ENTRY_TO_CHANGE_ACCESS'), 'error'); return; } foreach ($ids as $id) { // Update record(s) $row = new Post($this->database); $row->load(intval($id)); $row->access = $state; if (!$row->store()) { throw new Exception($row->getError(), 500); } } // set message App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&category_id=' . $category, false), Lang::txt('COM_FORUM_ITEMS_ACCESS_CHANGED', count($ids))); }