Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into REDSHOP-6083
Browse files Browse the repository at this point in the history
  • Loading branch information
H.A committed Aug 24, 2020
2 parents c609319 + 4e9b592 commit ed34cc1
Show file tree
Hide file tree
Showing 44 changed files with 529 additions and 500 deletions.
15 changes: 15 additions & 0 deletions component/site/views/login/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
$params = $app->getParams('com_redshop');
$returnitemid = $params->get('login', $Itemid);

$thirdPartyLogin = Redshop\Helper\Login::getThirdPartyLogin();

?>
<form action="<?php echo JRoute::_($loginlink); ?>" method="post">
<div class="redshop-login form-horizontal">
Expand Down Expand Up @@ -60,3 +62,16 @@
<input type="hidden" name="returnitemid" id="returnitemid" value="<?php echo $returnitemid; ?>">
<input type="hidden" name="option" id="option" value="com_redshop"/>
</form>
<div class="form-group">
<div class="third-party-login ">
<?php foreach ($thirdPartyLogin as $login): ?>
<?php if (!empty($login['plugin']) && !empty($login['linkLogin'])): ?>
<div class="row login-<?php echo $login['plugin'] ?>">
<a href="<?php echo $login['linkLogin']; ?>" class="btn btn-primary login-button">
<?php echo ucfirst($login['plugin']) ?>
</a>
</div>
<?php endif; ?>
<?php endforeach; ?>
</div>
</div>
4 changes: 1 addition & 3 deletions libraries/redshop/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
"whichbrowser/parser": "2.0.32",
"imagine/imagine": "^0.7.1",
"ps/image-optimizer": "^1.1.2",
"facebook/graph-sdk": "^5.7",
"guzzlehttp/guzzle": "^6.5",
"google/apiclient": "^2.4"
"guzzlehttp/guzzle": "^6.5"
},
"autoload": {
"psr-4": {
Expand Down
13 changes: 13 additions & 0 deletions libraries/redshop/layouts/tags/checkout/onestep/login.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,16 @@
{{ jtext('COM_REDSHOP_FORGOT_PWD_LINK') }}
</a>
</form>
{% if thirdPartyLogin|length > 0 %}
<div class="third-party-login">
{% for login in thirdPartyLogin %}
{% if login['plugin'] != '' %}
<div class="row login-{{ login['plugin'] }}">
<a href="{{ login['linkLogin'] }}" class="btn btn-primary login-button">
{{ login['plugin']|title }}
</a>
</div>
{% endif %}
{% endfor %}
</div>
{% endif %}
15 changes: 14 additions & 1 deletion libraries/redshop/layouts/tags/login/form.html.twig
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
<form action="{{ jroute('index.php') }}" method="post">{{ content }}</form>
<form action="{{ jroute('index.php') }}" method="post">{{ content }}</form>
{% if thirdPartyLogin|length > 0 %}
<div class="third-party-login">
{% for login in thirdPartyLogin %}
{% if login['plugin'] != '' %}
<div class="row login-{{ login['plugin'] }}">
<a href="{{ login['linkLogin'] }}" class="btn btn-primary login-button">
{{ login['plugin']|title }}
</a>
</div>
{% endif %}
{% endfor %}
</div>
{% endif %}
59 changes: 59 additions & 0 deletions libraries/redshop/src/Helper/Login.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
/**
* @package RedShop
* @subpackage Libraries
*
* @copyright Copyright (C) 2008 - 2019 redCOMPONENT.com. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/

namespace Redshop\Helper;

defined('_JEXEC') or die;

/**
* Login helper class
*
* @since __DEPLOY_VERSION__
*/
class Login
{
/**
* @param $data
*
* @throws \Exception
*/
public static function loginJoomlaRedShop($data) {
$app = \JFactory::getApplication();
$jUser = \JUserHelper::getUserId($data['email']);

if ($jUser > 0) {
$jUser = \JFactory::getUser($jUser);

\JPluginHelper::importPlugin('user');

$options = array();
$options['action'] = 'core.login.site';

$result = $app->triggerEvent('onUserLogin', array($data, $options));
} else {
$jUser = \RedshopHelperJoomla::createJoomlaUser($data, 1);
}

$check = \RedshopHelperUser::getUserInformation($jUser->id);

if (empty($check)) {
$redUser = \RedshopHelperUser::storeRedshopUser($data, $jUser->id);
}

$app->redirect(\JUri::root());
}

/**
* @return array
*/
public static function getThirdPartyLogin() {
\JPluginHelper::importPlugin('redshop_login');
return \RedshopHelperUtility::getDispatcher()->trigger('onThirdPartyLogin');
}
}
6 changes: 4 additions & 2 deletions libraries/redshop/tags/sections/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,12 @@ public function replace()

$this->addReplace('{forget_password_link}', $forgotPwd);

$this->template = RedshopLayoutHelper::render(
$thirdPartyLogin = Redshop\Helper\Login::getThirdPartyLogin();
$this->template = RedshopLayoutHelper::render(
'tags.login.form',
array(
'content' => $this->template
'content' => $this->template,
'thirdPartyLogin' => $thirdPartyLogin
),
'',
$layoutOption
Expand Down
5 changes: 4 additions & 1 deletion libraries/redshop/tags/sections/onestepcheckout.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ public function replace()
$usersInfoId = $billingAddresses->users_info_id;
}

$thirdPartyLogin = Redshop\Helper\Login::getThirdPartyLogin();

$loginTemplate = "";

if (!$usersInfoId && Redshop::getConfig()->getInt('REGISTER_METHOD') != 1
Expand All @@ -91,7 +93,8 @@ public function replace()
'tags.checkout.onestep.login',
array(
'itemId' => $itemId,
'returnUrl' => base64_encode(JRoute::_('index.php?option=com_redshop&view=checkout', false))
'returnUrl' => base64_encode(JRoute::_('index.php?option=com_redshop&view=checkout', false)),
'thirdPartyLogin' => $thirdPartyLogin
),
'',
RedshopLayoutHelper::$layoutOption
Expand Down
Loading

0 comments on commit ed34cc1

Please sign in to comment.