Version Notes
Sixth release of social login
Download this release
Release Info
Developer | LoginRadius Team |
Extension | LoginRadius |
Version | 2.1.0 |
Comparing to | |
See all releases |
Code changes from version 2.0.0 to 2.1.0
- app/code/community/Loginradius/Sociallogin/Block/Auth.php +4 -56
- app/code/community/Loginradius/Sociallogin/Block/Info.php +1 -10
- app/code/community/Loginradius/Sociallogin/Block/Sociallogin.php +25 -14
- app/code/community/Loginradius/Sociallogin/Helper/Data.php +1 -3
- app/code/community/Loginradius/Sociallogin/Model/Mysql4/Sociallogin.php +7 -8
- app/code/community/Loginradius/Sociallogin/Model/Mysql4/Sociallogin/Collection.php +8 -9
- app/code/community/Loginradius/Sociallogin/Model/Sociallogin.php +8 -11
- app/code/community/Loginradius/Sociallogin/Model/Source/Uihover.php +11 -16
- app/code/community/Loginradius/Sociallogin/Model/Source/Uihover2.php +11 -16
- app/code/community/Loginradius/Sociallogin/controllers/IndexController.php +5 -259
- app/code/community/Loginradius/Sociallogin/controllers/inc.php +0 -1
- app/code/community/Loginradius/Sociallogin/etc/config.xml +5 -3
- app/code/community/Loginradius/Sociallogin/etc/system.xml +46 -5
- app/code/community/Loginradius/Sociallogin/sql/sociallogin_setup/{mysql4-install-2.0.0.php → mysql4-install-2.1.0.php} +0 -5
- app/design/frontend/default/default/layout/sociallogin.xml +23 -3
- app/design/frontend/default/default/template/sociallogin/abovelogin.phtml +26 -0
- app/design/frontend/default/default/template/sociallogin/aboveregister.phtml +26 -0
- app/design/frontend/default/default/template/sociallogin/belowlogin.phtml +26 -0
- app/design/frontend/default/default/template/sociallogin/belowregister.phtml +26 -0
- app/design/frontend/default/default/template/sociallogin/sociallogin.phtml +1 -30
- app/design/frontend/default/default/template/sociallogin/sociallogincustom.phtml +24 -0
- app/design/frontend/default/default/template/sociallogin/socialshare_head.phtml +1 -1
- package.xml +5 -5
app/code/community/Loginradius/Sociallogin/Block/Auth.php
CHANGED
@@ -1,98 +1,46 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
class Loginradius_Sociallogin_Block_Auth extends Mage_Core_Block_Template implements Mage_Widget_Block_Interface {
|
6 |
-
|
7 |
private $block_anyplace;
|
8 |
public function __construct(){
|
9 |
$this->block_anyplace = new Loginradius_Sociallogin_Block_Sociallogin();
|
10 |
}
|
11 |
function loginradius_buttons() {
|
12 |
-
|
13 |
-
// $this->block_anyplace = new Loginradius_Sociallogin_Block_Sociallogin();
|
14 |
-
|
15 |
$ApiKey = trim($this->block_anyplace->getApikey());
|
16 |
-
|
17 |
$ApiSecrete = trim($this->block_anyplace->getApiSecret());
|
18 |
-
|
19 |
$UserAuth = $this->block_anyplace->getApiResult($ApiKey, $ApiSecrete);
|
20 |
-
|
21 |
$titleText = $this->getLabelText();
|
22 |
-
|
23 |
$errormsg = '<p style ="color:red;">To activate your plugin, please log in to LoginRadius and get API Key & Secret. Web: <b><a href ="http://www.loginradius.com" target = "_blank">www.LoginRadius.com</a></b></p>';
|
24 |
-
|
25 |
if ($this->block_anyplace->user_is_already_login()) {
|
26 |
-
|
27 |
$userName = Mage::getSingleton('customer/session')->getCustomer()->getName();
|
28 |
-
|
29 |
return '<span>Welcome!'.' '.$userName .'</span>';
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
else {
|
34 |
-
|
35 |
-
if ( $ApiKey == "" && $ApiSecrete == "" ) {
|
36 |
-
|
37 |
return $errormsg;
|
38 |
-
|
39 |
-
}elseif( $UserAuth == false ){
|
40 |
-
|
41 |
return '<p style ="color:red;">Your LoginRadius API key and secret is not valid, please correct it or contact LoginRadius support at <b><a href ="http://www.loginradius.com" target = "_blank">www.LoginRadius.com</a></b></p>';
|
42 |
-
|
43 |
}else {
|
44 |
-
|
45 |
$IsHttps = (!empty($UserAuth->IsHttps)) ? $UserAuth->IsHttps : '';
|
46 |
-
|
47 |
$iframeHeight = (!empty($UserAuth->height)) ? $UserAuth->height : 50;
|
48 |
-
|
49 |
$iframeWidth = (!empty($UserAuth->width)) ? $UserAuth->width : 138;
|
50 |
-
|
51 |
$http = ($IsHttps == 1) ? "https://" : "http://";
|
52 |
-
|
53 |
$loc = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK)."sociallogin/";
|
54 |
-
|
55 |
if (empty($titleText)) {
|
56 |
-
|
57 |
$titleText = 'Social Login';
|
58 |
-
|
59 |
}
|
60 |
-
|
61 |
$label = '<span ><b>' . $titleText . '</b></span>';
|
62 |
-
|
63 |
$iframe = '<iframe src="'.$http.'hub.loginradius.com/Control/PluginSlider.aspx?apikey='.$ApiKey.'&callback='.$loc.'" width="'.$iframeWidth.'" height="'.$iframeHeight.'" frameborder="0" scrolling="no" allowtransparency="true"></iframe>';
|
64 |
-
|
65 |
return $label.$iframe;
|
66 |
-
|
67 |
}
|
68 |
-
|
69 |
}
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
}
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
protected function _toHtml() {
|
78 |
-
|
79 |
$content = '';
|
80 |
-
|
81 |
if (Mage::getSingleton('customer/session')->isLoggedIn() == false && $this->block_anyplace->loginEnable() == "1" ){
|
82 |
$content = $this->loginradius_buttons();
|
83 |
}
|
84 |
return $content;
|
85 |
}
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
protected function _prepareLayout() {
|
90 |
-
|
91 |
parent::_prepareLayout();
|
92 |
-
|
93 |
}
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
}
|
98 |
-
|
1 |
<?php
|
|
|
|
|
|
|
2 |
class Loginradius_Sociallogin_Block_Auth extends Mage_Core_Block_Template implements Mage_Widget_Block_Interface {
|
|
|
3 |
private $block_anyplace;
|
4 |
public function __construct(){
|
5 |
$this->block_anyplace = new Loginradius_Sociallogin_Block_Sociallogin();
|
6 |
}
|
7 |
function loginradius_buttons() {
|
|
|
|
|
|
|
8 |
$ApiKey = trim($this->block_anyplace->getApikey());
|
|
|
9 |
$ApiSecrete = trim($this->block_anyplace->getApiSecret());
|
|
|
10 |
$UserAuth = $this->block_anyplace->getApiResult($ApiKey, $ApiSecrete);
|
|
|
11 |
$titleText = $this->getLabelText();
|
|
|
12 |
$errormsg = '<p style ="color:red;">To activate your plugin, please log in to LoginRadius and get API Key & Secret. Web: <b><a href ="http://www.loginradius.com" target = "_blank">www.LoginRadius.com</a></b></p>';
|
|
|
13 |
if ($this->block_anyplace->user_is_already_login()) {
|
|
|
14 |
$userName = Mage::getSingleton('customer/session')->getCustomer()->getName();
|
|
|
15 |
return '<span>Welcome!'.' '.$userName .'</span>';
|
16 |
+
}else{
|
17 |
+
if( $ApiKey == "" && $ApiSecrete == "" ){
|
|
|
|
|
|
|
|
|
|
|
18 |
return $errormsg;
|
19 |
+
}elseif( $UserAuth == false ){
|
|
|
|
|
20 |
return '<p style ="color:red;">Your LoginRadius API key and secret is not valid, please correct it or contact LoginRadius support at <b><a href ="http://www.loginradius.com" target = "_blank">www.LoginRadius.com</a></b></p>';
|
|
|
21 |
}else {
|
|
|
22 |
$IsHttps = (!empty($UserAuth->IsHttps)) ? $UserAuth->IsHttps : '';
|
|
|
23 |
$iframeHeight = (!empty($UserAuth->height)) ? $UserAuth->height : 50;
|
|
|
24 |
$iframeWidth = (!empty($UserAuth->width)) ? $UserAuth->width : 138;
|
|
|
25 |
$http = ($IsHttps == 1) ? "https://" : "http://";
|
|
|
26 |
$loc = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK)."sociallogin/";
|
|
|
27 |
if (empty($titleText)) {
|
|
|
28 |
$titleText = 'Social Login';
|
|
|
29 |
}
|
|
|
30 |
$label = '<span ><b>' . $titleText . '</b></span>';
|
|
|
31 |
$iframe = '<iframe src="'.$http.'hub.loginradius.com/Control/PluginSlider.aspx?apikey='.$ApiKey.'&callback='.$loc.'" width="'.$iframeWidth.'" height="'.$iframeHeight.'" frameborder="0" scrolling="no" allowtransparency="true"></iframe>';
|
|
|
32 |
return $label.$iframe;
|
|
|
33 |
}
|
|
|
34 |
}
|
|
|
|
|
|
|
35 |
}
|
|
|
|
|
|
|
36 |
protected function _toHtml() {
|
|
|
37 |
$content = '';
|
|
|
38 |
if (Mage::getSingleton('customer/session')->isLoggedIn() == false && $this->block_anyplace->loginEnable() == "1" ){
|
39 |
$content = $this->loginradius_buttons();
|
40 |
}
|
41 |
return $content;
|
42 |
}
|
|
|
|
|
|
|
43 |
protected function _prepareLayout() {
|
|
|
44 |
parent::_prepareLayout();
|
|
|
45 |
}
|
46 |
+
}
|
|
|
|
|
|
|
|
app/code/community/Loginradius/Sociallogin/Block/Info.php
CHANGED
@@ -1,24 +1,15 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
class Loginradius_Sociallogin_Block_Info extends Mage_Adminhtml_Block_System_Config_Form_Fieldset {
|
4 |
-
|
5 |
public function render(Varien_Data_Form_Element_Abstract $element) {
|
6 |
-
|
7 |
$html = $this->_getHeaderHtml($element);
|
8 |
-
|
9 |
$html.= $this->_getFieldHtml($element);
|
10 |
-
|
11 |
$html .= $this->_getFooterHtml($element);
|
12 |
-
|
13 |
return $html;
|
14 |
}
|
15 |
-
|
16 |
protected function _getFieldHtml($fieldset) {
|
17 |
$content = '<p>Social Login for Magento ' . Mage::getConfig()->getModuleConfig("Loginradius_Sociallogin")->version . '</p>';
|
18 |
$content.= '<p>This extension is developed by <a href="http://loginradius.com/" target="_blank">LoginRadius</a>. Please refer to our <a href="http://support.loginradius.com/customer/portal/articles/682910-how-do-i-implement-social-login-on-my-magento-website-" target="_blank">Documentation</a> on how to install and configure this extension.</p>';
|
19 |
$content.= '<p>Copyright © ' . date("Y") . ' <a href="http://loginradius.com/" target="_blank">LoginRadius, Inc.</a></p>';
|
20 |
-
|
21 |
return $content;
|
22 |
}
|
23 |
-
|
24 |
-
}
|
1 |
<?php
|
|
|
2 |
class Loginradius_Sociallogin_Block_Info extends Mage_Adminhtml_Block_System_Config_Form_Fieldset {
|
|
|
3 |
public function render(Varien_Data_Form_Element_Abstract $element) {
|
|
|
4 |
$html = $this->_getHeaderHtml($element);
|
|
|
5 |
$html.= $this->_getFieldHtml($element);
|
|
|
6 |
$html .= $this->_getFooterHtml($element);
|
|
|
7 |
return $html;
|
8 |
}
|
|
|
9 |
protected function _getFieldHtml($fieldset) {
|
10 |
$content = '<p>Social Login for Magento ' . Mage::getConfig()->getModuleConfig("Loginradius_Sociallogin")->version . '</p>';
|
11 |
$content.= '<p>This extension is developed by <a href="http://loginradius.com/" target="_blank">LoginRadius</a>. Please refer to our <a href="http://support.loginradius.com/customer/portal/articles/682910-how-do-i-implement-social-login-on-my-magento-website-" target="_blank">Documentation</a> on how to install and configure this extension.</p>';
|
12 |
$content.= '<p>Copyright © ' . date("Y") . ' <a href="http://loginradius.com/" target="_blank">LoginRadius, Inc.</a></p>';
|
|
|
13 |
return $content;
|
14 |
}
|
15 |
+
}
|
|
app/code/community/Loginradius/Sociallogin/Block/Sociallogin.php
CHANGED
@@ -1,39 +1,34 @@
|
|
1 |
<?php
|
2 |
class Loginradius_Sociallogin_Block_Sociallogin extends Mage_Core_Block_Template
|
3 |
{
|
4 |
-
protected function _construct()
|
5 |
-
{
|
6 |
parent::_construct();
|
7 |
if( $this->shareEnable() == "1" || $this->counterEnable() == "1" ){
|
8 |
$this->setTemplate('sociallogin/socialshare.phtml');
|
9 |
}
|
10 |
}
|
11 |
-
public function _prepareLayout()
|
12 |
-
{
|
13 |
return parent::_prepareLayout();
|
14 |
}
|
15 |
-
public function getSociallogin()
|
16 |
-
{
|
17 |
if (!$this->hasData('sociallogin')) {
|
18 |
$this->setData('sociallogin', Mage::registry('sociallogin'));
|
19 |
}
|
20 |
return $this->getData('sociallogin');
|
21 |
-
|
22 |
-
|
23 |
if( Mage::getSingleton('customer/session')->isLoggedIn() ){
|
24 |
return true;
|
25 |
}
|
26 |
return false;
|
27 |
-
|
28 |
-
public function loginEnable()
|
29 |
-
{
|
30 |
return Mage::getStoreConfig('sociallogin_options/messages/loginEnable');
|
31 |
}
|
32 |
-
public function getApikey()
|
33 |
-
{
|
34 |
return Mage::getStoreConfig('sociallogin_options/messages/appid');
|
35 |
}
|
36 |
-
|
37 |
$socialLoginConn = Mage::getSingleton('core/resource')
|
38 |
->getConnection('core_read');
|
39 |
$SocialLoginTbl = Mage::getSingleton('core/resource')->getTableName("sociallogin");
|
@@ -48,6 +43,22 @@ class Loginradius_Sociallogin_Block_Sociallogin extends Mage_Core_Block_Template
|
|
48 |
public function getShowDefault()
|
49 |
{
|
50 |
return Mage::getStoreConfig('sociallogin_options/messages/showdefault');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
}
|
52 |
public function getApiSecret()
|
53 |
{
|
1 |
<?php
|
2 |
class Loginradius_Sociallogin_Block_Sociallogin extends Mage_Core_Block_Template
|
3 |
{
|
4 |
+
protected function _construct(){
|
|
|
5 |
parent::_construct();
|
6 |
if( $this->shareEnable() == "1" || $this->counterEnable() == "1" ){
|
7 |
$this->setTemplate('sociallogin/socialshare.phtml');
|
8 |
}
|
9 |
}
|
10 |
+
public function _prepareLayout(){
|
|
|
11 |
return parent::_prepareLayout();
|
12 |
}
|
13 |
+
public function getSociallogin(){
|
|
|
14 |
if (!$this->hasData('sociallogin')) {
|
15 |
$this->setData('sociallogin', Mage::registry('sociallogin'));
|
16 |
}
|
17 |
return $this->getData('sociallogin');
|
18 |
+
}
|
19 |
+
public function user_is_already_login() {
|
20 |
if( Mage::getSingleton('customer/session')->isLoggedIn() ){
|
21 |
return true;
|
22 |
}
|
23 |
return false;
|
24 |
+
}
|
25 |
+
public function loginEnable(){
|
|
|
26 |
return Mage::getStoreConfig('sociallogin_options/messages/loginEnable');
|
27 |
}
|
28 |
+
public function getApikey(){
|
|
|
29 |
return Mage::getStoreConfig('sociallogin_options/messages/appid');
|
30 |
}
|
31 |
+
public function getAvatar( $id ){
|
32 |
$socialLoginConn = Mage::getSingleton('core/resource')
|
33 |
->getConnection('core_read');
|
34 |
$SocialLoginTbl = Mage::getSingleton('core/resource')->getTableName("sociallogin");
|
43 |
public function getShowDefault()
|
44 |
{
|
45 |
return Mage::getStoreConfig('sociallogin_options/messages/showdefault');
|
46 |
+
}
|
47 |
+
public function getAboveLogin()
|
48 |
+
{
|
49 |
+
return Mage::getStoreConfig('sociallogin_options/messages/aboveLogin');
|
50 |
+
}
|
51 |
+
public function getBelowLogin()
|
52 |
+
{
|
53 |
+
return Mage::getStoreConfig('sociallogin_options/messages/belowLogin');
|
54 |
+
}
|
55 |
+
public function getAboveRegister()
|
56 |
+
{
|
57 |
+
return Mage::getStoreConfig('sociallogin_options/messages/aboveRegister');
|
58 |
+
}
|
59 |
+
public function getBelowRegister()
|
60 |
+
{
|
61 |
+
return Mage::getStoreConfig('sociallogin_options/messages/belowRegister');
|
62 |
}
|
63 |
public function getApiSecret()
|
64 |
{
|
app/code/community/Loginradius/Sociallogin/Helper/Data.php
CHANGED
@@ -1,7 +1,5 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
class Loginradius_Sociallogin_Helper_Data extends Mage_Core_Helper_Abstract {
|
4 |
-
|
5 |
/**
|
6 |
* Returns whether the Enabled config variable is set to true
|
7 |
*
|
@@ -13,4 +11,4 @@ class Loginradius_Sociallogin_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
13 |
}
|
14 |
return false;
|
15 |
}
|
16 |
-
}
|
1 |
<?php
|
|
|
2 |
class Loginradius_Sociallogin_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
|
3 |
/**
|
4 |
* Returns whether the Enabled config variable is set to true
|
5 |
*
|
11 |
}
|
12 |
return false;
|
13 |
}
|
14 |
+
}
|
app/code/community/Loginradius/Sociallogin/Model/Mysql4/Sociallogin.php
CHANGED
@@ -1,9 +1,8 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
}
|
9 |
}
|
1 |
+
<?php
|
2 |
+
class Loginradius_Sociallogin_Model_Mysql4_Sociallogin extends Mage_Core_Model_Mysql4_Abstract
|
3 |
+
{
|
4 |
+
public function _construct()
|
5 |
+
{
|
6 |
+
$this->_init('socialogin/socialogin', 'socialogin_id');
|
7 |
+
}
|
|
|
8 |
}
|
app/code/community/Loginradius/Sociallogin/Model/Mysql4/Sociallogin/Collection.php
CHANGED
@@ -1,10 +1,9 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
}
|
10 |
}
|
1 |
+
<?php
|
2 |
+
class Loginradius_Sociallogin_Model_Mysql4_Sociallogin_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
3 |
+
{
|
4 |
+
public function _construct()
|
5 |
+
{
|
6 |
+
//parent::__construct();
|
7 |
+
$this->_init('sociallogin/sociallogin');
|
8 |
+
}
|
|
|
9 |
}
|
app/code/community/Loginradius/Sociallogin/Model/Sociallogin.php
CHANGED
@@ -1,12 +1,9 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
$this->_init('sociallogin/sociallogin');
|
10 |
-
}
|
11 |
-
|
12 |
}
|
1 |
+
<?php
|
2 |
+
class Loginradius_Sociallogin_Model_Sociallogin extends Mage_Core_Model_Abstract
|
3 |
+
{
|
4 |
+
public function _construct()
|
5 |
+
{
|
6 |
+
parent::_construct();
|
7 |
+
$this->_init('sociallogin/sociallogin');
|
8 |
+
}
|
|
|
|
|
|
|
9 |
}
|
app/code/community/Loginradius/Sociallogin/Model/Source/Uihover.php
CHANGED
@@ -1,17 +1,12 @@
|
|
1 |
-
<?php
|
2 |
-
class Loginradius_Sociallogin_Model_Source_Uihover
|
3 |
-
{
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
$result[] = array('value' => 'custom', 'label'=>' Redirect to following url' );
|
13 |
-
|
14 |
-
return $result;
|
15 |
-
|
16 |
-
}
|
17 |
}
|
1 |
+
<?php
|
2 |
+
class Loginradius_Sociallogin_Model_Source_Uihover
|
3 |
+
{
|
4 |
+
public function toOptionArray()
|
5 |
+
{
|
6 |
+
$result = array();
|
7 |
+
$result[] = array('value' => 'account', 'label'=>' Redirect to Account page<br/>');
|
8 |
+
$result[] = array('value' => 'index', 'label'=>' Redirect to Home page<br/>');
|
9 |
+
$result[] = array('value' => 'custom', 'label'=>' Redirect to following url' );
|
10 |
+
return $result;
|
11 |
+
}
|
|
|
|
|
|
|
|
|
|
|
12 |
}
|
app/code/community/Loginradius/Sociallogin/Model/Source/Uihover2.php
CHANGED
@@ -1,17 +1,12 @@
|
|
1 |
-
<?php
|
2 |
-
class Loginradius_Sociallogin_Model_Source_Uihover2
|
3 |
-
{
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
$result[] = array('value' => 'fopen', 'label'=>'Use FSOCKOPEN' );
|
13 |
-
|
14 |
-
return $result;
|
15 |
-
|
16 |
-
}
|
17 |
}
|
1 |
+
<?php
|
2 |
+
class Loginradius_Sociallogin_Model_Source_Uihover2
|
3 |
+
{
|
4 |
+
public function toOptionArray()
|
5 |
+
{
|
6 |
+
$result = array();
|
7 |
+
$result[] = array('value' => 'varien', 'label'=>'Use "http_varien_client"');
|
8 |
+
$result[] = array('value' => 'curl', 'label'=>'Use cURL');
|
9 |
+
$result[] = array('value' => 'fopen', 'label'=>'Use FSOCKOPEN' );
|
10 |
+
return $result;
|
11 |
+
}
|
|
|
|
|
|
|
|
|
|
|
12 |
}
|
app/code/community/Loginradius/Sociallogin/controllers/IndexController.php
CHANGED
@@ -1,63 +1,31 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
Mage::app('default');
|
4 |
-
|
5 |
include_once("inc.php");
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
//customer will be re-directed to this file. this file handle all token, email etc things.
|
10 |
-
|
11 |
class Loginradius_Sociallogin_IndexController extends Mage_Core_Controller_Front_Action
|
12 |
-
|
13 |
{
|
14 |
-
|
15 |
var $blockObj;
|
16 |
private $loginRadiusPopMsg;
|
17 |
private $loginRadiusPopErr;
|
18 |
-
|
19 |
protected function _getSession(){
|
20 |
-
|
21 |
return Mage::getSingleton('sociallogin/session');
|
22 |
-
|
23 |
}
|
24 |
|
25 |
-
|
26 |
-
|
27 |
//if token is posted then this function will be called. It will login user if already in database. else if email is provided by api, it will insert data and login user. It will handle all after token.
|
28 |
-
|
29 |
-
|
30 |
function tokenHandle() {
|
31 |
-
|
32 |
//$this->blockObj = new Loginradius_Sociallogin_Block_Sociallogin(); //object to get api key and secrets, url etc
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
$ApiSecrete = $this->blockObj->getApiSecret();
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
$user_obj = $this->blockObj->getProfileResult($ApiSecrete);
|
41 |
-
|
42 |
$id = $user_obj->ID;
|
43 |
-
|
44 |
if(empty($id)){
|
45 |
-
|
46 |
//invalid user
|
47 |
-
|
48 |
return;
|
49 |
-
|
50 |
}
|
51 |
|
52 |
-
|
53 |
-
|
54 |
//valid user, checking if user in database?
|
55 |
-
|
56 |
$socialLoginIdResult = $this->loginRadiusRead( "sociallogin", "get user", array($id), true );
|
57 |
-
|
58 |
$socialLoginIds = $socialLoginIdResult->fetchAll();
|
59 |
foreach( $socialLoginIds as $socialLoginId ){
|
60 |
-
|
61 |
$select = $this->loginRadiusRead( "customer_entity", "get user2", array($socialLoginId['entity_id']), true );
|
62 |
if($rowArray = $select->fetch()){
|
63 |
if( $socialLoginId['verified'] == "0" ){
|
@@ -65,201 +33,105 @@ class Loginradius_Sociallogin_IndexController extends Mage_Core_Controller_Front
|
|
65 |
return;
|
66 |
}
|
67 |
break;
|
68 |
-
|
69 |
}
|
70 |
-
|
71 |
}
|
72 |
-
|
73 |
$sociallogin_id = $rowArray['entity_id'];
|
74 |
-
|
75 |
if(!empty($sociallogin_id)){//user is in database
|
76 |
-
|
77 |
$this->socialLoginUserLogin( $sociallogin_id );
|
78 |
-
|
79 |
return;
|
80 |
-
|
81 |
}
|
82 |
|
83 |
if( !empty($user_obj->Email[0]->Value) ){
|
84 |
-
|
85 |
//if email is provided by provider then check if it's in table
|
86 |
-
|
87 |
$email = $user_obj->Email['0']->Value;
|
88 |
-
|
89 |
$select = $this->loginRadiusRead( "customer_entity", "email exists login", array($email), true );
|
90 |
-
|
91 |
if( $rowArray = $select->fetch() ) {
|
92 |
-
|
93 |
$sociallogin_id = $rowArray['entity_id'];
|
94 |
-
|
95 |
if(!empty($sociallogin_id)) {
|
96 |
-
|
97 |
//user is in customer table
|
98 |
-
|
99 |
if( $this->blockObj->getLinking() == "1" ){ // Social Linking
|
100 |
if( !$this->loginRadiusRead( "sociallogin", "email exists in sociallogin", array($sociallogin_id)) ){
|
101 |
$socialLoginLinkData = array();
|
102 |
-
|
103 |
$socialLoginLinkData['sociallogin_id'] = $user_obj->ID;
|
104 |
-
|
105 |
$socialLoginLinkData['entity_id'] = $sociallogin_id;
|
106 |
-
|
107 |
$provider = empty($user_obj->Provider) ? "" : $user_obj->Provider;
|
108 |
-
|
109 |
$socialLoginLinkData['avatar'] = $this->socialLoginFilterAvatar( $user_obj->ID, $user_obj->ImageUrl, $provider );
|
110 |
$socialLoginLinkData['avatar'] = ($socialLoginLinkData['avatar'] == "") ? NULL : $socialLoginLinkData['avatar'] ;
|
111 |
$this->SocialLoginInsert( "sociallogin", $socialLoginLinkData );
|
112 |
}
|
113 |
}
|
114 |
-
|
115 |
$this->socialLoginUserLogin( $sociallogin_id );
|
116 |
-
|
117 |
return;
|
118 |
-
|
119 |
}
|
120 |
-
|
121 |
}
|
122 |
|
123 |
-
|
124 |
-
|
125 |
$socialloginProfileData = $this->socialLoginFilterData( $email, $user_obj );
|
126 |
-
|
127 |
$socialloginProfileData['lrId'] = $user_obj->ID;
|
128 |
-
|
129 |
$this->socialLoginAddNewUser( $socialloginProfileData, $email );
|
130 |
-
|
131 |
return;
|
132 |
-
|
133 |
}
|
134 |
|
135 |
// empty email
|
136 |
if( $this->blockObj->getEmailRequired() == 0 ) { // dummy email
|
137 |
-
|
138 |
$email = $this->loginradius_get_randomEmail( $user_obj );
|
139 |
-
|
140 |
$socialloginProfileData = $this->socialLoginFilterData( $email, $user_obj );
|
141 |
-
|
142 |
$socialloginProfileData['lrId'] = $user_obj->ID;
|
143 |
-
|
144 |
$this->socialLoginAddNewUser( $socialloginProfileData, $email );
|
145 |
-
|
146 |
return;
|
147 |
-
|
148 |
}else { // show popup
|
149 |
-
|
150 |
$id = $user_obj->ID;
|
151 |
-
|
152 |
$socialloginProfileData = $this->socialLoginFilterData( $email, $user_obj );
|
153 |
-
|
154 |
$this->setInSession($id, $socialloginProfileData);
|
155 |
-
|
156 |
SL_popUpWindow( $this->loginRadiusPopMsg );
|
157 |
-
|
158 |
return;
|
159 |
-
|
160 |
}
|
161 |
-
|
162 |
}
|
163 |
|
164 |
-
|
165 |
-
|
166 |
function loginradius_get_randomEmail( $user_obj ) {
|
167 |
-
|
168 |
switch ( $user_obj->Provider ) {
|
169 |
-
|
170 |
case 'twitter':
|
171 |
-
|
172 |
$email = $user_obj->ID. '@' . $user_obj->Provider . '.com';
|
173 |
-
|
174 |
break;
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
case 'linkedin':
|
179 |
-
|
180 |
$email = $user_obj->ID. '@' . $user_obj->Provider . '.com';
|
181 |
-
|
182 |
break;
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
default:
|
187 |
-
|
188 |
$Email_id = substr( $user_obj->ID, 7 );
|
189 |
-
|
190 |
$Email_id2 = str_replace("/", "_", $Email_id);
|
191 |
-
|
192 |
$email = str_replace(".", "_", $Email_id2) . '@' . $user_obj->Provider . '.com';
|
193 |
-
|
194 |
break;
|
195 |
-
|
196 |
}
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
return $email;
|
201 |
-
|
202 |
}
|
203 |
|
204 |
-
|
205 |
-
|
206 |
function socialLoginFilterData( $email, $user_obj ) {
|
207 |
-
|
208 |
$socialloginProfileData = array();
|
209 |
-
|
210 |
$socialloginProfileData['Provider'] = empty($user_obj->Provider) ? "" : $user_obj->Provider;
|
211 |
-
|
212 |
$socialloginProfileData['FirstName'] = empty($user_obj->FirstName) ? "" : $user_obj->FirstName;
|
213 |
-
|
214 |
$socialloginProfileData['FullName'] = empty($user_obj->FullName) ? "" : $user_obj->FullName;
|
215 |
-
|
216 |
$socialloginProfileData['NickName'] = empty($user_obj->NickName) ? "" : $user_obj->NickName;
|
217 |
-
|
218 |
$socialloginProfileData['LastName'] = empty($user_obj->LastName) ? "" : $user_obj->LastName;
|
219 |
-
|
220 |
$socialloginProfileData['Addresses'] = empty($user_obj->Addresses['0']->Address1) ? "" : $user_obj->Addresses['0']->Address1;
|
221 |
-
|
222 |
$socialloginProfileData['PhoneNumbers'] = empty( $user_obj->PhoneNumbers['0']->PhoneNumber ) ? "" : $user_obj->PhoneNumbers['0']->PhoneNumber;
|
223 |
-
|
224 |
$socialloginProfileData['State'] = empty($user_obj->State) ? "" : $user_obj->State;
|
225 |
-
|
226 |
$socialloginProfileData['City'] = empty($user_obj->City) ? "" : $user_obj->City;
|
227 |
-
|
228 |
$socialloginProfileData['Industry'] = empty($user_obj->Positions['0']->Comapny->Name) ? "" : $user_obj->Positions['0']->Comapny->Name;
|
229 |
-
|
230 |
$socialloginProfileData['Country'] = empty($user_obj->Country) ? "" : $user_obj->Country;
|
231 |
-
|
232 |
$socialloginProfileData['thumbnail'] = $this->socialLoginFilterAvatar( $user_obj->ID, $user_obj->ImageUrl, $socialloginProfileData['Provider'] );
|
233 |
-
|
234 |
-
|
235 |
$explode= explode("@",$email);
|
236 |
-
|
237 |
if( empty( $socialloginProfileData['FirstName'] ) && !empty( $socialloginProfileData['FullName'] ) ){
|
238 |
-
|
239 |
$socialloginProfileData['FirstName'] = $socialloginProfileData['FullName'];
|
240 |
-
|
241 |
}elseif(empty($socialloginProfileData['FirstName'] ) && !empty( $socialloginProfileData['NickName'] )){
|
242 |
-
|
243 |
$socialloginProfileData['FirstName'] = $socialloginProfileData['NickName'];
|
244 |
-
|
245 |
}elseif(empty($socialloginProfileData['FirstName'] ) && empty($socialloginProfileData['NickName'] ) && !empty($socialloginProfileData['FullName'] ) ){
|
246 |
-
|
247 |
$socialloginProfileData['FirstName'] = $explode[0];
|
248 |
-
|
249 |
}
|
250 |
-
|
251 |
if($socialloginProfileData['FirstName'] == '' ){
|
252 |
-
|
253 |
$letters = range('a', 'z');
|
254 |
-
|
255 |
for($i=0;$i<5;$i++){
|
256 |
-
|
257 |
$socialloginProfileData['FirstName'] .= $letters[rand(0,26)];
|
258 |
-
|
259 |
}
|
260 |
-
|
261 |
}
|
262 |
-
|
263 |
$socialloginProfileData['Gender'] = (!empty($user_obj->Gender) ? $user_obj->Gender : '');
|
264 |
if( strtolower(substr($socialloginProfileData['Gender'], 0, 1)) == 'm' ){
|
265 |
$socialloginProfileData['Gender'] = '1';
|
@@ -268,7 +140,6 @@ class Loginradius_Sociallogin_IndexController extends Mage_Core_Controller_Front
|
|
268 |
}else{
|
269 |
$socialloginProfileData['Gender'] = '';
|
270 |
}
|
271 |
-
|
272 |
$socialloginProfileData['BirthDate'] = (!empty($user_obj->BirthDate) ? $user_obj->BirthDate : '');
|
273 |
if( $socialloginProfileData['BirthDate'] != "" ){
|
274 |
switch( $socialloginProfileData['Provider'] ){
|
@@ -292,84 +163,50 @@ class Loginradius_Sociallogin_IndexController extends Mage_Core_Controller_Front
|
|
292 |
break;
|
293 |
}
|
294 |
}
|
295 |
-
|
296 |
return $socialloginProfileData;
|
297 |
-
|
298 |
}
|
299 |
|
300 |
-
|
301 |
-
|
302 |
function socialLoginFilterAvatar( $id, $ImgUrl, $provider ){
|
303 |
-
|
304 |
$thumbnail = (!empty($ImgUrl) ? trim($ImgUrl) : '');
|
305 |
-
|
306 |
if (empty($thumbnail) && ( $provider == 'facebook' ) ) {
|
307 |
-
|
308 |
$thumbnail = "http://graph.facebook.com/" . $id . "/picture?type=large";
|
309 |
-
|
310 |
}
|
311 |
-
|
312 |
return $thumbnail;
|
313 |
-
|
314 |
}
|
315 |
|
316 |
-
|
317 |
-
|
318 |
function socialLoginUserLogin( $sociallogin_id ) {
|
319 |
-
|
320 |
$session = Mage::getSingleton("customer/session");
|
321 |
-
|
322 |
$session->loginById($sociallogin_id);
|
323 |
-
|
324 |
$write_url = $this->blockObj->getCallBack();
|
325 |
-
|
326 |
$Hover = $this->blockObj->getRedirectOption();
|
327 |
-
|
328 |
$url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
|
329 |
-
|
330 |
if($Hover=='account' ){
|
331 |
-
|
332 |
header( 'Location: '.$url.'customer/account' );
|
333 |
-
|
334 |
return;
|
335 |
-
|
336 |
}elseif($Hover=='index' ){
|
337 |
-
|
338 |
header( 'Location: '.$url.'') ;
|
339 |
-
|
340 |
return;
|
341 |
-
|
342 |
}elseif( $Hover=='custom' && $write_url != '' ) {
|
343 |
-
|
344 |
header( 'Location: '.$write_url.'' );
|
345 |
-
|
346 |
return;
|
347 |
-
|
348 |
-
} else {
|
349 |
-
|
350 |
$currentUrl = Mage::helper('core/url')->getCurrentUrl();
|
351 |
-
|
352 |
header( 'Location: '.$currentUrl.'' );
|
353 |
-
|
354 |
return;
|
355 |
-
|
356 |
}
|
357 |
-
|
358 |
}
|
359 |
|
360 |
-
|
361 |
-
|
362 |
function setInSession( $id, $socialloginProfileData ){
|
363 |
-
|
364 |
$socialloginProfileData['lrId'] = $id;
|
365 |
-
|
366 |
Mage::getSingleton('core/session')->setSocialLoginData( $socialloginProfileData );
|
367 |
-
|
368 |
}
|
369 |
|
370 |
function loginRadiusEmail( $subject, $message, $to, $toName ){
|
371 |
$storeName = Mage::app()->getStore()->getGroup()->getName();
|
372 |
-
|
373 |
$mail = new Zend_Mail(); //class for mail
|
374 |
$mail->setBodyHtml( $message ); //for sending message containing html code
|
375 |
$mail->setFrom( "Owner", $storeName );
|
@@ -377,7 +214,6 @@ class Loginradius_Sociallogin_IndexController extends Mage_Core_Controller_Front
|
|
377 |
//$mail->addCc($cc, $ccname); //can set cc
|
378 |
//$mail->addBCc($bcc, $bccname); //can set bcc
|
379 |
$mail->setSubject( $subject );
|
380 |
-
|
381 |
try {
|
382 |
$mail->send();
|
383 |
}catch(Exception $ex) {
|
@@ -387,82 +223,45 @@ class Loginradius_Sociallogin_IndexController extends Mage_Core_Controller_Front
|
|
387 |
|
388 |
function socialLoginAddNewUser( $socialloginProfileData, $email, $verify = false ) {
|
389 |
// add new user magento way
|
390 |
-
|
391 |
$websiteId = Mage::app()->getWebsite()->getId();
|
392 |
$store = Mage::app()->getStore();
|
393 |
$customer = Mage::getModel("customer/customer");
|
394 |
-
|
395 |
$customer->website_id = $websiteId;
|
396 |
-
|
397 |
$customer->setStore($store);
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
$customer->firstname = $socialloginProfileData['FirstName'];
|
402 |
-
|
403 |
$customer->lastname = $socialloginProfileData['LastName'] == "" ? $socialloginProfileData['FirstName'] : $socialloginProfileData['LastName'];
|
404 |
-
|
405 |
$customer->email = $email;
|
406 |
-
|
407 |
$customer->dob = $socialloginProfileData['BirthDate'];
|
408 |
-
|
409 |
$customer->gender = $socialloginProfileData['Gender'];
|
410 |
-
|
411 |
-
|
412 |
$loginRadiusPwd = $customer->generatePassword(10);
|
413 |
$customer->password_hash = md5( $loginRadiusPwd );
|
414 |
$customer->setConfirmation(null);
|
415 |
$customer->save();
|
416 |
|
417 |
-
|
418 |
-
|
419 |
//$address = new Mage_Customer_Model_Address();
|
420 |
-
|
421 |
$address = Mage::getModel("customer/address");
|
422 |
-
|
423 |
$address->setCustomerId($customer->getId());
|
424 |
-
|
425 |
$address->firstname = $customer->firstname;
|
426 |
-
|
427 |
$address->lastname = $customer->lastname;
|
428 |
-
|
429 |
$address->country_id = ucfirst( $socialloginProfileData['Country'] ); //Country code here
|
430 |
|
431 |
// $address->postcode = "31000";
|
432 |
-
|
433 |
$address->city = ucfirst( $socialloginProfileData['City'] );
|
434 |
-
|
435 |
/* NOTE: If country is USA, please set up $address->region also */
|
436 |
-
|
437 |
$address->telephone = $socialloginProfileData['PhoneNumbers'];
|
438 |
-
|
439 |
$address->company = ucfirst( $socialloginProfileData['Industry'] );
|
440 |
-
|
441 |
$address->street = ucfirst( $socialloginProfileData['Addresses'] );
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
$address->save();
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
// add info in sociallogin table
|
450 |
if( !$verify ){
|
451 |
$fields = array();
|
452 |
-
|
453 |
$fields['sociallogin_id'] = $socialloginProfileData['lrId'] ;
|
454 |
-
|
455 |
$fields['entity_id'] = $customer->getId();
|
456 |
-
|
457 |
$fields['avatar'] = $socialloginProfileData['thumbnail'] ;
|
458 |
-
|
459 |
$this->SocialLoginInsert( "sociallogin", $fields );
|
460 |
-
|
461 |
-
|
462 |
//login user
|
463 |
$this->socialLoginUserLogin( $customer->getId() );
|
464 |
$loginRadiusUsername = $socialloginProfileData['FirstName']." ".$socialloginProfileData['LastName'];
|
465 |
-
|
466 |
// email notification to user
|
467 |
if( $this->blockObj->notifyUser() == "1" ){
|
468 |
$loginRadiusMessage = $this->blockObj->notifyUserText();
|
@@ -474,7 +273,6 @@ class Loginradius_Sociallogin_IndexController extends Mage_Core_Controller_Front
|
|
474 |
"<br/>Password : ".$loginRadiusPwd;
|
475 |
$this->loginRadiusEmail( "Welcome ".$loginRadiusUsername."!", $loginRadiusMessage, $email, $loginRadiusUsername );
|
476 |
}
|
477 |
-
|
478 |
// new user notification to admin
|
479 |
if( $this->blockObj->notifyAdmin() == "1" ){
|
480 |
$loginRadiusAdminEmail = Mage::getStoreConfig('trans_email/ident_general/email');
|
@@ -495,13 +293,9 @@ class Loginradius_Sociallogin_IndexController extends Mage_Core_Controller_Front
|
|
495 |
}
|
496 |
|
497 |
private function SocialLoginInsert( $lrTable, $lrInsertData, $update = false, $value ){
|
498 |
-
|
499 |
$connection = Mage::getSingleton('core/resource')
|
500 |
-
|
501 |
->getConnection('core_write');
|
502 |
-
|
503 |
$connection->beginTransaction();
|
504 |
-
|
505 |
$sociallogin = getMazeTable($lrTable);
|
506 |
if( !$update ){
|
507 |
$connection->insert($sociallogin, $lrInsertData);
|
@@ -512,27 +306,17 @@ class Loginradius_Sociallogin_IndexController extends Mage_Core_Controller_Front
|
|
512 |
$connection->commit();
|
513 |
}
|
514 |
|
515 |
-
|
516 |
-
|
517 |
private function SocialLoginShowLayout() {
|
518 |
-
|
519 |
$this->loadLayout();
|
520 |
-
|
521 |
$this->renderLayout();
|
522 |
-
|
523 |
}
|
524 |
|
525 |
private function loginRadiusRead( $table, $handle, $params, $result = false ){
|
526 |
$socialLoginConn = Mage::getSingleton('core/resource')
|
527 |
-
|
528 |
->getConnection('core_read');
|
529 |
-
|
530 |
$Tbl = getMazeTable($table);
|
531 |
-
|
532 |
$websiteId = Mage::app()->getWebsite()->getId();
|
533 |
-
|
534 |
$storeId = Mage::app()->getStore()->getId();
|
535 |
-
|
536 |
$query = "";
|
537 |
switch( $handle ){
|
538 |
case "email exists pop1":
|
@@ -544,22 +328,18 @@ class Loginradius_Sociallogin_IndexController extends Mage_Core_Controller_Front
|
|
544 |
case "get user2":
|
545 |
$query = "select entity_id from $Tbl where entity_id = ".$params[0]." and website_id = $websiteId and store_id = $storeId";
|
546 |
break;
|
547 |
-
|
548 |
case "email exists login":
|
549 |
$query = "select * from $Tbl where email = '".$params[0]."' and website_id = $websiteId and store_id = $storeId";
|
550 |
break;
|
551 |
-
|
552 |
case "email exists sl":
|
553 |
$query = "select verified,sociallogin_id from $Tbl where entity_id = '".$params[0]."' and provider = '".$params[1]."'";
|
554 |
break;
|
555 |
case "email exists in sociallogin":
|
556 |
$query = "select entity_id from $Tbl where entity_id = '".$params[0]."'";
|
557 |
break;
|
558 |
-
|
559 |
case "verification":
|
560 |
$query = "select entity_id, provider from $Tbl where vkey = '".$params[0]."'";
|
561 |
break;
|
562 |
-
|
563 |
case "verification2":
|
564 |
$query = "select entity_id from $Tbl where entity_id = ".$params[0]." and provider = '".$params[1]."' and vkey != '' ";
|
565 |
break;
|
@@ -583,19 +363,15 @@ class Loginradius_Sociallogin_IndexController extends Mage_Core_Controller_Front
|
|
583 |
$data['verified'] = "0";
|
584 |
$data['vkey'] = $vKey;
|
585 |
$data['provider'] = $provider;
|
586 |
-
|
587 |
// insert details in sociallogin table
|
588 |
$this->SocialLoginInsert( "sociallogin", $data );
|
589 |
-
|
590 |
// send verification mail
|
591 |
$message = trim($this->blockObj->verificationText());
|
592 |
if( $message == "" ){
|
593 |
$message = "Please click on the following link or paste it in browser to verify your email:-";
|
594 |
}
|
595 |
$message .= "<br/>".Mage::getBaseUrl()."sociallogin/?loginRadiusKey=".$vKey;
|
596 |
-
|
597 |
$this->loginRadiusEmail( "Email verification", $message, $email, $email);
|
598 |
-
|
599 |
// show popup message
|
600 |
SL_popUpWindow( "Confirmation link Has Been Sent To Your Email Address. Please verify your email by clicking on confirmation link.", "", false );
|
601 |
$this->SocialLoginShowLayout();
|
@@ -606,26 +382,18 @@ class Loginradius_Sociallogin_IndexController extends Mage_Core_Controller_Front
|
|
606 |
$this->blockObj = new Loginradius_Sociallogin_Block_Sociallogin();
|
607 |
$this->loginRadiusPopMsg = trim($this->blockObj->getPopupText() );
|
608 |
$this->loginRadiusPopMsg = $this->loginRadiusPopMsg == "" ? "Please enter your email to proceed" : $this->loginRadiusPopMsg;
|
609 |
-
|
610 |
$this->loginRadiusPopErr = trim($this->blockObj->getPopupError() );
|
611 |
$this->loginRadiusPopErr = $this->loginRadiusPopErr == "" ? "Email you entered is either invalid or already registered. Please enter a valid email." : $this->loginRadiusPopErr;
|
612 |
-
|
613 |
if(isset($_REQUEST['token'])) {
|
614 |
-
|
615 |
$this->tokenHandle();
|
616 |
-
|
617 |
$this->loadLayout();
|
618 |
-
|
619 |
$this->renderLayout();
|
620 |
-
|
621 |
return;
|
622 |
-
|
623 |
}
|
624 |
|
625 |
// email verification
|
626 |
if( isset($_GET['loginRadiusKey']) && !empty($_GET['loginRadiusKey']) ){
|
627 |
$loginRadiusVkey = trim( $_GET['loginRadiusKey'] );
|
628 |
-
|
629 |
// get entity_id and provider of the vKey
|
630 |
$result = $this->loginRadiusRead( "sociallogin", "verification", array( $loginRadiusVkey ), true );
|
631 |
if( $temp = $result->fetch() ){
|
@@ -644,26 +412,18 @@ class Loginradius_Sociallogin_IndexController extends Mage_Core_Controller_Front
|
|
644 |
}
|
645 |
}
|
646 |
|
647 |
-
|
648 |
$socialLoginProfileData = Mage::getSingleton('core/session')->getSocialLoginData();
|
649 |
-
|
650 |
$session_user_id = $socialLoginProfileData['lrId'];
|
651 |
$loginRadiusPopProvider = $socialLoginProfileData['Provider'];
|
652 |
$loginRadiusAvatar = $socialLoginProfileData['thumbnail'];
|
653 |
|
654 |
if( isset($_POST['LoginRadiusRedSliderClick']) ) {
|
655 |
-
|
656 |
if( !empty($session_user_id) ){
|
657 |
-
|
658 |
$email = trim($_POST['SL_EMAIL']);
|
659 |
if( !preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/", $email) ){
|
660 |
-
|
661 |
SL_popUpWindow( $this->loginRadiusPopMsg, $this->loginRadiusPopErr );
|
662 |
-
|
663 |
$this->SocialLoginShowLayout();
|
664 |
-
|
665 |
return false;
|
666 |
-
|
667 |
}
|
668 |
|
669 |
// check if email already exists
|
@@ -700,31 +460,17 @@ class Loginradius_Sociallogin_IndexController extends Mage_Core_Controller_Front
|
|
700 |
$this->verifyUser( $session_user_id, $rowArray['entity_id'], $loginRadiusAvatar, $loginRadiusPopProvider, $email );
|
701 |
return;
|
702 |
}
|
703 |
-
|
704 |
}
|
705 |
-
|
706 |
$socialloginProfileData = Mage::getSingleton('core/session')->getSocialLoginData();
|
707 |
-
|
708 |
Mage::getSingleton('core/session')->unsSocialLoginData(); // unset session
|
709 |
-
|
710 |
//$this->blockObj = new Loginradius_Sociallogin_Block_Sociallogin(); //object to get api key and secrets, url etc
|
711 |
-
|
712 |
$this->socialLoginAddNewUser( $socialloginProfileData, $email, true );
|
713 |
-
|
714 |
}
|
715 |
-
|
716 |
}elseif( isset($_POST['LoginRadiusPopupCancel']) ) { // popup cancelled
|
717 |
-
|
718 |
Mage::getSingleton('core/session')->unsSocialLoginData(); // unset session
|
719 |
-
|
720 |
$url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
|
721 |
-
|
722 |
header("Location:".$url); // redirect to index page
|
723 |
-
|
724 |
}
|
725 |
-
|
726 |
$this->SocialLoginShowLayout();
|
727 |
-
|
728 |
}
|
729 |
-
|
730 |
}
|
1 |
<?php
|
|
|
2 |
Mage::app('default');
|
|
|
3 |
include_once("inc.php");
|
|
|
|
|
|
|
4 |
//customer will be re-directed to this file. this file handle all token, email etc things.
|
|
|
5 |
class Loginradius_Sociallogin_IndexController extends Mage_Core_Controller_Front_Action
|
|
|
6 |
{
|
|
|
7 |
var $blockObj;
|
8 |
private $loginRadiusPopMsg;
|
9 |
private $loginRadiusPopErr;
|
|
|
10 |
protected function _getSession(){
|
|
|
11 |
return Mage::getSingleton('sociallogin/session');
|
|
|
12 |
}
|
13 |
|
|
|
|
|
14 |
//if token is posted then this function will be called. It will login user if already in database. else if email is provided by api, it will insert data and login user. It will handle all after token.
|
|
|
|
|
15 |
function tokenHandle() {
|
|
|
16 |
//$this->blockObj = new Loginradius_Sociallogin_Block_Sociallogin(); //object to get api key and secrets, url etc
|
|
|
|
|
|
|
17 |
$ApiSecrete = $this->blockObj->getApiSecret();
|
|
|
|
|
|
|
18 |
$user_obj = $this->blockObj->getProfileResult($ApiSecrete);
|
|
|
19 |
$id = $user_obj->ID;
|
|
|
20 |
if(empty($id)){
|
|
|
21 |
//invalid user
|
|
|
22 |
return;
|
|
|
23 |
}
|
24 |
|
|
|
|
|
25 |
//valid user, checking if user in database?
|
|
|
26 |
$socialLoginIdResult = $this->loginRadiusRead( "sociallogin", "get user", array($id), true );
|
|
|
27 |
$socialLoginIds = $socialLoginIdResult->fetchAll();
|
28 |
foreach( $socialLoginIds as $socialLoginId ){
|
|
|
29 |
$select = $this->loginRadiusRead( "customer_entity", "get user2", array($socialLoginId['entity_id']), true );
|
30 |
if($rowArray = $select->fetch()){
|
31 |
if( $socialLoginId['verified'] == "0" ){
|
33 |
return;
|
34 |
}
|
35 |
break;
|
|
|
36 |
}
|
|
|
37 |
}
|
|
|
38 |
$sociallogin_id = $rowArray['entity_id'];
|
|
|
39 |
if(!empty($sociallogin_id)){//user is in database
|
|
|
40 |
$this->socialLoginUserLogin( $sociallogin_id );
|
|
|
41 |
return;
|
|
|
42 |
}
|
43 |
|
44 |
if( !empty($user_obj->Email[0]->Value) ){
|
|
|
45 |
//if email is provided by provider then check if it's in table
|
|
|
46 |
$email = $user_obj->Email['0']->Value;
|
|
|
47 |
$select = $this->loginRadiusRead( "customer_entity", "email exists login", array($email), true );
|
|
|
48 |
if( $rowArray = $select->fetch() ) {
|
|
|
49 |
$sociallogin_id = $rowArray['entity_id'];
|
|
|
50 |
if(!empty($sociallogin_id)) {
|
|
|
51 |
//user is in customer table
|
|
|
52 |
if( $this->blockObj->getLinking() == "1" ){ // Social Linking
|
53 |
if( !$this->loginRadiusRead( "sociallogin", "email exists in sociallogin", array($sociallogin_id)) ){
|
54 |
$socialLoginLinkData = array();
|
|
|
55 |
$socialLoginLinkData['sociallogin_id'] = $user_obj->ID;
|
|
|
56 |
$socialLoginLinkData['entity_id'] = $sociallogin_id;
|
|
|
57 |
$provider = empty($user_obj->Provider) ? "" : $user_obj->Provider;
|
|
|
58 |
$socialLoginLinkData['avatar'] = $this->socialLoginFilterAvatar( $user_obj->ID, $user_obj->ImageUrl, $provider );
|
59 |
$socialLoginLinkData['avatar'] = ($socialLoginLinkData['avatar'] == "") ? NULL : $socialLoginLinkData['avatar'] ;
|
60 |
$this->SocialLoginInsert( "sociallogin", $socialLoginLinkData );
|
61 |
}
|
62 |
}
|
|
|
63 |
$this->socialLoginUserLogin( $sociallogin_id );
|
|
|
64 |
return;
|
|
|
65 |
}
|
|
|
66 |
}
|
67 |
|
|
|
|
|
68 |
$socialloginProfileData = $this->socialLoginFilterData( $email, $user_obj );
|
|
|
69 |
$socialloginProfileData['lrId'] = $user_obj->ID;
|
|
|
70 |
$this->socialLoginAddNewUser( $socialloginProfileData, $email );
|
|
|
71 |
return;
|
|
|
72 |
}
|
73 |
|
74 |
// empty email
|
75 |
if( $this->blockObj->getEmailRequired() == 0 ) { // dummy email
|
|
|
76 |
$email = $this->loginradius_get_randomEmail( $user_obj );
|
|
|
77 |
$socialloginProfileData = $this->socialLoginFilterData( $email, $user_obj );
|
|
|
78 |
$socialloginProfileData['lrId'] = $user_obj->ID;
|
|
|
79 |
$this->socialLoginAddNewUser( $socialloginProfileData, $email );
|
|
|
80 |
return;
|
|
|
81 |
}else { // show popup
|
|
|
82 |
$id = $user_obj->ID;
|
|
|
83 |
$socialloginProfileData = $this->socialLoginFilterData( $email, $user_obj );
|
|
|
84 |
$this->setInSession($id, $socialloginProfileData);
|
|
|
85 |
SL_popUpWindow( $this->loginRadiusPopMsg );
|
|
|
86 |
return;
|
|
|
87 |
}
|
|
|
88 |
}
|
89 |
|
|
|
|
|
90 |
function loginradius_get_randomEmail( $user_obj ) {
|
|
|
91 |
switch ( $user_obj->Provider ) {
|
|
|
92 |
case 'twitter':
|
|
|
93 |
$email = $user_obj->ID. '@' . $user_obj->Provider . '.com';
|
|
|
94 |
break;
|
|
|
|
|
|
|
95 |
case 'linkedin':
|
|
|
96 |
$email = $user_obj->ID. '@' . $user_obj->Provider . '.com';
|
|
|
97 |
break;
|
|
|
|
|
|
|
98 |
default:
|
|
|
99 |
$Email_id = substr( $user_obj->ID, 7 );
|
|
|
100 |
$Email_id2 = str_replace("/", "_", $Email_id);
|
|
|
101 |
$email = str_replace(".", "_", $Email_id2) . '@' . $user_obj->Provider . '.com';
|
|
|
102 |
break;
|
|
|
103 |
}
|
|
|
|
|
|
|
104 |
return $email;
|
|
|
105 |
}
|
106 |
|
|
|
|
|
107 |
function socialLoginFilterData( $email, $user_obj ) {
|
|
|
108 |
$socialloginProfileData = array();
|
|
|
109 |
$socialloginProfileData['Provider'] = empty($user_obj->Provider) ? "" : $user_obj->Provider;
|
|
|
110 |
$socialloginProfileData['FirstName'] = empty($user_obj->FirstName) ? "" : $user_obj->FirstName;
|
|
|
111 |
$socialloginProfileData['FullName'] = empty($user_obj->FullName) ? "" : $user_obj->FullName;
|
|
|
112 |
$socialloginProfileData['NickName'] = empty($user_obj->NickName) ? "" : $user_obj->NickName;
|
|
|
113 |
$socialloginProfileData['LastName'] = empty($user_obj->LastName) ? "" : $user_obj->LastName;
|
|
|
114 |
$socialloginProfileData['Addresses'] = empty($user_obj->Addresses['0']->Address1) ? "" : $user_obj->Addresses['0']->Address1;
|
|
|
115 |
$socialloginProfileData['PhoneNumbers'] = empty( $user_obj->PhoneNumbers['0']->PhoneNumber ) ? "" : $user_obj->PhoneNumbers['0']->PhoneNumber;
|
|
|
116 |
$socialloginProfileData['State'] = empty($user_obj->State) ? "" : $user_obj->State;
|
|
|
117 |
$socialloginProfileData['City'] = empty($user_obj->City) ? "" : $user_obj->City;
|
|
|
118 |
$socialloginProfileData['Industry'] = empty($user_obj->Positions['0']->Comapny->Name) ? "" : $user_obj->Positions['0']->Comapny->Name;
|
|
|
119 |
$socialloginProfileData['Country'] = empty($user_obj->Country) ? "" : $user_obj->Country;
|
|
|
120 |
$socialloginProfileData['thumbnail'] = $this->socialLoginFilterAvatar( $user_obj->ID, $user_obj->ImageUrl, $socialloginProfileData['Provider'] );
|
|
|
|
|
121 |
$explode= explode("@",$email);
|
|
|
122 |
if( empty( $socialloginProfileData['FirstName'] ) && !empty( $socialloginProfileData['FullName'] ) ){
|
|
|
123 |
$socialloginProfileData['FirstName'] = $socialloginProfileData['FullName'];
|
|
|
124 |
}elseif(empty($socialloginProfileData['FirstName'] ) && !empty( $socialloginProfileData['NickName'] )){
|
|
|
125 |
$socialloginProfileData['FirstName'] = $socialloginProfileData['NickName'];
|
|
|
126 |
}elseif(empty($socialloginProfileData['FirstName'] ) && empty($socialloginProfileData['NickName'] ) && !empty($socialloginProfileData['FullName'] ) ){
|
|
|
127 |
$socialloginProfileData['FirstName'] = $explode[0];
|
|
|
128 |
}
|
|
|
129 |
if($socialloginProfileData['FirstName'] == '' ){
|
|
|
130 |
$letters = range('a', 'z');
|
|
|
131 |
for($i=0;$i<5;$i++){
|
|
|
132 |
$socialloginProfileData['FirstName'] .= $letters[rand(0,26)];
|
|
|
133 |
}
|
|
|
134 |
}
|
|
|
135 |
$socialloginProfileData['Gender'] = (!empty($user_obj->Gender) ? $user_obj->Gender : '');
|
136 |
if( strtolower(substr($socialloginProfileData['Gender'], 0, 1)) == 'm' ){
|
137 |
$socialloginProfileData['Gender'] = '1';
|
140 |
}else{
|
141 |
$socialloginProfileData['Gender'] = '';
|
142 |
}
|
|
|
143 |
$socialloginProfileData['BirthDate'] = (!empty($user_obj->BirthDate) ? $user_obj->BirthDate : '');
|
144 |
if( $socialloginProfileData['BirthDate'] != "" ){
|
145 |
switch( $socialloginProfileData['Provider'] ){
|
163 |
break;
|
164 |
}
|
165 |
}
|
|
|
166 |
return $socialloginProfileData;
|
|
|
167 |
}
|
168 |
|
|
|
|
|
169 |
function socialLoginFilterAvatar( $id, $ImgUrl, $provider ){
|
|
|
170 |
$thumbnail = (!empty($ImgUrl) ? trim($ImgUrl) : '');
|
|
|
171 |
if (empty($thumbnail) && ( $provider == 'facebook' ) ) {
|
|
|
172 |
$thumbnail = "http://graph.facebook.com/" . $id . "/picture?type=large";
|
|
|
173 |
}
|
|
|
174 |
return $thumbnail;
|
|
|
175 |
}
|
176 |
|
|
|
|
|
177 |
function socialLoginUserLogin( $sociallogin_id ) {
|
|
|
178 |
$session = Mage::getSingleton("customer/session");
|
|
|
179 |
$session->loginById($sociallogin_id);
|
|
|
180 |
$write_url = $this->blockObj->getCallBack();
|
|
|
181 |
$Hover = $this->blockObj->getRedirectOption();
|
|
|
182 |
$url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
|
|
|
183 |
if($Hover=='account' ){
|
|
|
184 |
header( 'Location: '.$url.'customer/account' );
|
185 |
+
exit();
|
186 |
return;
|
|
|
187 |
}elseif($Hover=='index' ){
|
|
|
188 |
header( 'Location: '.$url.'') ;
|
189 |
+
exit();
|
190 |
return;
|
|
|
191 |
}elseif( $Hover=='custom' && $write_url != '' ) {
|
|
|
192 |
header( 'Location: '.$write_url.'' );
|
193 |
+
exit();
|
194 |
return;
|
195 |
+
}else{
|
|
|
|
|
196 |
$currentUrl = Mage::helper('core/url')->getCurrentUrl();
|
|
|
197 |
header( 'Location: '.$currentUrl.'' );
|
198 |
+
exit();
|
199 |
return;
|
|
|
200 |
}
|
|
|
201 |
}
|
202 |
|
|
|
|
|
203 |
function setInSession( $id, $socialloginProfileData ){
|
|
|
204 |
$socialloginProfileData['lrId'] = $id;
|
|
|
205 |
Mage::getSingleton('core/session')->setSocialLoginData( $socialloginProfileData );
|
|
|
206 |
}
|
207 |
|
208 |
function loginRadiusEmail( $subject, $message, $to, $toName ){
|
209 |
$storeName = Mage::app()->getStore()->getGroup()->getName();
|
|
|
210 |
$mail = new Zend_Mail(); //class for mail
|
211 |
$mail->setBodyHtml( $message ); //for sending message containing html code
|
212 |
$mail->setFrom( "Owner", $storeName );
|
214 |
//$mail->addCc($cc, $ccname); //can set cc
|
215 |
//$mail->addBCc($bcc, $bccname); //can set bcc
|
216 |
$mail->setSubject( $subject );
|
|
|
217 |
try {
|
218 |
$mail->send();
|
219 |
}catch(Exception $ex) {
|
223 |
|
224 |
function socialLoginAddNewUser( $socialloginProfileData, $email, $verify = false ) {
|
225 |
// add new user magento way
|
|
|
226 |
$websiteId = Mage::app()->getWebsite()->getId();
|
227 |
$store = Mage::app()->getStore();
|
228 |
$customer = Mage::getModel("customer/customer");
|
|
|
229 |
$customer->website_id = $websiteId;
|
|
|
230 |
$customer->setStore($store);
|
|
|
|
|
|
|
231 |
$customer->firstname = $socialloginProfileData['FirstName'];
|
|
|
232 |
$customer->lastname = $socialloginProfileData['LastName'] == "" ? $socialloginProfileData['FirstName'] : $socialloginProfileData['LastName'];
|
|
|
233 |
$customer->email = $email;
|
|
|
234 |
$customer->dob = $socialloginProfileData['BirthDate'];
|
|
|
235 |
$customer->gender = $socialloginProfileData['Gender'];
|
|
|
|
|
236 |
$loginRadiusPwd = $customer->generatePassword(10);
|
237 |
$customer->password_hash = md5( $loginRadiusPwd );
|
238 |
$customer->setConfirmation(null);
|
239 |
$customer->save();
|
240 |
|
|
|
|
|
241 |
//$address = new Mage_Customer_Model_Address();
|
|
|
242 |
$address = Mage::getModel("customer/address");
|
|
|
243 |
$address->setCustomerId($customer->getId());
|
|
|
244 |
$address->firstname = $customer->firstname;
|
|
|
245 |
$address->lastname = $customer->lastname;
|
|
|
246 |
$address->country_id = ucfirst( $socialloginProfileData['Country'] ); //Country code here
|
247 |
|
248 |
// $address->postcode = "31000";
|
|
|
249 |
$address->city = ucfirst( $socialloginProfileData['City'] );
|
|
|
250 |
/* NOTE: If country is USA, please set up $address->region also */
|
|
|
251 |
$address->telephone = $socialloginProfileData['PhoneNumbers'];
|
|
|
252 |
$address->company = ucfirst( $socialloginProfileData['Industry'] );
|
|
|
253 |
$address->street = ucfirst( $socialloginProfileData['Addresses'] );
|
|
|
|
|
|
|
254 |
$address->save();
|
|
|
|
|
|
|
255 |
// add info in sociallogin table
|
256 |
if( !$verify ){
|
257 |
$fields = array();
|
|
|
258 |
$fields['sociallogin_id'] = $socialloginProfileData['lrId'] ;
|
|
|
259 |
$fields['entity_id'] = $customer->getId();
|
|
|
260 |
$fields['avatar'] = $socialloginProfileData['thumbnail'] ;
|
|
|
261 |
$this->SocialLoginInsert( "sociallogin", $fields );
|
|
|
|
|
262 |
//login user
|
263 |
$this->socialLoginUserLogin( $customer->getId() );
|
264 |
$loginRadiusUsername = $socialloginProfileData['FirstName']." ".$socialloginProfileData['LastName'];
|
|
|
265 |
// email notification to user
|
266 |
if( $this->blockObj->notifyUser() == "1" ){
|
267 |
$loginRadiusMessage = $this->blockObj->notifyUserText();
|
273 |
"<br/>Password : ".$loginRadiusPwd;
|
274 |
$this->loginRadiusEmail( "Welcome ".$loginRadiusUsername."!", $loginRadiusMessage, $email, $loginRadiusUsername );
|
275 |
}
|
|
|
276 |
// new user notification to admin
|
277 |
if( $this->blockObj->notifyAdmin() == "1" ){
|
278 |
$loginRadiusAdminEmail = Mage::getStoreConfig('trans_email/ident_general/email');
|
293 |
}
|
294 |
|
295 |
private function SocialLoginInsert( $lrTable, $lrInsertData, $update = false, $value ){
|
|
|
296 |
$connection = Mage::getSingleton('core/resource')
|
|
|
297 |
->getConnection('core_write');
|
|
|
298 |
$connection->beginTransaction();
|
|
|
299 |
$sociallogin = getMazeTable($lrTable);
|
300 |
if( !$update ){
|
301 |
$connection->insert($sociallogin, $lrInsertData);
|
306 |
$connection->commit();
|
307 |
}
|
308 |
|
|
|
|
|
309 |
private function SocialLoginShowLayout() {
|
|
|
310 |
$this->loadLayout();
|
|
|
311 |
$this->renderLayout();
|
|
|
312 |
}
|
313 |
|
314 |
private function loginRadiusRead( $table, $handle, $params, $result = false ){
|
315 |
$socialLoginConn = Mage::getSingleton('core/resource')
|
|
|
316 |
->getConnection('core_read');
|
|
|
317 |
$Tbl = getMazeTable($table);
|
|
|
318 |
$websiteId = Mage::app()->getWebsite()->getId();
|
|
|
319 |
$storeId = Mage::app()->getStore()->getId();
|
|
|
320 |
$query = "";
|
321 |
switch( $handle ){
|
322 |
case "email exists pop1":
|
328 |
case "get user2":
|
329 |
$query = "select entity_id from $Tbl where entity_id = ".$params[0]." and website_id = $websiteId and store_id = $storeId";
|
330 |
break;
|
|
|
331 |
case "email exists login":
|
332 |
$query = "select * from $Tbl where email = '".$params[0]."' and website_id = $websiteId and store_id = $storeId";
|
333 |
break;
|
|
|
334 |
case "email exists sl":
|
335 |
$query = "select verified,sociallogin_id from $Tbl where entity_id = '".$params[0]."' and provider = '".$params[1]."'";
|
336 |
break;
|
337 |
case "email exists in sociallogin":
|
338 |
$query = "select entity_id from $Tbl where entity_id = '".$params[0]."'";
|
339 |
break;
|
|
|
340 |
case "verification":
|
341 |
$query = "select entity_id, provider from $Tbl where vkey = '".$params[0]."'";
|
342 |
break;
|
|
|
343 |
case "verification2":
|
344 |
$query = "select entity_id from $Tbl where entity_id = ".$params[0]." and provider = '".$params[1]."' and vkey != '' ";
|
345 |
break;
|
363 |
$data['verified'] = "0";
|
364 |
$data['vkey'] = $vKey;
|
365 |
$data['provider'] = $provider;
|
|
|
366 |
// insert details in sociallogin table
|
367 |
$this->SocialLoginInsert( "sociallogin", $data );
|
|
|
368 |
// send verification mail
|
369 |
$message = trim($this->blockObj->verificationText());
|
370 |
if( $message == "" ){
|
371 |
$message = "Please click on the following link or paste it in browser to verify your email:-";
|
372 |
}
|
373 |
$message .= "<br/>".Mage::getBaseUrl()."sociallogin/?loginRadiusKey=".$vKey;
|
|
|
374 |
$this->loginRadiusEmail( "Email verification", $message, $email, $email);
|
|
|
375 |
// show popup message
|
376 |
SL_popUpWindow( "Confirmation link Has Been Sent To Your Email Address. Please verify your email by clicking on confirmation link.", "", false );
|
377 |
$this->SocialLoginShowLayout();
|
382 |
$this->blockObj = new Loginradius_Sociallogin_Block_Sociallogin();
|
383 |
$this->loginRadiusPopMsg = trim($this->blockObj->getPopupText() );
|
384 |
$this->loginRadiusPopMsg = $this->loginRadiusPopMsg == "" ? "Please enter your email to proceed" : $this->loginRadiusPopMsg;
|
|
|
385 |
$this->loginRadiusPopErr = trim($this->blockObj->getPopupError() );
|
386 |
$this->loginRadiusPopErr = $this->loginRadiusPopErr == "" ? "Email you entered is either invalid or already registered. Please enter a valid email." : $this->loginRadiusPopErr;
|
|
|
387 |
if(isset($_REQUEST['token'])) {
|
|
|
388 |
$this->tokenHandle();
|
|
|
389 |
$this->loadLayout();
|
|
|
390 |
$this->renderLayout();
|
|
|
391 |
return;
|
|
|
392 |
}
|
393 |
|
394 |
// email verification
|
395 |
if( isset($_GET['loginRadiusKey']) && !empty($_GET['loginRadiusKey']) ){
|
396 |
$loginRadiusVkey = trim( $_GET['loginRadiusKey'] );
|
|
|
397 |
// get entity_id and provider of the vKey
|
398 |
$result = $this->loginRadiusRead( "sociallogin", "verification", array( $loginRadiusVkey ), true );
|
399 |
if( $temp = $result->fetch() ){
|
412 |
}
|
413 |
}
|
414 |
|
|
|
415 |
$socialLoginProfileData = Mage::getSingleton('core/session')->getSocialLoginData();
|
|
|
416 |
$session_user_id = $socialLoginProfileData['lrId'];
|
417 |
$loginRadiusPopProvider = $socialLoginProfileData['Provider'];
|
418 |
$loginRadiusAvatar = $socialLoginProfileData['thumbnail'];
|
419 |
|
420 |
if( isset($_POST['LoginRadiusRedSliderClick']) ) {
|
|
|
421 |
if( !empty($session_user_id) ){
|
|
|
422 |
$email = trim($_POST['SL_EMAIL']);
|
423 |
if( !preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/", $email) ){
|
|
|
424 |
SL_popUpWindow( $this->loginRadiusPopMsg, $this->loginRadiusPopErr );
|
|
|
425 |
$this->SocialLoginShowLayout();
|
|
|
426 |
return false;
|
|
|
427 |
}
|
428 |
|
429 |
// check if email already exists
|
460 |
$this->verifyUser( $session_user_id, $rowArray['entity_id'], $loginRadiusAvatar, $loginRadiusPopProvider, $email );
|
461 |
return;
|
462 |
}
|
|
|
463 |
}
|
|
|
464 |
$socialloginProfileData = Mage::getSingleton('core/session')->getSocialLoginData();
|
|
|
465 |
Mage::getSingleton('core/session')->unsSocialLoginData(); // unset session
|
|
|
466 |
//$this->blockObj = new Loginradius_Sociallogin_Block_Sociallogin(); //object to get api key and secrets, url etc
|
|
|
467 |
$this->socialLoginAddNewUser( $socialloginProfileData, $email, true );
|
|
|
468 |
}
|
|
|
469 |
}elseif( isset($_POST['LoginRadiusPopupCancel']) ) { // popup cancelled
|
|
|
470 |
Mage::getSingleton('core/session')->unsSocialLoginData(); // unset session
|
|
|
471 |
$url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
|
|
|
472 |
header("Location:".$url); // redirect to index page
|
|
|
473 |
}
|
|
|
474 |
$this->SocialLoginShowLayout();
|
|
|
475 |
}
|
|
|
476 |
}
|
app/code/community/Loginradius/Sociallogin/controllers/inc.php
CHANGED
@@ -6,7 +6,6 @@ function showDie($line,$msg){
|
|
6 |
die;
|
7 |
}
|
8 |
}
|
9 |
-
|
10 |
function SL_popUpWindow( $loginRadiusPopupTxt, $socialLoginMsg = "", $loginRadiusShowForm = true ){
|
11 |
?>
|
12 |
<!--css of email block -->
|
6 |
die;
|
7 |
}
|
8 |
}
|
|
|
9 |
function SL_popUpWindow( $loginRadiusPopupTxt, $socialLoginMsg = "", $loginRadiusShowForm = true ){
|
10 |
?>
|
11 |
<!--css of email block -->
|
app/code/community/Loginradius/Sociallogin/etc/config.xml
CHANGED
@@ -4,10 +4,12 @@
|
|
4 |
<sociallogin_options>
|
5 |
<messages>
|
6 |
<loginEnable>1</loginEnable>
|
7 |
-
<loginradius_title>Login with</loginradius_title>
|
8 |
<showdefault>1</showdefault>
|
9 |
<socialLinking>1</socialLinking>
|
10 |
<redirect>account</redirect>
|
|
|
|
|
11 |
</messages>
|
12 |
<email_settings>
|
13 |
<emailrequired>0</emailrequired>
|
@@ -28,7 +30,7 @@
|
|
28 |
</default>
|
29 |
<modules>
|
30 |
<Loginradius_Sociallogin>
|
31 |
-
<version>2.
|
32 |
</Loginradius_Sociallogin>
|
33 |
</modules>
|
34 |
<frontend>
|
@@ -160,4 +162,4 @@
|
|
160 |
</sociallogin>
|
161 |
</helpers>
|
162 |
</global>
|
163 |
-
</config>
|
4 |
<sociallogin_options>
|
5 |
<messages>
|
6 |
<loginEnable>1</loginEnable>
|
7 |
+
<loginradius_title>Login with your social account</loginradius_title>
|
8 |
<showdefault>1</showdefault>
|
9 |
<socialLinking>1</socialLinking>
|
10 |
<redirect>account</redirect>
|
11 |
+
<aboveLogin>1</aboveLogin>
|
12 |
+
<aboveRegister>1</aboveRegister>
|
13 |
</messages>
|
14 |
<email_settings>
|
15 |
<emailrequired>0</emailrequired>
|
30 |
</default>
|
31 |
<modules>
|
32 |
<Loginradius_Sociallogin>
|
33 |
+
<version>2.1.0</version>
|
34 |
</Loginradius_Sociallogin>
|
35 |
</modules>
|
36 |
<frontend>
|
162 |
</sociallogin>
|
163 |
</helpers>
|
164 |
</global>
|
165 |
+
</config>
|
app/code/community/Loginradius/Sociallogin/etc/system.xml
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
-
|
3 |
<config>
|
4 |
<tabs>
|
5 |
<socialconfig translate="label" module="sociallogin">
|
@@ -65,7 +64,7 @@
|
|
65 |
<show_in_store>1</show_in_store>
|
66 |
</loginradius_title>
|
67 |
<showdefault translate="label">
|
68 |
-
<label>Show interface in right side panel</label>
|
69 |
<frontend_type>select</frontend_type>
|
70 |
<comment><![CDATA[Select No you don't want to display module in right panel. You can also set widget in pages or any area of your site. ]]>
|
71 |
</comment>
|
@@ -75,6 +74,50 @@
|
|
75 |
<show_in_website>1</show_in_website>
|
76 |
<show_in_store>1</show_in_store>
|
77 |
</showdefault>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
<socialLinking translate="label">
|
79 |
<label>Social Linking</label>
|
80 |
<frontend_type>select</frontend_type>
|
@@ -277,9 +320,7 @@
|
|
277 |
<show_in_website>1</show_in_website>
|
278 |
<show_in_store>1</show_in_store>
|
279 |
</info>
|
280 |
-
|
281 |
</groups>
|
282 |
</sociallogin_options>
|
283 |
-
|
284 |
</sections>
|
285 |
-
</config>
|
1 |
<?xml version="1.0"?>
|
|
|
2 |
<config>
|
3 |
<tabs>
|
4 |
<socialconfig translate="label" module="sociallogin">
|
64 |
<show_in_store>1</show_in_store>
|
65 |
</loginradius_title>
|
66 |
<showdefault translate="label">
|
67 |
+
<label>Show Social Login interface in right side panel</label>
|
68 |
<frontend_type>select</frontend_type>
|
69 |
<comment><![CDATA[Select No you don't want to display module in right panel. You can also set widget in pages or any area of your site. ]]>
|
70 |
</comment>
|
74 |
<show_in_website>1</show_in_website>
|
75 |
<show_in_store>1</show_in_store>
|
76 |
</showdefault>
|
77 |
+
<aboveLogin translate="label">
|
78 |
+
<label>Show Social Login interface above login form</label>
|
79 |
+
<frontend_type>select</frontend_type>
|
80 |
+
<comment><![CDATA[Select 'Yes' to enable Social Login interface above login form.]]>
|
81 |
+
</comment>
|
82 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
83 |
+
<sort_order>24</sort_order>
|
84 |
+
<show_in_default>1</show_in_default>
|
85 |
+
<show_in_website>1</show_in_website>
|
86 |
+
<show_in_store>1</show_in_store>
|
87 |
+
</aboveLogin>
|
88 |
+
<belowLogin translate="label">
|
89 |
+
<label>Show Social Login interface below login form</label>
|
90 |
+
<frontend_type>select</frontend_type>
|
91 |
+
<comment><![CDATA[Select 'Yes' to enable Social Login interface below login form.]]>
|
92 |
+
</comment>
|
93 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
94 |
+
<sort_order>25</sort_order>
|
95 |
+
<show_in_default>1</show_in_default>
|
96 |
+
<show_in_website>1</show_in_website>
|
97 |
+
<show_in_store>1</show_in_store>
|
98 |
+
</belowLogin>
|
99 |
+
<aboveRegister translate="label">
|
100 |
+
<label>Show Social Login interface above registration form</label>
|
101 |
+
<frontend_type>select</frontend_type>
|
102 |
+
<comment><![CDATA[Select 'Yes' to enable Social Login interface above registration form.]]>
|
103 |
+
</comment>
|
104 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
105 |
+
<sort_order>26</sort_order>
|
106 |
+
<show_in_default>1</show_in_default>
|
107 |
+
<show_in_website>1</show_in_website>
|
108 |
+
<show_in_store>1</show_in_store>
|
109 |
+
</aboveRegister>
|
110 |
+
<belowRegister translate="label">
|
111 |
+
<label>Show Social Login interface below registration form</label>
|
112 |
+
<frontend_type>select</frontend_type>
|
113 |
+
<comment><![CDATA[Select 'Yes' to enable Social Login interface below registration form.]]>
|
114 |
+
</comment>
|
115 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
116 |
+
<sort_order>27</sort_order>
|
117 |
+
<show_in_default>1</show_in_default>
|
118 |
+
<show_in_website>1</show_in_website>
|
119 |
+
<show_in_store>1</show_in_store>
|
120 |
+
</belowRegister>
|
121 |
<socialLinking translate="label">
|
122 |
<label>Social Linking</label>
|
123 |
<frontend_type>select</frontend_type>
|
320 |
<show_in_website>1</show_in_website>
|
321 |
<show_in_store>1</show_in_store>
|
322 |
</info>
|
|
|
323 |
</groups>
|
324 |
</sociallogin_options>
|
|
|
325 |
</sections>
|
326 |
+
</config>
|
app/code/community/Loginradius/Sociallogin/sql/sociallogin_setup/{mysql4-install-2.0.0.php → mysql4-install-2.1.0.php}
RENAMED
@@ -1,9 +1,6 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
$installer = $this;
|
4 |
-
|
5 |
$installer->startSetup();
|
6 |
-
|
7 |
$installer->run("
|
8 |
DROP TABLE IF EXISTS {$this->getTable('sociallogin')};
|
9 |
CREATE TABLE IF NOT EXISTS {$this->getTable('sociallogin')} (
|
@@ -14,7 +11,5 @@ CREATE TABLE IF NOT EXISTS {$this->getTable('sociallogin')} (
|
|
14 |
`vkey` varchar(40) default NULL,
|
15 |
`provider` varchar(20) default NULL
|
16 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
17 |
-
|
18 |
");
|
19 |
-
|
20 |
$installer->endSetup();
|
1 |
<?php
|
|
|
2 |
$installer = $this;
|
|
|
3 |
$installer->startSetup();
|
|
|
4 |
$installer->run("
|
5 |
DROP TABLE IF EXISTS {$this->getTable('sociallogin')};
|
6 |
CREATE TABLE IF NOT EXISTS {$this->getTable('sociallogin')} (
|
11 |
`vkey` varchar(40) default NULL,
|
12 |
`provider` varchar(20) default NULL
|
13 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
|
14 |
");
|
|
|
15 |
$installer->endSetup();
|
app/design/frontend/default/default/layout/sociallogin.xml
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
-
<layout version="2.
|
3 |
<default>
|
4 |
<reference name="right">
|
5 |
-
<block type="sociallogin/sociallogin" name="sociallogin" template="sociallogin/sociallogin.phtml" />
|
6 |
</reference>
|
7 |
<reference name="head">
|
8 |
<block type="sociallogin/sociallogin" name="socialshare_head" template="sociallogin/socialshare_head.phtml" />
|
@@ -16,4 +16,24 @@
|
|
16 |
<block type="sociallogin/sociallogin" name="socialcounter" template="sociallogin/socialcounter.phtml" />
|
17 |
</reference>
|
18 |
</catalog_product_view>
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?xml version="1.0"?>
|
2 |
+
<layout version="2.1.0">
|
3 |
<default>
|
4 |
<reference name="right">
|
5 |
+
<block type="sociallogin/sociallogin" name="sociallogin" template="sociallogin/sociallogin.phtml" before="-" />
|
6 |
</reference>
|
7 |
<reference name="head">
|
8 |
<block type="sociallogin/sociallogin" name="socialshare_head" template="sociallogin/socialshare_head.phtml" />
|
16 |
<block type="sociallogin/sociallogin" name="socialcounter" template="sociallogin/socialcounter.phtml" />
|
17 |
</reference>
|
18 |
</catalog_product_view>
|
19 |
+
<customer_account_login>
|
20 |
+
<reference name="content">
|
21 |
+
<block type="sociallogin/sociallogin" name="lrabovelogin" template="sociallogin/abovelogin.phtml" before="-" />
|
22 |
+
</reference>
|
23 |
+
</customer_account_login>
|
24 |
+
<customer_account_login>
|
25 |
+
<reference name="content">
|
26 |
+
<block type="sociallogin/sociallogin" name="lrbelowlogin" template="sociallogin/belowlogin.phtml" />
|
27 |
+
</reference>
|
28 |
+
</customer_account_login>
|
29 |
+
<customer_account_create>
|
30 |
+
<reference name="content">
|
31 |
+
<block type="sociallogin/sociallogin" name="lraboveregister" template="sociallogin/aboveregister.phtml" before="-" />
|
32 |
+
</reference>
|
33 |
+
</customer_account_create>
|
34 |
+
<customer_account_create>
|
35 |
+
<reference name="content">
|
36 |
+
<block type="sociallogin/sociallogin" name="lrbelowregister" template="sociallogin/belowregister.phtml" />
|
37 |
+
</reference>
|
38 |
+
</customer_account_create>
|
39 |
+
</layout>
|
app/design/frontend/default/default/template/sociallogin/abovelogin.phtml
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if( $this->loginEnable() == "1" && !$this->user_is_already_login() ){
|
3 |
+
$aboveLogin = $this->getAboveLogin();
|
4 |
+
$ApiKey = trim($this->getApikey());
|
5 |
+
$ApiSecrete = trim($this->getApiSecret());
|
6 |
+
$loginRadiusTitle = trim( $this->getLoginRadiusTitle() );
|
7 |
+
$UserAuth = $this->getApiResult($ApiKey, $ApiSecrete);
|
8 |
+
if ($aboveLogin == 1) {
|
9 |
+
echo '<div class="block" style="margin-top:15px"><div class="block-title"><strong><span>Social Login</span></strong></div><div class="block-content"><p class="empty">';
|
10 |
+
if($ApiKey == "" && $ApiSecrete == ""){
|
11 |
+
echo '<p style ="color:red;">To activate your plugin, please log in to LoginRadius and get API Key & Secret. Web: <b><a href ="http://www.loginradius.com" target = "_blank">www.LoginRadius.com</a></b></p>';
|
12 |
+
}elseif ($UserAuth == false) {
|
13 |
+
echo '<p style ="color:red;">Your LoginRadius API key and secret is not valid, please correct it or contact LoginRadius support at <b><a href ="http://www.loginradius.com" target = "_blank">www.LoginRadius.com</a></b></p>';
|
14 |
+
}
|
15 |
+
else {
|
16 |
+
$IsHttps = (!empty($UserAuth->IsHttps)) ? $UserAuth->IsHttps : '';
|
17 |
+
$iframeHeight = (!empty($UserAuth->height)) ? $UserAuth->height : 50;
|
18 |
+
$iframeWidth = (!empty($UserAuth->width)) ? $UserAuth->width : 138;
|
19 |
+
$http = ($IsHttps == 1) ? "https://" : "http://";
|
20 |
+
$loc = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK)."sociallogin/";
|
21 |
+
echo '<div style="margin:5px"><div style="margin-bottom:5px">'.$loginRadiusTitle.'</div><iframe src="'.$http.'hub.loginradius.com/Control/PluginSlider.aspx?apikey='.$ApiKey.'&callback='.$loc.'" width="'.$iframeWidth.'" height="'.$iframeHeight.'" frameborder="0" scrolling="no" allowtransparency="true"></iframe></div>';
|
22 |
+
}
|
23 |
+
echo '</p></div></div>';
|
24 |
+
}
|
25 |
+
}
|
26 |
+
?>
|
app/design/frontend/default/default/template/sociallogin/aboveregister.phtml
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if( $this->loginEnable() == "1" && !$this->user_is_already_login() ){
|
3 |
+
$aboveRegister = $this->getAboveRegister();
|
4 |
+
$ApiKey = trim($this->getApikey());
|
5 |
+
$ApiSecrete = trim($this->getApiSecret());
|
6 |
+
$loginRadiusTitle = trim( $this->getLoginRadiusTitle() );
|
7 |
+
$UserAuth = $this->getApiResult($ApiKey, $ApiSecrete);
|
8 |
+
if ($aboveRegister == 1) {
|
9 |
+
echo '<div class="block" style="margin-top:15px"><div class="block-title"><strong><span>Social Login</span></strong></div><div class="block-content"><p class="empty">';
|
10 |
+
if($ApiKey == "" && $ApiSecrete == ""){
|
11 |
+
echo '<p style ="color:red;">To activate your plugin, please log in to LoginRadius and get API Key & Secret. Web: <b><a href ="http://www.loginradius.com" target = "_blank">www.LoginRadius.com</a></b></p>';
|
12 |
+
}elseif ($UserAuth == false) {
|
13 |
+
echo '<p style ="color:red;">Your LoginRadius API key and secret is not valid, please correct it or contact LoginRadius support at <b><a href ="http://www.loginradius.com" target = "_blank">www.LoginRadius.com</a></b></p>';
|
14 |
+
}
|
15 |
+
else {
|
16 |
+
$IsHttps = (!empty($UserAuth->IsHttps)) ? $UserAuth->IsHttps : '';
|
17 |
+
$iframeHeight = (!empty($UserAuth->height)) ? $UserAuth->height : 50;
|
18 |
+
$iframeWidth = (!empty($UserAuth->width)) ? $UserAuth->width : 138;
|
19 |
+
$http = ($IsHttps == 1) ? "https://" : "http://";
|
20 |
+
$loc = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK)."sociallogin/";
|
21 |
+
echo '<div style="margin:5px"><div style="margin-bottom:5px">'.$loginRadiusTitle.'</div><iframe src="'.$http.'hub.loginradius.com/Control/PluginSlider.aspx?apikey='.$ApiKey.'&callback='.$loc.'" width="'.$iframeWidth.'" height="'.$iframeHeight.'" frameborder="0" scrolling="no" allowtransparency="true"></iframe></div>';
|
22 |
+
}
|
23 |
+
echo '</p></div></div>';
|
24 |
+
}
|
25 |
+
}
|
26 |
+
?>
|
app/design/frontend/default/default/template/sociallogin/belowlogin.phtml
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if( $this->loginEnable() == "1" && !$this->user_is_already_login() ){
|
3 |
+
$belowLogin = $this->getBelowLogin();
|
4 |
+
$ApiKey = trim($this->getApikey());
|
5 |
+
$ApiSecrete = trim($this->getApiSecret());
|
6 |
+
$loginRadiusTitle = trim( $this->getLoginRadiusTitle() );
|
7 |
+
$UserAuth = $this->getApiResult($ApiKey, $ApiSecrete);
|
8 |
+
if ($belowLogin == 1) {
|
9 |
+
echo '<div class="block" style="margin-top:15px"><div class="block-title"><strong><span>Social Login</span></strong></div><div class="block-content"><p class="empty">';
|
10 |
+
if($ApiKey == "" && $ApiSecrete == ""){
|
11 |
+
echo '<p style ="color:red;">To activate your plugin, please log in to LoginRadius and get API Key & Secret. Web: <b><a href ="http://www.loginradius.com" target = "_blank">www.LoginRadius.com</a></b></p>';
|
12 |
+
}elseif ($UserAuth == false) {
|
13 |
+
echo '<p style ="color:red;">Your LoginRadius API key and secret is not valid, please correct it or contact LoginRadius support at <b><a href ="http://www.loginradius.com" target = "_blank">www.LoginRadius.com</a></b></p>';
|
14 |
+
}
|
15 |
+
else {
|
16 |
+
$IsHttps = (!empty($UserAuth->IsHttps)) ? $UserAuth->IsHttps : '';
|
17 |
+
$iframeHeight = (!empty($UserAuth->height)) ? $UserAuth->height : 50;
|
18 |
+
$iframeWidth = (!empty($UserAuth->width)) ? $UserAuth->width : 138;
|
19 |
+
$http = ($IsHttps == 1) ? "https://" : "http://";
|
20 |
+
$loc = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK)."sociallogin/";
|
21 |
+
echo '<div style="margin:5px"><div style="margin-bottom:5px">'.$loginRadiusTitle.'</div><iframe src="'.$http.'hub.loginradius.com/Control/PluginSlider.aspx?apikey='.$ApiKey.'&callback='.$loc.'" width="'.$iframeWidth.'" height="'.$iframeHeight.'" frameborder="0" scrolling="no" allowtransparency="true"></iframe></div>';
|
22 |
+
}
|
23 |
+
echo '</p></div></div>';
|
24 |
+
}
|
25 |
+
}
|
26 |
+
?>
|
app/design/frontend/default/default/template/sociallogin/belowregister.phtml
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if( $this->loginEnable() == "1" && !$this->user_is_already_login() ){
|
3 |
+
$belowRegister = $this->getBelowRegister();
|
4 |
+
$ApiKey = trim($this->getApikey());
|
5 |
+
$ApiSecrete = trim($this->getApiSecret());
|
6 |
+
$loginRadiusTitle = trim( $this->getLoginRadiusTitle() );
|
7 |
+
$UserAuth = $this->getApiResult($ApiKey, $ApiSecrete);
|
8 |
+
if ($belowRegister == 1) {
|
9 |
+
echo '<div class="block" style="margin-top:15px"><div class="block-title"><strong><span>Social Login</span></strong></div><div class="block-content"><p class="empty">';
|
10 |
+
if($ApiKey == "" && $ApiSecrete == ""){
|
11 |
+
echo '<p style ="color:red;">To activate your plugin, please log in to LoginRadius and get API Key & Secret. Web: <b><a href ="http://www.loginradius.com" target = "_blank">www.LoginRadius.com</a></b></p>';
|
12 |
+
}elseif ($UserAuth == false) {
|
13 |
+
echo '<p style ="color:red;">Your LoginRadius API key and secret is not valid, please correct it or contact LoginRadius support at <b><a href ="http://www.loginradius.com" target = "_blank">www.LoginRadius.com</a></b></p>';
|
14 |
+
}
|
15 |
+
else {
|
16 |
+
$IsHttps = (!empty($UserAuth->IsHttps)) ? $UserAuth->IsHttps : '';
|
17 |
+
$iframeHeight = (!empty($UserAuth->height)) ? $UserAuth->height : 50;
|
18 |
+
$iframeWidth = (!empty($UserAuth->width)) ? $UserAuth->width : 138;
|
19 |
+
$http = ($IsHttps == 1) ? "https://" : "http://";
|
20 |
+
$loc = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK)."sociallogin/";
|
21 |
+
echo '<div style="margin:5px"><div style="margin-bottom:5px">'.$loginRadiusTitle.'</div><iframe src="'.$http.'hub.loginradius.com/Control/PluginSlider.aspx?apikey='.$ApiKey.'&callback='.$loc.'" width="'.$iframeWidth.'" height="'.$iframeHeight.'" frameborder="0" scrolling="no" allowtransparency="true"></iframe></div>';
|
22 |
+
}
|
23 |
+
echo '</p></div></div>';
|
24 |
+
}
|
25 |
+
}
|
26 |
+
?>
|
app/design/frontend/default/default/template/sociallogin/sociallogin.phtml
CHANGED
@@ -1,64 +1,35 @@
|
|
1 |
<?php
|
2 |
if( $this->loginEnable() == "1" ){
|
3 |
$showdefault = $this->getShowDefault();
|
4 |
-
|
5 |
$ApiKey = trim($this->getApikey());
|
6 |
-
|
7 |
$ApiSecrete = trim($this->getApiSecret());
|
8 |
-
|
9 |
$loginRadiusTitle = trim( $this->getLoginRadiusTitle() );
|
10 |
-
|
11 |
$UserAuth = $this->getApiResult($ApiKey, $ApiSecrete);
|
12 |
-
|
13 |
if ($showdefault == 1) {
|
14 |
-
|
15 |
-
echo '<div class="block"><div class="block-title"><strong><span>Social Login Module</span></strong></div><div class="block-content"><p class="empty">';
|
16 |
-
|
17 |
if ($this->user_is_already_login()) {
|
18 |
-
|
19 |
$userName = Mage::getSingleton('customer/session')->getCustomer()->getName();
|
20 |
-
|
21 |
if( $loginRadiusAvatar = trim( $this->getAvatar( Mage::getSingleton('customer/session')->getCustomer()->getId() ) ) ){
|
22 |
-
|
23 |
echo "<img style='float:left' width='50' height='50' src='".$loginRadiusAvatar."' />";
|
24 |
-
|
25 |
}
|
26 |
-
|
27 |
echo "<span style='clear:both; float:left'>Welcome! $userName </span>";
|
28 |
-
|
29 |
}
|
30 |
-
|
31 |
else {
|
32 |
-
|
33 |
if($ApiKey == "" && $ApiSecrete == ""){
|
34 |
-
|
35 |
echo '<p style ="color:red;">To activate your plugin, please log in to LoginRadius and get API Key & Secret. Web: <b><a href ="http://www.loginradius.com" target = "_blank">www.LoginRadius.com</a></b></p>';
|
36 |
-
|
37 |
}elseif ($UserAuth == false) {
|
38 |
-
|
39 |
echo '<p style ="color:red;">Your LoginRadius API key and secret is not valid, please correct it or contact LoginRadius support at <b><a href ="http://www.loginradius.com" target = "_blank">www.LoginRadius.com</a></b></p>';
|
40 |
-
|
41 |
}
|
42 |
-
|
43 |
else {
|
44 |
-
|
45 |
$IsHttps = (!empty($UserAuth->IsHttps)) ? $UserAuth->IsHttps : '';
|
46 |
-
|
47 |
$iframeHeight = (!empty($UserAuth->height)) ? $UserAuth->height : 50;
|
48 |
-
|
49 |
$iframeWidth = (!empty($UserAuth->width)) ? $UserAuth->width : 138;
|
50 |
-
|
51 |
$http = ($IsHttps == 1) ? "https://" : "http://";
|
52 |
-
|
53 |
$loc = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK)."sociallogin/";
|
54 |
-
|
55 |
echo $loginRadiusTitle.'<iframe src="'.$http.'hub.loginradius.com/Control/PluginSlider.aspx?apikey='.$ApiKey.'&callback='.$loc.'" width="'.$iframeWidth.'" height="'.$iframeHeight.'" frameborder="0" scrolling="no" allowtransparency="true"></iframe>';
|
56 |
}
|
57 |
-
|
58 |
}
|
59 |
-
|
60 |
echo '</p></div></div>';
|
61 |
-
|
62 |
}
|
63 |
}
|
64 |
?>
|
1 |
<?php
|
2 |
if( $this->loginEnable() == "1" ){
|
3 |
$showdefault = $this->getShowDefault();
|
|
|
4 |
$ApiKey = trim($this->getApikey());
|
|
|
5 |
$ApiSecrete = trim($this->getApiSecret());
|
|
|
6 |
$loginRadiusTitle = trim( $this->getLoginRadiusTitle() );
|
|
|
7 |
$UserAuth = $this->getApiResult($ApiKey, $ApiSecrete);
|
|
|
8 |
if ($showdefault == 1) {
|
9 |
+
echo '<div class="block"><div class="block-title"><strong><span>Social Login</span></strong></div><div class="block-content"><p class="empty">';
|
|
|
|
|
10 |
if ($this->user_is_already_login()) {
|
|
|
11 |
$userName = Mage::getSingleton('customer/session')->getCustomer()->getName();
|
|
|
12 |
if( $loginRadiusAvatar = trim( $this->getAvatar( Mage::getSingleton('customer/session')->getCustomer()->getId() ) ) ){
|
|
|
13 |
echo "<img style='float:left' width='50' height='50' src='".$loginRadiusAvatar."' />";
|
|
|
14 |
}
|
|
|
15 |
echo "<span style='clear:both; float:left'>Welcome! $userName </span>";
|
|
|
16 |
}
|
|
|
17 |
else {
|
|
|
18 |
if($ApiKey == "" && $ApiSecrete == ""){
|
|
|
19 |
echo '<p style ="color:red;">To activate your plugin, please log in to LoginRadius and get API Key & Secret. Web: <b><a href ="http://www.loginradius.com" target = "_blank">www.LoginRadius.com</a></b></p>';
|
|
|
20 |
}elseif ($UserAuth == false) {
|
|
|
21 |
echo '<p style ="color:red;">Your LoginRadius API key and secret is not valid, please correct it or contact LoginRadius support at <b><a href ="http://www.loginradius.com" target = "_blank">www.LoginRadius.com</a></b></p>';
|
|
|
22 |
}
|
|
|
23 |
else {
|
|
|
24 |
$IsHttps = (!empty($UserAuth->IsHttps)) ? $UserAuth->IsHttps : '';
|
|
|
25 |
$iframeHeight = (!empty($UserAuth->height)) ? $UserAuth->height : 50;
|
|
|
26 |
$iframeWidth = (!empty($UserAuth->width)) ? $UserAuth->width : 138;
|
|
|
27 |
$http = ($IsHttps == 1) ? "https://" : "http://";
|
|
|
28 |
$loc = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK)."sociallogin/";
|
|
|
29 |
echo $loginRadiusTitle.'<iframe src="'.$http.'hub.loginradius.com/Control/PluginSlider.aspx?apikey='.$ApiKey.'&callback='.$loc.'" width="'.$iframeWidth.'" height="'.$iframeHeight.'" frameborder="0" scrolling="no" allowtransparency="true"></iframe>';
|
30 |
}
|
|
|
31 |
}
|
|
|
32 |
echo '</p></div></div>';
|
|
|
33 |
}
|
34 |
}
|
35 |
?>
|
app/design/frontend/default/default/template/sociallogin/sociallogincustom.phtml
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if( $this->loginEnable() == "1" && !$this->user_is_already_login() ){
|
3 |
+
$aboveRegister = $this->getAboveRegister();
|
4 |
+
$ApiKey = trim($this->getApikey());
|
5 |
+
$ApiSecrete = trim($this->getApiSecret());
|
6 |
+
$loginRadiusTitle = trim( $this->getLoginRadiusTitle() );
|
7 |
+
$UserAuth = $this->getApiResult($ApiKey, $ApiSecrete);
|
8 |
+
echo '<div><h2>OR</h2>';
|
9 |
+
if($ApiKey == "" && $ApiSecrete == ""){
|
10 |
+
echo '<p style ="color:red;">To activate your plugin, please log in to LoginRadius and get API Key & Secret. Web: <b><a href ="http://www.loginradius.com" target = "_blank">www.LoginRadius.com</a></b></p>';
|
11 |
+
}elseif ($UserAuth == false) {
|
12 |
+
echo '<p style ="color:red;">Your LoginRadius API key and secret is not valid, please correct it or contact LoginRadius support at <b><a href ="http://www.loginradius.com" target = "_blank">www.LoginRadius.com</a></b></p>';
|
13 |
+
}
|
14 |
+
else {
|
15 |
+
$IsHttps = (!empty($UserAuth->IsHttps)) ? $UserAuth->IsHttps : '';
|
16 |
+
$iframeHeight = (!empty($UserAuth->height)) ? $UserAuth->height : 50;
|
17 |
+
$iframeWidth = (!empty($UserAuth->width)) ? $UserAuth->width : 138;
|
18 |
+
$http = ($IsHttps == 1) ? "https://" : "http://";
|
19 |
+
$loc = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK)."sociallogin/";
|
20 |
+
echo '<div style="margin-bottom:5px">'.$loginRadiusTitle.'</div><iframe src="'.$http.'hub.loginradius.com/Control/PluginSlider.aspx?apikey='.$ApiKey.'&callback='.$loc.'" width="'.$iframeWidth.'" height="'.$iframeHeight.'" frameborder="0" scrolling="no" allowtransparency="true"></iframe>';
|
21 |
+
}
|
22 |
+
echo '</div>';
|
23 |
+
}
|
24 |
+
?>
|
app/design/frontend/default/default/template/sociallogin/socialshare_head.phtml
CHANGED
@@ -20,4 +20,4 @@ if( $this->counterEnable() == "1" ){
|
|
20 |
</style>
|
21 |
<?php
|
22 |
}
|
23 |
-
?>
|
20 |
</style>
|
21 |
<?php
|
22 |
}
|
23 |
+
?>
|
package.xml
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>LoginRadius</name>
|
4 |
-
<version>2.
|
5 |
<stability>stable</stability>
|
6 |
<license>GNU General Public License (GPL)</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Social Login, Sharing and Counter for Magento</summary>
|
10 |
<description>Add Social Login, Sharing and Counter to your Magento website and also get accurate User Profile Data and Social Analytics.</description>
|
11 |
-
<notes>
|
12 |
<authors><author><name>LoginRadius Team</name><user>LoginRadius</user><email>developers@loginradius.com</email></author></authors>
|
13 |
-
<date>2012-
|
14 |
-
<time>
|
15 |
-
<contents><target name="magecommunity"><dir name="Loginradius"><dir name="Sociallogin"><dir name="Block"><file name="Auth.php" hash="
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>LoginRadius</name>
|
4 |
+
<version>2.1.0</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>GNU General Public License (GPL)</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Social Login, Sharing and Counter for Magento</summary>
|
10 |
<description>Add Social Login, Sharing and Counter to your Magento website and also get accurate User Profile Data and Social Analytics.</description>
|
11 |
+
<notes>Sixth release of social login</notes>
|
12 |
<authors><author><name>LoginRadius Team</name><user>LoginRadius</user><email>developers@loginradius.com</email></author></authors>
|
13 |
+
<date>2012-12-03</date>
|
14 |
+
<time>20:32:09</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Loginradius"><dir name="Sociallogin"><dir name="Block"><file name="Auth.php" hash="185ee3072b18a49bfd72112210ae118e"/><file name="Counter.php" hash="f79411371642a6940fe68f35cf09ef7b"/><file name="Info.php" hash="cb4e9999795b628b5e41ae1fb00fd78f"/><file name="Share.php" hash="ea9a80891c1c88f96b4f0a2e337d6d27"/><file name="Sociallogin.php" hash="22db3938658d802a56893c34eb1c7374"/></dir><dir name="Helper"><file name="Data.php" hash="7fe10f157031a33dd5c312f61f36f650"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Sociallogin"><file name="Collection.php" hash="b4632ab82692843577c985a3ed23981f"/></dir><file name="Sociallogin.php" hash="8c8d5d266c57ea0400d5a560a943ea14"/></dir><file name="Sociallogin.php" hash="a49fc157930cd09fcbe522aabb1d986b"/><dir name="Source"><file name="Uihover.php" hash="f82ae802e2561906bc4539e33aa041b8"/><file name="Uihover2.php" hash="6653f962c12471b1c635dae26af22a19"/></dir></dir><dir name="controllers"><file name="IndexController.php" hash="4ed0fcbe01a5906168096206ef27ed20"/><file name="inc.php" hash="05078196f80363c3802acf7180c22157"/></dir><dir name="etc"><file name="config.xml" hash="43aa42e183eb0a89ea2437c6662fd586"/><file name="system.xml" hash="30ed62a27b7d691f31584dedf2cd6a7f"/><file name="widget.xml" hash="75f4ee0b08fdd001bbd216bd965b644d"/></dir><dir name="sql"><dir name="sociallogin_setup"><file name="mysql4-install-2.1.0.php" hash="a04e6f43b037bea1d40147e9b7df3ef9"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="sociallogin.xml" hash="3799d71955c1f5158ffced051051cbd3"/></dir><dir name="template"><dir name="sociallogin"><file name="sociallogin.phtml" hash="68fe4b553ce258dea9a76f367847429f"/><file name="socialshare.phtml" hash="d93ab7c0904ec6688924398f503d6cf5"/><file name="socialshare_head.phtml" hash="8905696bbde0ef363bd4a0c74e3b6d40"/><file name="socialcounter.phtml" hash="1c6ec1e3f25dacbb005391e764b9885d"/><file name="abovelogin.phtml" hash="6cdbe94c8e7bb3368565f40a7281dc3b"/><file name="belowlogin.phtml" hash="397ea3e8f3ca99d8266aaeed829424db"/><file name="belowregister.phtml" hash="0149d7760a85c9bc505b4950360d2a35"/><file name="aboveregister.phtml" hash="29617c839a4a97b0098fbe43325de764"/><file name="sociallogincustom.phtml" hash="976e73b33fd32b3d8a468fad200a3854"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Loginradius_Sociallogin.xml" hash="6c5bb03c460936006692aa1d01d142ba"/></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|