Example #1
0
 /**
  * Creates virtual 'Discussions' method in ProfileController.
  * 
  * @since 2.0.0
  * @package Vanilla
  *
  * @param ProfileController $Sender ProfileController.
  */
 public function ProfileController_Discussions_Create($Sender, $UserReference = '', $Username = '', $Page = '', $UserID = '')
 {
     $Sender->EditMode(FALSE);
     // Tell the ProfileController what tab to load
     $Sender->GetUserInfo($UserReference, $Username, $UserID);
     $Sender->_SetBreadcrumbs(T('Discussions'), '/profile/discussions');
     $Sender->SetTabView('Discussions', 'Profile', 'Discussions', 'Vanilla');
     $Sender->CountCommentsPerPage = C('Vanilla.Comments.PerPage', 30);
     list($Offset, $Limit) = OffsetLimit($Page, Gdn::Config('Vanilla.Discussions.PerPage', 30));
     $DiscussionModel = new DiscussionModel();
     $Discussions = $DiscussionModel->GetByUser($Sender->User->UserID, $Limit, $Offset, FALSE, Gdn::Session()->UserID);
     $CountDiscussions = $Offset + $DiscussionModel->LastDiscussionCount + 1;
     $Sender->DiscussionData = $Sender->SetData('Discussions', $Discussions);
     // Build a pager
     $PagerFactory = new Gdn_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, UserUrl($Sender->User, '', 'discussions') . '/{Page}');
     // 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;
     if ($Sender->Head) {
         // These pages offer only duplicate content to search engines and are a bit slow.
         $Sender->Head->AddTag('meta', array('name' => 'robots', 'content' => 'noindex,noarchive'));
     }
     // Render the ProfileController
     $Sender->Render();
 }