/** * Creates addons tab ProfileController. * * @since 2.0.0 * @package Vanilla * * @param ProfileController $Sender */ public function profileController_addons_create($Sender) { $UserReference = val(0, $Sender->RequestArgs, ''); $Username = val(1, $Sender->RequestArgs, ''); // Tell the ProfileController what tab to load $Sender->getUserInfo($UserReference, $Username); $Sender->setTabView('Addons', 'Profile', 'Addon', 'Addons'); $Offset = 0; $Limit = 100; $AddonModel = new AddonModel(); $ResultSet = $AddonModel->getWhere(array('UserID' => $Sender->User->UserID), 'DateUpdated', 'desc', $Limit, $Offset); $Sender->setData('Addons', $ResultSet); $NumResults = $AddonModel->getCount(array('InsertUserID' => $Sender->User->UserID)); // Set the HandlerType back to normal on the profilecontroller so that it fetches it's own views $Sender->HandlerType = HANDLER_TYPE_NORMAL; // Render the ProfileController $Sender->render(); }
/** * 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'), userUrl($Sender->User, '', 'discussions')); $Sender->setTabView('Discussions', 'Profile', 'Discussions', 'Vanilla'); $Sender->CountCommentsPerPage = c('Vanilla.Comments.PerPage', 30); list($Offset, $Limit) = offsetLimit($Page, c('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={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(); }
/** * @param ProfileController $Sender * @param array $Args * @param array $Where * @param int $Limit * @return bool */ public function joinAttachmentsToUser($Sender, $Args, $Where = array(), $Limit = 20) { $User = $Sender->User; if (!is_object($User)) { return false; } $Where = array_merge(array('ForeignUserID' => $User->UserID), $Where); $Attachments = $this->getWhere($Where, '', 'desc', $Limit)->resultArray(); $Sender->setData('Attachments', $Attachments); return true; }