/** * This is the first entry point when the social site redirects back to this callback. * It is responsible to close the popup and redirect to the appropriate url. * * @since 1.0 * @access public */ public function oauthDialog() { // Get allowed clients $allowedClients = array_keys((array) $this->config->get('oauth')); // Get the current client. $oauthClient = $this->input->get('client', '', 'word'); if (!in_array($oauthClient, $allowedClients)) { FD::info()->set(false, JText::sprintf('COM_EASYSOCIAL_OAUTH_INVALID_OAUTH_CLIENT_PROVIDED', $oauthClient), SOCIAL_MSG_ERROR); return $this->redirect(FRoute::login(array(), false)); } // Get the oauth client object. $client = FD::oauth($oauthClient); // Detect if the user has already registered with the site. if ($client->isRegistered()) { // We need to update the token $client->updateToken(); $client->login(); // Determine which URL to redirect the user to based on the settings $url = FRoute::getMenuLink($this->config->get('general.site.login')); if ($url === false) { // Default URL redirection $url = FRoute::dashboard(array(), false); // Determine if there a referer URL $callback = FRoute::referer(); if ($callback) { $url = $callback; } } $redirect = $url; } else { // Get the access $access = $client->getAccess(); // Set the access token on the session $key = $oauthClient . '.token'; $session = JFactory::getSession(); $session->set($key, $access->token, SOCIAL_SESSION_NAMESPACE); $redirect = FRoute::registration(array('layout' => 'oauth', 'client' => $oauthClient), false); } $this->set('redirect', $redirect); parent::display('site/registration/oauth.popup'); }
/** * Renders a login page if necessary. If this is called via an ajax method, it will trigger a dialog instead. * * @access public * @param null * @return string Contents. */ public static function requireLogin() { $document = JFactory::getDocument(); $my = FD::user(); if ($my->id > 0) { return true; } switch ($document->getType()) { case 'html': // Do some redirects here? $info = FD::info(); $message = new stdClass(); $message->message = JText::_('COM_EASYSOCIAL_PLEASE_LOGIN_FIRST'); $message->type = SOCIAL_MSG_INFO; $info->set($message); // Get the application framework. $app = JFactory::getApplication(); // Get the current URI. $callback = FRoute::current(); FD::setCallback($callback); $url = FRoute::login(array(), false); $app->redirect($url); $app->close(); break; case 'ajax': $ajax = FD::ajax(); // Get the referer URI. $callback = FRoute::referer(); if ($callback) { FD::setCallback($callback); } $ajax->script('EasySocial.login();'); return $ajax->send(); break; } }
/** * Retrieve a list of albums on the site. * * @since 1.0 * @access public * @param string * @return */ public function getAlbums() { // Check for request forgeries FD::checkToken(); // To get the referer url for sorting purpose $callback = FRoute::referer(); // Get the current view. $view = $this->getCurrentView(); // Default sorting value $ordering = $this->input->get('sort', 'created', 'cmd'); // Sort items if ($callback) { $callback = parse_url($callback); parse_str($callback['query'], $query); $ordering = $query['sort']; } // Get a list of normal albums $options = array('pagination' => true, 'order' => 'a.assigned_date', 'direction' => 'DESC', 'core' => false); if ($ordering == 'alphabetical') { $options['order'] = 'a.title'; $options['direction'] = 'ASC'; } if ($ordering == 'popular') { $options['order'] = 'a.hits'; $options['direction'] = 'DESC'; } $model = FD::model('Albums'); $model->initStates(); $albums = $model->getAlbums('', SOCIAL_TYPE_USER, $options); $pagination = $model->getPagination(); $pagination->setVar('view', 'albums'); $pagination->setVar('layout', 'all'); $pagination->setVar('ordering', $ordering); return $view->call(__FUNCTION__, $albums, $pagination); }