public function GetData($Limit = 10) { $Session = Gdn::Session(); if ($Session->IsValid()) { $DiscussionModel = new Gdn_DiscussionModel(); $this->_DiscussionData = $DiscussionModel->Get(0, $Limit, array('w.Bookmarked' => '1', 'w.UserID' => $Session->UserID)); } }
public function ProfileController_Discussions_Create(&$Sender) { $UserReference = ArrayValue(0, $Sender->EventArguments, ''); $Offset = ArrayValue(1, $Sender->EventArguments, 0); // Tell the ProfileController what tab to load $Sender->SetTabView($UserReference, 'Discussions', 'Profile', 'Discussions', 'Vanilla'); // Load the data for the requested tab. if (!is_numeric($Offset) || $Offset < 0) { $Offset = 0; } $Limit = Gdn::Config('Vanilla.Discussions.PerPage', 30); $DiscussionModel = new Gdn_DiscussionModel(); $Sender->DiscussionData = $DiscussionModel->Get($Offset, $Limit, array('d.InsertUserID' => $Sender->User->UserID)); $CountDiscussions = $Offset + $Sender->DiscussionData->NumRows(); if ($Sender->DiscussionData->NumRows() == $Limit) { $CountDiscussions = $Offset + $Limit + 1; } // Build a pager $PagerFactory = new PagerFactory(); $Sender->Pager = $PagerFactory->GetPager('MorePager', $Sender); $Sender->Pager->MoreCode = 'More Discussions'; $Sender->Pager->LessCode = 'Newer Discussions'; $Sender->Pager->ClientID = 'Pager'; $Sender->Pager->Configure($Offset, $Limit, $CountDiscussions, 'profile/discussions/' . urlencode($Sender->User->Name) . '/%1$s/'); // Deliver json data if necessary if ($Sender->DeliveryType() != DELIVERY_TYPE_ALL && $Offset > 0) { $Sender->SetJson('LessRow', $Sender->Pager->ToString('less')); $Sender->SetJson('MoreRow', $Sender->Pager->ToString('more')); $Sender->View = 'discussions'; } // Set the handlertype back to normal on the profilecontroller so that it fetches it's own views $Sender->HandlerType = HANDLER_TYPE_NORMAL; // Do not show discussion options $Sender->ShowOptions = FALSE; // Render the ProfileController $Sender->Render(); }
/** * Show all categories, and few discussions from each. */ public function All() { $this->AddCssFile('vanilla.css'); $this->Menu->HighlightRoute('/discussions'); if ($this->Head) { $this->Head->AddScript('/applications/vanilla/js/discussions.js'); $this->Head->AddScript('/applications/vanilla/js/options.js'); $this->Head->Title(Translate('All Categories')); } $this->DiscussionsPerCategory = Gdn::Config('Vanilla.Discussions.PerCategory', 5); $DiscussionModel = new Gdn_DiscussionModel(); $this->CategoryData = $this->CategoryModel->GetFull(); $this->CategoryDiscussionData = array(); foreach ($this->CategoryData->Result() as $Category) { $this->CategoryDiscussionData[$Category->CategoryID] = $DiscussionModel->Get(0, $this->DiscussionsPerCategory, array('d.CategoryID' => $Category->CategoryID)); } // Add Modules $this->AddModule('NewDiscussionModule'); $this->AddModule('CategoriesModule'); $BookmarkedModule = new BookmarkedModule($this); $BookmarkedModule->GetData(); $this->AddModule($BookmarkedModule); $DraftsModule = new DraftsModule($this); $DraftsModule->GetData(); $this->AddModule($DraftsModule); $this->View = 'all'; $this->Render(); }
public function Mine($Offset = '0') { $this->Permission('Garden.SignIn.Allow'); $this->AddJsFile('/js/library/jquery.resizable.js'); $this->AddJsFile('/js/library/jquery.ui.packed.js'); $this->AddJsFile('bookmark.js'); $this->AddJsFile('discussions.js'); $this->AddJsFile('options.js'); $this->Title(Translate('My Discussions')); if (!is_numeric($Offset) || $Offset < 0) { $Offset = 0; } $Limit = Gdn::Config('Vanilla.Discussions.PerPage', 30); $Session = Gdn::Session(); $Wheres = array('d.InsertUserID' => $Session->UserID); $DiscussionModel = new Gdn_DiscussionModel(); $this->SetData('DiscussionData', $DiscussionModel->Get($Offset, $Limit, $Wheres), TRUE); $CountDiscussions = $this->SetData('CountDiscussions', $DiscussionModel->GetCount($Wheres)); // Build a pager $PagerFactory = new PagerFactory(); $this->Pager = $PagerFactory->GetPager('MorePager', $this); $this->Pager->MoreCode = 'More Discussions'; $this->Pager->LessCode = 'Newer Discussions'; $this->Pager->Wrapper = '<li %1$s>%2$s</li>'; $this->Pager->ClientID = 'Pager'; $this->Pager->Configure($Offset, $Limit, $CountDiscussions, 'discussions/mine/%1$s'); // 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('NewDiscussionModule'); $this->AddModule('CategoriesModule'); $BookmarkedModule = new BookmarkedModule($this); $BookmarkedModule->GetData(); $this->AddModule($BookmarkedModule); // Render the controller $this->Render(); }