/** * @param DiscussionsController $Sender * @param array $Args */ public function DiscussionsController_UnansweredCount_Create($Sender, $Args = array()) { $Count = $this->GetUnansweredCount(); $Sender->SetData('UnansweredCount', $Count); $Sender->SetData('_Value', $Count); $Sender->Render('Value', 'Utility', 'Dashboard'); }
/** * @param DiscussionsController $Sender * @param array $Args */ public function DiscussionsController_UnansweredCount_Create($Sender, $Args = array()) { Gdn::SQL()->WhereIn('QnA', array('Unanswered', 'Rejected')); $Count = Gdn::SQL()->GetCount('Discussion', array('Type' => 'Question')); Gdn::Cache()->Store('QnA-UnansweredCount', $Count, array(Gdn_Cache::FEATURE_EXPIRY => 15 * 60)); $Sender->SetData('UnansweredCount', $Count); $Sender->SetData('_Value', $Count); $Sender->Render('Value', 'Utility', 'Dashboard'); }
/** * Load discussions for a specific tag. * @param DiscussionsController $Sender */ public function DiscussionsController_Tagged_Create($Sender) { Gdn_Theme::Section('DiscussionList'); $Args = $Sender->RequestArgs; $Get = array_change_key_case($Sender->Request->Get()); if ($UseCategories = C('Plugins.Tagging.UseCategories')) { // The url is in the form /category/tag/p1 $CategoryCode = GetValue(0, $Args); $Tag = GetValue(1, $Args); $Page = GetValue(2, $Args); } else { // The url is in the form /tag/p1 $CategoryCode = ''; $Tag = GetValue(0, $Args); $Page = GetValue(1, $Args); } // Look for explcit values. $CategoryCode = GetValue('category', $Get, $CategoryCode); $Tag = GetValue('tag', $Get, $Tag); $Page = GetValue('page', $Get, $Page); $Category = CategoryModel::Categories($CategoryCode); $Tag = StringEndsWith($Tag, '.rss', TRUE, TRUE); list($Offset, $Limit) = OffsetLimit($Page, C('Vanilla.Discussions.PerPage', 30)); $MultipleTags = strpos($Tag, ',') !== FALSE; $Sender->SetData('Tag', $Tag, TRUE); $TagModel = TagModel::instance(); $RecordCount = FALSE; if (!$MultipleTags) { $Tags = $TagModel->GetWhere(array('Name' => $Tag))->ResultArray(); if (count($Tags) == 0) { throw NotFoundException('Page'); } if (count($Tags) > 1) { foreach ($Tags as $TagRow) { if ($TagRow['CategoryID'] == GetValue('CategoryID', $Category)) { break; } } } else { $TagRow = array_pop($Tags); } $Tags = $TagModel->getRelatedTags($TagRow); $RecordCount = $TagRow['CountDiscussions']; $Sender->SetData('CountDiscussions', $RecordCount); $Sender->SetData('Tags', $Tags); $Sender->SetData('Tag', $TagRow); $ChildTags = $TagModel->getChildTags($TagRow['TagID']); $Sender->SetData('ChildTags', $ChildTags); } $Sender->Title(htmlspecialchars($TagRow['FullName'])); $UrlTag = rawurlencode($Tag); if (urlencode($Tag) == $Tag) { $Sender->CanonicalUrl(Url(ConcatSep('/', "/discussions/tagged/{$UrlTag}", PageNumber($Offset, $Limit, TRUE)), TRUE)); $FeedUrl = Url(ConcatSep('/', "/discussions/tagged/{$UrlTag}/feed.rss", PageNumber($Offset, $Limit, TRUE, FALSE)), '//'); } else { $Sender->CanonicalUrl(Url(ConcatSep('/', 'discussions/tagged', PageNumber($Offset, $Limit, TRUE)) . '?Tag=' . $UrlTag, TRUE)); $FeedUrl = Url(ConcatSep('/', 'discussions/tagged', PageNumber($Offset, $Limit, TRUE, FALSE), 'feed.rss') . '?Tag=' . $UrlTag, '//'); } if ($Sender->Head) { $Sender->AddJsFile('discussions.js'); $Sender->Head->AddRss($FeedUrl, $Sender->Head->Title()); } if (!is_numeric($Offset) || $Offset < 0) { $Offset = 0; } // Add Modules $Sender->AddModule('NewDiscussionModule'); $Sender->AddModule('DiscussionFilterModule'); $Sender->AddModule('BookmarkedModule'); $Sender->SetData('Category', FALSE, TRUE); $Sender->AnnounceData = FALSE; $Sender->SetData('Announcements', array(), TRUE); $DiscussionModel = new DiscussionModel(); $TagModel->SetTagSql($DiscussionModel->SQL, $Tag, $Limit, $Offset, $Sender->Request->Get('op', 'or')); $Sender->DiscussionData = $DiscussionModel->Get($Offset, $Limit, array('Announce' => 'all')); $Sender->SetData('Discussions', $Sender->DiscussionData, TRUE); $Sender->SetJson('Loading', $Offset . ' to ' . $Limit); // Build a pager. $PagerFactory = new Gdn_PagerFactory(); $Sender->Pager = $PagerFactory->GetPager('Pager', $Sender); $Sender->Pager->ClientID = 'Pager'; $Sender->Pager->Configure($Offset, $Limit, $RecordCount, ''); $Sender->View = C('Vanilla.Discussions.Layout'); /* // If these don't equal, then there is a category that should be inserted. if ($UseCategories && $Category && $TagRow['FullName'] != GetValue('Name', $Category)) { $Sender->Data['Breadcrumbs'][] = array('Name' => $Category['Name'], 'Url' => TagUrl($TagRow)); } $Sender->Data['Breadcrumbs'][] = array('Name' => $TagRow['FullName'], 'Url' => ''); */ // Render the controller. $this->View = C('Vanilla.Discussions.Layout') == 'table' ? 'table' : 'index'; $Sender->Render($this->View, 'discussions', 'vanilla'); }
/** * Displays the amounts of unanswered questions. * * @param DiscussionsController $sender Sending controller instance. * @param array $args Event arguments. */ public function discussionsController_unansweredCount_create($sender, $args) { $Count = $this->getUnansweredCount(); $sender->setData('UnansweredCount', $Count); $sender->setData('_Value', $Count); $sender->render('Value', 'Utility', 'Dashboard'); }
<?php /** * @package Codingfish Discussions * @subpackage com_discussions * @copyright Copyright (C) 2010 Codingfish (Achim Fischer). All rights reserved. * @license GNU General Public License <http://www.gnu.org/copyleft/gpl.html> * @link http://www.codingfish.com */ // no direct access defined('_JEXEC') or die('Restricted access'); /* * Make sure the user is authorized to view this page */ $user =& JFactory::getUser(); //if (!$user->authorize( 'com_discussions', 'manage' )) { // $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); //} require_once JPATH_COMPONENT . DS . 'controller.php'; $controller = new DiscussionsController(); $controller->execute(JRequest::getCmd('task')); $controller->redirect();
/** * Allows user to mark all discussions as viewed. * * @since 1.0 * @access public * * @param DiscussionsController $sender */ public function discussionsController_markAllViewed_create($sender) { if (Gdn::request()->isAuthenticatedPostBack()) { $CategoryModel = new CategoryModel(); $this->markCategoryRead($CategoryModel, -1); $this->recursiveMarkCategoryRead($CategoryModel, CategoryModel::categories(), [-1]); $sender->informMessage(t('All discussions marked as viewed.')); // Didn't use the default async option and landed here directly. if ($sender->deliveryType() == DELIVERY_TYPE_ALL) { redirect('/'); } $sender->render('blank', 'utility', 'dashboard'); } else { throw new Exception('Requires POST', 405); } }
/** * Load discussions for a specific tag. * * @param DiscussionsController $Sender Sending controller instance * @param array $Args Event's arguments * @throws Exception */ public function discussionsController_tagged_create($Sender, $Args) { Gdn_Theme::section('DiscussionList'); $Args = $Sender->RequestArgs; $Get = array_change_key_case($Sender->Request->get()); if ($UseCategories = c('Plugins.Tagging.UseCategories')) { // The url is in the form /category/tag/p1 $CategoryCode = val(0, $Args); $Tag = val(1, $Args); $Page = val(2, $Args); } else { // The url is in the form /tag/p1 $CategoryCode = ''; $Tag = val(0, $Args); $Page = val(1, $Args); } // Look for explcit values. $CategoryCode = val('category', $Get, $CategoryCode); $Tag = val('tag', $Get, $Tag); $Page = val('page', $Get, $Page); $Category = CategoryModel::categories($CategoryCode); $Tag = stringEndsWith($Tag, '.rss', true, true); list($Offset, $Limit) = offsetLimit($Page, c('Vanilla.Discussions.PerPage', 30)); $MultipleTags = strpos($Tag, ',') !== false; $Sender->setData('Tag', $Tag, true); $TagModel = TagModel::instance(); $RecordCount = false; if (!$MultipleTags) { $Tags = $TagModel->getWhere(array('Name' => $Tag))->resultArray(); if (count($Tags) == 0) { throw notFoundException('Page'); } if (count($Tags) > 1) { foreach ($Tags as $TagRow) { if ($TagRow['CategoryID'] == val('CategoryID', $Category)) { break; } } } else { $TagRow = array_pop($Tags); } $Tags = $TagModel->getRelatedTags($TagRow); $RecordCount = $TagRow['CountDiscussions']; $Sender->setData('CountDiscussions', $RecordCount); $Sender->setData('Tags', $Tags); $Sender->setData('Tag', $TagRow); $ChildTags = $TagModel->getChildTags($TagRow['TagID']); $Sender->setData('ChildTags', $ChildTags); } $Sender->title(htmlspecialchars($TagRow['FullName'])); $UrlTag = empty($CategoryCode) ? rawurlencode($Tag) : rawurlencode($CategoryCode) . '/' . rawurlencode($Tag); if (urlencode($Tag) == $Tag) { $Sender->canonicalUrl(url(ConcatSep('/', "/discussions/tagged/{$UrlTag}", PageNumber($Offset, $Limit, true)), true)); $FeedUrl = url(ConcatSep('/', "/discussions/tagged/{$UrlTag}/feed.rss", PageNumber($Offset, $Limit, true, false)), '//'); } else { $Sender->canonicalUrl(url(ConcatSep('/', 'discussions/tagged', PageNumber($Offset, $Limit, true)) . '?Tag=' . $UrlTag, true)); $FeedUrl = url(ConcatSep('/', 'discussions/tagged', PageNumber($Offset, $Limit, true, false), 'feed.rss') . '?Tag=' . $UrlTag, '//'); } if ($Sender->Head) { $Sender->addJsFile('discussions.js'); $Sender->Head->addRss($FeedUrl, $Sender->Head->title()); } if (!is_numeric($Offset) || $Offset < 0) { $Offset = 0; } // Add Modules $Sender->addModule('NewDiscussionModule'); $Sender->addModule('DiscussionFilterModule'); $Sender->addModule('BookmarkedModule'); $Sender->setData('Category', false, true); $Sender->AnnounceData = false; $Sender->setData('Announcements', array(), true); $DiscussionModel = new DiscussionModel(); $TagModel->setTagSql($DiscussionModel->SQL, $Tag, $Limit, $Offset, $Sender->Request->get('op', 'or')); $Sender->DiscussionData = $DiscussionModel->get($Offset, $Limit, array('Announce' => 'all')); $Sender->setData('Discussions', $Sender->DiscussionData, true); $Sender->setJson('Loading', $Offset . ' to ' . $Limit); // Build a pager. $PagerFactory = new Gdn_PagerFactory(); $Sender->EventArguments['PagerType'] = 'Pager'; $Sender->fireEvent('BeforeBuildPager'); if (!$Sender->data('_PagerUrl')) { $Sender->setData('_PagerUrl', "/discussions/tagged/{$UrlTag}/{Page}"); } $Sender->Pager = $PagerFactory->GetPager($Sender->EventArguments['PagerType'], $Sender); $Sender->Pager->ClientID = 'Pager'; $Sender->Pager->configure($Offset, $Limit, $RecordCount, $Sender->data('_PagerUrl')); $Sender->setData('_Page', $Page); $Sender->setData('_Limit', $Limit); $Sender->fireEvent('AfterBuildPager'); $Sender->View = c('Vanilla.Discussions.Layout'); // Render the controller. $this->View = c('Vanilla.Discussions.Layout') == 'table' && $Sender->SyndicationMethod == SYNDICATION_NONE ? 'table' : 'index'; $Sender->render($this->View, 'discussions', 'vanilla'); }