コード例 #1
0
ファイル: view.html.php プロジェクト: knigherrant/decopatio
 /**
  * Responsible to display the generic login form.
  *
  * @since	1.0
  * @access	public
  */
 public function display($tpl = null)
 {
     $my = FD::user();
     // If user is already logged in, they should not see this page.
     if ($my->id > 0) {
         return $this->redirect(FRoute::dashboard(array(), false));
     }
     // Add page title
     FD::page()->title(JText::_('COM_EASYSOCIAL_LOGIN_PAGE_TITLE'));
     // Add breadcrumb
     FD::page()->breadcrumb(JText::_('COM_EASYSOCIAL_LOGIN_PAGE_BREADCRUMB'));
     // Facebook codes.
     $facebook = FD::oauth('Facebook');
     $config = FD::config();
     $loginMenu = $config->get('general.site.login');
     // Get any callback urls.
     $return = FD::getCallback();
     // If return value is empty, always redirect back to the dashboard
     if (!$return) {
         // Determine if there's a login redirection
         $urlFromCaller = FD::input()->getVar('return', '');
         if ($urlFromCaller) {
             $return = $urlFromCaller;
         } else {
             if ($loginMenu != 'null') {
                 $return = FRoute::getMenuLink($loginMenu);
             } else {
                 $return = FRoute::dashboard(array(), false);
             }
             $return = base64_encode($return);
         }
     } else {
         $return = base64_encode($return);
     }
     if ($config->get('registrations.enabled')) {
         $profileId = $config->get('registrations.mini.profile', 'default');
         if ($profileId === 'default') {
             $profileId = Foundry::model('profiles')->getDefaultProfile()->id;
         }
         $options = array('visible' => SOCIAL_PROFILES_VIEW_MINI_REGISTRATION, 'profile_id' => $profileId);
         $fieldsModel = Foundry::model('fields');
         $fields = $fieldsModel->getCustomFields($options);
         if (!empty($fields)) {
             FD::language()->loadAdmin();
             $fieldsLib = FD::fields();
             $session = JFactory::getSession();
             $registration = FD::table('Registration');
             $registration->load($session->getId());
             $data = $registration->getValues();
             $args = array(&$data, &$registration);
             $fieldsLib->trigger('onRegisterMini', SOCIAL_FIELDS_GROUP_USER, $fields, $args);
             $this->set('fields', $fields);
         }
     }
     $this->set('return', $return);
     $this->set('facebook', $facebook);
     return parent::display('site/login/default');
 }
コード例 #2
0
 /**
  * Responsible to process cron items for oauth items
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function onCronExecute()
 {
     // We'll temporarily disable this.
     return;
     $model = FD::model('OAuth');
     // Load up facebook client
     $facebookClient = FD::oauth('facebook');
     // Get a list of pullable items
     $oauthUsers = $model->getPullableClients();
     if (!$oauthUsers) {
         return;
     }
     // Go through each of the pullable users
     foreach ($oauthUsers as $oauthUser) {
         // Simulate the user now by passing in their valid token.
         $facebookClient->setAccess($oauthUser->token);
         // Get the stream items from Facebook
         $items = $facebookClient->pull();
         // echo '<pre>';
         // print_r( $items );
         // echo '</pre>';
         // exit;
         foreach ($items as $item) {
             // Store this into the stream now.
             $stream = FD::stream();
             // Get the stream template
             $template = $stream->getTemplate();
             $template->setActor($oauthUser->uid, $oauthUser->type);
             $template->setContext($item->get('id'), SOCIAL_TYPE_FACEBOOK);
             $template->setContent($item->get('content'));
             $template->setVerb('update');
             $template->setAccess('core.view');
             // Create the new stream item.
             $streamTable = $stream->add($template);
             // Store into the stream assets table as the app needs this.
             $assets = FD::table('StreamAsset');
             $assets->stream_id = $streamTable->id;
             $assets->type = SOCIAL_TYPE_FACEBOOK;
             $assets->data = $item->toString();
             $assets->store();
             // Store into the import history.
             $history = FD::table('OAuthHistory');
             $history->remote_id = $item->get('id');
             $history->remote_type = $item->get('type');
             $history->local_id = $streamTable->id;
             $history->local_type = SOCIAL_TYPE_STREAM;
             $history->store();
         }
         // Update the last pulled item datetime.
         $oauthTable = FD::table('OAuth');
         $oauthTable->bind($oauthUser);
         $oauthTable->last_pulled = FD::date()->toMySQL();
         $state = $oauthTable->store();
     }
 }
コード例 #3
0
ファイル: view.ajax.php プロジェクト: ppantilla/bbninja
 /**
  * Responsible to display the generic login form via ajax
  *
  * @since	1.0
  * @access	public
  */
 public function form($tpl = null)
 {
     $ajax = FD::ajax();
     $my = FD::user();
     // If user is already logged in, they should not see this page.
     if ($my->id > 0) {
         $this->setMessage(JText::_('COM_EASYSOCIAL_LOGIN_ALREADY_LOGGED_IN'), SOCIAL_MSG_ERROR);
         return $ajax->reject($this->getMessage());
     }
     // Facebook codes.
     $facebook = FD::oauth('Facebook');
     // Get any callback urls.
     $return = FD::getCallback();
     // If return value is empty, always redirect back to the dashboard
     if (!$return) {
         $return = FRoute::dashboard(array(), false);
     }
     // Determine if there's a login redirection
     $config = FD::config();
     $loginMenu = $config->get('general.site.login');
     if ($loginMenu != 'null') {
         $return = FD::get('toolbar')->getRedirectionUrl($loginMenu);
     }
     $return = base64_encode($return);
     $this->set('return', $return);
     $this->set('facebook', $facebook);
     if ($config->get('registrations.enabled')) {
         $profileId = $config->get('registrations.mini.profile', 'default');
         if ($profileId === 'default') {
             $profileId = Foundry::model('profiles')->getDefaultProfile()->id;
         }
         $options = array('visible' => SOCIAL_PROFILES_VIEW_MINI_REGISTRATION, 'profile_id' => $profileId);
         $fieldsModel = FD::model('Fields');
         $fields = $fieldsModel->getCustomFields($options);
         if (!empty($fields)) {
             FD::language()->loadAdmin();
             $fieldsLib = FD::fields();
             $session = JFactory::getSession();
             $registration = FD::table('Registration');
             $registration->load($session->getId());
             $data = $registration->getValues();
             $args = array(&$data, &$registration);
             $fieldsLib->trigger('onRegisterMini', SOCIAL_FIELDS_GROUP_USER, $fields, $args);
             $this->set('fields', $fields);
         }
     }
     $contents = parent::display('site/login/dialog.login');
     return $ajax->resolve($contents);
 }
コード例 #4
0
<?php

/**
* @package		EasySocial
* @copyright	Copyright (C) 2010 - 2014 Stack Ideas Sdn Bhd. All rights reserved.
* @license		GNU/GPL, see LICENSE.php
* EasySocial is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
defined('_JEXEC') or die('Unauthorized Access');
$model = FD::model('Profiles');
$profiles = $model->getItems();
$profilesList = array();
foreach ($profiles as $profile) {
    $profilesList[] = $settings->makeOption($profile->title, $profile->id, false);
}
echo $settings->renderPage($settings->renderColumn($settings->renderSection($settings->renderHeader('Twitter Application Settings'), $settings->renderSetting('Twitter Consumer Key', 'oauth.twitter.app', 'input', array('help' => true, 'info' => true, 'class="input-full"')), $settings->renderSetting('Twitter Consumer Secret', 'oauth.twitter.secret', 'input', array('help' => true, 'info' => true, 'class="input-full"')), $settings->renderSetting('Twitter Authentication', '', 'custom', array('field' => FD::oauth('Twitter')->getLoginButton('/administrator/index.php?option=com_easysocial&controller=oauth&task=grant&uid=1&type=config&client=twitter&callback=' . urlencode(FRoute::_('index.php?option=com_easysocial&view=settings&layout=closeOauthDialog&tmpl=component')), array('publish_stream'), 'popup'), 'rowAttributes' => array('data-oauth-twitter-button'))))));
コード例 #5
0
ファイル: toolbar.php プロジェクト: ppantilla/bbninja
 /**
  * Renders the HTML block for the notification bar.
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function render($options = array())
 {
     // The current logged in user.
     $my = FD::user();
     $theme = FD::themes();
     if ($my->id) {
         // Get a list of new conversations
         $newConversations = $my->getTotalNewConversations();
         // Get total pending request count
         $newRequests = $my->getTotalFriendRequests();
         // Get new system notifications
         $model = FD::model('Notifications');
         $newNotifications = $model->getCount(array('unread' => true, 'target' => array('id' => $my->id, 'type' => SOCIAL_TYPE_USER)));
         $theme->set('newConversations', $newConversations);
         $theme->set('newRequests', $newRequests);
         $theme->set('newNotifications', $newNotifications);
     }
     // Only render facebook codes if user is not logged in
     $facebook = false;
     if (!$my->id) {
         // Facebook codes.
         $facebook = FD::oauth('Facebook');
     }
     $config = FD::config();
     // Get login redirection url
     $loginMenu = $config->get('general.site.login');
     if ($loginMenu == 'null') {
         $loginReturn = base64_encode(JRequest::getURI());
     } else {
         $loginReturn = $this->getRedirectionUrl($loginMenu);
         $loginReturn = base64_encode($loginReturn);
     }
     // Get logout redirection url
     $logoutMenu = $config->get('general.site.logout');
     $logoutReturn = $this->getRedirectionUrl($logoutMenu);
     $logoutReturn = base64_encode($logoutReturn);
     // Determines if there's any force display options passed in arguments
     $forceOption = isset($options['forceoption']) ? $options['forceoption'] : false;
     // default this two is enabled.
     $friends = isset($options['friends']) ? $options['friends'] : true;
     $notifications = isset($options['notifications']) ? $options['notifications'] : true;
     // from arguments.
     $toolbar = isset($options['toolbar']) ? $options['toolbar'] : false;
     $dashboard = isset($options['dashboard']) ? $options['dashboard'] : false;
     $conversations = isset($options['conversations']) ? $options['conversations'] : false;
     $search = isset($options['search']) ? $options['search'] : false;
     $login = isset($options['login']) ? $options['login'] : false;
     $profile = isset($options['profile']) ? $options['profile'] : false;
     // Get template settings
     $template = FD::themes()->getConfig();
     // Determines if the current viewer is a guest user.
     $isGuest = $my->id == 0 ? true : false;
     if ($isGuest && !$template->get('toolbar_guests')) {
         $toolbar = false;
     }
     if (!$forceOption) {
         $dashboard = $template->get('toolbar_dashboard') || $dashboard;
         $conversations = $config->get('conversations.enabled') || $conversations;
         $search = $template->get('toolbar_search') || $search;
         $login = $template->get('toolbar_login') || $login;
         $profile = $template->get('toolbar_account') || $profile;
         $toolbar = $template->get('toolbar') || $toolbar;
         if ($isGuest && !$template->get('toolbar_guests')) {
             $toolbar = false;
         }
     }
     // Get the current view
     $view = JRequest::getCmd('view');
     $layout = JRequest::getCmd('layout');
     $userId = JRequest::getInt('id');
     $theme->set('facebook', $facebook);
     $theme->set('userId', $userId);
     $theme->set('view', $view);
     $theme->set('layout', $layout);
     $theme->set('login', $login);
     $theme->set('profile', $profile);
     $theme->set('search', $search);
     $theme->set('dashboard', $dashboard);
     $theme->set('friends', $friends);
     $theme->set('conversations', $conversations);
     $theme->set('notifications', $notifications);
     $theme->set('toolbar', $toolbar);
     $theme->set('loginReturn', $loginReturn);
     $theme->set('logoutReturn', $logoutReturn);
     $html = $theme->output('site/toolbar/default');
     return $html;
 }
コード例 #6
0
$layout = $params->get('layout', 'default');
$suffix = $params->get('suffix', '');
$config = FD::config();
$facebook = FD::oauth('Facebook');
// Get any callback urls.
$return = EasySocialModLogBoxHelper::getReturnURL($params);
// Get the profile id
$profileId = $params->get('profile_id');
// If there's no profile id, then we automatically assign the default profile id
if (empty($profileId)) {
    $profileModel = FD::model('profiles');
    $defaultProfile = $profileModel->getDefaultProfile();
    $profileId = $defaultProfile->id;
}
if ($params->get('show_quick_registration', true)) {
    $fieldsModel = FD::model('fields');
    $options = array('visible' => SOCIAL_PROFILES_VIEW_MINI_REGISTRATION, 'profile_id' => $profileId);
    $fields = $fieldsModel->getCustomFields($options);
    if (!empty($fields)) {
        FD::language()->loadAdmin();
        $fieldsLib = FD::fields();
        $session = JFactory::getSession();
        $registration = FD::table('Registration');
        $registration->load($session->getId());
        $data = $registration->getValues();
        $args = array(&$data, &$registration);
        $fieldsLib->trigger('onRegisterMini', SOCIAL_FIELDS_GROUP_USER, $fields, $args);
    }
}
$facebook = FD::oauth('facebook');
require JModuleHelper::getLayoutPath('mod_easysocial_logbox', $layout);
コード例 #7
0
ファイル: view.html.php プロジェクト: ppantilla/bbninja
 /**
  * Responsible to output the edit profile layout
  *
  * @since	1.0
  * @access	public
  * @param	string	The name of the template file to parse; automatically searches through the template paths.
  * @return	null
  * @author	Mark Lee <*****@*****.**>
  */
 public function edit($errors = null)
 {
     // Unauthorized users should not be allowed to access this page.
     FD::requireLogin();
     // Set any messages here.
     FD::info()->set($this->getMessage());
     // Load the language file from the back end.
     FD::language()->loadAdmin();
     // Get list of steps for this user's profile type.
     $profile = $this->my->getProfile();
     // Get user's installed apps
     $appsModel = FD::model('Apps');
     $userApps = $appsModel->getUserApps($this->my->id);
     // Get the steps model
     $stepsModel = FD::model('Steps');
     $steps = $stepsModel->getSteps($profile->id, SOCIAL_TYPE_PROFILES, SOCIAL_PROFILES_VIEW_EDIT);
     // Get custom fields model.
     $fieldsModel = FD::model('Fields');
     // Get custom fields library.
     $fields = FD::fields();
     // Set page title
     FD::page()->title(JText::_('COM_EASYSOCIAL_PAGE_TITLE_ACCOUNT_SETTINGS'));
     // Set the page breadcrumb
     FD::page()->breadcrumb(JText::_('COM_EASYSOCIAL_PAGE_TITLE_PROFILE'), FRoute::profile());
     FD::page()->breadcrumb(JText::_('COM_EASYSOCIAL_PAGE_TITLE_ACCOUNT_SETTINGS'));
     // Check if there are any errors in the session
     // If session contains error, means that this is from the FD::fields()->checkCompleteProfile();
     if (empty($errors)) {
         $session = JFactory::getSession();
         $errors = $session->get('easysocial.profile.errors', '', SOCIAL_SESSION_NAMESPACE);
         if (!empty($errors)) {
             FD::info()->set(false, JText::_('COM_EASYSOCIAL_PROFILE_PLEASE_COMPLETE_YOUR_PROFILE'), SOCIAL_MSG_ERROR);
         }
     }
     // Set the callback for the triggered custom fields
     $callback = array($fields->getHandler(), 'getOutput');
     // Get the custom fields for each of the steps.
     foreach ($steps as &$step) {
         $step->fields = $fieldsModel->getCustomFields(array('step_id' => $step->id, 'data' => true, 'dataId' => $this->my->id, 'dataType' => SOCIAL_TYPE_USER, 'visible' => 'edit'));
         // Trigger onEdit for custom fields.
         if (!empty($step->fields)) {
             $post = JRequest::get('post');
             $args = array(&$post, &$this->my, $errors);
             $fields->trigger('onEdit', SOCIAL_FIELDS_GROUP_USER, $step->fields, $args, $callback);
         }
     }
     // Determines if we should show the social tabs on the left.
     $showSocialTabs = false;
     // Determines if the user has associated
     $associatedFacebook = $this->my->isAssociated('facebook');
     $facebookClient = false;
     $facebookMeta = array();
     $fbOAuth = false;
     $fbUserMeta = array();
     if ($associatedFacebook) {
         // We want to show the tabs
         $showSocialTabs = true;
         $facebookToken = $this->my->getOAuthToken('facebook');
         $facebookClient = FD::oauth('facebook');
         // Set the access for the client.
         $facebookClient->setAccess($facebookToken);
         try {
             $fbUserMeta = $facebookClient->getUserMeta();
         } catch (Exception $e) {
             $message = (object) array('message' => JText::sprintf('COM_EASYSOCIAL_OAUTH_FACEBOOK_ERROR_MESSAGE', $e->getMessage()), 'type' => SOCIAL_MSG_ERROR);
             FD::info()->set($message);
         }
         $fbUserMeta = false;
         $fbOAuth = $this->my->getOAuth(SOCIAL_TYPE_FACEBOOK);
         $facebookMeta = FD::registry($fbOAuth->params);
         $facebookPermissions = FD::makeArray($fbOAuth->permissions);
     }
     $this->set('fbUserMeta', $fbUserMeta);
     $this->set('fbOAuth', $fbOAuth);
     $this->set('showSocialTabs', $showSocialTabs);
     $this->set('facebookMeta', $facebookMeta);
     $this->set('facebookClient', $facebookClient);
     $this->set('associatedFacebook', $associatedFacebook);
     $this->set('profile', $profile);
     $this->set('steps', $steps);
     $this->set('apps', $userApps);
     return parent::display('site/profile/default.edit.profile');
 }
コード例 #8
0
ファイル: default.php プロジェクト: knigherrant/decopatio
 &rarr;</button>

				<?php 
if ($params->get('social', true) && $config->get('oauth.facebook.registration.enabled') && $config->get('registrations.enabled') && ($config->get('oauth.facebook.secret') && $config->get('oauth.facebook.app') || $config->get('oauth.facebook.jfbconnect.enabled'))) {
    ?>
					<hr />
					<div class="text-center mb-10">
						<p class="line">
							<strong><?php 
    echo JText::_('MOD_EASYSOCIAL_REGISTER_OR_REGISTER_WITH_YOUR_SOCIAL_IDENTITY');
    ?>
</strong>
						</p>

						<?php 
    echo FD::oauth('Facebook')->getLoginButton(FRoute::registration(array('layout' => 'oauthDialog', 'client' => 'facebook', 'external' => true), false), false, 'popup', JText::_('MOD_EASYSOCIAL_REGISTER_REGISTER_WITH_YOUR_FACEBOOK_ACCOUNT'));
    ?>
					</div>
				<?php 
}
?>
			</div>
		</div>

		<?php 
echo $modules->html('form.token');
?>
		<input type="hidden" name="redirect" value="<?php 
echo base64_encode(JRequest::getURI());
?>
" />
コード例 #9
0
ファイル: toolbar.php プロジェクト: knigherrant/decopatio
 /**
  * Renders the HTML block for the notification bar.
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function render($options = array())
 {
     $theme = FD::themes();
     // Default options
     $newConversations = false;
     $newRequests = false;
     $newNotifications = false;
     $facebook = false;
     // Display counter related stuffs for logged in user and user that has access to the community
     if ($this->my->id && $this->my->hasCommunityAccess()) {
         // Get a list of new conversations
         $newConversations = $this->my->getTotalNewConversations();
         // Get total pending request count
         $newRequests = $this->my->getTotalFriendRequests();
         // Get new system notifications
         $model = FD::model('Notifications');
         $notificationOptions = array('unread' => true, 'target' => array('id' => $this->my->id, 'type' => SOCIAL_TYPE_USER));
         $newNotifications = $model->getCount($notificationOptions);
     }
     // Only render facebook codes if user is not logged in
     if ($this->my->guest) {
         $facebook = FD::oauth('Facebook');
     }
     // Get login redirection url
     $loginMenu = $this->config->get('general.site.login');
     $loginReturn = base64_encode(JRequest::getURI());
     if ($loginMenu != 'null') {
         $loginReturn = FRoute::getMenuLink($loginMenu);
         $loginReturn = base64_encode($loginReturn);
     }
     // Get logout redirection url
     $logoutMenu = $this->config->get('general.site.logout');
     $logoutReturn = FRoute::getMenuLink($logoutMenu);
     $logoutReturn = base64_encode($logoutReturn);
     // Determines if there's any force display options passed in arguments
     $forceOption = isset($options['forceoption']) ? $options['forceoption'] : false;
     // Default this two is enabled.
     $friends = isset($options['friends']) ? $options['friends'] : true;
     $notifications = isset($options['notifications']) ? $options['notifications'] : true;
     // Get other options from arguments
     $toolbar = isset($options['toolbar']) ? $options['toolbar'] : false;
     $dashboard = isset($options['dashboard']) ? $options['dashboard'] : false;
     $conversations = isset($options['conversations']) ? $options['conversations'] : false;
     $search = isset($options['search']) ? $options['search'] : false;
     $login = isset($options['login']) ? $options['login'] : false;
     $profile = isset($options['profile']) ? $options['profile'] : false;
     // Get template settings
     $template = $theme->getConfig();
     // If the user is guests, ensure that the theme is configured to display toolbar to the guest
     if ($this->my->guest && !$template->get('toolbar_guests')) {
         $toolbar = false;
     }
     // Should we enforce the arguments that is passed in?
     if (!$forceOption) {
         $dashboard = $template->get('toolbar_dashboard') || $dashboard;
         $conversations = $this->config->get('conversations.enabled') || $conversations;
         $search = $template->get('toolbar_search') || $search;
         $login = $template->get('toolbar_login') || $login;
         $profile = $template->get('toolbar_account') || $profile;
         $toolbar = $template->get('toolbar') || $toolbar;
         if ($this->my->guest && !$template->get('toolbar_guests')) {
             $toolbar = false;
         }
     }
     // If toolbar has been disabled altogether skip this
     if (!$toolbar) {
         return;
     }
     // If the user doesn't have access to the community we need to enforce specific options here
     if (!$this->my->hasCommunityAccess()) {
         $friends = false;
         $conversations = false;
         $notifications = false;
         $dashboard = false;
         $search = false;
     }
     // Get the current request variables
     $view = $this->input->get('view', '', 'cmd');
     $layout = $this->input->get('layout', '', 'cmd');
     $userId = $this->input->get('id', 0, 'int');
     $theme->set('newConversations', $newConversations);
     $theme->set('newRequests', $newRequests);
     $theme->set('newNotifications', $newNotifications);
     $theme->set('facebook', $facebook);
     $theme->set('userId', $userId);
     $theme->set('view', $view);
     $theme->set('layout', $layout);
     $theme->set('login', $login);
     $theme->set('profile', $profile);
     $theme->set('search', $search);
     $theme->set('dashboard', $dashboard);
     $theme->set('friends', $friends);
     $theme->set('conversations', $conversations);
     $theme->set('notifications', $notifications);
     $theme->set('toolbar', $toolbar);
     $theme->set('loginReturn', $loginReturn);
     $theme->set('logoutReturn', $logoutReturn);
     $output = $theme->output('site/toolbar/default');
     return $output;
 }
コード例 #10
0
ファイル: view.html.php プロジェクト: knigherrant/decopatio
 /**
  * Displays the first step of user signing up with oauth
  *
  * @since	1.0
  * @access	public
  */
 public function oauthPreferences($profileId = '', $username = '', $email = '', $oauthClient = '')
 {
     $config = FD::config();
     if ($this->hasErrors()) {
         FD::info()->set($this->getMessage());
     }
     // Get allowed clients
     $allowedClients = array_keys((array) $config->get('oauth'));
     // Get the profile id.
     $profileId = JRequest::getInt('profile', $profileId);
     // Get the current client.
     $oauthClient = JRequest::getWord('client', $oauthClient);
     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));
     }
     // Add page title
     $title = JText::sprintf('COM_EASYSOCIAL_OAUTH_PAGE_TITLE_INFO', ucfirst($oauthClient));
     FD::page()->title($title);
     // Add breadcrumbs
     $url = FRoute::registration(array('view' => 'registration', 'layout' => 'oauth', 'client' => $oauthClient));
     FD::page()->breadcrumb(JText::sprintf('COM_EASYSOCIAL_OAUTH_PAGE_TITLE', ucfirst($oauthClient)), $url);
     FD::page()->breadcrumb($title);
     // We might reach here from oauth.profile from normal registration, and in that case, username and email might be empty
     if (empty($username) || empty($email)) {
         $client = FD::oauth($oauthClient);
         try {
             $meta = $client->getUserMeta();
         } catch (Exception $e) {
             $app = JFactory::getApplication();
             // Use dashboard here instead of login because api error calls might come from after user have successfully logged in
             $url = FRoute::dashboard(array(), false);
             $message = (object) array('message' => JText::sprintf('COM_EASYSOCIAL_OAUTH_FACEBOOK_ERROR_MESSAGE', $e->getMessage()), 'type' => SOCIAL_MSG_ERROR);
             FD::info()->set($message);
             $app->redirect($url);
             $app->close();
         }
         if (empty($username)) {
             $username = $meta['username'];
         }
         if (empty($email)) {
             $email = $meta['email'];
         }
     }
     // @TODO: Check if the username has been used, if it does, generate a username for him.
     $model = FD::model('Registration');
     $usernameExists = $model->isUsernameExists($username);
     if ($usernameExists && !FD::config()->get('registrations.emailasusername')) {
         // Generate username
         $username = $model->generateUsername($username);
     }
     $emailExists = $model->isEmailExists($email);
     $this->set('emailExists', $emailExists);
     $this->set('usernameExists', $usernameExists);
     $this->set('username', $username);
     $this->set('email', $email);
     $this->set('profileId', $profileId);
     $this->set('clientType', $oauthClient);
     parent::display('site/registration/oauth.preferences');
 }
コード例 #11
0
ファイル: registration.php プロジェクト: ppantilla/bbninja
 /**
  * This is when user clicks on Create account which we will automatically register them on the site.
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function oauthSignup()
 {
     // Load our own configuration.
     $config = FD::config();
     // Retrieve current view.
     $view = $this->getCurrentView();
     // Get the current client
     $client = JRequest::getWord('client');
     // Get allowed clients
     $allowedClients = array_keys((array) $config->get('oauth'));
     // Check for allowed clients.
     if (!in_array($client, $allowedClients)) {
         $view->setMessage(JText::sprintf('COM_EASYSOCIAL_OAUTH_INVALID_OAUTH_CLIENT_PROVIDED', $client), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__);
     }
     // Load up oauth library
     $oauthClient = FD::oauth($client);
     // Get the external user id.
     $oauthUserId = $oauthClient->getUser();
     // Determines if the oauth id is already registered on the site.
     $isRegistered = $oauthClient->isRegistered();
     // If user has already registered previously, just log them in.
     if ($isRegistered) {
         $state = $oauthClient->login();
         if ($state) {
             $view->setMessage('COM_EASYSOCIAL_OAUTH_AUTHENTICATED_ACCOUNT_SUCCESS', SOCIAL_MSG_SUCCESS);
         }
         return $view->call(__FUNCTION__);
     }
     // Get the access tokens.
     $accessToken = $oauthClient->getAccess();
     // Retrieve user's information
     try {
         $meta = $oauthClient->getUserMeta();
     } catch (Exception $e) {
         $app = JFactory::getApplication();
         // Use dashboard here instead of login because api error calls might come from after user have successfully logged in
         $url = FRoute::dashboard(array(), false);
         $message = (object) array('message' => JText::sprintf('COM_EASYSOCIAL_OAUTH_FACEBOOK_ERROR_MESSAGE', $e->getMessage()), 'type' => SOCIAL_MSG_ERROR);
         FD::info()->set($message);
         $app->redirect($url);
         $app->close();
     }
     // Get the registration type.
     $registrationType = $config->get('oauth.' . $client . '.registration.type');
     // Load up registration model
     $model = FD::model('Registration');
     // If this is a simplified registration, check if the user name exists.
     if ($registrationType == 'simplified') {
         // If the username or email exists
         if ($model->isEmailExists($meta['email']) || $model->isUsernameExists($meta['username'])) {
             return $view->call('oauthPreferences', $meta['profileId'], $meta['username'], $meta['email'], $client);
         }
     }
     // Create user account
     $user = $model->createOauthUser($accessToken, $meta, $oauthClient);
     // @badge: registration.create
     // Assign badge for the person that initiated the friend request.
     $badge = FD::badges();
     $badge->log('com_easysocial', 'registration.create', $user->id, JText::_('COM_EASYSOCIAL_REGISTRATION_BADGE_REGISTERED'));
     if (!$user) {
         $view->setMessage($model->getError(), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__);
     }
     // If the profile type is auto login, we need to log the user in
     $profile = FD::table('Profile');
     $profile->load($meta['profileId']);
     // Check if the profile type requires activation. Only log the user in when user is supposed to automatically login.
     $type = $profile->getRegistrationType(false, true);
     // Send notification to admin if necessary.
     $model->notifyAdmins($meta, $user, $profile, true);
     JFactory::getSession()->clear('user');
     // Only log the user in if the profile allows this.
     if ($type == 'auto') {
         // Log the user in
         $oauthClient->login();
         // Once the user is logged in, get the new user object.
         $my = FD::user();
         // @points: user.register
         // Assign points when user registers on the site.
         $points = FD::points();
         $points->assign('user.registration', 'com_easysocial', $my->id);
         // Add activity logging when a uer registers on the site.
         if ($config->get('registrations.stream.create')) {
             $stream = FD::stream();
             $streamTemplate = $stream->getTemplate();
             // Set the actor
             $streamTemplate->setActor($my->id, SOCIAL_TYPE_USER);
             // Set the context
             $streamTemplate->setContext($my->id, SOCIAL_TYPE_PROFILES);
             // Set the verb
             $streamTemplate->setVerb('register');
             $streamTemplate->setSiteWide();
             $streamTemplate->setAccess('core.view');
             // Add stream template.
             $stream->add($streamTemplate);
         }
     } else {
         // Send notification to user
         $model->notify($meta, $user, $profile, true);
     }
     return $view->call('oauthCreateAccount', $user);
 }
コード例 #12
0
ファイル: easysocial.php プロジェクト: knigherrant/decopatio
 /**
  * This method should handle any authentication and report back to the subject
  *
  * @param   array   $credentials  Array holding the user credentials
  * @param   array   $options      Array of extra options
  * @param   object  $response     Authentication response object
  *
  * @return  boolean
  *
  * @since   1.5
  */
 public function onAuthenticate(&$credentials, $options, &$response)
 {
     $file = JPATH_ROOT . '/administrator/components/com_easysocial/includes/foundry.php';
     jimport('joomla.filesystem.file');
     if (!JFile::exists($file)) {
         return;
     }
     // Include main library
     require_once $file;
     // Check if Foundry exists
     if (!FD::exists()) {
         FD::language()->loadSite();
         echo JText::_('COM_EASYSOCIAL_FOUNDRY_DEPENDENCY_MISSING');
         return;
     }
     // Load oauth table
     $oauthTable = FD::table('OAuth');
     $config = FD::config();
     // Check if email login is allowed.
     $emailAllowed = $config->get('general.site.loginemail');
     $isEmail = JMailHelper::isEmailAddress($credentials['username']);
     // Try to find a valid username if user tries to login with their email.
     if ($emailAllowed && $isEmail) {
         // Search for the email
         $model = FD::model('Users');
         $username = $model->getUsernameByEmail($credentials['username']);
         // If there's a username, replace the credentials with the username.
         if ($username) {
             $response->type = 'Joomla';
             $credentials['username'] = $username;
             // Avoid using JFactory::getApplication()->login() to prevent inception because login triggers authentication plugin.
             // Get the user id based on the username
             $uid = $model->getUserid('username', $username);
             if (empty($uid)) {
                 $response->status = JAuthentication::STATUS_FAILURE;
                 $response->error_message = JText::_('JGLOBAL_AUTH_NO_USER');
             } else {
                 // Verify the password
                 $match = $model->verifyUserPassword($uid, $credentials['password']);
                 if ($match === true) {
                     // Bring this in line with the rest of the system
                     $user = JUser::getInstance($uid);
                     $response->email = $user->email;
                     $response->fullname = $user->name;
                     $app = JFactory::getApplication();
                     if ($app->isAdmin()) {
                         $response->language = $user->getParam('admin_language');
                     } else {
                         $response->language = $user->getParam('language');
                     }
                     $response->status = JAuthentication::STATUS_SUCCESS;
                     $response->error_message = '';
                 } else {
                     // Invalid password
                     $response->status = JAuthentication::STATUS_FAILURE;
                     $response->error_message = JText::_('JGLOBAL_AUTH_INVALID_PASS');
                 }
             }
         }
     }
     // Lets try to load the user.
     $state = $oauthTable->loadByUsername($credentials['username']);
     if ($state) {
         // Now we really need to ensure that they are logged in with their respective oauth client.
         $client = FD::oauth($oauthTable->client);
         // Check the current user's token and the stored token.
         $oauthUserId = $client->getUserId();
         // We cannot match the access token because everytime the user click on the Facebook login button, the tokens are re-generated.
         if ($oauthUserId == $oauthTable->oauth_id) {
             $user = FD::user($oauthTable->uid);
             // User login successfull. We need to update the access token with the new token.
             $oauthTable->bindToken($client);
             $oauthTable->store();
             $response->fullname = $user->getName();
             $response->username = $user->username;
             $response->password = $credentials['password'];
             $response->status = JAuthentication::STATUS_SUCCESS;
             $response->error_message = '';
             return true;
         }
     }
     return false;
 }
コード例 #13
0
ファイル: oauth.php プロジェクト: knigherrant/decopatio
 /**
  * Performs a request to social network sites to request for
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function grant()
 {
     // Get config
     $config = FD::config();
     // Get the current view.
     $view = $this->getCurrentView();
     // Get the client.
     $client = JRequest::getWord('client');
     // Determine what we should do next with the provided callback url.
     $callback = JRequest::getVar('callback', '');
     $callback = urldecode($callback);
     // Check for oauth_callback as well
     if (!$client) {
         $view->setMessage(JText::_('Invalid client provided'), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__, $callback);
     }
     // Load the respective oauth library
     $oauth = FD::oauth(ucfirst($client));
     $access = $oauth->getAccess();
     // Get the necessary composite index
     $uid = JRequest::getInt('uid');
     $type = JRequest::getWord('type');
     if (empty($uid) || empty($type)) {
         $view->setMessage(JText::_('Please provide us with the proper keys'), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__, $callback);
     }
     // Try to load the access object from the database first.
     $table = FD::table('OAuth');
     $table->load(array('uid' => $uid, 'type' => $type));
     $table->uid = $uid;
     $table->type = $type;
     $table->client = $client;
     $table->secret = $access->secret;
     $table->token = $access->token;
     $table->expires = $access->expires;
     $table->params = $access->params;
     // Try to store the access;
     $state = $table->store();
     $view->setMessage(JText::_('COM_EASYSOCIAL_OAUTH_GRANTED_SUCCESSFULLY'), SOCIAL_MSG_SUCCESS);
     return $view->call(__FUNCTION__, $callback);
 }
コード例 #14
0
ファイル: view.html.php プロジェクト: knigherrant/decopatio
 /**
  * Displays the guest view for the dashboard
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function displayGuest()
 {
     // Determine if the current request is for "tags"
     $hashtag = $this->input->get('tag', '');
     $hashtagAlias = $hashtag;
     if ($this->config->get('stream.rss.enabled')) {
         $this->addRss(FRoute::dashboard(array(), false));
     }
     // Default stream filter
     $filter = 'everyone';
     if (!empty($hashtag)) {
         $filter = 'hashtag';
     }
     // Get the layout to use.
     $stream = FD::stream();
     $stream->getPublicStream($this->config->get('stream.pagination.pagelimit', 10), 0, $hashtag);
     // Get any callback urls.
     $return = FD::getCallback();
     // Try to get the login return url
     if (!$return) {
         $return = FRoute::getMenuLink($this->config->get('general.site.login'));
     }
     // If return value is empty, always redirect back to the dashboard
     if (!$return) {
         $return = FRoute::dashboard(array(), false);
     }
     // In guests view, there shouldn't be an app id
     $appId = $this->input->get('appId', '', 'default');
     if ($appId) {
         return JError::raiseError(404, JText::_('COM_EASYSOCIAL_PAGE_IS_NOT_AVAILABLE'));
     }
     // Ensure that the return url is always encoded correctly.
     $return = base64_encode($return);
     $facebook = FD::oauth('Facebook');
     $fields = false;
     if ($this->config->get('registrations.enabled')) {
         $fieldsModel = FD::model('Fields');
         $profileId = $this->config->get('registrations.mini.profile', 'default');
         if ($profileId === 'default') {
             $profileId = FD::model('Profiles')->getDefaultProfile()->id;
         }
         $options = array('visible' => SOCIAL_PROFILES_VIEW_MINI_REGISTRATION, 'profile_id' => $profileId);
         // Get a list of custom fields
         $fields = $fieldsModel->getCustomFields($options);
         if (!empty($fields)) {
             FD::language()->loadAdmin();
             $fieldsLib = FD::fields();
             $session = JFactory::getSession();
             $registration = FD::table('Registration');
             $registration->load($session->getId());
             $data = $registration->getValues();
             $args = array(&$data, &$registration);
             $fieldsLib->trigger('onRegisterMini', SOCIAL_FIELDS_GROUP_USER, $fields, $args);
         }
     }
     $this->set('rssLink', $this->rssLink);
     $this->set('fields', $fields);
     $this->set('filter', $filter);
     $this->set('facebook', $facebook);
     $this->set('hashtag', $hashtag);
     $this->set('hashtagAlias', $hashtagAlias);
     $this->set('stream', $stream);
     $this->set('return', $return);
     echo parent::display('site/dashboard/default.guests');
 }
コード例 #15
0
<?php

/**
* @package		EasySocial
* @copyright	Copyright (C) 2010 - 2014 Stack Ideas Sdn Bhd. All rights reserved.
* @license		GNU/GPL, see LICENSE.php
* EasySocial is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
defined('_JEXEC') or die('Unauthorized Access');
echo $settings->renderPage($settings->renderColumn($settings->renderSection($settings->renderHeader('LinkedIn Application Settings'), $settings->renderSetting('LinkedIn API Key', 'oauth.linkedin.app', 'input', array('help' => true, 'info' => true, 'class="input-full"')), $settings->renderSetting('LinkedIn Secret Key', 'oauth.linkedin.secret', 'input', array('help' => true, 'info' => true, 'class="input-full"')), $settings->renderSetting('LinkedIn Authentication', '', 'custom', FD::oauth('LinkedIn')->getLoginButton(3, 'config', FRoute::_('index.php?option=com_easysocial&view=settings&layout=closeOauthDialog&tmpl=component'), array('publish_stream'))))));