/** * Generate and return various links to the entry * Link will vary depending upon action desired, such as edit, delete, etc. * * @param string $type The type of link to return * @return string */ public function link($type = '') { $link = $this->_base; if (!$this->get('section')) { $article = Article::oneOrFail($this->get('entry_id')); $this->set('category', $article->category()->get('alias')); $this->set('article', $article->get('alias')); } $link .= '§ion=' . $this->get('section'); $link .= '&alias=' . $this->get('article'); // If it doesn't exist or isn't published switch (strtolower($type)) { case 'component': case 'base': return $this->_base; break; case 'article': // Return as is break; case 'edit': $link .= '&action=edit&comment=' . $this->get('id'); break; case 'delete': $link .= '&action=delete&comment=' . $this->get('id'); break; case 'reply': $link .= '&reply=' . $this->get('id') . '#c' . $this->get('id'); break; case 'vote': $link = $this->_base . '&task=vote&category=comment&id=' . $this->get('id'); break; case 'report': $link = 'index.php?option=com_support&task=reportabuse&category=kb&id=' . $this->get('id') . '&parent=' . $this->get('entry_id'); break; case 'permalink': default: $link .= '#c' . $this->get('id'); break; } return $link; }
/** * Reset the vote count on an entry * * @return void */ public function resetvotesTask() { // Incoming $cid = Request::getInt('cid', 0); $id = Request::getInt('id', 0); // Make sure we have an ID to work with if (!$id) { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_KB_NO_ID'), 'error'); } // Load and reset the article's ratings $article = Article::oneOrFail($id); $article->set('helpful', 0); $article->set('nothelpful', 0); if (!$article->save()) { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), $article->getError(), 'error'); return; } // Delete all the entries associated with this article foreach ($article->votes() as $vote) { $vote->destroy(); } // Set the redirect App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false)); }
/** * Displays an RSS feed of comments for a given article * * @return void */ public function commentsTask() { if (!$this->config->get('feeds_enabled')) { throw new Exception(Lang::txt('COM_KB_ERROR_ARTICLE_NOT_FOUND'), 404); } // Incoming $alias = Request::getVar('alias', ''); $id = Request::getInt('id', 0); // Load the article $category = Category::oneByAlias(Request::getVar('category')); $article = $alias ? Article::oneByAlias($alias) : Article::oneOrFail($id); if (!$article->get('id')) { throw new Exception(Lang::txt('COM_KB_ERROR_ARTICLE_NOT_FOUND'), 404); } // Set the mime encoding for the document Document::setType('feed'); // Start a new feed object Document::setLink(Route::url($article->link())); // Build some basic RSS document information $title = Config::get('sitename') . ' - ' . Lang::txt(strtoupper($this->_option)); $title .= $article->get('title') ? ': ' . stripslashes($article->get('title')) : ''; $title .= ': ' . Lang::txt('COM_KB_COMMENTS'); Document::setTitle($title); Document::instance()->description = Lang::txt('COM_KB_COMMENTS_RSS_DESCRIPTION', Config::get('sitename'), stripslashes($article->get('title'))); Document::instance()->copyright = Lang::txt('COM_KB_COMMENTS_RSS_COPYRIGHT', gmdate("Y"), Config::get('sitename')); // Start outputing results if any found $this->_feedItem($article->comments('list')); }
/** * Reset the vote count on an entry * * @return void */ public function resetvotesTask() { if (!User::authorise('core.edit', $this->_option) && !User::authorise('core.edit.state', $this->_option)) { App::abort(403, Lang::txt('JERROR_ALERTNOAUTHOR')); } // Incoming $cid = Request::getInt('cid', 0); $id = Request::getInt('id', 0); // Make sure we have an ID to work with if (!$id) { Notify::warning(Lang::txt('COM_KB_NO_ID')); return $this->cancelTask(); } // Load and reset the article's ratings $article = Article::oneOrFail($id); $article->set('helpful', 0); $article->set('nothelpful', 0); if (!$article->save()) { Notify::error($article->getError()); return $this->cancelTask(); } // Delete all the entries associated with this article foreach ($article->votes()->rows() as $vote) { $vote->destroy(); } // Set the redirect $this->cancelTask(); }