/** * * @param ProfileController $Sender * @param type $UserReference * @param type $Username * @param type $oauth_token * @param type $oauth_verifier */ public function ProfileController_TwitterConnect_Create($Sender, $UserReference = '', $Username = '', $oauth_token = '', $oauth_verifier = '') { $Sender->Permission('Garden.SignIn.Allow'); $Sender->GetUserInfo($UserReference, $Username, '', TRUE); $Sender->_SetBreadcrumbs(T('Connections'), '/profile/connections'); // Get the access token. Trace('GetAccessToken()'); $AccessToken = $this->GetAccessToken($oauth_token, $oauth_verifier); $this->AccessToken($AccessToken); // Get the profile. Trace('GetProfile()'); $Profile = $this->GetProfile(); // Save the authentication. Gdn::UserModel()->SaveAuthentication(array('UserID' => $Sender->User->UserID, 'Provider' => self::ProviderKey, 'UniqueID' => $Profile['id'])); // Save the information as attributes. $Attributes = array('AccessToken' => array($AccessToken->key, $AccessToken->secret), 'Profile' => $Profile); Gdn::UserModel()->SaveAttribute($Sender->User->UserID, self::ProviderKey, $Attributes); $this->EventArguments['Provider'] = self::ProviderKey; $this->EventArguments['User'] = $Sender->User; $this->FireEvent('AfterConnection'); Redirect(UserUrl($Sender->User, '', 'connections')); }
/** * 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(); }
/** * This method shows the highest scoring discussions/comments a user has ever posted * * @param ProfileController $Sender * @param int $UserReference * @param string $Username * @param int $Page */ public function ProfileController_Best_Create($Sender, $UserReference = '', $Username = '', $Page = 0) { if (!C('Yaga.Reactions.Enabled')) { return; } list($Offset, $Limit) = OffsetLimit($Page, C('Yaga.BestContent.PerPage', 10)); if (!is_numeric($Offset) || $Offset < 0) { $Offset = 0; } $Sender->EditMode(FALSE); // Tell the ProfileController what tab to load $Sender->GetUserInfo($UserReference, $Username); $Sender->_SetBreadcrumbs(T('Yaga.BestContent'), UserUrl($Sender->User, '', 'best')); $Sender->SetTabView(T('Yaga.BestContent'), 'best', 'profile', 'Yaga'); $Sender->AddJsFile('jquery.expander.js'); $Sender->AddJsFile('reactions.js', 'yaga'); $Sender->AddDefinition('ExpandText', T('(more)')); $Sender->AddDefinition('CollapseText', T('(less)')); $Model = new ActedModel(); $Data = $Model->GetBest($Sender->User->UserID, $Limit, $Offset); $Sender->SetData('Content', $Data); // 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) { $Sender->Head->AddTag('meta', array('name' => 'robots', 'content' => 'noindex,noarchive')); } // Build a pager $PagerFactory = new Gdn_PagerFactory(); $Sender->Pager = $PagerFactory->GetPager('Pager', $Sender); $Sender->Pager->ClientID = 'Pager'; $Sender->Pager->Configure($Offset, $Limit, FALSE, 'profile/best/' . $Sender->User->UserID . '/' . Gdn_Format::Url($Sender->User->Name) . '/%1$s/'); // Render the ProfileController $Sender->Render(); }