/** * Method to log in a user. * * @since 1.6 */ public function login() { //JSession::checkToken('post') or jexit(JText::_('JInvalid_Token')); $app = JFactory::getApplication(); $jinput = JFactory::getApplication()->input; $session = JFactory::getSession(); $linkRedirect = $session->get('redirectAfterUserSave'); // Populate the data array: $data = array(); $data['return'] = base64_decode($jinput->post->get('return', '', 'BASE64')); $config = JComponentHelper::getParams('com_bt_socialconnect'); if (!$config->get('remove_user')) { $data['username'] = $jinput->post->get('username', '', 'USERNAME'); } else { $data['username'] = Bt_SocialconnectHelper::getUserName($jinput->post->get('email', '', 'EMAIL')); } $data['password'] = $jinput->post->get('password', '', JREQUEST_ALLOWRAW); // Set the return URL if empty. if (empty($data['return'])) { $data['return'] = 'index.php?option=com_bt_socialconnect&view=profile'; } // Set the return URL in the user state to allow modification by plugins $app->setUserState('users.login.form.return', $data['return']); // Get the log in options. $options = array(); $options['remember'] = $jinput->get('remember', false, 'BOOL'); $options['return'] = $data['return']; // Get the log in credentials. $credentials = array(); $credentials['username'] = $data['username']; $credentials['password'] = $data['password']; $user = $session->get('btPrepareUser'); // Perform the log in. if (true === $app->login($credentials, $options)) { if ($user) { $return = self::checkUser($data, $user); } // Success $app->setUserState('users.login.form.data', array()); $user = JFactory::getUser(); if ($linkRedirect && $user->id) { $this->setRedirect(JRoute::_($linkRedirect . '&userid=' . $user->id, false)); $session->clear('redirectAfterUserSave'); } else { $app->redirect(JRoute::_($app->getUserState('users.login.form.return'), false)); } } else { // Login failed ! $data['remember'] = (int) $options['remember']; $app->setUserState('users.login.form.data', $data); if ($user) { $app->redirect(JRoute::_('index.php?option=com_bt_socialconnect&view=registration&return=' . $jinput->post->get('return'), false)); } else { $app->redirect(JRoute::_('index.php?option=com_bt_socialconnect&view=login&return=' . $jinput->post->get('return'), false)); } } }
public static function loadUserFields() { return Bt_SocialconnectHelper::loadUserFields(array()); }
<dt><div class="control-label"><label title="<?php echo strip_tags($el->description); ?> " <?php echo $title; ?> ><?php echo Jtext::_($el->name); ?> <?php echo $span; ?> </label></div></dt> <dd><div class="controls btl-input"> <?php Bt_SocialconnectHelper::loadFieldData($el, $required); ?> </div></dd> </div> <?php } } ?> </dl> <dl> <?php $params = JComponentHelper::getParams('com_bt_socialconnect'); ?> <?php if ($params->get('remove_user')) { ?>
<?php /** * @package bt_socialconnect - BT Social Connect Component * @version 1.0.0 * @created February 2014 * @author BowThemes * @email support@bowthems.com * @website http://bowthemes.com * @support Forum - http://bowthemes.com/forum/ * @copyright Copyright (C) 2014 Bowthemes. All rights reserved. * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ defined('_JEXEC') or die; jimport('joomla.application.component.controller'); require_once JPATH_COMPONENT . '/helpers/helper.php'; require_once JPATH_COMPONENT . '/helpers/route.php'; Bt_SocialconnectHelper::addSiteScript(); $controller = JControllerLegacy::getInstance('Bt_Socialconnect'); $jinput = JFactory::getApplication()->input; $controller->execute($jinput->get('task', 'display', 'CMD')); $controller->redirect();
?> <div class="profile-edit"> <div id="menu"> <ul class="nav nav-tabs"> <li class="active"><a href="#edit-profile"><?php echo JText::_('COM_BT_SOCIALCONNECT_PROFILE_DETAIL_CORE_LEGEND'); ?> </a></li> </ul> </div> <div class="tab-content"> <div id="edit-profile" class="tab-pane active"> <fieldset id="users-profile-custom"> <dl class="dl-horizontal"> <?php $groupList = Bt_SocialconnectHelper::getGroupList(); foreach ($this->data->user_fields as $key => $value) { ?> <?php if (!trim($value->value)) { continue; } switch ($value->type) { case 'usergroup': echo '<dt>' . Jtext::_($value->name) . '</dt>'; echo '<span class="colon">:</span>'; echo '<dd>'; if (isset($groupList[$value->value])) { echo $groupList[$value->value]->text; }
public static function loadFieldData($el, $required) { switch ($el->type) { case 'date': if ($el->value == '' || $el->value == '0000-00-00') { $el->value = null; } echo JHTML::_('calendar', $el->value, 'user_fields[' . $el->alias . ']', 'user_fields_' . $el->alias, '%Y-%m-%d ', $el->required ? array('aria-required' => 'true', 'required' => 'required') : null); break; case 'string': echo '<input size="35" ' . $required . ' type="text" name="user_fields[' . $el->alias . ']" value="' . $el->value . '">'; break; case 'text': // jimport('joomla.html.editor'); // $wysiwyg = JEditor::getInstance(); //echo $wysiwyg->display('user_fields[' . $el->alias . ']', strip_tags($el->value), '365', '140', '75', '20', false ); echo '<textarea style="width:350px;" cols="40" rows="3" ' . $required . ' name="user_fields[' . $el->alias . ']">' . strip_tags($el->value) . '</textarea>'; break; case 'dropdown': $options = array(); $options[] = JHtml::_('select.option', '', $el->default_values['label']); if (!empty($el->default_values['value'])) { foreach ($el->default_values['value'] as $value) { $options[] = JHtml::_('select.option', $value, $value); } } echo JHtml::_('select.genericlist', $options, 'user_fields[' . $el->alias . '][]', $required, 'value', 'text', $el->value); break; case 'image': if ($el->value != '') { $pathImage = array(); $pathImage[$el->alias] = $el->value; $session = JFactory::getSession(); $session->set('btimage', $pathImage); $avatar = '<img src="' . JURI::root() . 'images/bt_socialconnect/avatar/' . $el->value . '"/>'; $html = '<div class=\'imageupload\'>'; $html .= '<span class="editlinktip hasTip" title="' . htmlspecialchars($avatar) . '">'; $html .= '<img src=' . JURI::root() . 'images/bt_socialconnect/avatar/' . $el->value . ' width=\'50\' />'; $html .= '<input type="hidden" name="user_fields[' . $el->alias . ']" value="' . $el->value . '" />'; $html .= '</span>'; $html .= '<span"><input type="file" name="user_fields[' . $el->alias . ']" style="width:202px;" class="inputbox" size="14"/></span>'; $html .= '</div>'; $html .= '<input type="checkbox" class="textbook" name="user_fields[' . $el->alias . ']" value="">' . Jtext::_('COM_BT_SOCIALCONNECT_DELETE_IMAGE'); } else { $html = '<div class=\'inputupload\'>'; $html .= '<input type="file" name="user_fields[' . $el->alias . ']" ' . $required . ' size="30"/>'; $html .= '</div>'; } echo $html; break; case 'usergroup': $required = $el->required ? ' required aria-required="true"' : ''; $html = '<fieldset class="btn-group radio" ' . $required . '>'; $groupList = Bt_SocialconnectHelper::getGroupList(); if (!empty($el->default_values['group'])) { foreach ($el->default_values['group'] as $i => $group) { $checked = ''; $fieldClass = array(); if ($el->value == $group) { $checked = 'checked="checked"'; } if (isset($el->default_values['field'][$i])) { foreach ($el->default_values['field'][$i] as $alias) { $fieldClass[] = '.field-' . $alias; } } $fieldClass = implode(',', $fieldClass); $html .= '<label for="jform_' . $el->alias . $i . '">' . '<input id="jform_' . $el->alias . $i . '" data-fields="' . $fieldClass . '" class="jform_' . $el->alias . '" type="radio" name="user_fields[' . $el->alias . ']" ' . $checked . ' value="' . $group . '">' . $groupList[$group]->text . '</label>'; } } $html .= '</fieldset>'; $html .= '<script>'; $html .= 'function changeFields(el){'; $html .= 'jQuery(el).each(function(){'; $html .= 'var datafields = jQuery(this).attr("data-fields");'; $html .= 'if(datafields){'; $html .= 'if(this.checked){'; $html .= 'jQuery(datafields).fadeIn().find("input").attr("disabled",false);'; $html .= '}else{jQuery(datafields).hide().find("input").attr("disabled",true);};'; $html .= '}'; $html .= '});'; $html .= '};'; $html .= 'jQuery(".jform_' . $el->alias . '").click(function(){'; $html .= 'changeFields(".jform_' . $el->alias . '")'; $html .= '});jQuery(".jform_' . $el->alias . '").on("ifClicked", function(event) {setTimeout(function(){changeFields(".jform_' . $el->alias . '");},100);});'; $html .= 'if(jQuery(".jform_' . $el->alias . ':checked").length==0){jQuery(".jform_' . $el->alias . ':first").attr("checked",true);};jQuery(document).ready(function(){changeFields(".jform_' . $el->alias . '");});'; $html .= '</script>'; echo $html; break; case 'sql': echo JHtml::_('select.genericlist', $el->default_values, 'user_fields[' . $el->alias . '][]', $required, 'value', 'text', $el->value); break; } }
public static function prepareData($user, $type) { $data = array(); $data['user_fields'] = array(); $user_fields = Bt_SocialconnectHelper::loadUserFields(); switch ($type) { case 'facebook': $data['id'] = $user->id; $data['user_id'] = ''; $data['name'] = $user->name; $data['username'] = $user->username; if ($data['username'] == '') { $data['username'] = $user->email; } $data['email'] = $user->email; $user->picture = 'http://graph.facebook.com/' . $user->id . '/picture?type=large'; $user->location = isset($user->location->name) ? $user->location->name : ''; $user->about = isset($user->bio) ? $user->bio : ''; foreach ($user_fields as $key => $value) { $data['user_fields'][$value->alias] = self::assignValueSocial($value, $user, $value->facebook); } break; case 'google': $data['id'] = $user->id; $data['user_id'] = ''; $data['name'] = $user->name; list($data['username']) = explode('@', $user->email); $user->username = $data['username']; $data['email'] = $user->email; foreach ($user_fields as $key => $value) { $data['user_fields'][$value->alias] = self::assignValueSocial($value, $user, $value->google); } break; case 'twitter': $data['id'] = $user->id; $data['user_id'] = ''; $data['name'] = $user->name; $data['email'] = $user->screen_name . '@twitter.com'; $data['username'] = $user->screen_name; $user->username = $user->screen_name; $user->picture = isset($user->profile_image_url) ? $user->profile_image_url : ''; $user->website = $user->url; $user->about = $user->description; $user->link = 'https://twitter.com/' . $user->screen_name; foreach ($user_fields as $key => $value) { $data['user_fields'][$value->alias] = self::assignValueSocial($value, $user, $value->twitter); } break; case 'linkedin': $data['id'] = $user->id; $data['user_id'] = ''; $data['name'] = $user->formattedName; $data['email'] = $user->emailAddress; $data['username'] = $user->firstName . $user->lastName; $user->username = $data['username']; $user->birthday = isset($user->dateOfBirth) ? $user->dateOfBirth->year . '-' . $user->dateOfBirth->month . '-' . $user->dateOfBirth->day : ''; $user->location = isset($user->location->name) ? $user->location->name : ''; $user->picture = isset($user->pictureUrl) ? $user->pictureUrl : ''; $user->quotes = isset($user->interests) ? $user->interests : ''; $user->about = isset($user->summary) ? $user->summary : ''; $user->link = isset($user->publicProfileUrl) ? $user->publicProfileUrl : ''; foreach ($user_fields as $key => $value) { $data['user_fields'][$value->alias] = self::assignValueSocial($value, $user, $value->linkedin); } break; } $data['loginType'] = $type; $data['rawData'] = serialize($user); return $data; }
public function getData() { if ($this->data === null) { $this->data = new stdClass(); $app = JFactory::getApplication(); $params = JComponentHelper::getParams('com_users'); $temp = (array) $app->getUserState('com_bt_socialconnect.registration.data', array()); foreach ($temp as $k => $v) { $this->data->{$k} = $v; } if (!isset($this->data->user_fields)) { $this->data->user_fields = array(); } $this->data->groups = array(); $session = JFactory::getSession(); $user = $session->get('btPrepareUser'); if ($user) { $this->data->user_fields = $user->user_fields; } $this->data->user_fields = Bt_SocialconnectHelper::loadUserFields($this->data->user_fields); $system = $params->get('new_usertype', 2); $this->data->groups[] = $system; unset($this->data->password1); unset($this->data->password2); $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('user'); $results = $dispatcher->trigger('onContentPrepareData', array('com_bt_socialconnect.registration', $this->data)); if (count($results) && in_array(false, $results, true)) { $this->setError($dispatcher->getError()); $this->data = false; } } return $this->data; }
public function getData() { if ($this->data === null) { $db = $this->getDbo(); $userId = $this->getState('user.id'); $this->data = new JUser($userId); // Set the base user data. $this->data->email1 = $this->data->get('email'); $this->data->email2 = $this->data->get('email'); $temp = (array) JFactory::getApplication()->getUserState('com_bt_socialconnect.edit.profile.data', array()); foreach ($temp as $k => $v) { $this->data->{$k} = $v; } unset($this->data->password1); unset($this->data->password2); $registry = new JRegistry($this->data->params); $this->data->params = $registry->toArray(); $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('user'); $results = $dispatcher->trigger('onContentPrepareData', array('com_bt_socialconnect.profile', $this->data)); // Check for errors encountered while preparing the data. if (count($results) && in_array(false, $results, true)) { $this->setError($dispatcher->getError()); $this->data = false; } $loadData = self::getValueData($userId); if (isset($this->data->user_fields)) { $this->data->user_fields = Bt_SocialconnectHelper::loadUserFields($this->data->user_fields); } else { $this->data->user_fields = Bt_SocialconnectHelper::loadUserFields($loadData); } //Get avatar from userid $ImgFormats = array("png", "jpg", "jpeg", "gif", "tiff"); foreach ($this->data->user_fields as $key => $value) { if ($value->type == 'image') { $PathInfo = pathinfo($value->value); if (@in_array(@strtolower($PathInfo['extension']), $ImgFormats)) { $this->data->avatar = $value->value; break; } else { $this->data->avatar = ''; } } } } return $this->data; }