/** * Display discussions started by the user. * * @since 2.0.0 * @access public * * @param int $Offset Number of discussions to skip. */ public function mine($Page = 'p1') { $this->permission('Garden.SignIn.Allow'); Gdn_Theme::section('DiscussionList'); // Set criteria & get discussions data list($Offset, $Limit) = offsetLimit($Page, c('Vanilla.Discussions.PerPage', 30)); $Session = Gdn::session(); $Wheres = array('d.InsertUserID' => $Session->UserID); $DiscussionModel = new DiscussionModel(); $DiscussionModel->setSort(Gdn::request()->get()); $DiscussionModel->setFilters(Gdn::request()->get()); $this->setData('Sort', $DiscussionModel->getSort()); $this->setData('Filters', $DiscussionModel->getFilters()); $this->DiscussionData = $DiscussionModel->get($Offset, $Limit, $Wheres); $this->setData('Discussions', $this->DiscussionData); $CountDiscussions = $this->setData('CountDiscussions', $DiscussionModel->getCount($Wheres)); $this->View = 'index'; if (c('Vanilla.Discussions.Layout') === 'table') { $this->View = 'table'; } // Build a pager $PagerFactory = new Gdn_PagerFactory(); $this->EventArguments['PagerType'] = 'MorePager'; $this->fireEvent('BeforeBuildMinePager'); $this->Pager = $PagerFactory->GetPager($this->EventArguments['PagerType'], $this); $this->Pager->MoreCode = 'More Discussions'; $this->Pager->LessCode = 'Newer Discussions'; $this->Pager->ClientID = 'Pager'; $this->Pager->configure($Offset, $Limit, $CountDiscussions, 'discussions/mine/%1$s'); $this->setData('_PagerUrl', 'discussions/mine/{Page}'); $this->setData('_Page', $Page); $this->setData('_Limit', $Limit); $this->fireEvent('AfterBuildMinePager'); // Deliver JSON data if necessary if ($this->_DeliveryType != DELIVERY_TYPE_ALL) { $this->setJson('LessRow', $this->Pager->toString('less')); $this->setJson('MoreRow', $this->Pager->toString('more')); $this->View = 'discussions'; } // Add modules $this->addModule('DiscussionFilterModule'); $this->addModule('NewDiscussionModule'); $this->addModule('CategoriesModule'); $this->addModule('BookmarkedModule'); // Render view $this->setData('Title', t('My Discussions')); $this->setData('Breadcrumbs', array(array('Name' => t('My Discussions'), 'Url' => '/discussions/mine'))); $this->render(); }
/** * Show all categories and few discussions from each. * * @param string $Category The url code of the parent category. * @since 2.0.0 * @access public */ public function discussions($Category = '') { // Setup head $this->addJsFile('discussions.js'); $this->Menu->highlightRoute('/discussions'); if (!$this->title()) { $Title = c('Garden.HomepageTitle'); if ($Title) { $this->title($Title, ''); } else { $this->title(t('All Categories')); } } if (!$Category) { $this->Description(c('Garden.Description', null)); } Gdn_Theme::section('CategoryDiscussionList'); // Set the category follow toggle before we load category data so that it affects the category query appropriately. $CategoryFollowToggleModule = new CategoryFollowToggleModule($this); $CategoryFollowToggleModule->SetToggle(); $this->CategoryModel->Watching = !Gdn::session()->GetPreference('ShowAllCategories'); if ($Category) { $Subtree = CategoryModel::GetSubtree($Category, false); $CategoryIDs = consolidateArrayValuesByKey($Subtree, 'CategoryID'); $Categories = $this->CategoryModel->GetFull($CategoryIDs)->resultArray(); } else { $Categories = $this->CategoryModel->GetFull()->resultArray(); } $this->setData('Categories', $Categories); // Get category data and discussions $this->DiscussionsPerCategory = c('Vanilla.Discussions.PerCategory', 5); $DiscussionModel = new DiscussionModel(); $DiscussionModel->setSort(Gdn::request()->get()); $DiscussionModel->setFilters(Gdn::request()->get()); $this->setData('Sort', $DiscussionModel->getSort()); $this->setData('Filters', $DiscussionModel->getFilters()); $this->CategoryDiscussionData = array(); foreach ($this->CategoryData->result() as $Category) { if ($Category->CategoryID > 0) { $this->CategoryDiscussionData[$Category->CategoryID] = $DiscussionModel->get(0, $this->DiscussionsPerCategory, array('d.CategoryID' => $Category->CategoryID, 'Announce' => 'all')); } } // Add modules $this->addModule('NewDiscussionModule'); $this->addModule('DiscussionFilterModule'); $this->addModule('CategoriesModule'); $this->addModule('BookmarkedModule'); $this->addModule($CategoryFollowToggleModule); // Set view and render $this->View = 'discussions'; $this->canonicalUrl(url('/categories', true)); $Path = $this->fetchViewLocation('helper_functions', 'discussions', false, false); if ($Path) { include_once $Path; } // For GetOptions function $Path2 = $this->fetchViewLocation('helper_functions', 'categories', false, false); if ($Path2) { include_once $Path2; } $this->render(); }