public function bookmarked($Page = '0')
{
$this->permission('Garden.SignIn.Allow');
Gdn_Theme::section('DiscussionList');
// Figure out which discussions layout to choose (Defined on "Homepage" settings page).
$Layout = c('Vanilla.Discussions.Layout');
switch ($Layout) {
case 'table':
if ($this->SyndicationMethod == SYNDICATION_NONE) {
$this->View = 'table';
}
break;
default:
$this->View = 'index';
break;
}
// Determine offset from $Page
list($Page, $Limit) = offsetLimit($Page, c('Vanilla.Discussions.PerPage', 30));
$this->canonicalUrl(url(ConcatSep('/', 'discussions', 'bookmarked', PageNumber($Page, $Limit, true, false)), true));
// Validate $Page
if (!is_numeric($Page) || $Page < 0) {
$Page = 0;
}
$DiscussionModel = new DiscussionModel();
$DiscussionModel->setSort(Gdn::request()->get());
$DiscussionModel->setFilters(Gdn::request()->get());
$this->setData('Sort', $DiscussionModel->getSort());
$this->setData('Filters', $DiscussionModel->getFilters());
$Wheres = array('w.Bookmarked' => '1', 'w.UserID' => Gdn::session()->UserID);
$this->DiscussionData = $DiscussionModel->get($Page, $Limit, $Wheres);
$this->setData('Discussions', $this->DiscussionData);
$CountDiscussions = $DiscussionModel->getCount($Wheres);
$this->setData('CountDiscussions', $CountDiscussions);
$this->Category = false;
$this->setJson('Loading', $Page . ' to ' . $Limit);
// Build a pager
$PagerFactory = new Gdn_PagerFactory();
$this->EventArguments['PagerType'] = 'Pager';
$this->fireEvent('BeforeBuildBookmarkedPager');
$this->Pager = $PagerFactory->GetPager($this->EventArguments['PagerType'], $this);
$this->Pager->ClientID = 'Pager';
$this->Pager->configure($Page, $Limit, $CountDiscussions, 'discussions/bookmarked/%1$s');
if (!$this->data('_PagerUrl')) {
$this->setData('_PagerUrl', 'discussions/bookmarked/{Page}');
}
$this->setData('_Page', $Page);
$this->setData('_Limit', $Limit);
$this->fireEvent('AfterBuildBookmarkedPager');
// 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');
// Render default view (discussions/bookmarked.php)
$this->setData('Title', t('My Bookmarks'));
$this->setData('Breadcrumbs', array(array('Name' => t('My Bookmarks'), 'Url' => '/discussions/bookmarked')));
$this->render();
}