示例#1
0
 public function onAfterDispatch()
 {
     if ($this->enabled) {
         $path = JPATH_SITE . '/components/com_jfbconnect/libraries/toolbar/button/';
         $files = JFolder::files($path, '\\.php$');
         // Probably need to add some way to order these things..
         foreach ($files as $f) {
             $class = 'JFBConnectToolbarButton' . ucfirst(str_replace('.php', '', $f));
             if (class_exists($class)) {
                 $obj = new $class();
                 $this->buttons[$obj->order] = $obj;
             }
         }
         ksort($this->buttons);
         $doc = JFactory::getDocument();
         JFBCFactory::addStylesheet('jfbconnect.css');
         if (JFBCFactory::config()->get('facebook_display_errors')) {
             //                $doc->addScript('media/sourcecoast/js/jquery-ui.js');
             $doc->addStyleSheet('media/sourcecoast/css/jquery-ui/jquery-ui.css');
         } else {
             //                $doc->addScript('media/sourcecoast/js/jquery-ui.min.js');
             $doc->addStyleSheet('media/sourcecoast/css/jquery-ui/jquery-ui.min.css');
         }
     }
 }
示例#2
0
 function setupAuthentication()
 {
     $options = new JRegistry();
     $options->set('authurl', 'https://api.instagram.com/oauth/authorize');
     $options->set('tokenurl', 'https://api.instagram.com/oauth/access_token');
     $options->set('authmethod', 'get');
     $headers = array();
     $headers['Content-Type'] = 'application/json';
     $options->set('headers', $headers);
     $options->set('scope', '');
     $this->client = new JFBConnectAuthenticationOauth2($options);
     $token = JFactory::getApplication()->getUserState('com_jfbconnect.' . strtolower($this->name) . '.token', null);
     if ($token) {
         $token = (array) json_decode($token);
         $this->client->setToken($token);
     }
     $this->client->initialize($this);
     // Need to override the callback URL to force http or https
     $origRedirect = $this->client->getOption('redirecturi');
     if (JFBCFactory::config()->get('instagram_callback_ssl')) {
         $redirect = str_replace('http://', 'https://', $origRedirect);
     } else {
         $redirect = str_replace('https://', 'http://', $origRedirect);
     }
     $this->client->setOption('redirecturi', $redirect);
 }
示例#3
0
 function display($tpl = null)
 {
     $model = JFBCFactory::config();
     $jfbcLibrary = JFBCFactory::provider('facebook');
     require_once JPATH_ADMINISTRATOR . '/components/com_templates/helpers/templates.php';
     JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_templates/models');
     $templatesModel = JModelLegacy::getInstance('Styles', 'TemplatesModel');
     $allTemplates = $templatesModel->getItems();
     $templates = array();
     foreach ($allTemplates as $template) {
         if ($template->client_id == 0) {
             // Make it the same as J15 so we can use the same selectlist
             $template->directory = $template->id;
             $template->name = $template->title;
             $templates[] = $template;
         }
     }
     // Add the "Don't Override" option to set no special template
     $defaultTemplate = new stdClass();
     $defaultTemplate->directory = -1;
     $defaultTemplate->name = JText::_('COM_JFBCONNECT_CANVAS_DISPLAY_TEMPLATE_DEFAULT');
     array_unshift($templates, $defaultTemplate);
     require_once JPATH_ADMINISTRATOR . '/components/com_jfbconnect/controllers/canvas.php';
     $canvasProperties = JFBConnectControllerCanvas::setupCanvasProperties();
     $canvasTabTemplate = $model->getSetting('canvas_tab_template', -1);
     $canvasCanvasTemplate = $model->getSetting('canvas_canvas_template', -1);
     $this->assignRef('canvasProperties', $canvasProperties);
     $this->assignRef('canvasTabTemplate', $canvasTabTemplate);
     $this->assignRef('canvasCanvasTemplate', $canvasCanvasTemplate);
     $this->assignRef('templates', $templates);
     $this->assignRef('model', $model);
     $this->assignRef('jfbcLibrary', $jfbcLibrary);
     $this->addToolbar();
     parent::display($tpl);
 }
示例#4
0
 function apply()
 {
     $app = JFactory::getApplication();
     $configs = JRequest::get('POST');
     $model = JFBCFactory::config();
     JPluginHelper::importPlugin('socialprofiles');
     $profilePlugins = $app->triggerEvent('socialProfilesGetPlugins');
     foreach ($profilePlugins as $plugin) {
         $pluginName = $plugin->getName();
         $settings = new JRegistry();
         $search = "profiles_" . $pluginName . "_";
         $stdFields = JRequest::getVar('profiles_' . $pluginName);
         $settings->loadArray($stdFields);
         foreach ($configs as $key => $value) {
             $pos = strpos($key, $search);
             if ($pos === 0) {
                 $key = str_replace($search, "", $key);
                 if (strpos($key, "field_map") != false) {
                     $key = str_replace("_field_map", ".", $key);
                     $settings->set('field_map.' . $key, $value);
                 }
             }
         }
         $model->update("profile_" . $pluginName, $settings->toString());
     }
     JFBCFactory::log(JText::_('COM_JFBCONNECT_MSG_SETTINGS_UPDATED'));
     $this->display();
 }
示例#5
0
文件: vk.php 项目: q0821/esportshop
 public function fetchStatus($providerUserId)
 {
     $status = "";
     $url = 'https://api.vk.com/method/wall.get';
     $url .= '?owner_id=' . $providerUserId;
     $url .= '&count=10&extended=0&filter=owner';
     try {
         $data = $this->provider->client->query($url);
         if ($data->code == 200) {
             $posts = json_decode($data->body, true);
             foreach ($posts['response'] as $post) {
                 if (is_array($post)) {
                     if ($post['post_type'] == 'post' && $post['text'] !== "") {
                         $status = $post['text'];
                         break;
                     }
                 }
             }
         }
     } catch (Exception $e) {
         if (JFBCFactory::config()->get('facebook_display_errors')) {
             JFBCFactory::log($e->getMessage());
         }
     }
     return $status;
 }
示例#6
0
 function apply()
 {
     $configs = JRequest::get('POST', 4);
     JFBCFactory::config()->saveSettings($configs);
     JFBCFactory::log(JText::_('COM_JFBCONNECT_MSG_SETTINGS_UPDATED'));
     $this->display();
 }
示例#7
0
 function display($tpl = null)
 {
     $configModel = JFBCFactory::config();
     if ($this->getLayout() == 'fbapp') {
         $appConfig = $this->get('mergedRecommendations');
         $this->assignRef('appConfig', $appConfig);
         $appConfigUpdated = $configModel->getUpdatedDate('autotune_app_config');
         $fieldsUpdated = $configModel->getUpdatedDate('autotune_field_descriptors');
         $this->assignRef('appConfigUpdated', $appConfigUpdated);
         $this->assignRef('fieldsUpdated', $fieldsUpdated);
         $subscriberId = $configModel->getSetting('sc_download_id', 'No ID Set!');
         $this->assignRef('subscriberId', $subscriberId);
     }
     $this->assignRef('config', $configModel);
     $this->addToolbar();
     parent::display($tpl);
     $atModel = $this->getModel('autotune');
     $subStatus = $atModel->getSubscriptionStatus();
     if ($subStatus) {
         $subStatus = $subStatus->messages;
         $this->assignRef('subStatus', $subStatus);
         $subStatusUpdated = $configModel->getUpdatedDate('autotune_authorization');
         $subStatusUpdated = strftime("%Y/%m/%d", strtotime($subStatusUpdated));
         $this->assignRef('subStatusUpdated', $subStatusUpdated);
         include 'tmpl/subscription_status.php';
     }
 }
示例#8
0
 public function ajaxAction()
 {
     JSession::checkToken('get') or die;
     $actionId = JRequest::getInt('action');
     $href = JRequest::getVar('href');
     $href = urldecode($href);
     $params = JRequest::getVar('params');
     if (is_array($params)) {
         foreach ($params as $key => $value) {
             $params[$key] = rawurldecode($value);
         }
     } else {
         $params = array();
     }
     JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_jfbconnect/models');
     $jfbcOgActionModel = JModelLegacy::getInstance('OpenGraphAction', 'JFBConnectModel');
     $action = $jfbcOgActionModel->getAction($actionId);
     $response = $jfbcOgActionModel->triggerAction($action, $href, $params);
     if ($response->status) {
         echo $response->message;
     } else {
         if (JFBCFactory::config()->getSetting('facebook_display_errors') && $response->message != "") {
             echo "Error: " . $response->message;
         }
     }
     exit;
 }
示例#9
0
 public function __construct($options = array())
 {
     $this->debug = intval(JFBCFactory::config()->get('facebook_display_errors'));
     $this->text_file = isset($options['text_file']) ? $options['text_file'] : $this->text_file;
     if ($this->debug) {
         JLog::addLogger(array('text_file' => $this->text_file), JLog::ALL, 'jfbconnect');
     }
 }
示例#10
0
 public function __construct()
 {
     $this->cache = JFactory::getCache('com_jfbconnect', '');
     // Only enable caching if Debug Mode is off
     $debug = JFBCFactory::config()->get('facebook_display_errors');
     $cacheTimeout = JFBCFactory::config()->get('cache_duration');
     $this->cache->setCaching(!$debug && $cacheTimeout != 0);
     $this->cache->setLifeTime($cacheTimeout);
 }
示例#11
0
 function display($tpl = null)
 {
     $model = JFBCFactory::config();
     $this->assignRef('model', $model);
     $filter_provider = JRequest::getVar('filter_provider');
     $this->assignRef('filter_provider', $filter_provider);
     $this->addToolbar();
     parent::display($tpl);
 }
示例#12
0
 public function formBind($name, $data = null)
 {
     if (!isset($this->forms[$name])) {
         return false;
     }
     if (!$data) {
         $data = JFBCFactory::config()->getSettings();
     }
     $this->forms[$name]->bind($data);
 }
示例#13
0
 private function checkAutotune()
 {
     // Saving an object or action
     $appConfig = JFBCFactory::config()->getSetting('autotune_app_config', array());
     $namespace = $appConfig['namespace'];
     if ($namespace == '') {
         return false;
     } else {
         return true;
     }
 }
示例#14
0
 public function getKeys()
 {
     $app = JFactory::getApplication();
     $jfb_params = JFBCFactory::config()->getSettings();
     $result = array();
     $result['fb_app_id'] = $jfb_params->get('facebook_app_id');
     $result['fb_app_key'] = $jfb_params->get('facebook_secret_key');
     $result['g_app_id'] = $jfb_params->get('google_app_id');
     $result['g_app_key'] = $jfb_params->get('google_secret_key');
     return $result;
 }
示例#15
0
 private function sendEmail($subject, $body)
 {
     $toname = JFBCFactory::config()->getSetting('social_notification_email_address');
     $toname = explode(',', $toname);
     // Don't send emails to no one :)
     if ($toname[0] == "") {
         return;
     }
     $app = JFactory::getApplication();
     $sitename = $app->getCfg('sitename');
     $mailfrom = $app->getCfg('mailfrom');
     $fromname = $app->getCfg('fromname');
     $subject = $subject . " - " . $sitename;
     JFactory::getMailer()->sendMail($mailfrom, $fromname, $toname, $subject, $body);
 }
示例#16
0
 public function fetchProfile($userId, $fields)
 {
     $profile = new JFBConnectProfileDataWindowsLive();
     $url = 'https://apis.live.net/v5.0/' . $userId;
     try {
         $jdata = $this->provider->client->query($url);
         if ($jdata->code == 200) {
             $data = json_decode($jdata->body, true);
             $profile->loadObject($data);
         }
     } catch (Exception $e) {
         if (JFBCFactory::config()->get('facebook_display_errors')) {
             JFBCFactory::log($e->getMessage());
         }
     }
     return $profile;
 }
示例#17
0
 function getRedirect()
 {
     $query = "SELECT r.destination_url rDestinationUrl, breakout_canvas FROM #__jfbconnect_request r INNER JOIN #__jfbconnect_notification n ON r.id = n.jfbc_request_id " . " WHERE n.fb_request_id IN (" . implode(', ', $this->_fbRequestIds) . ") ORDER BY n.created DESC LIMIT 1";
     $this->_db->setQuery($query);
     $data = $this->_db->loadObject();
     $redirectInfo = new stdClass();
     // Get Autotune settings to see if Canvas is enabled and if we should even check/use the breakout_canvas setting
     $autotune = JFBCFactory::config()->getSetting('autotune_app_config', null);
     if (empty($autotune)) {
         return null;
     }
     $appConfig = new JRegistry();
     $appConfig->loadArray($autotune);
     $canvasEnabled = $appConfig->get('canvas_url', null) != null && $appConfig->get('secure_canvas_url', null) != null ? true : false;
     $redirectInfo->breakout_canvas = $canvasEnabled && $data->breakout_canvas;
     $redirectInfo->destination_url = $data->rDestinationUrl;
     return $redirectInfo;
 }
示例#18
0
 public function fetchProfile($userId, $fields)
 {
     $profile = new JFBConnectProfileDataInstagram();
     $url = 'https://api.instagram.com/v1/users/' . $userId;
     // get the current user
     try {
         $jdata = $this->provider->client->query($url);
         if ($jdata->code == 200) {
             $data = json_decode($jdata->body, true);
             $profile->loadObject($data['data']);
         }
     } catch (Exception $e) {
         if (JFBCFactory::config()->get('facebook_display_errors')) {
             JFBCFactory::log($e->getMessage());
         }
     }
     return $profile;
 }
示例#19
0
 public function fetchProfile($user, $fields)
 {
     $profile = new JFBConnectProfileDataAmazon();
     $url = 'https://api.amazon.com/user/profile';
     // get the current user
     try {
         $jdata = $this->provider->client->query($url);
         $data = json_decode($jdata->body, true);
         if (is_array($data)) {
             $profile->loadObject($data);
         }
     } catch (Exception $e) {
         if (JFBCFactory::config()->get('facebook_display_errors')) {
             JFBCFactory::log($e->getMessage());
         }
     }
     return $profile;
 }
示例#20
0
 public function setupAuthentication()
 {
     $options = new JRegistry();
     $options->set('authurl', 'https://accounts.google.com/o/oauth2/auth');
     $options->set('tokenurl', 'https://accounts.google.com/o/oauth2/token');
     $scope = 'https://www.googleapis.com/auth/plus.me  https://www.googleapis.com/auth/plus.profile.emails.read';
     if (JFBCFactory::config()->getSetting('google_openid_fallback')) {
         $scope .= " email profile";
     }
     $options->set('scope', $scope);
     $this->client = new JFBConnectAuthenticationOauth2($options);
     $token = JFactory::getApplication()->getUserState('com_jfbconnect.' . strtolower($this->name) . '.token', null);
     if ($token) {
         $token = (array) json_decode($token);
         $this->client->setToken($token);
     }
     $this->client->initialize($this);
 }
示例#21
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     JPluginHelper::importPlugin('socialprofiles');
     $profilePlugins = $app->triggerEvent('socialProfilesGetPlugins');
     $this->assignRef('profilePlugins', $profilePlugins);
     foreach ($profilePlugins as $p) {
         $options = array();
         $options['control'] = "profiles_" . $p->getName();
         SCStringUtilities::loadLanguage('plg_socialprofiles_' . $p->getName(), JPATH_ADMINISTRATOR);
         $path = JPATH_SITE . '/plugins/socialprofiles/' . $p->getName();
         JForm::addFieldPath($path . '/fields/');
         $this->formLoad($p->getName(), $path . '/forms/config.xml', $options);
         $data = JFBCFactory::config()->get('profile_' . $p->getName());
         $reg = new JRegistry();
         $reg->loadString($data);
         $this->formBind($p->getName(), $reg);
     }
     parent::display($tpl);
 }
示例#22
0
 public function fetchProfile($userId, $fields)
 {
     if (!is_array($fields)) {
         $fields = array($fields);
     }
     if (in_array('first_name', $fields)) {
         $fields[] = 'first-name';
         unset($fields[array_search('first_name', $fields)]);
     }
     if (in_array('last_name', $fields)) {
         $fields[] = 'last-name';
         unset($fields[array_search('last_name', $fields)]);
     }
     if (in_array('full_name', $fields)) {
         $fields[] = 'first-name';
         $fields[] = 'last-name';
         unset($fields[array_search('full_name', $fields)]);
     }
     if (in_array('email', $fields)) {
         $fields[] = 'email-address';
         unset($fields[array_search('email', $fields)]);
     }
     if (in_array('middle_name', $fields)) {
         unset($fields[array_search('middle_name', $fields)]);
     }
     $fields = array_unique($fields);
     $profile = new JFBConnectProfileDataLinkedin();
     if (!empty($fields)) {
         $url = 'https://api.linkedin.com/v1/people/' . $userId . ':(' . implode(',', $fields) . ')';
         try {
             $data = $this->provider->client->query($url);
             $data = json_decode($data->body, true);
             $profile->loadObject($data);
         } catch (Exception $e) {
             if (JFBCFactory::config()->get('facebook_display_errors')) {
                 JFBCFactory::log($e->getMessage());
             }
         }
     }
     return $profile;
 }
示例#23
0
 function display($tpl = null)
 {
     JForm::addFieldPath(JPATH_ADMINISTRATOR . '/components/com_jfbconnect/models/fields');
     $this->formLoad('config', JPATH_ADMINISTRATOR . '/components/com_jfbconnect/models/forms/config.xml');
     $this->formBind('config', JFBCFactory::config()->getSettings());
     foreach (JFBCFactory::getAllProviders() as $p) {
         $configPath = JPATH_SITE . '/components/com_jfbconnect/libraries/provider/' . strtolower($p->systemName) . '/config/';
         JForm::addFieldPath($configPath . 'fields');
         $this->formLoad($p->systemName, $configPath . 'config.xml');
         $loginField = '<form>' . '<fieldset name="login_button" label="' . JText::_('COM_JFBCONNECT_PROVIDER_MENU_LOGIN_BUTTON') . '">' . '<field type="providerloginbutton"
                 label="' . JText::_('COM_JFBCONNECT_CONFIG_LOGIN_BUTTON_DEFAULT_LABEL') . '"
                 description="' . JText::_('COM_JFBCONNECT_CONFIG_LOGIN_BUTTON_DEFAULT_DESC') . '"
                 provider="' . $p->systemName . '"
                 name="' . $p->systemName . '_login_button"
                 required="true"
                 default="icon_label.png"
                 />' . '</fieldset>' . '</form>';
         $this->forms[$p->systemName]->load($loginField);
         $this->formBind($p->systemName, JFBCFactory::config()->getSettings());
     }
     parent::display($tpl);
 }
示例#24
0
 function display($tpl = null)
 {
     $model = JFBCFactory::model('updates');
     $downloadId = JFBCFactory::config()->get('sc_download_id');
     $xmlElement = simplexml_load_file(JPATH_ADMINISTRATOR . '/components/com_jfbconnect/jfbconnect.xml');
     if ($xmlElement) {
         $jfbcVersion = (string) $xmlElement->version;
     } else {
         $jfbcVersion = "Unknown. XML Manifest could not be read.";
     }
     $jfbcUpdateSite = $model->getUpdateSite();
     if (is_object($jfbcUpdateSite) && $jfbcUpdateSite->enabled) {
         $jfbcUpdateSiteEnabled = true;
     } else {
         $jfbcUpdateSiteEnabled = false;
     }
     $jfbcUpdate = $model->getJfbconnectUpdateId();
     $this->jfbcUpdateSiteEnabled = $jfbcUpdateSiteEnabled;
     $this->jfbcVersion = $jfbcVersion;
     $this->jfbcUpdate = $jfbcUpdate;
     $this->addToolbar();
     parent::display($tpl);
 }
示例#25
0
 public function callback()
 {
     $input = JFactory::getApplication()->input;
     // Have to do our own token checking here. Redirect shouldn't happen to normal users since token was just inserted
     // when they tried to authenticate
     $token = JSession::getFormToken();
     $returnToken = $input->get('state', '', 'alnum');
     if ($token != $returnToken) {
         $this->setRedirect('index.php', JText::_('JLIB_ENVIRONMENT_SESSION_EXPIRED'));
         $this->redirect();
     }
     $provider = $this->getProvider();
     try {
         $provider->client->authenticate();
     } catch (Exception $e) {
         JFBCFactory::log(JText::sprintf('COM_JFBCONNECT_UNABLE_TO_RETRIEVE_USER', ucwords($provider->name)), 'warning');
         if (JFBCFactory::config()->getSetting('facebook_display_errors')) {
             JFBCFactory::log($e->getMessage(), 'error');
         }
         $this->redirectOnFailedAuth();
     }
     $this->doLogin($provider);
 }
示例#26
0
 public function fetchProfile($userId, $fields = array(), $only = array())
 {
     if (!is_array($fields)) {
         $fields = array($fields);
     }
     $unsetFields = array('full_name', 'first_name', 'last_name', 'middle_name');
     foreach ($unsetFields as $unsetField) {
         if (in_array($unsetField, $fields)) {
             unset($fields[array_search($unsetField, $fields)]);
         }
     }
     $fields = array_unique($fields);
     $profile = new JFBConnectProfileDataMeetup();
     $url = 'https://api.meetup.com/2/member/' . $userId;
     if (!empty($fields)) {
         $url .= '?fields=' . implode(',', $fields);
     }
     if (!empty($only)) {
         if (!is_array($only)) {
             $only = array($only);
         }
         $only = array_unique($only);
         $url .= empty($fields) ? '?only=' . implode(',', $only) : '&only=' . implode(',', $only);
     }
     try {
         $jdata = $this->provider->client->query($url);
         if ($jdata->code == 200) {
             $data = json_decode($jdata->body, true);
             $profile->loadObject($data);
         }
     } catch (Exception $e) {
         if (JFBCFactory::config()->get('facebook_display_errors')) {
             JFBCFactory::log($e->getMessage());
         }
     }
     return $profile;
 }
示例#27
0
 function display($tpl = null)
 {
     $configModel = JFBCFactory::config();
     $usermapModel = JFBCFactory::usermap();
     $autotuneModel = JModelLegacy::getInstance('AutoTune', 'JFBConnectModel');
     if (JFBCFactory::provider('facebook')->appId) {
         $appConfig = JFBCFactory::config()->get('autotune_app_config', null);
         if (!$appConfig || count($appConfig) == 0) {
             JFBCFactory::log(JText::sprintf('COM_JFBCONNECT_MSG_RUN_AUTOTUNE', '<a href="index.php?option=com_jfbconnect&view=autotune">AutoTune</a>'), 'error');
         }
     }
     $userCounts = array();
     foreach (JFBCFactory::getAllProviders() as $p) {
         if ($p->appId) {
             $userCounts[$p->systemName] = $usermapModel->getTotalMappings($p->systemName);
         }
     }
     $this->configModel = $configModel;
     $this->autotuneModel = $autotuneModel;
     $this->usermapModel = $usermapModel;
     $this->userCounts = $userCounts;
     $this->addToolbar();
     parent::display($tpl);
 }
示例#28
0
 public function getData()
 {
     try {
         $key = strtolower($this->systemName) . '.' . strtolower($this->provider->systemName);
         $key .= '.' . strtolower(str_replace(' ', '_', $this->name)) . '.' . md5($this->options->toString());
         //add caching capability
         $this->response = JFBCFactory::cache()->get($key);
         if ($this->response === false) {
             $data = $this->query();
             if ($data->code == 200) {
                 $this->response = json_decode($data->body, true);
                 if (is_array($this->response)) {
                     $this->response = (object) $this->response;
                 }
                 // Perform the curl Request and get $response
                 JFBCFactory::cache()->store($this->response, $key);
             }
         }
     } catch (Exception $e) {
         if (JFBCFactory::config()->get('facebook_display_errors')) {
             JFBCFactory::log($e->getMessage());
         }
     }
 }
示例#29
0
 * @license         http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 * @version         Release v4.5.3
 * @build-date      2015/12/18
 */
defined('_JEXEC') or die('Restricted access');
if ($params->get('displayType') == 'modal') {
    $loginClass = "";
    $registerClass = "";
    $spacer = JText::_('MOD_SCLOGIN_LOGINREG_SEPARATOR');
    if ($params->get('modalButtonStyle') == 'button') {
        $loginClass = 'class="btn btn-primary"';
        $registerClass = 'class="btn"';
        $spacer = "";
    }
    if ($helper->isJFBConnectInstalled) {
        $modalName = JFBCFactory::config()->getSetting('jquery_load') ? 'sc-modal' : 'modal';
    } else {
        $modalName = $params->get('loadJQuery') ? 'sc-modal' : 'modal';
    }
    echo '<div class="sourcecoast sclogin-modal-links sclogin"><a ' . $loginClass . ' href="#login-modal" role="button" data-toggle="' . $modalName . '">' . JText::_('MOD_SCLOGIN_LOGIN') . '</a>';
    if ($showRegisterLinkInModal) {
        echo $spacer . '<a ' . $registerClass . ' href="' . $helper->registerLink . '">' . JText::_('MOD_SCLOGIN_REGISTER_FOR_THIS_SITE') . '</a>';
    }
    echo '</div>';
    ob_start();
}
?>

    <div class="sclogin sourcecoast" id="sclogin-<?php 
echo $module->id;
?>
示例#30
0
 public function fetchProfile($socialId, $fields)
 {
     if (!is_array($fields)) {
         $fields = array($fields);
     }
     $profile = new JFBConnectProfileDataGoogle();
     if (!empty($fields)) {
         // We must always implement calls for: id, first_name, last_name, full_name and email if the provider uses different terminology
         if (in_array('first_name', $fields)) {
             unset($fields[array_search('first_name', $fields)]);
             $fields[] = 'name';
         }
         if (in_array('middle_name', $fields)) {
             unset($fields[array_search('middle_name', $fields)]);
             $fields[] = 'name';
         }
         if (in_array('last_name', $fields)) {
             unset($fields[array_search('last_name', $fields)]);
             $fields[] = 'name';
         }
         if (in_array('full_name', $fields)) {
             unset($fields[array_search('full_name', $fields)]);
             $fields[] = 'displayName';
         }
         if (in_array('email', $fields)) {
             unset($fields[array_search('email', $fields)]);
             $fields[] = 'emails';
         }
         if (!empty($fields)) {
             $fields = array_unique($fields);
             try {
                 if ($this->provider->client->isAuthenticated()) {
                     $url = 'https://www.googleapis.com/plus/v1/people/' . $socialId;
                     $url .= '?fields=' . implode(',', $fields);
                     $jdata = $this->provider->client->query($url);
                     $data = json_decode($jdata->body, true);
                     $profile->loadArray($data);
                 }
             } catch (Exception $e) {
                 if (JFBCFactory::config()->getSetting('google_openid_fallback')) {
                     // Only time an exception should happen is if the user doesn't have a plus profile
                     $url = 'https://www.googleapis.com/oauth2/v3/userinfo';
                     //$url = 'https://www.googleapis.com/userinfo/email?alt=json';
                     $data = $this->provider->client->query($url);
                     $data = json_decode($data->body);
                     if (is_object($data)) {
                         if (isset($data->email)) {
                             $profile->set('email', $data->email);
                         } else {
                             // If no email is available, we're done.. bail now.
                             return $profile;
                         }
                         if (isset($data->sub)) {
                             $profile->set('id', $data->sub);
                         }
                         if (isset($data->name)) {
                             $profile->set('full_name', $data->name);
                         }
                         if (isset($data->family_name)) {
                             $profile->set('last_name', $data->family_name);
                         }
                         if (isset($data->given_name) && $data->given_name != '') {
                             $profile->set('first_name', $data->given_name);
                         } else {
                             // No given name, need to return something so Joomla doesn't choke
                             // In this case, we're just using their email handle (before the @) as their name. Not ideal, but it lets them register
                             $profile->set('first_name', substr($profile->get('email'), 0, strpos($profile->get('email'), '@')));
                             // If a name isn't set, then the 'name' field from Google is the email address.
                             // Can't use this as the full name or we'll have irate users.
                             $profile->set('full_name', $profile->get('first_name') . ' ' . $profile->get('last_name'));
                         }
                     }
                 } else {
                     //                        SCStringUtilities::loadLanguage('com_jfbconnect');
                     //                        JFBCFactory::log(JText::_("COM_JFBCONNECT_GOOGLE_NO_PLUS_PROFILE"), 'error');
                 }
             }
         }
     }
     return $profile;
 }