function display($tpl = null) { $user = JFactory::getUser(); $providers = JFBCFactory::getAllProviders(); $providerData = array(); foreach ($providers as $provider) { if ($provider->appId && $provider->secretKey) { $userModel = JFBConnectModelUserMap::getUser($user->get('id'), $provider->systemName); $userData = $userModel->getData(); $providerInfo = new stdClass(); $providerInfo->profileUrl = $userData->params->get('data.profile_url'); if (empty($providerInfo->profileUrl)) { //JOOMLA 2.5 $providerInfo->profileUrl = $userData->params->get('profile_url'); } $providerInfo->isMapped = $userData->provider != null; $providerInfo->name = $provider->name; $providerInfo->provider = $provider; $providerInfo->systemName = $provider->systemName; $providerData[$provider->name] = $providerInfo; } } $this->providerData = $providerData; JFBCFactory::addStylesheet('jfbconnect.css'); parent::display($tpl); }
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); }
function getFeed() { $feedHtml = JFBCFactory::cache()->get('sourcecoast.rss'); if ($feedHtml === false) { $curl = curl_init(); curl_setopt_array($curl, array(CURLOPT_URL => 'http://feeds.sourcecoast.com/sourcecoast-blog', CURLOPT_USERAGENT => 'spider', CURLOPT_TIMEOUT => 120, CURLOPT_CONNECTTIMEOUT => 30, CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_ENCODING => 'UTF-8')); $data = curl_exec($curl); $errorCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); curl_close($curl); if ($data && !empty($data) && $errorCode == 200) { $xml = simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA); if ($xml) { $feedHtml = '<h4>Recent News from SourceCoast</h4>'; for ($i = 0; $i < 4; $i++) { if (isset($xml->channel->item[$i])) { $item = $xml->channel->item[$i]; $date = JFactory::getDate($item->pubDate); $dateStr = $date->format(JText::_('DATE_FORMAT_LC4')); $feedHtml .= '<p><a href="' . $item->link . '">' . $item->title . '</a> <span><em>' . $dateStr . '</em></span></p>'; } } } } JFBCFactory::cache()->store($feedHtml, 'sourcecoast.rss'); } return $feedHtml; }
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; }
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'); } } }
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(); }
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'; } }
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); }
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(); }
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>'; } }
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); }
function display($tpl = null) { $actionModel = $this->getModel('OpenGraphAction', 'JFBConnectModel'); $activityModel = $this->getModel('OpenGraphActivity', 'JFBConnectModel'); $objectModel = $this->getModel('OpenGraphObject', 'JFBConnectModel'); $user = JFactory::getUser(); if ($this->getLayout() == 'activity') { $activityModel->setUserId($user->get('id')); $rows = $activityModel->getActivityForUser(); $this->rows = $rows; $this->actionModel = $actionModel; $this->objectModel = $objectModel; $pagination = $activityModel->getPagination(); $this->pagination = $pagination; } else { if ($this->getLayout() == 'settings') { $user = JFactory::getUser(); $userModel = JFBConnectModelUserMap::getUser($user->get('id'), 'facebook'); $userData = $userModel->getData(); $actionsDisabled = $userData->params->get('og_actions_disabled'); $this->actionsDisabled = $actionsDisabled; $actionModel = $this->getModel('OpenGraphAction', 'JFBConnectModel'); $actions = $actionModel->getActions(true); $editableActions = array(); foreach ($actions as $action) { if ($action->can_disable) { $editableActions[] = $action; } } $this->actions = $editableActions; } } JFBCFactory::addStylesheet('jfbconnect.css'); parent::display($tpl); }
public function register($data = null) { //require_once (JPATH_COMPONENT.'/libraries/profile.php'); $mainframe = JFactory::getApplication(); $my = CFactory::getUser(); $config = CFactory::getConfig(); /** * Opengraph */ CHeadHelper::setType('website', JText::_('COM_COMMUNITY_REGISTER_NEW')); // Hide this form for logged in user if ($my->id) { $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_REGISTER_ALREADY_USER'), 'warning'); return; } // If user registration is not allowed, show 403 not authorized. $usersConfig = JComponentHelper::getParams('com_users'); if ($usersConfig->get('allowUserRegistration') == '0') { //show warning message $this->addWarning(JText::_('COM_COMMUNITY_REGISTRATION_DISABLED')); return; } $fields = array(); $post = JRequest::get('post'); $isUseFirstLastName = CUserHelper::isUseFirstLastName(); $data = array(); $data['fields'] = $fields; $data['html_field']['jsname'] = empty($post['jsname']) ? '' : $post['jsname']; $data['html_field']['jsusername'] = empty($post['jsusername']) ? '' : $post['jsusername']; $data['html_field']['jsemail'] = empty($post['jsemail']) ? '' : $post['jsemail']; $data['html_field']['jsfirstname'] = empty($post['jsfirstname']) ? '' : $post['jsfirstname']; $data['html_field']['jslastname'] = empty($post['jslastname']) ? '' : $post['jslastname']; // $js = 'assets/validate-1.5.min.js'; // CFactory::attach($js, 'js'); $recaptcha = new CRecaptchaHelper(); $recaptchaHTML = $recaptcha->html(); $fbHtml = ''; if ($config->get('fbconnectkey') && $config->get('fbconnectsecret') && !$config->get('usejfbc')) { //CFactory::load( 'libraries' , 'facebook' ); $facebook = new CFacebook(); $fbHtml = $facebook->getLoginHTML(); } if ($config->get('usejfbc')) { if (class_exists('JFBCFactory')) { $providers = JFBCFactory::getAllProviders(); foreach ($providers as $p) { $fbHtml .= $p->loginButton(); } } } $tmpl = new CTemplate(); $content = $tmpl->set('data', $data)->set('recaptchaHTML', $recaptchaHTML)->set('config', $config)->set('isUseFirstLastName', $isUseFirstLastName)->set('fbHtml', $fbHtml)->fetch('register/base'); $appsLib = CAppPlugins::getInstance(); $appsLib->loadApplications(); $args = array(&$content); $appsLib->triggerEvent('onUserRegisterFormDisplay', $args); echo $this->_getProgressBar(1); echo $content; }
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'); } }
function apply() { $configs = JRequest::get('POST', 4); $model = $this->getModel('config'); $model->saveSettings($configs); JFBCFactory::log(JText::_('COM_JFBCONNECT_MSG_SETTINGS_UPDATED')); $this->setRedirect('index.php?option=com_jfbconnect&view=social'); }
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); }
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); }
function importConnections() { $app = JFactory::getApplication(); JPluginHelper::importPlugin('socialprofiles'); $profilePlugins = $app->triggerEvent('jfbcImportConnections'); $msg = JText::_('COM_JFBCONNECT_MSG_IMPORT_SUCCESS'); JFBCFactory::log($msg); $this->display(); }
public function formBind($name, $data = null) { if (!isset($this->forms[$name])) { return false; } if (!$data) { $data = JFBCFactory::config()->getSettings(); } $this->forms[$name]->bind($data); }
function getAvatarUrl($providerId, $nullForDefault = true, $params = null) { $nullString = $nullForDefault ? 'null' : 'notnull'; $avatarUrl = JFBCFactory::cache()->get('windowslive.avatar.' . $nullString . '.' . $providerId); if ($avatarUrl === false) { $avatarUrl = "https://apis.live.net/v5.0/{$providerId}/picture"; JFBCFactory::cache()->store($avatarUrl, 'windowslive.avatar.' . $nullString . '.' . $providerId); } return $avatarUrl; }
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'); }
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; }
public function unlink() { JSession::checkToken('get') or die('Invalid Token'); $provider = JRequest::getString('provider', ''); $user = JFactory::getUser(); $userModel = JFBConnectModelUserMap::getUser($user->get('id'), $provider); $provider_user_id = $userModel->getProviderUserId($user->get('id'), $provider); $userModel->deleteMapping($provider_user_id, $provider); JFBCFactory::log(JText::sprintf('COM_JFBCONNECT_ACCOUNT_LINKED_ACCOUNTS_UNLINK_MESSAGE', $provider)); $this->setRedirect(JRoute::_('index.php?option=com_jfbconnect&view=account')); }
protected function getOptions() { require_once JPATH_ROOT . '/components/com_jfbconnect/libraries/factory.php'; $providers = JFBCFactory::getAllWidgetProviderNames(); $options = array(); $options[] = JHtml::_('select.option', "provider", "--Select your provider--"); foreach ($providers as $provider) { $options[] = JHtml::_('select.option', $provider, ucfirst($provider)); } return $options; }
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; } }
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; }
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; }
function getProfileUrl($providerUserId) { $profileUrl = JFBCFactory::cache()->get('instagram.profile.' . $providerUserId); $token = $this->provider->client->getToken(); if (!empty($token)) { //instragram token includes user data //get username from token $user = (array) $token['user']; $profileUrl = 'https://instagram.com/' . $user['username']; JFBCFactory::cache()->store($profileUrl, 'instagram.profile.' . $providerUserId); } return $profileUrl; }
public function getButtons() { if (!$this->exists()) { return; } $providers = JFBCFactory::getAllProviders(); $params = array('buttonSize' => 'icon_text_button'); $buttons = ''; foreach ($providers as $provider) { $buttons .= $provider->loginButton($params); } return $buttons; }
protected function getOptions() { $options = array(); $options[] = JHtml::_('select.option', "--", "-- Select a Provider --"); $providers = JFBCFactory::getAllProviders(); foreach ($providers as $p) { $channels = $p->getChannelsOutbound(); if (count($channels) > 0) { $options[] = JHtml::_('select.option', strtolower($p->name), $p->name); } } return $options; }