/** * Remove a thread * * @return void */ public function deletethread() { $section = Request::getVar('section', ''); $category = Request::getVar('category', ''); // Is the user logged in? if (User::isGuest()) { App::redirect(Route::url($this->base . '&scope=' . $section . '/' . $category), Lang::txt('PLG_GROUPS_FORUM_LOGIN_NOTICE'), 'warning'); return; } // Incoming $id = Request::getInt('thread', 0); $this->markForDelete($id); // Initiate a forum object $model = new \Components\Forum\Tables\Post($this->database); $model->load($id); // Make the sure the category exist if (!$model->id) { App::redirect(Route::url($this->base . '&scope=' . $section . '/' . $category), Lang::txt('PLG_GROUPS_FORUM_MISSING_ID'), 'error'); return; } // Check if user is authorized to delete entries $this->_authorize('thread', $id); if (!$this->params->get('access-delete-thread')) { App::redirect(Route::url($this->base . '&scope=' . $section . '/' . $category), Lang::txt('PLG_GROUPS_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($this->base . '&scope=' . $section . '/' . $category), $forum->getError(), 'error'); return; } // Redirect to main listing App::redirect(Route::url($this->base . '&scope=' . $section . '/' . $category), Lang::txt('PLG_GROUPS_FORUM_THREAD_DELETED'), 'passed'); }
/** * Retrieves a row from the database * * @param string $refid ID of the database table row * @param string $parent If the element has a parent element * @param string $category Element type (determines table to look in) * @param string $message If the element has a parent element * @return array */ public function deleteReportedItem($refid, $parent, $category, $message) { if ($category != 'forum') { return null; } require_once PATH_CORE . DS . 'components' . DS . 'com_forum' . DS . 'tables' . DS . 'post.php'; $database = App::get('db'); $comment = new \Components\Forum\Tables\Post($database); $comment->load($refid); $comment->state = 2; $comment->store(); return ''; }