Ejemplo n.º 1
0
 public function getTagHtml()
 {
     if ($this->fields->exists('image') && $this->getParamValue('image') != "") {
         self::$needsJavascript = true;
         $url = $this->getParamValueEx('href', 'url', null, SCSocialUtilities::getStrippedUrl());
         $layout = $this->getParamValue('layout');
         $url = rawurlencode($url);
         $image = rawurlencode($this->getParamValue('image'));
         $desc = rawurlencode($this->getParamValue('desc'));
         $tagButtonText = '<a href="//pinterest.com/pin/create/button/?url=' . $url;
         if ($image) {
             $tagButtonText .= '&media=' . $image;
         }
         if ($desc) {
             $tagButtonText .= '&description=' . $desc;
         }
         $tagButtonText .= '"';
         if ($layout) {
             $tagButtonText .= SCEasyTags::getShareButtonLayout('pinterest', $layout, '"');
         } else {
             $tagButtonText .= $this->getField('data-pin-config', 'pin_count', null, 'none', 'data-pin-config');
         }
         if (strpos($tagButtonText, 'above') !== false) {
             $pinItButton = 'pinit_fg_en_rect_gray_28.png';
             $tagButtonText .= $this->getField('data-pin-height', '', null, '28', 'data-pin-height');
         } else {
             $pinItButton = 'pin_it_button.png';
         }
         $tagButtonText .= ' data-pin-do="buttonPin" ><img src="//assets.pinterest.com/images/pidgets/' . $pinItButton . '" alt="Share on Pinterest"/></a>';
     } else {
         $tagButtonText = '';
     }
     return $tagButtonText;
 }
Ejemplo n.º 2
0
 protected function getTagHtml()
 {
     $tag = '<div class="fb-share-button"';
     $tag .= $this->getField('href', 'url', null, SCSocialUtilities::getStrippedUrl(), 'data-href');
     $tag .= $this->getField('width', null, null, '', 'data-width');
     $tag .= $this->getField('layout', null, null, '', 'data-type');
     $tag .= '></div>';
     return $tag;
 }
Ejemplo n.º 3
0
 private static function _getCompleteURL($url)
 {
     $path = JRoute::_($url, true);
     $jUri = JURI::getInstance();
     $url = rtrim($jUri->toString(array('scheme', 'host', 'port')), '/');
     // URL Encode the path only, but not the slashes within the path
     $url .= implode('/', array_map('urlencode', explode('/', $path)));
     $url = SCSocialUtilities::forceScheme($url);
     return $url;
 }
Ejemplo n.º 4
0
 protected function getTagHtml()
 {
     //Get the Comments Count string
     $tagString = '<div class="fb-comments-count"';
     $tagString .= $this->getField('href', 'url', null, SCSocialUtilities::getStrippedUrl(), 'data-href');
     $tagString .= '></div>';
     SCStringUtilities::loadLanguage('com_jfbconnect');
     $tag = JText::sprintf('COM_JFBCONNECT_COMMENTS_COUNT', $tagString);
     return $tag;
 }
Ejemplo n.º 5
0
 protected function getTagHtml()
 {
     $tag = '<div class="fb-comments"';
     $tag .= $this->getField('href', 'url', null, SCSocialUtilities::getStrippedUrl(), 'data-href');
     $tag .= $this->getField('width', null, null, '', 'data-width');
     $tag .= $this->getField('num_posts', null, null, '', 'data-num-posts');
     $tag .= $this->getField('colorscheme', null, null, '', 'data-colorscheme');
     $tag .= $this->getField('mobile', null, 'boolean', 'false', 'data-mobile');
     $tag .= $this->getField('order_by', null, null, '', 'data-order-by');
     $tag .= '></div>';
     return $tag;
 }
Ejemplo n.º 6
0
 protected function getTagHtml()
 {
     $tag = '<div class="fb-send"';
     $tag .= $this->getField('href', 'url', null, SCSocialUtilities::getStrippedUrl(), 'data-href');
     $tag .= $this->getField('colorscheme', null, null, '', 'data-colorscheme');
     $tag .= $this->getField('ref', null, null, '', 'data-ref');
     $tag .= $this->getField('width', null, null, '', 'data-width');
     $tag .= $this->getField('height', null, null, '', 'data-height');
     $tag .= $this->getField('kid_directed_site', null, 'boolean', 'false', 'data-kid-directed-site');
     $tag .= '></div>';
     return $tag;
 }
Ejemplo n.º 7
0
 protected function getTagHtml()
 {
     JFBCFactory::addStylesheet('jfbconnect.css');
     $tag = '<script type="IN/Share"';
     $tag .= $this->getField('href', 'url', null, SCSocialUtilities::getStrippedUrl(), 'data-url');
     $tag .= $this->getField('showzero', 'show_zero', 'boolean', 'false', 'data-showzero');
     if ($this->fields->exists('layout')) {
         $tag .= SCEasyTags::getShareButtonLayout('linkedin', $this->fields->get('layout'), '"');
     } else {
         $tag .= $this->getField('counter', null, null, '', 'data-counter');
     }
     $tag .= ' data-onsuccess="jfbc.social.linkedin.share"';
     $tag .= '></script>';
     return $tag;
 }
Ejemplo n.º 8
0
 protected function getTagHtml()
 {
     JFBCFactory::addStylesheet('jfbconnect.css');
     $tag = '<div class="fb-like"';
     $tag .= $this->getField('href', 'url', null, SCSocialUtilities::getStrippedUrl(), 'data-href');
     $tag .= $this->getField('show_faces', null, 'boolean', 'true', 'data-show-faces');
     $tag .= $this->getField('share', 'show_send_button', 'boolean', 'true', 'data-share');
     $tag .= $this->getField('layout', null, null, '', 'data-layout');
     $tag .= $this->getField('width', null, null, '', 'data-width');
     $tag .= $this->getField('action', null, null, '', 'data-action');
     $tag .= $this->getField('colorscheme', null, null, '', 'data-colorscheme');
     $tag .= $this->getField('ref', null, null, '', 'data-ref');
     $tag .= $this->getField('kid_directed_site', null, 'boolean', 'false', 'data-kid-directed-site');
     $tag .= '></div>';
     return $tag;
 }
Ejemplo n.º 9
0
 protected function getTagHtml()
 {
     JFBCFactory::addStylesheet('jfbconnect.css');
     $tag = '<div class="g-plusone"';
     if ($this->fields->exists('layout')) {
         $tag .= SCEasyTags::getShareButtonLayout('google', $this->fields->get('layout'), '"');
     } else {
         $tag .= $this->getField('size', null, null, '', 'data-size');
         $tag .= $this->getField('annotation', null, null, '', 'data-annotation');
     }
     $tag .= $this->getField('href', 'url', null, SCSocialUtilities::getStrippedUrl(), 'data-href');
     $tag .= $this->getField('width', null, null, '', 'data-width');
     $tag .= $this->getField('align', null, null, '', 'data-align');
     $tag .= $this->getField('expandTo', null, null, '', 'expandTo');
     $tag .= $this->getField('recommendations', null, 'boolean', 'true', 'data-recommendations');
     $tag .= ' data-callback="plusone_callback"';
     $tag .= '></div>';
     return $tag;
 }
Ejemplo n.º 10
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);
     }
 }
Ejemplo n.º 11
0
 protected function getTagHtml()
 {
     JFBCFactory::addStylesheet('jfbconnect.css');
     $tagButtonText = '<a href="http://twitter.com/share" class="twitter-share-button" ';
     $tagButtonText .= $this->getField('href', 'url', null, SCSocialUtilities::getStrippedUrl(), 'data-url');
     if ($this->fields->exists('layout')) {
         $tagButtonText .= SCEasyTags::getShareButtonLayout('twitter', $this->fields->get('layout'), '"');
     } else {
         $tagButtonText .= $this->getField('data-count', 'data_count', null, '', 'data-count');
     }
     $tagButtonText .= $this->getField('via', null, null, '', 'data-via');
     $tagButtonText .= $this->getField('text', null, null, '', 'data-text');
     $tagButtonText .= $this->getField('related', null, null, '', 'data-related');
     $tagButtonText .= $this->getField('lang', null, null, '', 'data-lang');
     $tagButtonText .= $this->getField('counturl', null, null, '', 'data-counturl');
     $tagButtonText .= $this->getField('hashtags', null, null, '', 'data-hashtags');
     $tagButtonText .= $this->getField('size', null, null, '', 'data-size');
     $tagButtonText .= $this->getField('dnt', null, 'boolean', 'false', 'data-dnt');
     $tagButtonText .= '>Tweet</a>';
     return $tagButtonText;
 }
Ejemplo n.º 12
0
 private function replaceTagInMetadata($metadataTag)
 {
     $doc = JFactory::getDocument();
     $description = $doc->getDescription();
     $replace = SCSocialUtilities::stripSystemTags($description, $metadataTag);
     if ($replace) {
         $description = SCStringUtilities::trimNBSP($description);
         $doc->setDescription($description);
     }
 }
Ejemplo n.º 13
0
 static function getLinkFromMenuItem($itemId, $isLogout)
 {
     $app = JFactory::getApplication();
     $menu = $app->getMenu();
     $item = $menu->getItem($itemId);
     if ($item) {
         if ($item->type == 'url') {
             $redirect = $item->link;
         } else {
             if ($item->type == 'alias') {
                 $aliasedId = $item->params->get('aliasoptions');
                 if ($isLogout && SCSocialUtilities::isMenuRegistered($aliasedId)) {
                     $link = 'index.php';
                 } else {
                     $link = SCSocialUtilities::getLinkWithItemId($item->link, $aliasedId);
                 }
                 $redirect = JRoute::_($link, false);
             } else {
                 if ($isLogout && SCSocialUtilities::isMenuRegistered($itemId)) {
                     $link = 'index.php';
                 } else {
                     $link = SCSocialUtilities::getLinkWithItemId($item->link, $itemId);
                 }
                 $redirect = JRoute::_($link, false);
             }
         }
     } else {
         $redirect = '';
     }
     return $redirect;
 }
Ejemplo n.º 14
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $input = JFactory::getApplication()->input;
     $provider = $input->getCmd('provider', null);
     if (!$provider) {
         $app->redirect('index.php');
     }
     $provider = JFBCFactory::provider($provider);
     $providerUserId = $provider->getProviderUserId();
     $profile = $provider->profile->fetchProfile($providerUserId, array('first_name', 'last_name', 'email', 'full_name'));
     if ($providerUserId == null) {
         $app->redirect('index.php');
     }
     $args = array(strtolower($provider->name));
     $profileFields = $app->triggerEvent('socialProfilesOnShowRegisterForm', $args);
     // Get previously filled in values
     $postData = $app->getUserState('com_jfbconnect.registration.data', array());
     $email1 = '';
     $email2 = '';
     SCUserUtilities::getDisplayEmail($postData, $profile->get('email'), $email1, $email2);
     $config = JFBCFactory::config();
     $providerUsername = '';
     $postUsername = SCUserUtilities::getPostData($postData, 'username');
     if ($postUsername != '') {
         $providerUsername = $postUsername;
     } else {
         if (JFBCFactory::config()->get('registration_show_username') > USERNAME_LEAVE_BLANK) {
             $usernamePrefixFormat = $config->get('auto_username_format');
             $providerUsername = SCUserUtilities::getAutoUsername($profile->get('first_name'), $profile->get('last_name'), $profile->get('email'), $provider->usernamePrefix, $providerUserId, $usernamePrefixFormat);
         }
     }
     $providerMemberName = SCUserUtilities::getDisplayNameByFullName($postData, $profile->get('full_name'));
     $language = JFactory::getLanguage();
     $language->load('com_users');
     JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_users/models');
     $userModel = JModelLegacy::getInstance('Registration', 'UsersModel');
     $this->data = $userModel->getData();
     JForm::addFormPath(JPATH_SITE . '/components/com_users/models/forms');
     JForm::addFieldPath(JPATH_SITE . '/components/com_users/models/fields');
     $this->form = $userModel->getForm();
     // Setup the fields we can pre-populate
     // To do: Give option to show/hide the name on the form
     $this->form->setValue('name', null, $providerMemberName);
     if ($config->get('registration_show_name') == NAME_HIDE && $providerMemberName != '') {
         $this->form->setFieldAttribute('name', 'type', 'hidden');
     }
     $this->form->setValue('username', null, $providerUsername);
     if ($providerUsername != '') {
         if ($config->get('registration_show_username') == USERNAME_GENERATE_HIDE) {
             $this->form->setFieldAttribute('username', 'type', 'hidden');
         } else {
             if ($config->get('registration_show_username') == USERNAME_GENERATE_DISABLE) {
                 $this->form->setFieldAttribute('username', 'readonly', 'true');
             }
         }
     }
     $this->form->setValue('email1', null, $email1);
     $this->form->setValue('email2', null, $email2);
     if ($email1 != '' && $email2 != '') {
         if ($config->get('registration_show_email') == EMAIL_HIDE) {
             $this->form->setFieldAttribute('email1', 'type', 'hidden');
             $this->form->setFieldAttribute('email2', 'type', 'hidden');
         } else {
             if ($config->get('registration_show_email') == EMAIL_SHOW_DISABLE) {
                 $this->form->setFieldAttribute('email1', 'readonly', 'true');
                 $this->form->setFieldAttribute('email2', 'readonly', 'true');
             }
         }
     }
     if ($config->get('registration_show_password') == 1) {
         $password = JUserHelper::genRandomPassword();
         $this->form->setValue('password1', null, $password);
         $this->form->setValue('password2', null, $password);
         $this->form->setFieldAttribute('password1', 'type', 'hidden');
         $this->form->setFieldAttribute('password2', 'type', 'hidden');
     }
     // Set an inputbox style on all the input elements so that inherited template styles look better
     $this->form->setFieldAttribute('name', 'class', 'inputbox required');
     $this->form->setFieldAttribute('username', 'class', 'validate-username inputbox required');
     $this->form->setFieldAttribute('email1', 'class', 'inputbox required');
     $this->form->setFieldAttribute('email2', 'class', 'inputbox required');
     $this->form->setFieldAttribute('password1', 'class', 'validate-password inputbox required');
     $this->form->setFieldAttribute('password2', 'class', 'validate-password inputbox required');
     //Check for form validation from each of the plugins
     $areProfilesValidating = $app->triggerEvent('socialProfilesAddFormValidation');
     $defaultValidationNeeded = true;
     foreach ($areProfilesValidating as $hasDoneValidation) {
         if ($hasDoneValidation == true) {
             $defaultValidationNeeded = false;
             break;
         }
     }
     // Setup the view appearance
     // TODO: Make the addStyleSheet into a Utilities function to be used elsewhere.
     $displayType = $config->get('registration_display_mode');
     $css = JPath::find($this->_path['template'], 'loginregister.css');
     $css = str_replace(JPATH_SITE, '', $css);
     $css = JURI::root() . $css;
     $css = str_replace('\\', "/", $css);
     //Windows support for file separators
     $doc = JFactory::getDocument();
     $doc->addStyleSheet($css);
     // get the other providers, for showing their login buttons
     $altParams = array();
     $allProviders = JFBCFactory::getAllProviders();
     $altProviders = array();
     foreach ($allProviders as $p) {
         if ($p->name != $provider->name) {
             $altParams['providers'][] = $p->systemName;
         }
     }
     $altParams['image'] = 'icon.png';
     // Set the session bit to check for a new login on next page load
     SCSocialUtilities::setJFBCNewMappingEnabled();
     $this->altParams = $altParams;
     $this->assignRef('providerUserId', $providerUserId);
     $this->assignRef('profile', $profile);
     $this->assignRef('configModel', $config);
     $this->assignRef('profileFields', $profileFields);
     $this->assignRef('defaultValidationNeeded', $defaultValidationNeeded);
     $this->assignRef('displayType', $displayType);
     $this->assignRef('providerName', $provider->name);
     $this->assignRef('altProviders', $altProviders);
     parent::display($tpl);
 }
Ejemplo n.º 15
0
 private function getLikeBtn($article, $infix = 'article')
 {
     $buttonStyle = $this->configModel->getSetting('social_' . $infix . '_like_layout_style');
     $showFaces = $this->configModel->getSetting('social_' . $infix . '_like_show_faces');
     $showShareButton = $this->configModel->getSetting('social_' . $infix . '_like_show_send_button');
     $width = $this->configModel->getSetting('social_' . $infix . '_like_width');
     $verbToDisplay = $this->configModel->getSetting('social_' . $infix . '_like_verb_to_display');
     $font = $this->configModel->getSetting('social_' . $infix . '_like_font');
     $colorScheme = $this->configModel->getSetting('social_a' . $infix . '_like_color_scheme');
     $showFacebook = $this->configModel->getSetting('social_' . $infix . '_like_show_facebook');
     $showLinkedIn = $this->configModel->getSetting('social_' . $infix . '_like_show_linkedin');
     $showTwitter = $this->configModel->getSetting('social_' . $infix . '_like_show_twitter');
     $showGooglePlus = $this->configModel->getSetting('social_' . $infix . '_like_show_googleplus');
     $showPinterest = $this->configModel->getSetting('social_' . $infix . '_like_show_pinterest');
     //only call opengraph plugin if we show pinterest to remove unnecessary overhead
     $pinImage = $pinText = '';
     if ($showPinterest) {
         $pinImage = $this->getPinterestImage($article);
         $pinText = $this->getPinterestText($article);
     }
     $url = SCArticleContent::getCurrentURL($article, $this->isJoomla);
     $btnHTML = $likeHTML = $likeExtraHTML = $widthField = '';
     //Only set width for standard layout, not box_count or button_count
     if ($buttonStyle == 'standard') {
         $widthField .= ' width=' . $width;
     }
     //show like or with share button
     if ($showFacebook) {
         $likeHTML .= '{JFBCLike layout=' . $buttonStyle . ' show_faces=' . $showFaces . ' share=' . $showShareButton . $widthField . ' action=' . $verbToDisplay . ' font=' . $font . ' colorscheme=' . $colorScheme . ' href=' . $url . $this->renderKeyString . '}';
     } else {
         if ($showShareButton && !$showFacebook) {
             if ($buttonStyle == 'standard' || $buttonStyle == 'button') {
                 $style = 'button';
             } else {
                 if ($buttonStyle == 'box_count') {
                     $style = 'box_count';
                 } else {
                     $style = 'button_count';
                 }
             }
             $likeHTML .= '{JFBCShare layout=' . $style . $widthField . ' href=' . $url . $this->renderKeyString . '}';
         }
     }
     if ($showLinkedIn || $showTwitter || $showGooglePlus || $showPinterest) {
         $likeExtraHTML = SCSocialUtilities::getExtraShareButtons($url, $buttonStyle, false, false, $showTwitter, $showGooglePlus, $this->renderKeyString, $showLinkedIn, '50', $showPinterest, $pinImage, $pinText);
     }
     if (!empty($likeHTML) || !empty($likeExtraHTML)) {
         $btnHTML .= '<div style="position: relative; top:0px; left:0px; z-index: 99;" class="scsocialbuttons ' . $buttonStyle . '">';
         $btnHTML .= $likeExtraHTML;
         $btnHTML .= $likeHTML;
         $btnHTML .= '</div><div style="clear:both"></div>';
     }
     $html = '';
     $intro_text = $this->configModel->getSetting('social_' . $infix . '_like_intro_text');
     if (!empty($intro_text)) {
         $html .= '<div class="scsocialbuttons-intro-text">' . $intro_text . '</div>';
     }
     $html .= $btnHTML;
     return $html;
 }
Ejemplo n.º 16
0
 protected function importCoverPhoto()
 {
     $cover = $this->profileLibrary->getCoverPhoto($this->socialId);
     if (!$cover) {
         return false;
     }
     $data = SCSocialUtilities::getRemoteContent($cover->get('url'));
     $tmpImgName = 'sccover_' . $this->network . $this->socialId . '_pic_tmp.jpg';
     JFile::write($this->getAvatarPath() . '/' . $tmpImgName, $data);
     $cover->set('path', $this->getAvatarPath() . '/' . $tmpImgName);
     list($width, $height, $type) = getimagesize($cover->get('path'));
     // Resize to the offsets provided if non-0
     if ($type != 2 || $cover->get('offsetX') != 0 || $cover->get('offsetY') != 0) {
         $image_p = imagecreatetruecolor($width - $cover->get('offsetX'), $height - $cover->get('offsetY'));
         $origImage = imagecreatefromstring($data);
         imagecopyresampled($image_p, $origImage, 0, 0, $cover->get('offsetX'), $cover->get('offsetY'), $width, $height, $width, $height);
         if (!imagejpeg($image_p, $this->getAvatarPath() . '/' . $tmpImgName, 100)) {
             return false;
         }
     }
     $cover->set('type', "image/jpeg");
     return $this->setCoverPhoto($cover);
 }
Ejemplo n.º 17
0
<?php

/**
 * @package         JFBConnect
 * @copyright (c)   2009-2015 by SourceCoast - All Rights Reserved
 * @license         http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 * @version         Release v6.4.2
 * @build-date      2015/08/24
 */
defined('_JEXEC') or die('Restricted access');
jimport('joomla.filesystem.folder');
jimport('sourcecoast.utilities');
JHTML::_('behavior.tooltip');
$model = $this->model;
$k2IsInstalled = SCSocialUtilities::isJoomlaComponentEnabled('com_k2');
$provider = $this->filter_provider;
$task = JRequest::getVar('task', '', 'post');
if (!empty($task)) {
    $provider = '';
}
?>
<script type="text/javascript">
    function toggleHide(rowId, styleType)
    {
        document.getElementById(rowId).style.display = styleType;
    }
</script>

<div class="sourcecoast">
<form method="post" id="adminForm" name="adminForm">
<?php 
Ejemplo n.º 18
0
 function migrateSocialAvatarToProfile($joomlaId, $socialUserId)
 {
     jimport('joomla.filesystem.file');
     jimport('joomla.utilities.utility');
     $avatarURL = $this->getAvatarURL($socialUserId, true);
     if ($avatarURL == null) {
         $this->setDefaultAvatar($joomlaId);
         return false;
     }
     $data = SCSocialUtilities::getRemoteContent($avatarURL);
     if ($data) {
         $baseImgPath = $this->getAvatarPath();
         $tmpImgName = 'scprofile_' . $joomlaId . '_pic_tmp.jpg';
         JFile::write($baseImgPath . '/' . $tmpImgName, $data);
         if ($this->updateAvatar($tmpImgName, $joomlaId, $socialUserId)) {
             return true;
         }
     }
     # there was a problem adding the avatar, use the default
     $this->setDefaultAvatar($joomlaId);
     return false;
 }
Ejemplo n.º 19
0
 protected function getSelectedText($contentText, $socialGraphFirstText, $numCharacters)
 {
     $articleText = SCStringUtilities::trimNBSP($contentText);
     $articleText = strip_tags($articleText);
     $articleText = preg_replace('/\\s+/', ' ', $articleText);
     $articleText = str_replace('{K2Splitter}', '', $articleText);
     SCSocialUtilities::stripSystemTags($articleText, 'JFBC');
     SCSocialUtilities::stripSystemTags($articleText, 'JLinked');
     SCSocialUtilities::stripSystemTags($articleText, 'SC');
     SCSocialUtilities::stripSystemTags($articleText, 'loadposition');
     $articleText = trim($articleText);
     $addEllipsis = false;
     if ($socialGraphFirstText == '1') {
         $addEllipsis = strlen($articleText) > $numCharacters;
         if (function_exists('mb_substr')) {
             $articleText = mb_substr($articleText, 0, $numCharacters, 'UTF-8');
         } else {
             $articleText = substr($articleText, 0, $numCharacters);
         }
     } else {
         if ($socialGraphFirstText == '2') {
             if (function_exists('mb_split')) {
                 $parts = mb_split('\\s+', $articleText);
             } else {
                 $parts = preg_split('/\\s+/', $articleText);
             }
             $selParts = array_slice($parts, 0, $numCharacters);
             $articleText = implode(" ", $selParts);
             $addEllipsis = count($parts) > $numCharacters;
         } else {
             $articleText = '';
         }
     }
     if ($addEllipsis) {
         $articleText .= '...';
     }
     return $articleText;
 }
Ejemplo n.º 20
0
<?php

/**
 * @package         JFBConnect
 * @copyright (c)   2009-2015 by SourceCoast - All Rights Reserved
 * @license         http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 * @version         Release v6.4.2
 * @build-date      2015/08/24
 */
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
jimport('sourcecoast.utilities');
//Powered By
$showPoweredBy = $params->get('showPoweredByLink');
$showJfbcPoweredBy = $showPoweredBy == '2' && JFBCFactory::config()->get('show_powered_by_link') || $showPoweredBy == '1';
if ($showJfbcPoweredBy) {
    //Affiliate ID
    $link = SCSocialUtilities::getAffiliateLink(JFBCFactory::config()->get('affiliate_id'), EXT_JFBCONNECT);
    SCStringUtilities::loadLanguage('com_jfbconnect');
    echo '<div class="powered-by">' . JText::_('COM_JFBCONNECT_POWERED_BY') . ' <a target="_blank" href="' . $link . '" title="Facebook for Joomla">JFBConnect</a></div>';
}
Ejemplo n.º 21
0
 public static function getCurrentAppId()
 {
     if (SCSocialUtilities::areJFBConnectTagsEnabled()) {
         $appId = JFBCFactory::provider('facebook')->appId;
         if ($appId != '') {
             return $appId;
         }
     }
     return '';
 }
Ejemplo n.º 22
0
 function autoCreateUser($providerUserId, $provider)
 {
     $provider->setInitialRegistration();
     $profile = $provider->profile->fetchProfile($providerUserId, array('first_name', 'last_name', 'email', 'full_name'));
     if ($profile == null || $profile->get('email') == null) {
         # not enough information returned to auto-create account
         return false;
     }
     $newEmail = $profile->get('email');
     $fullname = $profile->get('full_name');
     $user['fullname'] = $fullname;
     $user['email'] = $newEmail;
     // Create random password for FB User Only, but save so we can email to the user on account creation
     if (JFBCFactory::config()->getSetting('generate_random_password')) {
         $this->_newUserPassword = JUserHelper::genRandomPassword();
         $user['password_clear'] = $this->_newUserPassword;
         // Check for Joomla 3.2.1's new hashPassword functions and use those, if exist
         if (method_exists('JUserHelper', 'hashPassword')) {
             $user['password'] = JUserHelper::hashPassword($this->_newUserPassword);
         } else {
             $salt = JUserHelper::genRandomPassword(32);
             $crypt = JUserHelper::getCryptedPassword($this->_newUserPassword, $salt);
             $user['password'] = $crypt . ':' . $salt;
         }
     } else {
         $user['password_clear'] = "";
         $this->_newUserPassword = '';
     }
     $lang = JRequest::getVar(JApplication::getHash('language'), '', 'COOKIE');
     $user['language'] = $lang;
     $usernamePrefixFormat = JFBCFactory::config()->getSetting('auto_username_format');
     $username = SCUserUtilities::getAutoUsername($profile->get('first_name'), $profile->get('last_name'), $profile->get('email'), $provider->usernamePrefix, $providerUserId, $usernamePrefixFormat);
     $user['username'] = $username;
     $useractivation = $this->getActivationMode();
     $jUser = $this->getBlankUser($user, $useractivation);
     if ($jUser && $jUser->get('id', null)) {
         $this->onAfterRegister($provider, $jUser);
         SCSocialUtilities::clearJFBCNewMappingEnabled();
         if (JFBCFactory::usermap()->map($jUser->get('id'), $providerUserId, $provider->systemName, $provider->client->getToken())) {
             JFBCFactory::log(JText::sprintf('COM_JFBCONNECT_MAP_USER_SUCCESS', $provider->name));
             return true;
         } else {
             JFBCFactory::log(JText::sprintf('COM_JFBCONNECT_MAP_USER_FAIL', $provider->name));
         }
     }
     return false;
     // User creation failed for some reason
 }
Ejemplo n.º 23
0
echo $this->providerName;
?>
" />
                <?php 
echo JHTML::_('form.token');
?>
                </fieldset>
            </form>
        </div>
    </div>

    <div style="clear:both;"></div>

    <?php 
if ($this->configModel->getSetting('show_powered_by_link')) {
    $link = SCSocialUtilities::getAffiliateLink($this->configModel->getSetting('affiliate_id'), EXT_JFBCONNECT);
    ?>
        <div id="powered-by"><?php 
    echo JText::_('COM_JFBCONNECT_POWERED_BY');
    ?>
 <a target="_blank"
                                                                                     href="<?php 
    echo $link;
    ?>
"
                                                                                     title="Joomla Facebook Integration">JFBConnect</a>
        </div>
    <?php 
}
?>
Ejemplo n.º 24
0
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');
$padding = $params->get('padding');
$backgroundColor = $params->get('background_color');
$floatTop = trim($params->get('float_position_top'));
$floatLeft = trim($params->get('float_position_left'));
//Advanced
$userIntro = $params->get('user_intro');
//Facebook
Ejemplo n.º 25
0
 function login($provider = null)
 {
     if (!is_object($provider)) {
         $provider = JFBCFactory::provider(JRequest::getCmd('provider'));
     }
     // Let the provider do anything it wants before we try to login.
     $provider->onBeforeLogin();
     $loginRegisterModel = $this->getModel('LoginRegister', 'JFBConnectModel');
     // Set a cookie to prevent auto-logging in for the remainder of the session time
     $config = JFactory::getConfig();
     $lifetime = $config->get('lifetime', 15);
     setcookie('jfbconnect_autologin_disable', 1, time() + $lifetime * 60);
     // Not a perfect solution, but fixes autologin loops..
     $app = JFactory::getApplication();
     $providerUserId = $provider->getProviderUserId();
     if (!$providerUserId) {
         # Facebook isn't returning information about this user.  Redirect them.
         JFBCFactory::log(JText::sprintf('COM_JFBCONNECT_UNABLE_TO_RETRIEVE_USER', $provider->name));
         $app->redirect('index.php');
     }
     $userMapModel = JFBCFactory::usermap();
     $jUser = JFactory::getUser();
     if (!$jUser->guest) {
         SCSocialUtilities::clearJFBCNewMappingEnabled();
         if ($userMapModel->map($jUser->get('id'), $providerUserId, strtolower($provider->name), $provider->client->getToken())) {
             JFBCFactory::log(JText::sprintf('COM_JFBCONNECT_MAP_USER_SUCCESS', $provider->name));
         } else {
             JFBCFactory::log(JText::sprintf('COM_JFBCONNECT_MAP_USER_FAIL', $provider->name));
         }
         $return = $loginRegisterModel->getLoginRedirect($provider);
         $app->redirect($return);
     }
     // They're not logged in. Check if they have a Joomla user and log that user in. If not, create them one
     $jUserId = $userMapModel->getJoomlaUserId($providerUserId, strtolower($provider->name));
     if (!$jUserId) {
         $profile = $provider->profile->fetchProfile($providerUserId, array('email'));
         $providerEmail = $profile->get('email', null);
         # Check if automatic email mapping is allowed, and see if that email is registered
         # AND the Facebook user doesn't already have a Joomla account
         if (!$provider->initialRegistration && JFBCFactory::config()->getSetting('facebook_auto_map_by_email')) {
             if ($providerEmail != null) {
                 $jUserEmailId = $userMapModel->getJoomlaUserIdFromEmail($providerEmail);
                 if (!empty($jUserEmailId)) {
                     // Found a user with the same email address
                     // do final check to make sure there isn't a FB account already mapped to it
                     $tempId = $userMapModel->getProviderUserId($jUserEmailId, strtolower($provider->name));
                     if (!$tempId) {
                         SCSocialUtilities::clearJFBCNewMappingEnabled();
                         if ($userMapModel->map($jUserEmailId, $providerUserId, strtolower($provider->name), $provider->client->getToken())) {
                             JFBCFactory::log(JText::sprintf('COM_JFBCONNECT_MAP_USER_SUCCESS', $provider->name));
                             $jUserId = $jUserEmailId;
                             // Update the temp jId so that we login below
                         } else {
                             JFBCFactory::log(JText::sprintf('COM_JFBCONNECT_MAP_USER_FAIL', $provider->name));
                         }
                     }
                 }
             }
         }
         // Check if no mapping, and Automatic Registration is set. If so, auto-create the new user.
         if (!$jUserId && JFBCFactory::config()->getSetting('automatic_registration')) {
             # User is not in system, should create their account automatically
             if ($loginRegisterModel->autoCreateUser($providerUserId, $provider)) {
                 $jUserId = $userMapModel->getJoomlaUserId($providerUserId, strtolower($provider->name));
             }
         }
         // At this point, we have nothing left to do but redirect the user to the registration page
         if (!$jUserId) {
             $return = $loginRegisterModel->getLoginRedirect($provider);
             $app = JFactory::getApplication();
             $regComponent = JFBCFactory::config()->get('registration_component');
             if ($regComponent == 'jfbconnect') {
                 $app->redirect(JRoute::_('index.php?option=com_jfbconnect&view=loginregister&provider=' . strtolower($provider->name) . '&return=' . base64_encode($return), false));
             } else {
                 $app->setUserState('com_jfbconnect.registration.alternateflow', true);
                 $app->setUserState('com_jfbconnect.registration.provider.name', strtolower($provider->name));
                 $app->setUserState('com_jfbconnect.registration.provider.user_id', $providerUserId);
                 $plugins = $app->triggerEvent('socialProfilesGetPlugins');
                 foreach ($plugins as $plugin) {
                     if ($plugin->getName() == $regComponent) {
                         $redirect = $plugin->registration_url;
                     }
                 }
                 if ($redirect) {
                     $app->redirect(JRoute::_($redirect, false));
                 }
             }
         }
     }
     $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);
     }
     if ($loginSuccess) {
         // lets update the user's access token with whatever we just received
         $jUser = JFactory::getUser();
         $userMapModel->updateUserToken($jUser->get('id'), $provider->systemName, $provider->client->getToken());
         // Store Profile URL and Avatar URL
         $userModel = JFBConnectModelUserMap::getUser($jUser->get('id'), $provider->name);
         $userModel->saveParameter('profile_url', JFBCFactory::provider($provider->name)->profile->getProfileUrl($providerUserId));
         $avatarSettings = new JRegistry();
         $avatarSettings->set('width', 50);
         $avatarSettings->set('height', 50);
         $userModel->saveParameter('avatar_thumb', JFBCFactory::provider($provider->name)->profile->getAvatarUrl($providerUserId, false, $avatarSettings));
         if (!$provider->initialRegistration) {
             $args = array(strtolower($provider->name), $jUser->get('id'), $providerUserId);
             $app->triggerEvent('socialProfilesOnLogin', $args);
         }
     }
     JFactory::getApplication()->setUserState('com_jfbconnect.' . strtolower($provider->name) . '.checkForNewMapping', null);
     $allProviders = JFBCFactory::getAllProviders();
     foreach ($allProviders as $p) {
         $p->checkNewMapping();
     }
     $redirect = $loginRegisterModel->getLoginRedirect($provider);
     // Clear the 'alternate flow' session bit to prevent further alterations to reg pages for this user/session
     $app->setUserState('com_jfbconnect.registration.alternateflow', false);
     $app->redirect($redirect);
 }