示例#1
0
 function save($data)
 {
     $oldData = array();
     if ($data['id'] > 0) {
         $table = $this->getTable();
         $table->load($data['id']);
         $oldData['id'] = $table->id;
         $oldData['provider'] = $table->provider;
         $oldData['type'] = $table->type;
         $oldData['attribs'] = (array) $table->attribs;
     }
     // Set the dates
     $date = JFactory::getDate();
     if ($data['id'] == 0) {
         $data['created'] = $date->toSql();
     }
     $data['modified'] = $date->toSql();
     if ($data['provider'] != '--' && $data['type'] != '--') {
         $channel = JFBCFactory::provider($data['provider'])->channel($data['type']);
         $data = $channel->onBeforeSave($data);
         // Manipulate the data however may be necessary
     }
     $return = parent::save($data);
     // Used to removed permissions from users that aren't associated with this channel (or anything else needed for cleanup)
     if ($return && $data['provider'] != '--' && $data['type'] != '--') {
         $data['id'] = $this->getState('channel.id');
         $channel->onAfterSave($data, $oldData);
     }
     return $return;
 }
示例#2
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);
 }
示例#3
0
 function getInput()
 {
     $jid = $this->form->getValue('attribs.user_id');
     if ($jid) {
         $uid = JFBCFactory::usermap()->getProviderUserId($jid, 'linkedin');
         if ($uid) {
             $access_token = JFBCFactory::usermap()->getUserAccessToken($jid, 'linkedin');
             $params['access_token'] = $access_token;
             $liLibrary = JFBCFactory::provider('linkedin');
             $liLibrary->client->setToken((array) $access_token);
             $url = 'https://api.linkedin.com/v1/companies/?is-company-admin=true&start=0&count=20';
             try {
                 $companies = $liLibrary->client->query($url);
                 if ($companies->code == '200') {
                     $this->companies = json_decode($companies->body);
                 }
                 return parent::getInput();
             } catch (Exception $e) {
                 return '<div class="jfbc-error">' . JText::_('COM_JFBCONNECT_CHANNEL_LINKEDIN_PERM_TOKEN_EXPIRED_LABEL') . '</div>';
             }
         } else {
             return '<div class="jfbc-error">' . JText::_('COM_JFBCONNECT_CHANNEL_LINKEDIN_PERM_USER_AUTH_ERROR_LABEL') . '</div>';
         }
     } else {
         return '<div class="jfbc-error">' . JText::_('COM_JFBCONNECT_CHANNEL_SELECT_USER_ERROR_LABEL') . '</div>';
     }
 }
示例#4
0
 function requestSent()
 {
     $jfbcRequestId = JRequest::getInt('jfbcId');
     $fbRequestId = JRequest::getString('requestId');
     $inToList = JRequest::getVar('to');
     // Get the from user id from the request
     $to = $inToList[0];
     $requestInfo = JFBCFactory::provider('facebook')->api('/' . $fbRequestId . "_" . $to);
     $fbFrom = $requestInfo['from']['id'];
     // Not using the model, as we're doing a simple store.
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_jfbconnect/tables');
     $data = array();
     $data['fb_request_id'] = $fbRequestId;
     $data['fb_user_from'] = $fbFrom;
     $data['jfbc_request_id'] = $jfbcRequestId;
     $data['created'] = JFactory::getDate()->toSql();
     $data['modified'] = null;
     //        $data['destination_url'] = JRequest::getString('destinationUrl');
     foreach ($inToList as $fbTo) {
         $row =& JTable::getInstance('JFBConnectNotification', 'Table');
         $to = JFilterInput::clean($fbTo, 'ALNUM');
         $data['fb_user_to'] = $to;
         $row->save($data);
         $point = new JFBConnectPoint();
         $point->set('name', 'facebook.request.create');
         $point->set('key', $to);
         $point->award();
     }
     $app = JFactory::getApplication();
     $app->close();
 }
示例#5
0
 protected function getInput()
 {
     $html = array();
     $provider = $this->element['provider'] ? (string) $this->element['provider'] : null;
     $style = $this->element['style'] ? (string) $this->element['style'] . '"' : '';
     // Initialize some field attributes.
     $class = !empty($this->class) ? ' class="radio ' . $this->class . '"' : ' class="radio"';
     $required = $this->required ? ' required aria-required="true"' : '';
     $autofocus = $this->autofocus ? ' autofocus' : '';
     $disabled = $this->disabled ? ' disabled' : '';
     $readonly = $this->readonly;
     $style = 'style="float:left;' . $style . '"';
     $html[] = '<div style="clear: both"> </div>';
     // Start the radio field output.
     $html[] = '<fieldset id="' . $this->id . '"' . $class . $required . $autofocus . $disabled . $style . ' >';
     // Get the field options.
     $options = $this->getOptions();
     $p = JFBCFactory::provider($provider);
     // Build the radio field output.
     $html[] = '<label class="providername">' . $p->name . '</label>';
     foreach ($options as $i => $option) {
         // Initialize some option attributes.
         $checked = (string) $option->value == (string) $this->value ? ' checked="checked"' : '';
         $class = !empty($option->class) ? ' class="' . $option->class . '"' : '';
         $disabled = !empty($option->disable) || $readonly && !$checked;
         $disabled = $disabled ? ' disabled' : '';
         $html[] = '<input type="radio" id="' . $this->id . $i . '" name="' . $this->name . '" value="' . htmlspecialchars($option->value, ENT_COMPAT, 'UTF-8') . '"' . $checked . $class . $required . $disabled . ' />';
         $html[] = '<label for="' . $this->id . $i . '"' . $class . ' >' . '<img src="' . JUri::root() . 'media/sourcecoast/images/provider/' . $provider . '/' . $option->value . '" />' . '</label>' . ($required = '');
     }
     // End the radio field output.
     $html[] = '</fieldset>';
     $html[] = '<div style="clear: both"> </div>';
     return implode($html);
 }
示例#6
0
 public function post()
 {
     $app = JFactory::getApplication();
     //$type = $app->input->get('type','story','STRING');
     $provider_nm = $app->input->get('provider', 'facebook', 'CMD');
     $user_id = $app->input->get('user_id', 0, 'INT');
     $tokan = $app->input->get('tokan', 0, 'RAW');
     $email = $app->input->get('email', '', 'STRING');
     $password = $app->input->get('password', '', 'STRING');
     //$log_usr = $this->plugin->get('user')->id;
     $provider = JFBCFactory::provider($provider_nm);
     $provider->client->authenticate();
     $loginRegisterModel = JFBCFactory::model('LoginRegister');
     //$user = jFactory::getUser(161);
     $provider->setSessionToken();
     $provider->client->setExtendedAccessToken();
     //$provider_obj->client->getUser();
     $provider->onBeforeLogin();
     $config = JFactory::getConfig();
     $lifetime = $config->get('lifetime', 15);
     setcookie('jfbconnect_autologin_disable', 1, time() + $lifetime * 60);
     $providerUserId = $provider->getProviderUserId();
     $userMapModel = JFBCFactory::usermap();
     $jUserId = $userMapModel->getJoomlaUserId($providerUserId, strtolower($provider->name));
     $jUserEmailId = $userMapModel->getJoomlaUserIdFromEmail($email);
     //get temp id
     if ($jUserEmailId) {
         $providerUserId = $userMapModel->getProviderUserId($jUserEmailId, strtolower($provider->name));
         $jUserId = $userMapModel->getJoomlaUserId($providerUserId, strtolower($provider->name));
     } else {
         if (!$jUserEmailId && JFBCFactory::config()->getSetting('automatic_registration')) {
             //# User is not in system, should create their account automatically
             //$jUserEmailId = $userMapModel->getJoomlaUserIdFromEmail($email);
             if (!$jUserEmailId) {
                 $pdata = array();
                 $pdata['email'] = $email;
                 $pdata['password'] = $password;
                 $fbuser = $loginRegisterModel->createNewUser($provider);
             }
             if ($loginRegisterModel->autoCreateUser($providerUserId, $provider)) {
                 $jUserId = $userMapModel->getJoomlaUserId($providerUserId, strtolower($provider->name));
             }
         }
     }
     $jUser = JUser::getInstance($jUserId);
     $loginSuccess = false;
     // Try to log the user, but not if blocked and initial registration (then there will be a pretty message on how to activate)
     if (!$provider->initialRegistration || $jUser->get('block') == 0 && $provider->initialRegistration) {
         $options = array('silent' => 1, 'provider' => $provider, 'provider_user_id' => $providerUserId);
         // Disable other authentication messages
         // hack for J3.2.0 bug. Should remove after 3.2.1 is available.
         $password = $provider->secretKey;
         $loginSuccess = $app->login(array('username' => $provider->appId, 'password' => $password), $options);
     }
     $this->plugin->setResponse($jUser);
 }
示例#7
0
 private function getProvider()
 {
     $input = JFactory::getApplication()->input;
     $provider = $input->getCmd('provider', null);
     if ($provider) {
         return JFBCFactory::provider($provider);
     }
     // No provider given, not a real call. Redirect to home
     $this->setRedirect('index.php');
 }
示例#8
0
 function onUserLogout($user, $options = array())
 {
     // Disable auto-logins for session length after a logout. Prevents auto-logins
     $config = JFactory::getConfig();
     $lifetime = $config->get('lifetime', 15);
     setcookie('jfbconnect_autologin_disable', 1, time() + $lifetime * 60);
     setcookie('jfbconnect_permissions_granted', '', time() - 10000, "/");
     // clear the granted permissions cookie
     // Tell Facebook to delete session information stored for this user.
     JFBCFactory::provider('facebook')->client->destroySession();
     return true;
 }
示例#9
0
文件: page.php 项目: q0821/esportshop
 public function canPublish($data)
 {
     $canPublish = false;
     $jid = $data['attribs']['user_id'];
     if ($jid) {
         $uid = JFBCFactory::usermap()->getProviderUserId($jid, 'facebook');
         if ($uid && isset($data['attribs']['page_id']) && $data['attribs']['page_id'] != '--' && JFBCFactory::provider('facebook')->hasScope($uid, 'manage_pages') && (JFBCFactory::provider('facebook')->hasScope($uid, 'publish_actions') || !$data['attribs']['allow_posts'])) {
             $canPublish = true;
         }
     }
     return $canPublish;
 }
示例#10
0
 public static function setupCanvasProperties()
 {
     $jfbcLibrary = JFBCFactory::provider('facebook');
     $canvasProperties = new JObject();
     $appId = $jfbcLibrary->appId;
     if ($appId) {
         $params = "?fields=canvas_url,secure_canvas_url,page_tab_default_name,page_tab_url,secure_page_tab_url,namespace,website_url,canvas_fluid_height,canvas_fluid_width";
         $appProps = $jfbcLibrary->api($appId . $params, null, FALSE);
         $canvasProperties->setProperties($appProps);
     }
     return $canvasProperties;
 }
示例#11
0
文件: ajax.php 项目: q0821/esportshop
 public function places()
 {
     JSession::checkToken('get') or die;
     $search = JRequest::getString('q', '');
     $params = array('type' => 'place', 'fields' => 'id,name,location,picture,were_here_count,is_published,link', 'q' => trim($search));
     $center = JRequest::getVar('center');
     if ($center) {
         $params['center'] = trim($center);
         $params['distance'] = 1000;
     }
     $results = JFBCFactory::provider('facebook')->api('search', $params, true, 'GET');
     $results = $results['data'];
     $clean_results = array();
     foreach ($results as $result) {
         if (!(isset($result['is_published']) && $result['is_published'] && isset($result['id']) && $result['id'] && isset($result['name']) && $result['name'])) {
             continue;
         }
         $clean_result = array('label' => trim($result['name']), 'value' => $result['id'], 'link' => $result['link']);
         // build location components for use in place summary
         if (isset($result['location'])) {
             $location = array();
             if (isset($result['location']['street']) && $result['location']['street']) {
                 $location['street'] = trim($result['location']['street']);
             }
             if (isset($result['location']['city']) && $result['location']['city'] && isset($result['location']['state']) && $result['location']['state']) {
                 $location['area'] = trim($result['location']['city'] . ', ' . $result['location']['state']);
             } else {
                 if (isset($result['location']['state']) && $result['location']['state'] && isset($result['location']['country']) && $result['location']['country']) {
                     $location['area'] = trim($result['location']['state'] . ', ' . $result['location']['country']);
                 } else {
                     if (isset($result['location']['country']) && $result['location']['country']) {
                         $location['area'] = trim($result['location']['country']);
                     }
                 }
             }
             if (!empty($location)) {
                 $clean_result['location'] = $location;
             }
             unset($location);
         }
         if (isset($result['were_here_count']) && $result['were_here_count']) {
             $clean_result['were_here_count'] = (int) $result['were_here_count'];
         }
         if (isset($result['picture']['data']['url']) && $result['picture']['data']['url']) {
             $clean_result['picture'] = $result['picture']['data']['url'];
         }
         $clean_results[] = $clean_result;
         unset($clean_result);
     }
     echo json_encode($clean_results);
     JFactory::getApplication()->close(0);
 }
示例#12
0
文件: ajax.php 项目: q0821/esportshop
 public function channelGetOutboundChannels()
 {
     $input = JFactory::getApplication()->input;
     $p = $input->getString('provider');
     $options = array();
     $options[] = JHtml::_('select.option', "--", "-- Select a Channel --");
     $provider = JFBCFactory::provider($p);
     $channels = $provider->getChannelsOutbound();
     foreach ($channels as $c) {
         $options[] = JHtml::_('select.option', strtolower($c->name), $c->name);
     }
     echo JHTML::_('select.genericlist', $options, 'jform[type]', 'onchange="jfbcAdmin.channels.outbound.fetchChannelSettings(this.value);"', 'value', 'text', '--', 'jform_type');
     exit;
 }
示例#13
0
 public function addChannel($channel)
 {
     $channelId = trim($channel);
     $row = JTable::getInstance('Channel', 'Table');
     $row->load($channelId);
     if ($row->published) {
         $options = new JRegistry();
         $options->loadObject($row->attribs);
         $channel = JFBCFactory::provider($row->provider)->channel($row->type, $options);
         // This is a bit hacky as we're temporarily saving the row to use in the addPost. Should be handling this better.
         $this->currentRow = $row;
         $channel->getStream($this);
     }
 }
示例#14
0
 protected function getOptions()
 {
     $options = array();
     $options[] = JHtml::_('select.option', "--", "-- Select a Channel --");
     $p = $this->form->getValue('provider');
     if ($p && $p != '--') {
         $provider = JFBCFactory::provider($p);
         $channels = $provider->getChannelsOutbound();
         foreach ($channels as $c) {
             $options[] = JHtml::_('select.option', strtolower($c->name), $c->name);
         }
     }
     return $options;
 }
示例#15
0
 function deauthorizeUser()
 {
     $fbClient = JFBCFactory::provider('facebook')->getFbClient();
     $signedRequest = JRequest::getString('signed_request', null, 'POST');
     if ($signedRequest) {
         $parsed = $fbClient->parseSignedRequest($signedRequest);
         $fbUserId = $parsed['user_id'];
         if ($fbUserId) {
             JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_jfbconnect/' . 'models');
             $userModel = JModelLegacy::getInstance('UserMap', 'JFBConnectModel');
             $userModel->setAuthorized($fbUserId, '0');
         }
     }
     exit;
 }
示例#16
0
 private function userHasToken($jid)
 {
     $access_token = JFBCFactory::usermap()->getUserAccessToken($jid, 'linkedin');
     $params['access_token'] = $access_token;
     $liLibrary = JFBCFactory::provider('linkedin');
     $liLibrary->client->setToken((array) $access_token);
     $url = 'https://api.linkedin.com/v1/companies/?is-company-admin=true&start=0&count=20';
     try {
         $companies = $liLibrary->client->query($url);
         if ($companies->code == '200') {
             $this->companies = json_decode($companies->body);
         }
         return true;
     } catch (Exception $e) {
         return false;
     }
     return true;
 }
示例#17
0
 function __construct(&$subject, $config)
 {
     $this->pluginName = $config['name'];
     $this->extensionName = $config['name'];
     // Should be overridden by the plugin itself.
     if (class_exists('JFBConnectFacebookLibrary')) {
         JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_jfbconnect/models');
         $this->jfbcOgActionModel = JModelLegacy::getInstance('OpenGraphAction', 'JFBConnectModel');
         $this->jfbcOgObjectModel = JModelLegacy::getInstance('OpenGraphObject', 'JFBConnectModel');
         $this->jfbcLibrary = JFBCFactory::provider('facebook');
     }
     if (class_exists('OpenGraphLibrary')) {
         $this->openGraphLibrary = OpenGraphLibrary::getInstance();
     }
     $this->hasDefaultTags = false;
     $this->db = JFactory::getDBO();
     parent::__construct($subject, $config);
     $this->init();
 }
示例#18
0
 public function loginMap()
 {
     JRequest::checkToken('post') or jexit(JText::_('JInvalid_Token'));
     $app = JFactory::getApplication();
     $provider = JFactory::getApplication()->input->getCmd('provider');
     $provider = JFBCFactory::provider($provider);
     SCSocialUtilities::setJFBCNewMappingEnabled();
     $loginRegisterModel = $this->getModel('LoginRegister', 'JFBConnectModel');
     $redirect = $loginRegisterModel->getLoginRedirect($provider);
     $returnParam = '&return=' . base64_encode($redirect);
     $providerUserId = $provider->getProviderUserId();
     if (!$providerUserId) {
         $app->redirect(JRoute::_('index.php?option=com_jfbconnect&view=loginregister&provider=' . $provider->systemName . $returnParam, false));
     }
     // Populate the data array:
     $data = array();
     $data['username'] = JRequest::getVar('username', '', 'method', 'username');
     $data['password'] = JRequest::getString('password', '', 'post', 'string', JREQUEST_ALLOWRAW);
     // Perform the log in.
     $error = $app->login($data);
     // Check if the log in succeeded.
     if (JError::isError($error) || $error == false) {
         $app->redirect(JRoute::_('index.php?option=com_jfbconnect&view=loginregister&provider=' . $provider->systemName . $returnParam, false));
     } else {
         $jUser = JFactory::getUser();
         if (JFBCFactory::usermap()->map($jUser->get('id'), $providerUserId, $provider->systemName, $provider->client->getToken())) {
             JFBCFactory::log(JText::sprintf('COM_JFBCONNECT_MAP_USER_SUCCESS', $provider->name));
         }
         /* Don't import on just a mapping update, for now. Need to investigate.
                     $jUser = JFactory::getUser();
                     $jfbcLibrary = JFBConnectFacebookLibrary::getInstance();
                     $fbUserId = $jfbcLibrary->getMappedFbUserId();
                     $args = array($jUser->get('id'), $fbUserId);
         
                     JPluginHelper::importPlugin('jfbcprofiles');
                     $app->triggerEvent('scProfilesImportProfile', $args);
                     JFBCFactory::log('Profile Imported!');*/
         JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_jfbconnect/' . 'models');
         $loginRegisterModel = JModelLegacy::getInstance('LoginRegister', 'JFBConnectModel');
         $redirect = $loginRegisterModel->getLoginRedirect($provider);
         $app->redirect($redirect);
     }
 }
示例#19
0
 function getInput()
 {
     $jid = $this->form->getValue('attribs.user_id');
     if ($jid) {
         $uid = JFBCFactory::usermap()->getProviderUserId($jid, 'facebook');
         if ($uid) {
             if (!JFBCFactory::provider('facebook')->hasScope($uid, 'user_managed_groups')) {
                 return '<div class="jfbc-error">' . JText::_('COM_JFBCONNECT_CHANNEL_FACEBOOK_PERM_USER_GROUPS_ERROR_LABEL') . '</div>';
             } else {
                 if (!JFBCFactory::provider('facebook')->hasScope($uid, 'publish_actions') && $this->form->getValue('attribs.allow_posts')) {
                     return '<div class="jfbc-error">' . JText::_('COM_JFBCONNECT_CHANNEL_FACEBOOK_PERM_PUBLISH_ACTIONS_ERROR_LABEL') . '</div>';
                 } else {
                     return parent::getInput();
                 }
             }
         } else {
             return '<div class="jfbc-error">' . JText::_('COM_JFBCONNECT_CHANNEL_FACEBOOK_PERM_PAGE_USER_AUTH_ERROR_LABEL') . '</div>';
         }
     } else {
         return '<div class="jfbc-error">' . JText::_('COM_JFBCONNECT_CHANNEL_SELECT_USER_ERROR_LABEL') . '</div>';
     }
 }
示例#20
0
 private function isRender($article, $context, $params)
 {
     if (!class_exists('JFBCFactory')) {
         return false;
     }
     $this->app = JFactory::getApplication();
     //only render in the frontend/site
     if ($this->app->isAdmin()) {
         return false;
     }
     //Get Social RenderKey
     $jfbcLibrary = JFBCFactory::provider('facebook');
     $renderKey = $jfbcLibrary->getSocialTagRenderKey();
     if ($renderKey) {
         $this->renderKeyString = " key=" . $renderKey;
     }
     $this->configModel = $jfbcLibrary->getConfigModel();
     $this->option = $this->app->input->getCmd('option');
     $this->view = $this->app->input->getCmd('view');
     //Don't show when printing
     $template = $this->app->input->getCmd('tmpl');
     $printing = $this->app->input->getInt('print', 0);
     if ($printing && $template == 'component') {
         return false;
     }
     switch ($this->option) {
         case "com_content":
             $result = $this->isRenderContent($article, $context, $params);
             break;
         case "com_k2":
             $this->isJoomla = false;
             $result = $this->isRenderK2($article, $context, $params);
             break;
         default:
             $result = true;
             break;
     }
     return $result;
 }
示例#21
0
 private function getSelectedProviders($providerList)
 {
     if (!is_array($providerList)) {
         $providerList = str_replace("\r\n", ",", $providerList);
         $providerList = explode(',', $providerList);
     }
     $providers = array();
     foreach ($providerList as $p) {
         if ($p) {
             $providers[] = JFBCFactory::provider(trim($p));
         }
     }
     //For backwards compatibility:
     // - For Facebook, if no providers are specified, then show all providers
     // - For Others, if no providers are specified, just show the login button for that provider
     if (empty($providers)) {
         if ($this->provider->name == 'Facebook') {
             $providers = JFBCFactory::getAllProviders();
         } else {
             $providers[] = $this->provider;
         }
     }
     return $providers;
 }
示例#22
0
 public function checkForNotification()
 {
     $fbRequestIds = JRequest::getVar('request_ids');
     if ($fbRequestIds == "" || $fbRequestIds == null) {
         return;
     }
     JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_jfbconnect/' . 'models');
     $notificationModel = JModelLegacy::getInstance('Notification', 'JFBConnectModel');
     // Check for a signed request. This gives us more information about who is coming from Facebook, but only exists on SSL connections
     $request = JRequest::getString('signed_request', null, 'POST');
     if ($request) {
         $request = JFBCFactory::provider('facebook')->client->parseSignedRequest($request);
         if (array_key_exists('user_id', $request)) {
             $notificationModel->setFbUserId($request['user_id']);
         }
     }
     // Next, find the most recent (local) request, and take action on it.
     $notificationModel->setFbRequestIds($fbRequestIds);
     // First, delete all requests on Facebook, if possible. If no Signed Request or user hasn't approved app, we can't do this (Facebook won't allow it)
     foreach ($notificationModel->getRequestsToDelete() as $sig) {
         JFBCFactory::provider('facebook')->api('/' . $sig, null, false, 'DELETE');
     }
     // Mark all notifications as 'read'
     $notificationModel->markAsRead();
     // Get the request information from the last request sent
     $redirectInfo = $notificationModel->getRedirect();
     if ($redirectInfo && $redirectInfo->destination_url) {
         $app = JFactory::getApplication();
         if (!$redirectInfo->breakout_canvas) {
             $app->redirect($redirectInfo->destination_url);
         } else {
             echo "<html><head></head><body><script type='text/javascript'>top.location.href='" . $redirectInfo->destination_url . "'</script></body></html>";
             $app->close();
         }
     }
 }
示例#23
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);
 }
示例#24
0
 private function parseSignedRequest()
 {
     $jSession = JFactory::getSession();
     // For our detection of canvas or tab integration, we only look at the query string (not the cookie!)
     $request = JRequest::getString('signed_request', null, 'POST');
     if ($request) {
         $request = JFBCFactory::provider('facebook')->client->parseSignedRequest($request);
         // Check if this is the first load from FB, and set up our session vars
         if (is_array($request)) {
             $jSession->set('jfbcCanvasEnabled', true);
             if (isset($request['page'])) {
                 $jSession->set('jfbcCanvasInTab', true);
                 $jSession->set('jfbcCanvasInCanvas', false);
             } else {
                 $jSession->set('jfbcCanvasInCanvas', true);
                 $jSession->set('jfbcCanvasInTab', false);
             }
             return true;
             // We are definitely inside FB
         }
     }
     return $jSession->get('jfbcCanvasEnabled', false);
     // Return session state for if in canvas or not
 }
示例#25
0
文件: post.php 项目: q0821/esportshop
 public function ajaxCreatePost()
 {
     if (JFactory::getUser()->authorise('jfbconnect.channels.post', 'com_jfbconnect')) {
         $response = array();
         $input = JFactory::getApplication()->input;
         $message = $input->post->getString('message');
         $link = $input->post->getString('link');
         $cids = $input->post->get('cids', array(), 'array');
         if (empty($cids)) {
             $response[] = JText::_('COM_JFBCONNECT_CHANNELS_SELECT_CHANNEL_LABEL');
         }
         JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_jfbconnect/tables/');
         $row = JTable::getInstance('Channel', 'Table');
         foreach ($cids as $cid) {
             $row->load($cid);
             $options = new JRegistry();
             $options->loadObject($row->attribs);
             $channel = JFBCFactory::provider($row->provider)->channel($row->type, $options);
             $post = new JRegistry();
             $post->set('message', $message);
             $post->set('link', $link);
             try {
                 $return = $channel->post($post);
             } catch (Exception $e) {
                 $return = false;
             }
             if (!$return) {
                 $response[] = JText::sprintf('COM_JFBCONNECT_CHANNELS_POST_FAILED_LABEL', $row->provider, $row->type);
             } else {
                 $response[] = $return;
             }
         }
         echo implode("<br/>", $response);
     }
     exit;
 }
示例#26
0
 * @version         Release v6.4.2
 * @build-date      2015/08/24
 */
// no direct access
defined('_JEXEC') or die('Restricted access');
jimport('joomla.filesystem.file');
$jfbcLibraryFile = JPATH_ROOT . '/components/com_jfbconnect/libraries/facebook.php';
if (!JFile::exists($jfbcLibraryFile)) {
    echo "JFBConnect not found. Please reinstall.";
    return;
}
require_once $jfbcLibraryFile;
require_once dirname(__FILE__) . '/helper.php';
$helper = new modJFBCSocialShareHelper($params);
$fbClient = JFBConnectFacebookLibrary::getInstance();
$fbAppId = JFBCFactory::provider('facebook')->appId;
$renderKey = $fbClient->getSocialTagRenderKey();
$renderKeyString = " key=" . $renderKey;
//General
$url = $params->get('url');
$href = '';
if (!$url) {
    $url = SCSocialUtilities::getStrippedUrl();
}
if ($url) {
    $href = ' href=' . $url;
}
$layout = $params->get('layout_style');
$orientation = $params->get('orientation');
$position = $params->get('position');
$margin = $params->get('margin');
示例#27
0
?>
<div>
    <div class="config_setting header config_row" style="width:250px"><?php 
echo JText::_('COM_JFBCONNECT_CANVAS_PAGE_TAB_CONFIG_STATUS');
?>
</div>
    <div style="clear:both"></div>
    <div class="config_row">
        <?php 
if ($tabReady) {
    ?>
            <?php 
    echo JText::_('COM_JFBCONNECT_CANVAS_PAGE_TAB_CONFIG_DESC');
    ?>
            <a href="https://www.facebook.com/dialog/pagetab?app_id=<?php 
    echo JFBCFactory::provider('facebook')->appId;
    ?>
&display=popup&next=<?php 
    echo $websiteUrl;
    ?>
"
               target="_BLANK"><?php 
    echo JText::_('COM_JFBCONNECT_CANVAS_PAGE_TAB_CONFIG_DESC1');
    ?>
</a>
        <?php 
} else {
    ?>
            <?php 
    echo JText::_('COM_JFBCONNECT_CANVAS_PAGE_TAB_CONFIG_DESC2');
    ?>
示例#28
0
 private function replaceGraphTags()
 {
     $placeholder = '<SCOpenGraphPlaceholder />';
     $regex1 = '/\\{SCOpenGraph\\s+(.*?)\\}/i';
     $regex2 = '/\\{JFBCGraph\\s+(.*?)\\}/i';
     $newGraphTags1 = array();
     $newGraphTags2 = array();
     $contents = JResponse::getBody();
     $this->getGraphContents($regex1, $contents, $newGraphTags1);
     $this->getGraphContents($regex2, $contents, $newGraphTags2);
     $newGraphTags = array_merge($newGraphTags1, $newGraphTags2);
     //Replace Placeholder with new Head tags
     $defaultGraphFields = JFBCFactory::config()->getSetting('social_graph_fields');
     $skipGraphFields = JFBCFactory::config()->getSetting('social_graph_skip_fields');
     $locale = JFBCFactory::provider('facebook')->getLocale();
     $openGraphLibrary = OpenGraphLibrary::getInstance();
     $openGraphLibrary->addBlockedTags($skipGraphFields);
     $openGraphLibrary->addOpenGraphEasyTags($newGraphTags);
     $openGraphLibrary->addDefaultSettingsTags($defaultGraphFields);
     $openGraphLibrary->addAutoGeneratedTags($locale);
     $graphTags = $openGraphLibrary->buildCompleteOpenGraphList();
     $contents = $openGraphLibrary->removeOverlappingTags($contents);
     $search = '/' . preg_quote($placeholder, '/') . '/';
     $graphTags = str_replace('$', '\\$', $graphTags);
     $contents = preg_replace($search, $graphTags, $contents, 1);
     $contents = str_replace($placeholder, '', $contents);
     //If JLinked attempts to insert, ignore
     JResponse::setBody($contents);
 }
示例#29
0
                                <div class="span12">
                                    <img src="<?php 
        echo JURI::root() . 'media/sourcecoast/images/provider/' . $p . '/icon.png';
        ?>
" /> <span
                                        style="margin-left:8px; font-size:14px"><a
                                            href="index.php?option=com_jfbconnect&view=usermap&provider=<?php 
        echo $p;
        ?>
"><?php 
        echo $count;
        ?>
                                            Users</a></span>
                                    <?php 
        if ($p == 'facebook') {
            echo '<span style="margin-left:8px; font-size:12px"><a target="_BLANK" href="http://www.facebook.com/insights/?sk=ao_' . JFBCFactory::provider('facebook')->appId . '">' . JText::_('COM_JFBCONNECT_OVERVIEW_FB_INSIGHTS_LABEL') . '</a></span>';
        }
        ?>
                                </div>
                            </div>
                        <?php 
    }
}
?>
                </div>
                <?php 
if (!empty($feed)) {
    ?>
                    <div class="well well-small"><?php 
    echo $feed;
    ?>
示例#30
0
 static function clearJFBCNewMappingEnabled()
 {
     $jfbcLibrary = JFBCFactory::provider('facebook');
     $session = JFactory::getSession();
     $session->clear(CHECK_NEW_MAPPING_JFBCONNECT);
     $jfbcLibrary->checkNewMapping = false;
 }