LoginRadius - Version 2.0.0

Version Notes

Fifth release of social login

Download this release

Release Info

Developer LoginRadius Team
Extension LoginRadius
Version 2.0.0
Comparing to
See all releases


Code changes from version 1.2.1 to 2.0.0

app/code/community/Loginradius/Sociallogin/Block/Auth.php CHANGED
@@ -1,55 +1,98 @@
1
- <?php
2
-
3
- class Loginradius_Sociallogin_Block_Auth extends Mage_Core_Block_Template implements Mage_Widget_Block_Interface {
4
-
5
- function loginradius_buttons() {
6
- $block_anyplace = new Loginradius_Sociallogin_Block_Sociallogin();
7
- $ApiKey = trim($block_anyplace->getApikey());
8
- $ApiSecrete = trim($block_anyplace->getApiSecret());
9
- $UserAuth = $block_anyplace->getApiResult($ApiKey, $ApiSecrete);
10
- $titleText = $this->getLabelText();
11
- $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>';
12
- if ($block_anyplace->user_is_already_login()) {
13
- $userName = Mage::getSingleton('customer/session')->getCustomer()->getName();
14
- return '<span>Welcome!'.' '.$userName .'</span>';
15
- }
16
- else {
17
- if ($UserAuth == false) {
18
- return $errormsg;
19
- }
20
- else {
21
- $IsHttps = (!empty($UserAuth->IsHttps)) ? $UserAuth->IsHttps : '';
22
- $iframeHeight = (!empty($UserAuth->height)) ? $UserAuth->height : 50;
23
- $iframeWidth = (!empty($UserAuth->width)) ? $UserAuth->width : 138;
24
- $http = ($IsHttps == 1) ? "https://" : "http://";
25
- $loc = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK)."sociallogin/";
26
- if (empty($titleText)) {
27
- $titleText = 'Please login with';
28
- }
29
- $label = '<span ><b>' . $titleText . '</b></span>';
30
- $iframe = '<iframe src="'.$http.'hub.loginradius.com/Control/PluginSlider2.aspx?apikey='.$ApiKey.'&callback='.$loc.'" width="'.$iframeWidth.'" height="'.$iframeHeight.'" frameborder="0" scrolling="no" allowtransparency="true"></iframe>';
31
- return $label.$iframe;
32
- }
33
- }
34
-
35
- }
36
-
37
- protected function _toHtml() {
38
- $content = '';
39
- if (Mage::getSingleton('customer/session')->isLoggedIn() == false)
40
- $content = $this->loginradius_buttons();
41
- return $content;
42
- }
43
-
44
- protected function _prepareLayout() {
45
- /*if ($this->getLayout()->getBlock('loginradius_sociallogin_scripts') == false) {
46
- $block = $this->getLayout()
47
- ->createBlock('core/template', 'loginradius_sociallogin_scripts')
48
- ->setTemplate('loginradius/sociallogin/auth.phtml');
49
- $this->getLayout()->getBlock('before_body_end')->insert($block);
50
- }
51
- */
52
- parent::_prepareLayout();
53
- }
54
-
55
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
app/code/community/Loginradius/Sociallogin/Block/Counter.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Loginradius_Sociallogin_Block_Counter extends Mage_Core_Block_Template implements Mage_Widget_Block_Interface {
3
+ private $loginRadiusCounter;
4
+ public function __construct(){
5
+ $this->loginRadiusCounter = new Loginradius_Sociallogin_Block_Sociallogin();
6
+ }
7
+ protected function _toHtml() {
8
+ $content = "";
9
+ if ($this->loginRadiusCounter->counterEnable() == "1" ){
10
+ $content = "<div class='lrcounter_simplebox'></div>";
11
+ }
12
+ return $content;
13
+ }
14
+ protected function _prepareLayout() {
15
+ parent::_prepareLayout();
16
+ }
17
+ }
app/code/community/Loginradius/Sociallogin/Block/Share.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Loginradius_Sociallogin_Block_Share extends Mage_Core_Block_Template implements Mage_Widget_Block_Interface {
3
+ private $loginRadiusShare;
4
+ public function __construct(){
5
+ $this->loginRadiusShare = new Loginradius_Sociallogin_Block_Sociallogin();
6
+ }
7
+ protected function _toHtml() {
8
+ $content = "";
9
+ if ($this->loginRadiusShare->shareEnable() == "1" ){
10
+ $content = "<div class='lrsharecontainer'></div>";
11
+ }
12
+ return $content;
13
+ }
14
+ protected function _prepareLayout() {
15
+ parent::_prepareLayout();
16
+ }
17
+ }
app/code/community/Loginradius/Sociallogin/Block/Sociallogin.php CHANGED
@@ -1,6 +1,13 @@
1
  <?php
2
  class Loginradius_Sociallogin_Block_Sociallogin extends Mage_Core_Block_Template
3
  {
 
 
 
 
 
 
 
4
  public function _prepareLayout()
5
  {
6
  return parent::_prepareLayout();
@@ -17,11 +24,27 @@ class Loginradius_Sociallogin_Block_Sociallogin extends Mage_Core_Block_Template
17
  return true;
18
  }
19
  return false;
 
 
 
 
20
  }
21
  public function getApikey()
22
  {
23
  return Mage::getStoreConfig('sociallogin_options/messages/appid');
24
  }
 
 
 
 
 
 
 
 
 
 
 
 
25
  public function getShowDefault()
26
  {
27
  return Mage::getStoreConfig('sociallogin_options/messages/showdefault');
@@ -29,6 +52,10 @@ class Loginradius_Sociallogin_Block_Sociallogin extends Mage_Core_Block_Template
29
  public function getApiSecret()
30
  {
31
  return Mage::getStoreConfig('sociallogin_options/messages/appkey');
 
 
 
 
32
  }
33
  public function getRedirectOption(){
34
 
@@ -41,10 +68,48 @@ class Loginradius_Sociallogin_Block_Sociallogin extends Mage_Core_Block_Template
41
 
42
  public function getEmailRequired(){
43
 
44
- return Mage::getStoreConfig('sociallogin_options/messages/emailrequired');
45
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  public function getCallBack(){
47
-
48
  return Mage::getStoreConfig('sociallogin_options/messages/call');
49
  }
50
  public function getProfileResult($ApiSecrete)
@@ -64,7 +129,7 @@ class Loginradius_Sociallogin_Block_Sociallogin extends Mage_Core_Block_Template
64
  return false;
65
  }
66
  }
67
- public function getApiCall($url)
68
  {
69
 
70
  if ( $this->getApiOption() == 'curl' ){
@@ -89,20 +154,21 @@ class Loginradius_Sociallogin_Block_Sociallogin extends Mage_Core_Block_Template
89
  }
90
  }
91
  elseif($this->getApiOption() == 'fopen') {
92
-
93
  $JsonResponse = file_get_contents($url);
94
  }else {
95
-
96
  $method = 'GET';
97
- $client = new Varien_Http_Client($url);
98
- $response = $client->request($method);
99
- $JsonResponse = $response->getBody();
 
 
 
100
  }
101
  if ($JsonResponse) {
102
  return json_decode($JsonResponse);
103
  }
104
  else {
105
- return "something went wrong, Can not get api response.";
106
  }
107
 
108
  }
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();
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
+ public function getAvatar( $id ){
37
+ $socialLoginConn = Mage::getSingleton('core/resource')
38
+ ->getConnection('core_read');
39
+ $SocialLoginTbl = Mage::getSingleton('core/resource')->getTableName("sociallogin");
40
+ $select = $socialLoginConn->query("select avatar from $SocialLoginTbl where entity_id = '$id' limit 1");
41
+ if( $rowArray = $select->fetch() ) {
42
+ if( ($avatar = trim($rowArray['avatar'])) != "" ){
43
+ return $avatar;
44
+ }
45
+ }
46
+ return false;
47
+ }
48
  public function getShowDefault()
49
  {
50
  return Mage::getStoreConfig('sociallogin_options/messages/showdefault');
52
  public function getApiSecret()
53
  {
54
  return Mage::getStoreConfig('sociallogin_options/messages/appkey');
55
+ }
56
+ public function getLoginRadiusTitle()
57
+ {
58
+ return Mage::getStoreConfig('sociallogin_options/messages/loginradius_title');
59
  }
60
  public function getRedirectOption(){
61
 
68
 
69
  public function getEmailRequired(){
70
 
71
+ return Mage::getStoreConfig('sociallogin_options/email_settings/emailrequired');
72
  }
73
+ public function verificationText(){
74
+
75
+ return Mage::getStoreConfig('sociallogin_options/email_settings/verificationText');
76
+ }
77
+ public function getPopupText(){
78
+
79
+ return Mage::getStoreConfig('sociallogin_options/email_settings/popupText');
80
+ }
81
+ public function getPopupError(){
82
+
83
+ return Mage::getStoreConfig('sociallogin_options/email_settings/popupError');
84
+ }
85
+ public function getLinking(){
86
+ return Mage::getStoreConfig('sociallogin_options/messages/socialLinking');
87
+ }
88
+ public function notifyUser(){
89
+ return Mage::getStoreConfig('sociallogin_options/email_settings/notifyUser');
90
+ }
91
+ public function notifyUserText(){
92
+ return Mage::getStoreConfig('sociallogin_options/email_settings/notifyUserText');
93
+ }
94
+ public function notifyAdmin(){
95
+ return Mage::getStoreConfig('sociallogin_options/email_settings/notifyAdmin');
96
+ }
97
+ public function notifyAdminText(){
98
+ return Mage::getStoreConfig('sociallogin_options/email_settings/notifyAdminText');
99
+ }
100
+ public function shareEnable(){
101
+ return Mage::getStoreConfig('sociallogin_options/sharing/shareEnable');
102
+ }
103
+ public function sharingCode(){
104
+ return Mage::getStoreConfig('sociallogin_options/sharing/sharingCode');
105
+ }
106
+ public function counterEnable(){
107
+ return Mage::getStoreConfig('sociallogin_options/counter/counterEnable');
108
+ }
109
+ public function counterCode(){
110
+ return Mage::getStoreConfig('sociallogin_options/counter/counterCode');
111
+ }
112
  public function getCallBack(){
 
113
  return Mage::getStoreConfig('sociallogin_options/messages/call');
114
  }
115
  public function getProfileResult($ApiSecrete)
129
  return false;
130
  }
131
  }
132
+ public function getApiCall($url)
133
  {
134
 
135
  if ( $this->getApiOption() == 'curl' ){
154
  }
155
  }
156
  elseif($this->getApiOption() == 'fopen') {
 
157
  $JsonResponse = file_get_contents($url);
158
  }else {
 
159
  $method = 'GET';
160
+ try{
161
+ $client = new Varien_Http_Client($url);
162
+ $response = $client->request($method);
163
+ $JsonResponse = $response->getBody();
164
+ }catch(Exception $e){
165
+ }
166
  }
167
  if ($JsonResponse) {
168
  return json_decode($JsonResponse);
169
  }
170
  else {
171
+ return "something went wrong, Can not get api response.";
172
  }
173
 
174
  }
app/code/community/Loginradius/Sociallogin/Helper/Data.php CHANGED
@@ -1,16 +1,16 @@
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
- *
8
- * @return bool
9
- */
10
- public function isSocialloginEnabled() {
11
- if (Mage::getStoreConfig('sociallogin_options/messages/enabled') == '1')
12
- return true;
13
-
14
- return false;
15
- }
16
- }
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
+ *
8
+ * @return bool
9
+ */
10
+ public function isSocialloginEnabled() {
11
+ if (Mage::getStoreConfig('sociallogin_options/messages/enabled') == '1'){
12
+ return true;
13
+ }
14
+ return false;
15
+ }
16
+ }
app/code/community/Loginradius/Sociallogin/controllers/IndexController.php CHANGED
@@ -1,270 +1,730 @@
1
  <?php
 
2
  Mage::app('default');
3
- include_once("inc.php");//sdk file
 
 
 
4
 
5
  //customer will be re-directed to this file. this file handle all token, email etc things.
6
 
7
  class Loginradius_Sociallogin_IndexController extends Mage_Core_Controller_Front_Action
 
8
  {
9
 
 
 
 
 
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
 
16
  function tokenHandle() {
17
- $blockObj = new Loginradius_Sociallogin_Block_Sociallogin();//object to get api key and secrets, url etc
18
- $ApiSecrete = $blockObj->getApiSecret();
 
19
 
20
- $user_obj = $blockObj->getProfileResult($ApiSecrete);
 
 
21
 
22
- $id= $user_obj->ID;
 
 
 
 
23
  if(empty($id)){
 
24
  //invalid user
 
25
  return;
 
26
  }
 
27
 
 
28
  //valid user, checking if user in database?
29
- $connection = Mage::getSingleton('core/resource')
30
- ->getConnection('core_read');
31
- $tbl_sociallog = getMazeTable("sociallogin"); // mage_sociallogin
32
- $customerTbl = getMazeTable("customer_entity"); // customer_entity
33
 
34
- $websiteId = Mage::app()->getWebsite()->getId();
35
- $storeId = Mage::app()->getStore()->getId();
36
-
37
- $socialLoginIdResult = $connection->query("select entity_id from $tbl_sociallog where sociallogin_id= '$id'");
38
  $socialLoginIds = $socialLoginIdResult->fetchAll();
39
  foreach( $socialLoginIds as $socialLoginId ){
40
- $select = $connection->query("select entity_id from $customerTbl where entity_id = ".$socialLoginId['entity_id']." and website_id = $websiteId and store_id = $storeId" );
 
41
  if($rowArray = $select->fetch()){
 
 
 
 
42
  break;
 
43
  }
 
44
  }
 
45
  $sociallogin_id = $rowArray['entity_id'];
 
46
  if(!empty($sociallogin_id)){//user is in database
47
- $this->socialLoginUserLogin( $sociallogin_id, $blockObj);
 
 
48
  return;
 
49
  }
50
-
51
- if( !empty($user_obj->Email) ){
 
52
  //if email is provided by provider then check if it's in table
 
53
  $email = $user_obj->Email['0']->Value;
54
- $select = $connection->query("select * from $customerTbl where email = '$email' and website_id = $websiteId and store_id = $storeId");
55
-
56
-
57
  if( $rowArray = $select->fetch() ) {
 
58
  $sociallogin_id = $rowArray['entity_id'];
59
-
60
  if(!empty($sociallogin_id)) {
 
61
  //user is in customer table
62
- $this->socialLoginUserLogin( $sociallogin_id, $blockObj);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  return;
 
64
  }
 
65
  }
 
66
 
 
67
  $socialloginProfileData = $this->socialLoginFilterData( $email, $user_obj );
 
68
  $socialloginProfileData['lrId'] = $user_obj->ID;
69
- $this->socialLoginAddNewUser( $socialloginProfileData, $email, $blockObj );
 
 
70
  return;
 
71
  }
 
72
  // empty email
73
- if( $blockObj->getEmailRequired() == 0 ) { // dummy email
 
74
  $email = $this->loginradius_get_randomEmail( $user_obj );
 
75
  $socialloginProfileData = $this->socialLoginFilterData( $email, $user_obj );
 
76
  $socialloginProfileData['lrId'] = $user_obj->ID;
77
- $this->socialLoginAddNewUser( $socialloginProfileData, $email, $blockObj );
 
 
78
  return;
 
79
  }else { // show popup
 
80
  $id = $user_obj->ID;
 
81
  $socialloginProfileData = $this->socialLoginFilterData( $email, $user_obj );
 
82
  $this->setInSession($id, $socialloginProfileData);
83
- SL_popUpWindow();
 
 
84
  return;
 
85
  }
 
86
  }
 
87
 
 
88
  function loginradius_get_randomEmail( $user_obj ) {
 
89
  switch ( $user_obj->Provider ) {
 
90
  case 'twitter':
 
91
  $email = $user_obj->ID. '@' . $user_obj->Provider . '.com';
 
92
  break;
93
 
 
 
94
  case 'linkedin':
 
95
  $email = $user_obj->ID. '@' . $user_obj->Provider . '.com';
 
96
  break;
97
 
 
 
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
 
 
 
105
  return $email;
 
106
  }
 
107
 
 
108
  function socialLoginFilterData( $email, $user_obj ) {
 
109
  $socialloginProfileData = array();
110
-
111
  $socialloginProfileData['Provider'] = empty($user_obj->Provider) ? "" : $user_obj->Provider;
 
112
  $socialloginProfileData['FirstName'] = empty($user_obj->FirstName) ? "" : $user_obj->FirstName;
 
113
  $socialloginProfileData['FullName'] = empty($user_obj->FullName) ? "" : $user_obj->FullName;
 
114
  $socialloginProfileData['NickName'] = empty($user_obj->NickName) ? "" : $user_obj->NickName;
 
115
  $socialloginProfileData['LastName'] = empty($user_obj->LastName) ? "" : $user_obj->LastName;
 
116
  $socialloginProfileData['Addresses'] = empty($user_obj->Addresses['0']->Address1) ? "" : $user_obj->Addresses['0']->Address1;
 
117
  $socialloginProfileData['PhoneNumbers'] = empty( $user_obj->PhoneNumbers['0']->PhoneNumber ) ? "" : $user_obj->PhoneNumbers['0']->PhoneNumber;
 
118
  $socialloginProfileData['State'] = empty($user_obj->State) ? "" : $user_obj->State;
 
119
  $socialloginProfileData['City'] = empty($user_obj->City) ? "" : $user_obj->City;
 
120
  $socialloginProfileData['Industry'] = empty($user_obj->Positions['0']->Comapny->Name) ? "" : $user_obj->Positions['0']->Comapny->Name;
 
121
  $socialloginProfileData['Country'] = empty($user_obj->Country) ? "" : $user_obj->Country;
122
-
 
 
 
123
  $explode= explode("@",$email);
 
124
  if( empty( $socialloginProfileData['FirstName'] ) && !empty( $socialloginProfileData['FullName'] ) ){
 
125
  $socialloginProfileData['FirstName'] = $socialloginProfileData['FullName'];
 
126
  }elseif(empty($socialloginProfileData['FirstName'] ) && !empty( $socialloginProfileData['NickName'] )){
 
127
  $socialloginProfileData['FirstName'] = $socialloginProfileData['NickName'];
 
128
  }elseif(empty($socialloginProfileData['FirstName'] ) && empty($socialloginProfileData['NickName'] ) && !empty($socialloginProfileData['FullName'] ) ){
 
129
  $socialloginProfileData['FirstName'] = $explode[0];
 
130
  }
 
131
  if($socialloginProfileData['FirstName'] == '' ){
 
132
  $letters = range('a', 'z');
 
133
  for($i=0;$i<5;$i++){
 
134
  $socialloginProfileData['FirstName'] .= $letters[rand(0,26)];
 
135
  }
 
136
  }
137
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  return $socialloginProfileData;
 
139
  }
 
140
 
141
- function socialLoginUserLogin( $sociallogin_id, $blockObj ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
  $session = Mage::getSingleton("customer/session");
 
143
  $session->loginById($sociallogin_id);
144
- $write_url = $blockObj->getCallBack();
145
- $Hover = $blockObj->getRedirectOption();
 
 
 
146
  $url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
 
147
  if($Hover=='account' ){
 
148
  header( 'Location: '.$url.'customer/account' );
 
149
  return;
 
150
  }elseif($Hover=='index' ){
 
151
  header( 'Location: '.$url.'') ;
 
152
  return;
 
153
  }elseif( $Hover=='custom' && $write_url != '' ) {
 
154
  header( 'Location: '.$write_url.'' );
 
155
  return;
 
156
  } else {
 
157
  $currentUrl = Mage::helper('core/url')->getCurrentUrl();
 
158
  header( 'Location: '.$currentUrl.'' );
 
159
  return;
 
160
  }
 
161
  }
 
162
 
 
163
  function setInSession( $id, $socialloginProfileData ){
 
164
  $socialloginProfileData['lrId'] = $id;
 
165
  Mage::getSingleton('core/session')->setSocialLoginData( $socialloginProfileData );
 
166
  }
167
-
168
- function socialLoginAddNewUser( $socialloginProfileData, $email, $blockObj ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
  // add new user magento way
 
170
  $websiteId = Mage::app()->getWebsite()->getId();
171
  $store = Mage::app()->getStore();
172
-
173
  $customer = Mage::getModel("customer/customer");
 
174
  $customer->website_id = $websiteId;
 
175
  $customer->setStore($store);
 
176
 
 
177
  $customer->firstname = $socialloginProfileData['FirstName'];
178
- $customer->lastname = $socialloginProfileData['LastName'];
 
 
179
  $customer->email = $email;
 
 
 
 
 
180
 
181
- $customer->password_hash = md5( $customer->generatePassword(10) );
 
 
182
  $customer->save();
 
183
 
 
184
  //$address = new Mage_Customer_Model_Address();
 
185
  $address = Mage::getModel("customer/address");
 
186
  $address->setCustomerId($customer->getId());
 
187
  $address->firstname = $customer->firstname;
 
188
  $address->lastname = $customer->lastname;
 
189
  $address->country_id = ucfirst( $socialloginProfileData['Country'] ); //Country code here
 
190
  // $address->postcode = "31000";
 
191
  $address->city = ucfirst( $socialloginProfileData['City'] );
 
192
  /* NOTE: If country is USA, please set up $address->region also */
 
193
  $address->telephone = $socialloginProfileData['PhoneNumbers'];
 
194
  $address->company = ucfirst( $socialloginProfileData['Industry'] );
 
195
  $address->street = ucfirst( $socialloginProfileData['Addresses'] );
 
196
 
 
197
  $address->save();
 
 
198
 
199
  // add info in sociallogin table
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
  $connection = Mage::getSingleton('core/resource')
201
- ->getConnection('core_write');
 
 
202
  $connection->beginTransaction();
203
- $fields = array();
204
- $fields['sociallogin_id'] = $socialloginProfileData['lrId'] ;
205
- $fields['entity_id'] = $customer->getId();
206
- $sociallogin = getMazeTable("sociallogin");
207
 
208
- $connection->insert($sociallogin, $fields);
209
-
 
 
 
 
 
210
  $connection->commit();
211
-
212
- //login user
213
- $this->socialLoginUserLogin( $customer->getId(), $blockObj );
214
  }
 
215
 
 
216
  private function SocialLoginShowLayout() {
 
217
  $this->loadLayout();
 
218
  $this->renderLayout();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
219
  }
220
 
221
  public function indexAction() {
 
 
 
 
 
 
 
222
  if(isset($_REQUEST['token'])) {
 
223
  $this->tokenHandle();
 
224
  $this->loadLayout();
 
225
  $this->renderLayout();
 
226
  return;
 
227
  }
228
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
229
  $socialLoginProfileData = Mage::getSingleton('core/session')->getSocialLoginData();
 
230
  $session_user_id = $socialLoginProfileData['lrId'];
231
-
 
 
232
  if( isset($_POST['LoginRadiusRedSliderClick']) ) {
 
233
  if( !empty($session_user_id) ){
 
234
  $email = trim($_POST['SL_EMAIL']);
235
-
236
  if( !preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/", $email) ){
237
- SL_popUpWindow( "Please enter a valid email address" );
 
 
238
  $this->SocialLoginShowLayout();
 
239
  return false;
 
240
  }
241
-
242
  // check if email already exists
243
- $socialLoginConn = Mage::getSingleton('core/resource')
244
- ->getConnection('core_read');
245
- $customerTbl = getMazeTable("customer_entity"); // customer_entity
246
- $websiteId = Mage::app()->getWebsite()->getId();
247
- $storeId = Mage::app()->getStore()->getId();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
248
 
249
- $select = $socialLoginConn->query("select entity_id from $customerTbl where email = '$email' and website_id = $websiteId and store_id = $storeId");
250
-
251
- if( $rowArray = $select->fetch() ) { // email exists
252
- SL_popUpWindow( "This email already exists. Please enter valid email address." );
253
- $this->SocialLoginShowLayout();
254
- return false;
255
  }
256
 
257
  $socialloginProfileData = Mage::getSingleton('core/session')->getSocialLoginData();
 
258
  Mage::getSingleton('core/session')->unsSocialLoginData(); // unset session
259
-
260
- $blockObj = new Loginradius_Sociallogin_Block_Sociallogin(); //object to get api key and secrets, url etc
261
- $this->socialLoginAddNewUser($socialloginProfileData, $email, $blockObj);
 
 
262
  }
 
263
  }elseif( isset($_POST['LoginRadiusPopupCancel']) ) { // popup cancelled
 
264
  Mage::getSingleton('core/session')->unsSocialLoginData(); // unset session
 
265
  $url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
 
266
  header("Location:".$url); // redirect to index page
 
267
  }
 
268
  $this->SocialLoginShowLayout();
 
269
  }
 
270
  }
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" ){
64
+ SL_popUpWindow( "Please verify your email to login.", "", false );
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';
266
+ }elseif( strtolower(substr($socialloginProfileData['Gender'], 0, 1)) == 'f' ){
267
+ $socialloginProfileData['Gender'] = '2';
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'] ){
275
+ case 'facebook':
276
+ case 'foursquare':
277
+ case 'yahoo':
278
+ case 'openid':
279
+ break;
280
+
281
+ case 'google':
282
+ $temp = explode( '/', $socialloginProfileData['BirthDate'] ); // yy/mm/dd
283
+ $socialloginProfileData['BirthDate'] = $temp[1]."/".$temp[2]."/".$temp[0];
284
+ break;
285
+
286
+ case 'twitter':
287
+ case 'linkedin':
288
+ case 'vkontakte':
289
+ case 'live';
290
+ $temp = explode( '/', $socialloginProfileData['BirthDate'] ); // dd/mm/yy
291
+ $socialloginProfileData['BirthDate'] = $temp[1]."/".$temp[0]."/".$temp[2];
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 );
376
+ $mail->addTo( $to, $toName );
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) {
384
+ die("Error sending mail");
385
+ }
386
+ }
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();
469
+ if( $loginRadiusMessage == "" ){
470
+ $loginRadiusMessage = "Welcome to ".$store->getGroup()->getName().". You can login to the store using following e-mail address and password:-";
471
+ }
472
+ $loginRadiusMessage .= "<br/>".
473
+ "Email : ".$email.
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');
481
+ $loginRadiusAdminName = Mage::getStoreConfig('trans_email/ident_general/name');
482
+ $loginRadiusMessage = trim($this->blockObj->notifyAdminText());
483
+ if( $loginRadiusMessage == "" ){
484
+ $loginRadiusMessage = "New customer has been registered to your store with following details:-";
485
+ }
486
+ $loginRadiusMessage .= "<br/>".
487
+ "Name : ".$loginRadiusUsername."<br/>".
488
+ "Email : ".$email;
489
+ $this->loginRadiusEmail( "New User Registration", $loginRadiusMessage, $loginRadiusAdminEmail, $loginRadiusAdminName );
490
+ }
491
+ }
492
+ if( $verify ){
493
+ $this->verifyUser( $socialloginProfileData['lrId'], $customer->getId(), $socialloginProfileData['thumbnail'], $socialloginProfileData['Provider'], $email );
494
+ }
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);
508
+ }else{
509
+ $query = "UPDATE {$sociallogin} SET ".$lrInsertData." WHERE ".$value;
510
+ $offset = $connection->query( $query );
511
+ }
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":
539
+ $query = "select entity_id from $Tbl where email = '".$params[0]."' and website_id = $websiteId and store_id = $storeId";
540
+ break;
541
+ case "get user":
542
+ $query = "select entity_id, verified from $Tbl where sociallogin_id= '".$params[0]."'";
543
+ break;
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;
566
+ }
567
+ $select = $socialLoginConn->query($query);
568
+ if( $result ){
569
+ return $select;
570
+ }
571
+ if( $rowArray = $select->fetch() ) {
572
+ return true;
573
+ }
574
+ return false;
575
+ }
576
+
577
+ private function verifyUser( $slId, $entityId, $avatar, $provider, $email ){
578
+ $vKey = md5(uniqid(rand(), TRUE));
579
+ $data = array();
580
+ $data['sociallogin_id'] = $slId;
581
+ $data['entity_id'] = $entityId;
582
+ $data['avatar'] = $avatar;
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();
602
+ return;
603
  }
604
 
605
  public function indexAction() {
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() ){
632
+ // set verified status true at this verification key
633
+ $tempUpdate = "verified = '1', vkey = ''";
634
+ $tempUpdate2 = "vkey = '".$loginRadiusVkey."'";
635
+ $this->SocialLoginInsert( "sociallogin", $tempUpdate, true, $tempUpdate2 );
636
+ SL_popUpWindow( "Your email has been verified. Now you can login to your account.", "", false );
637
+
638
+ // check if verification for same provider is still pending on this entity_id
639
+ if( $this->loginRadiusRead( "sociallogin", "verification2", array( $temp['entity_id'], $temp['provider'] ) ) ){
640
+ $tempUpdate = "vkey = ''";
641
+ $tempUpdate2 = "entity_id = ".$temp['entity_id']." and provider = '".$temp['provider']."'";
642
+ $this->SocialLoginInsert( "sociallogin", $tempUpdate, true, $tempUpdate2 );
643
+ }
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
670
+ $userId = $this->loginRadiusRead( "customer_entity", "email exists pop1", array($email), true );
671
+ if( $rowArray = $userId->fetch() ) { // email exists
672
+ //check if entry exists on same provider in sociallogin table
673
+ $verified = $this->loginRadiusRead( "sociallogin", "email exists sl", array( $rowArray['entity_id'], $loginRadiusPopProvider ), true );
674
+ if( $rowArray2 = $verified->fetch() ){
675
+ // check verified field
676
+ if( $rowArray2['verified'] == "1" ){
677
+ // check sociallogin id
678
+ if( $rowArray2['sociallogin_id'] == $session_user_id ){
679
+ $this->socialLoginUserLogin( $rowArray['entity_id'] );
680
+ return;
681
+ }else{
682
+ SL_popUpWindow( $this->loginRadiusPopMsg, $this->loginRadiusPopErr );
683
+ $this->SocialLoginShowLayout();
684
+ return;
685
+ }
686
+ }else{
687
+ // check sociallogin id
688
+ if( $rowArray2['sociallogin_id'] == $session_user_id ){
689
+ SL_popUpWindow( "Please verify your email to login", "", false );
690
+ $this->SocialLoginShowLayout();
691
+ return;
692
+ }else{
693
+ // send verification email
694
+ $this->verifyUser( $session_user_id, $rowArray['entity_id'], $loginRadiusAvatar, $loginRadiusPopProvider, $email );
695
+ return;
696
+ }
697
+ }
698
+ }else{
699
+ // send verification email
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
  }
app/code/community/Loginradius/Sociallogin/controllers/inc.php CHANGED
@@ -1,143 +1,153 @@
1
- <?php
2
- define("MODE","testing");
3
- function showDie($line,$msg){
4
- if(defined("MODE")){
5
- echo "<p>Message from $line, message is $msg </p>";
6
- die;
7
- }
8
- }
9
-
10
- function SL_popUpWindow( $socialLoginMsg = "" ){
11
- ?>
12
- <!--css of email block -->
13
- <style type="text/css">
14
- .LoginRadius_overlay {
15
- background: none no-repeat scroll 0 0 rgba(127, 127, 127, 0.6);
16
- height: 100%;
17
- left: 0;
18
- overflow: auto;
19
- padding: 0px 20px 130px;
20
- position: fixed;
21
- top: 0;
22
- width: 100%;
23
- z-index: 100001;
24
- }
25
- #popupouter{
26
- -moz-border-radius:4px;
27
- -webkit-border-radius:4px;
28
- border-radius:4px;
29
- margin-left:-185px;
30
- left:50%;
31
- background:#f3f3f3;
32
- padding:1px 0px 1px 0px;
33
- width:370px;
34
- position: absolute;
35
- top:50%;
36
- z-index:9999;
37
- margin-top:-96px;
38
- }
39
- #popupinner {
40
- background: none repeat scroll 0 0 #FFFFFF;
41
- border-radius: 4px 4px 4px 4px;
42
- margin: 10px;
43
- overflow: auto;
44
- padding: 10px 8px 4px;
45
- }
46
- #textmatter {
47
- color: #666666;
48
- font-family: Arial,Helvetica,sans-serif;
49
- font-size: 14px;
50
- margin: 10px 0;
51
- float:left
52
- }
53
- .inputtxt{
54
- font-family:Arial, Helvetica, sans-serif;
55
- color:#a8a8a8;
56
- font-size:11px;
57
- border:#e5e5e5 1px solid;
58
- width:280px;
59
- height:27px;
60
- margin:5px 0px 15px 0px;
61
- float:left
62
- }
63
- .inputbutton{
64
- border:#dcdcdc 1px solid;
65
- -moz-border-radius:2px;
66
- -webkit-border-radius:2px;
67
- border-radius:2px;
68
- text-decoration:none;
69
- color:#6e6e6e;
70
- font-family:Arial, Helvetica, sans-serif;
71
- font-size:13px;
72
- cursor:pointer;
73
- background:#f3f3f3;
74
- padding:6px 7px 6px 8px;
75
- margin:0px 8px 0px 0px;
76
- float:left
77
- }
78
- .inputbutton:hover{
79
- border:#00ccff 1px solid;
80
- -moz-border-radius:2px;
81
- -webkit-border-radius:2px;
82
- border-radius:2px;
83
- khtml-border-radius:2px;
84
- text-decoration:none;
85
- color:#000000;
86
- font-family:Arial, Helvetica, sans-serif;
87
- font-size:13px;
88
- cursor:pointer;
89
- padding:6px 7px 6px 8px;
90
- -moz-box-shadow: 0px 0px 4px #8a8a8a;
91
- -webkit-box-shadow: 0px 0px 4px #8a8a8a;
92
- box-shadow: 0px 0px 4px #8a8a8a;
93
- background:#f3f3f3;
94
- margin:0px 8px 0px 0px;
95
- }
96
- #textdivpopup{
97
- text-align:right;
98
- font-family:Arial, Helvetica, sans-serif;
99
- font-size:11px;
100
- color:#000000;
101
- }
102
- .spanpopup{
103
- font-family:Arial, Helvetica, sans-serif;
104
- font-size:11px;
105
- color:#00ccff;
106
- }
107
- .span1{
108
- font-family:Arial, Helvetica, sans-serif;
109
- font-size:11px;
110
- color:#333333;
111
- }
112
- <!--[if IE]>
113
- .LoginRadius_content_IE
114
- {background:black;
115
- -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=90)";
116
- filter: alpha(opacity=90);
117
- }
118
- <![endif]-->
119
- </style>
120
- </head>
121
- <body>
122
- <div id="fade" class="LoginRadius_overlay">
123
- <div id="popupouter">
124
- <div id="popupinner">
125
- <div id="textmatter"><strong>Please enter your email to proceed</strong> </div>
126
- <div style="clear:both;"></div>
127
- <div style="color:red; text-align:justify"><?php echo $socialLoginMsg ?></div>
128
- <form method="post" action="">
129
- <div><input type="text" name="SL_EMAIL" id="SL_EMAIL" class="inputtxt" /></div>
130
- <div>
131
- <input type="submit" id="LoginRadiusRedSliderClick" name="LoginRadiusRedSliderClick" value="Submit" class="inputbutton">
132
- <input type="submit" value="Cancel" class="inputbutton" name="LoginRadiusPopupCancel" />
133
- </div>
134
- </form>
135
- </div>
136
- </div>
137
- </div>
138
- <?php
139
- }
140
- function getMazeTable($tbl){
141
- $tableName = Mage::getSingleton('core/resource')->getTableName($tbl);
142
- return($tableName);
 
 
 
 
 
 
 
 
 
 
143
  }?>
1
+ <?php
2
+ define("MODE","testing");
3
+ function showDie($line,$msg){
4
+ if(defined("MODE")){
5
+ echo "<p>Message from $line, message is $msg </p>";
6
+ die;
7
+ }
8
+ }
9
+
10
+ function SL_popUpWindow( $loginRadiusPopupTxt, $socialLoginMsg = "", $loginRadiusShowForm = true ){
11
+ ?>
12
+ <!--css of email block -->
13
+ <style type="text/css">
14
+ .LoginRadius_overlay {
15
+ background: none no-repeat scroll 0 0 rgba(127, 127, 127, 0.6);
16
+ height: 100%;
17
+ left: 0;
18
+ overflow: auto;
19
+ padding: 0px 20px 130px;
20
+ position: fixed;
21
+ top: 0;
22
+ width: 100%;
23
+ z-index: 100001;
24
+ }
25
+ #popupouter{
26
+ -moz-border-radius:4px;
27
+ -webkit-border-radius:4px;
28
+ border-radius:4px;
29
+ margin-left:-185px;
30
+ left:50%;
31
+ background:#f3f3f3;
32
+ padding:1px 0px 1px 0px;
33
+ width:370px;
34
+ position: absolute;
35
+ top:50%;
36
+ z-index:9999;
37
+ margin-top:-96px;
38
+ }
39
+ #popupinner {
40
+ background: none repeat scroll 0 0 #FFFFFF;
41
+ border-radius: 4px 4px 4px 4px;
42
+ margin: 10px;
43
+ overflow: auto;
44
+ padding: 10px 8px 4px;
45
+ }
46
+ #textmatter {
47
+ color: #666666;
48
+ font-family: Arial,Helvetica,sans-serif;
49
+ font-size: 14px;
50
+ margin: 10px 0;
51
+ float:left
52
+ }
53
+ .inputtxt{
54
+ font-family:Arial, Helvetica, sans-serif;
55
+ color:#a8a8a8;
56
+ font-size:11px;
57
+ border:#e5e5e5 1px solid;
58
+ width:280px;
59
+ height:27px;
60
+ margin:5px 0px 15px 0px;
61
+ float:left
62
+ }
63
+ .inputbutton{
64
+ border:#dcdcdc 1px solid;
65
+ -moz-border-radius:2px;
66
+ -webkit-border-radius:2px;
67
+ border-radius:2px;
68
+ text-decoration:none;
69
+ color:#6e6e6e;
70
+ font-family:Arial, Helvetica, sans-serif;
71
+ font-size:13px;
72
+ cursor:pointer;
73
+ background:#f3f3f3;
74
+ padding:6px 7px 6px 8px;
75
+ margin:0px 8px 0px 0px;
76
+ float:left
77
+ }
78
+ .inputbutton:hover{
79
+ border:#00ccff 1px solid;
80
+ -moz-border-radius:2px;
81
+ -webkit-border-radius:2px;
82
+ border-radius:2px;
83
+ khtml-border-radius:2px;
84
+ text-decoration:none;
85
+ color:#000000;
86
+ font-family:Arial, Helvetica, sans-serif;
87
+ font-size:13px;
88
+ cursor:pointer;
89
+ padding:6px 7px 6px 8px;
90
+ -moz-box-shadow: 0px 0px 4px #8a8a8a;
91
+ -webkit-box-shadow: 0px 0px 4px #8a8a8a;
92
+ box-shadow: 0px 0px 4px #8a8a8a;
93
+ background:#f3f3f3;
94
+ margin:0px 8px 0px 0px;
95
+ }
96
+ #textdivpopup{
97
+ text-align:right;
98
+ font-family:Arial, Helvetica, sans-serif;
99
+ font-size:11px;
100
+ color:#000000;
101
+ }
102
+ .spanpopup{
103
+ font-family:Arial, Helvetica, sans-serif;
104
+ font-size:11px;
105
+ color:#00ccff;
106
+ }
107
+ .span1{
108
+ font-family:Arial, Helvetica, sans-serif;
109
+ font-size:11px;
110
+ color:#333333;
111
+ }
112
+ <!--[if IE]>
113
+ .LoginRadius_content_IE
114
+ {background:black;
115
+ -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=90)";
116
+ filter: alpha(opacity=90);
117
+ }
118
+ <![endif]-->
119
+ </style>
120
+ </head>
121
+ <body>
122
+ <div id="fade" class="LoginRadius_overlay">
123
+ <div id="popupouter">
124
+ <div id="popupinner">
125
+ <div id="textmatter"><strong><?php echo $loginRadiusPopupTxt; ?></strong></div>
126
+ <div style="clear:both;"></div>
127
+ <div style="color:red; text-align:justify"><?php echo $socialLoginMsg ?></div>
128
+ <?php
129
+ if( $loginRadiusShowForm ){
130
+ ?>
131
+ <form method="post" action="">
132
+ <div><input type="text" name="SL_EMAIL" id="SL_EMAIL" class="inputtxt" /></div>
133
+ <div>
134
+ <input type="submit" id="LoginRadiusRedSliderClick" name="LoginRadiusRedSliderClick" value="Submit" class="inputbutton">
135
+ <input type="submit" value="Cancel" class="inputbutton" name="LoginRadiusPopupCancel" />
136
+ </div>
137
+ </form>
138
+ <?php
139
+ }else{
140
+ ?>
141
+ <input type="button" value="OK" onClick="location.href = '<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK); ?>'" />
142
+ <?php
143
+ }
144
+ ?>
145
+ </div>
146
+ </div>
147
+ </div>
148
+ <?php
149
+ }
150
+ function getMazeTable($tbl){
151
+ $tableName = Mage::getSingleton('core/resource')->getTableName($tbl);
152
+ return($tableName);
153
  }?>
app/code/community/Loginradius/Sociallogin/etc/config.xml CHANGED
@@ -1,8 +1,34 @@
1
  <?xml version="1.0"?>
2
- <config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  <modules>
4
  <Loginradius_Sociallogin>
5
- <version>1.2.1</version>
6
  </Loginradius_Sociallogin>
7
  </modules>
8
  <frontend>
1
  <?xml version="1.0"?>
2
+ <config>
3
+ <default>
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>
14
+ <verificationText>Please click on the following link or paste it in browser to verify your email:-</verificationText>
15
+ <popupText>Please enter your email to proceed</popupText>
16
+ <popupError>The email you entered is already registered or invalid. Please enter a valid email.</popupError>
17
+ <notifyUser>1</notifyUser>
18
+ <notifyAdmin>0</notifyAdmin>
19
+ <notifyAdminText>New customer has been registered to your store with following details:-</notifyAdminText>
20
+ </email_settings>
21
+ <sharing>
22
+ <shareEnable>1</shareEnable>
23
+ </sharing>
24
+ <counter>
25
+ <counterEnable>1</counterEnable>
26
+ </counter>
27
+ </sociallogin_options>
28
+ </default>
29
  <modules>
30
  <Loginradius_Sociallogin>
31
+ <version>2.0.0</version>
32
  </Loginradius_Sociallogin>
33
  </modules>
34
  <frontend>
app/code/community/Loginradius/Sociallogin/etc/system.xml CHANGED
@@ -1,124 +1,285 @@
1
- <?xml version="1.0"?>
2
-
3
- <config>
4
- <tabs>
5
- <socialconfig translate="label" module="sociallogin">
6
- <label>Social login</label>
7
- <sort_order>9999</sort_order>
8
- </socialconfig>
9
- </tabs>
10
- <sections>
11
- <sociallogin_options translate="label" module="sociallogin">
12
- <label>Social Login Configration</label>
13
- <tab>socialconfig</tab>
14
- <frontend_type>text</frontend_type>
15
- <sort_order>1000</sort_order>
16
- <show_in_default>1</show_in_default>
17
- <show_in_website>1</show_in_website>
18
- <show_in_store>1</show_in_store>
19
- <groups>
20
- <messages translate="label">
21
- <label>Social Login</label>
22
- <frontend_type>text</frontend_type>
23
- <sort_order>1</sort_order>
24
- <show_in_default>1</show_in_default>
25
- <show_in_website>1</show_in_website>
26
- <show_in_store>1</show_in_store>
27
- <fields>
28
- <enabled translate="label">
29
- <label>Enabled</label>
30
- <frontend_type>select</frontend_type>
31
- <source_model>adminhtml/system_config_source_yesno</source_model>
32
- <sort_order>10</sort_order>
33
- <show_in_default>1</show_in_default>
34
- <show_in_website>1</show_in_website>
35
- <show_in_store>1</show_in_store>
36
- </enabled>
37
- <appid translate="label">
38
- <label>LoginRadius API Key</label>
39
- <frontend_type>text</frontend_type>
40
- <comment><![CDATA[Paste LoginRadius API Key here. To get the API Key, log in to<a href="http://www.loginradius.com" target="_blank">LoginRadius</a>]]>
41
- </comment>
42
- <sort_order>15</sort_order>
43
- <show_in_default>1</show_in_default>
44
- <show_in_website>1</show_in_website>
45
- <show_in_store>1</show_in_store>
46
- </appid>
47
- <appkey translate="label">
48
- <label>LoginRadius API Secret</label>
49
- <frontend_type>text</frontend_type>
50
- <comment><![CDATA[Paste LoginRadius API Secret here. To get the API Secret, log in to<a href="http://www.loginradius.com" target="_blank">LoginRadius</a>]]>
51
- </comment>
52
- <sort_order>20</sort_order>
53
- <show_in_default>1</show_in_default>
54
- <show_in_website>1</show_in_website>
55
- <show_in_store>1</show_in_store>
56
- </appkey>
57
- <showdefault translate="label">
58
- <label>Show default widget in right panel</label>
59
- <frontend_type>select</frontend_type>
60
- <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. ]]>
61
- </comment>
62
- <source_model>adminhtml/system_config_source_yesno</source_model>
63
- <sort_order>25</sort_order>
64
- <show_in_default>1</show_in_default>
65
- <show_in_website>1</show_in_website>
66
- <show_in_store>1</show_in_store>
67
- </showdefault>
68
- <emailrequired translate="label">
69
- <label>Email Required</label>
70
- <frontend_type>select</frontend_type>
71
- <comment><![CDATA[A few ID providers do not provide user's Email ID. Select YES if you would like an email pop-up after login or select NO if you would like to auto-generate the email address.]]>
72
- </comment>
73
- <source_model>adminhtml/system_config_source_yesno</source_model>
74
- <sort_order>30</sort_order>
75
- <show_in_default>1</show_in_default>
76
- <show_in_website>1</show_in_website>
77
- <show_in_store>1</show_in_store>
78
- </emailrequired>
79
- <redirect translate="label">
80
- <label>Redirect After Login</label>
81
- <frontend_type>radios</frontend_type>
82
- <source_model>sociallogin/source_uihover</source_model>
83
- <sort_order>35</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
- </redirect>
88
- <call translate="label">
89
- <label></label>
90
- <frontend_type>text</frontend_type>
91
- <sort_order>40</sort_order>
92
- <show_in_default>1</show_in_default>
93
- <show_in_website>1</show_in_website>
94
- <show_in_store>1</show_in_store>
95
- </call>
96
- <api translate="label">
97
- <label>API Connection Method</label>
98
- <frontend_type>select</frontend_type>
99
- <comment><![CDATA[cURL require 'cURL support = enabled' in your php.ini settings, FSOCKOPEN require 'allow_url_fopen = On' and 'safemode = off' in your php.ini settings]]>
100
- </comment>
101
- <source_model>sociallogin/source_uihover2</source_model>
102
- <sort_order>45</sort_order>
103
- <show_in_default>1</show_in_default>
104
- <show_in_website>1</show_in_website>
105
- <show_in_store>1</show_in_store>
106
- </api>
107
-
108
- </fields>
109
- </messages>
110
- <info translate="label">
111
- <label>Extension Help</label>
112
- <frontend_type>text</frontend_type>
113
- <frontend_model>sociallogin/info</frontend_model>
114
- <sort_order>50</sort_order>
115
- <show_in_default>1</show_in_default>
116
- <show_in_website>1</show_in_website>
117
- <show_in_store>1</show_in_store>
118
- </info>
119
-
120
- </groups>
121
- </sociallogin_options>
122
-
123
- </sections>
124
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <tabs>
5
+ <socialconfig translate="label" module="sociallogin">
6
+ <label>Login Radius</label>
7
+ <sort_order>1</sort_order>
8
+ </socialconfig>
9
+ </tabs>
10
+ <sections>
11
+ <sociallogin_options translate="label" module="sociallogin">
12
+ <label>Social Login</label>
13
+ <tab>socialconfig</tab>
14
+ <frontend_type>text</frontend_type>
15
+ <sort_order>1000</sort_order>
16
+ <show_in_default>1</show_in_default>
17
+ <show_in_website>1</show_in_website>
18
+ <show_in_store>1</show_in_store>
19
+ <groups>
20
+ <messages translate="label">
21
+ <label>Social Login Basic Settings</label>
22
+ <frontend_type>text</frontend_type>
23
+ <sort_order>1</sort_order>
24
+ <show_in_default>1</show_in_default>
25
+ <show_in_website>1</show_in_website>
26
+ <show_in_store>1</show_in_store>
27
+ <fields>
28
+ <loginEnable translate="label">
29
+ <label>Enable Social Login</label>
30
+ <frontend_type>select</frontend_type>
31
+ <source_model>adminhtml/system_config_source_yesno</source_model>
32
+ <sort_order>14</sort_order>
33
+ <show_in_default>1</show_in_default>
34
+ <show_in_website>1</show_in_website>
35
+ <show_in_store>1</show_in_store>
36
+ </loginEnable>
37
+ <appid translate="label">
38
+ <label>LoginRadius API Key</label>
39
+ <frontend_type>text</frontend_type>
40
+ <comment><![CDATA[Paste LoginRadius API Key here. To get the API Key, log in to<a href="http://www.loginradius.com" target="_blank">LoginRadius</a>]]>
41
+ </comment>
42
+ <sort_order>15</sort_order>
43
+ <show_in_default>1</show_in_default>
44
+ <show_in_website>1</show_in_website>
45
+ <show_in_store>1</show_in_store>
46
+ </appid>
47
+ <appkey translate="label">
48
+ <label>LoginRadius API Secret</label>
49
+ <frontend_type>text</frontend_type>
50
+ <comment><![CDATA[Paste LoginRadius API Secret here. To get the API Secret, log in to<a href="http://www.loginradius.com" target="_blank">LoginRadius</a>]]>
51
+ </comment>
52
+ <sort_order>20</sort_order>
53
+ <show_in_default>1</show_in_default>
54
+ <show_in_website>1</show_in_website>
55
+ <show_in_store>1</show_in_store>
56
+ </appkey>
57
+ <loginradius_title translate="label">
58
+ <label>Title</label>
59
+ <frontend_type>text</frontend_type>
60
+ <comment><![CDATA[Text displayed above Social login Interface]]>
61
+ </comment>
62
+ <sort_order>22</sort_order>
63
+ <show_in_default>1</show_in_default>
64
+ <show_in_website>1</show_in_website>
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>
72
+ <source_model>adminhtml/system_config_source_yesno</source_model>
73
+ <sort_order>23</sort_order>
74
+ <show_in_default>1</show_in_default>
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>
81
+ <comment><![CDATA[Link existing user accounts with Social Login.]]>
82
+ </comment>
83
+ <source_model>adminhtml/system_config_source_yesno</source_model>
84
+ <sort_order>29</sort_order>
85
+ <show_in_default>1</show_in_default>
86
+ <show_in_website>1</show_in_website>
87
+ <show_in_store>1</show_in_store>
88
+ </socialLinking>
89
+ <redirect translate="label">
90
+ <label>Redirect After Login</label>
91
+ <frontend_type>radios</frontend_type>
92
+ <source_model>sociallogin/source_uihover</source_model>
93
+ <sort_order>34</sort_order>
94
+ <show_in_default>1</show_in_default>
95
+ <show_in_website>1</show_in_website>
96
+ <show_in_store>1</show_in_store>
97
+ </redirect>
98
+ <call translate="label">
99
+ <label></label>
100
+ <frontend_type>text</frontend_type>
101
+ <sort_order>40</sort_order>
102
+ <show_in_default>1</show_in_default>
103
+ <show_in_website>1</show_in_website>
104
+ <show_in_store>1</show_in_store>
105
+ </call>
106
+ <api translate="label">
107
+ <label>API Connection Method</label>
108
+ <frontend_type>select</frontend_type>
109
+ <comment><![CDATA[cURL require 'cURL support = enabled' in your php.ini settings, FSOCKOPEN require 'allow_url_fopen = On' and 'safemode = off' in your php.ini settings]]>
110
+ </comment>
111
+ <source_model>sociallogin/source_uihover2</source_model>
112
+ <sort_order>45</sort_order>
113
+ <show_in_default>1</show_in_default>
114
+ <show_in_website>1</show_in_website>
115
+ <show_in_store>1</show_in_store>
116
+ </api>
117
+
118
+ </fields>
119
+ </messages>
120
+ <email_settings>
121
+ <label>Social Login Advanced Settings</label>
122
+ <frontend_type>text</frontend_type>
123
+ <sort_order>20</sort_order>
124
+ <show_in_default>1</show_in_default>
125
+ <show_in_website>1</show_in_website>
126
+ <show_in_store>1</show_in_store>
127
+ <fields>
128
+ <emailrequired translate="label">
129
+ <label>Email Required</label>
130
+ <frontend_type>select</frontend_type>
131
+ <comment><![CDATA[A few ID providers do not provide user's Email ID. Select YES if you would like an email pop-up after login or select NO if you would like to auto-generate the email address.]]>
132
+ </comment>
133
+ <source_model>adminhtml/system_config_source_yesno</source_model>
134
+ <sort_order>24</sort_order>
135
+ <show_in_default>1</show_in_default>
136
+ <show_in_website>1</show_in_website>
137
+ <show_in_store>1</show_in_store>
138
+ </emailrequired>
139
+ <verificationText translate="label">
140
+ <label>Email verification message</label>
141
+ <frontend_type>text</frontend_type>
142
+ <comment><![CDATA[This message will be used in verification email.]]>
143
+ </comment>
144
+ <sort_order>25</sort_order>
145
+ <show_in_default>1</show_in_default>
146
+ <show_in_website>1</show_in_website>
147
+ <show_in_store>1</show_in_store>
148
+ </verificationText>
149
+ <popupText translate="label">
150
+ <label>"Email required" - Popup title</label>
151
+ <frontend_type>text</frontend_type>
152
+ <comment><![CDATA[This text will be displayed on "Email required" popup.]]>
153
+ </comment>
154
+ <sort_order>27</sort_order>
155
+ <show_in_default>1</show_in_default>
156
+ <show_in_website>1</show_in_website>
157
+ <show_in_store>1</show_in_store>
158
+ </popupText>
159
+ <popupError translate="label">
160
+ <label>Error message</label>
161
+ <frontend_type>text</frontend_type>
162
+ <comment><![CDATA[This text will be displayed on the popup if the entered email is already registered or invalid.]]>
163
+ </comment>
164
+ <sort_order>28</sort_order>
165
+ <show_in_default>1</show_in_default>
166
+ <show_in_website>1</show_in_website>
167
+ <show_in_store>1</show_in_store>
168
+ </popupError>
169
+ <notifyUser translate="label">
170
+ <label>Enable registration notification to user</label>
171
+ <frontend_type>select</frontend_type>
172
+ <comment><![CDATA[Send email to newly registered customer regarding login credentials.]]>
173
+ </comment>
174
+ <source_model>adminhtml/system_config_source_yesno</source_model>
175
+ <sort_order>30</sort_order>
176
+ <show_in_default>1</show_in_default>
177
+ <show_in_website>1</show_in_website>
178
+ <show_in_store>1</show_in_store>
179
+ </notifyUser>
180
+ <notifyUserText translate="label">
181
+ <label>User notification email message</label>
182
+ <frontend_type>text</frontend_type>
183
+ <comment><![CDATA[This message will be sent to user in notification email along with login credentials. If left empty, default message will be sent.]]>
184
+ </comment>
185
+ <sort_order>31</sort_order>
186
+ <show_in_default>1</show_in_default>
187
+ <show_in_website>1</show_in_website>
188
+ <show_in_store>1</show_in_store>
189
+ </notifyUserText>
190
+ <notifyAdmin translate="label">
191
+ <label>Enable registration notification to owner</label>
192
+ <frontend_type>select</frontend_type>
193
+ <comment><![CDATA[Send email to store owner on new customer registration regarding customer details.]]>
194
+ </comment>
195
+ <source_model>adminhtml/system_config_source_yesno</source_model>
196
+ <sort_order>32</sort_order>
197
+ <show_in_default>1</show_in_default>
198
+ <show_in_website>1</show_in_website>
199
+ <show_in_store>1</show_in_store>
200
+ </notifyAdmin>
201
+ <notifyAdminText translate="label">
202
+ <label>Owner notification email message</label>
203
+ <frontend_type>text</frontend_type>
204
+ <comment><![CDATA[This message will be sent to admin in notification email.]]>
205
+ </comment>
206
+ <sort_order>33</sort_order>
207
+ <show_in_default>1</show_in_default>
208
+ <show_in_website>1</show_in_website>
209
+ <show_in_store>1</show_in_store>
210
+ </notifyAdminText>
211
+ </fields>
212
+ </email_settings>
213
+ <sharing>
214
+ <label>Social Share Settings</label>
215
+ <frontend_type>text</frontend_type>
216
+ <sort_order>30</sort_order>
217
+ <show_in_default>1</show_in_default>
218
+ <show_in_website>1</show_in_website>
219
+ <show_in_store>1</show_in_store>
220
+ <fields>
221
+ <shareEnable translate="label">
222
+ <label>Enable Social Sharing</label>
223
+ <frontend_type>select</frontend_type>
224
+ <source_model>adminhtml/system_config_source_yesno</source_model>
225
+ <sort_order>24</sort_order>
226
+ <show_in_default>1</show_in_default>
227
+ <show_in_website>1</show_in_website>
228
+ <show_in_store>1</show_in_store>
229
+ </shareEnable>
230
+ <sharingCode translate="label">
231
+ <label>Sharing Code</label>
232
+ <frontend_type>textarea</frontend_type>
233
+ <comment><![CDATA[Paste sharing code from "Add this code to 'head' tag" section from your <a href="https://www.loginradius.com/account/socialshare" target="_blank" >LoginRadius</a> account.]]>
234
+ </comment>
235
+ <sort_order>25</sort_order>
236
+ <show_in_default>1</show_in_default>
237
+ <show_in_website>1</show_in_website>
238
+ <show_in_store>1</show_in_store>
239
+ </sharingCode>
240
+ </fields>
241
+ </sharing>
242
+ <counter>
243
+ <label>Social Counter Settings</label>
244
+ <frontend_type>text</frontend_type>
245
+ <sort_order>40</sort_order>
246
+ <show_in_default>1</show_in_default>
247
+ <show_in_website>1</show_in_website>
248
+ <show_in_store>1</show_in_store>
249
+ <fields>
250
+ <counterEnable translate="label">
251
+ <label>Enable Social Counter</label>
252
+ <frontend_type>select</frontend_type>
253
+ <source_model>adminhtml/system_config_source_yesno</source_model>
254
+ <sort_order>24</sort_order>
255
+ <show_in_default>1</show_in_default>
256
+ <show_in_website>1</show_in_website>
257
+ <show_in_store>1</show_in_store>
258
+ </counterEnable>
259
+ <counterCode translate="label">
260
+ <label>Counter Code</label>
261
+ <frontend_type>textarea</frontend_type>
262
+ <comment><![CDATA[Paste counter code from "Add this code to 'head' tag" section from your <a href="https://www.loginradius.com/account/socialcounter" target="_blank" >LoginRadius</a> account.]]>
263
+ </comment>
264
+ <sort_order>25</sort_order>
265
+ <show_in_default>1</show_in_default>
266
+ <show_in_website>1</show_in_website>
267
+ <show_in_store>1</show_in_store>
268
+ </counterCode>
269
+ </fields>
270
+ </counter>
271
+ <info translate="label">
272
+ <label>Extension Help</label>
273
+ <frontend_type>text</frontend_type>
274
+ <frontend_model>sociallogin/info</frontend_model>
275
+ <sort_order>50</sort_order>
276
+ <show_in_default>1</show_in_default>
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>
app/code/community/Loginradius/Sociallogin/etc/widget.xml CHANGED
@@ -1,17 +1,24 @@
1
- <?xml version="1.0"?>
2
- <widgets>
3
- <sociallogin_auth type="sociallogin/auth" translate="name description" module="sociallogin">
4
- <name>Social Login</name>
5
- <description type="desc">Adds a link to open the Sociallogin authentication dialog</description>
6
- <parameters>
7
- <label_text>
8
- <required>0</required>
9
- <visible>1</visible>
10
- <label>Label Text</label>
11
- <description>The text to display before Provider Icons. Defaults to 'please login with'</description>
12
- <type>text</type>
13
- </label_text>
14
- </parameters>
15
- </sociallogin_auth>
16
-
 
 
 
 
 
 
 
17
  </widgets>
1
+ <?xml version="1.0"?>
2
+ <widgets>
3
+ <sociallogin_auth type="sociallogin/auth" translate="name description" module="sociallogin">
4
+ <name>Social Login</name>
5
+ <description type="desc">Adds Social Login interface to the page.</description>
6
+ <parameters>
7
+ <label_text>
8
+ <required>0</required>
9
+ <visible>1</visible>
10
+ <label>Label Text</label>
11
+ <description>The text to display before Provider Icons. Defaults to 'Social Login'</description>
12
+ <type>text</type>
13
+ </label_text>
14
+ </parameters>
15
+ </sociallogin_auth>
16
+ <sociallogin_share type="sociallogin/share" translate="name description" module="sociallogin">
17
+ <name>Social Share</name>
18
+ <description type="desc">Adds Social Share interface to the page.</description>
19
+ </sociallogin_share>
20
+ <sociallogin_counter type="sociallogin/counter" translate="name description" module="sociallogin">
21
+ <name>Social Counter</name>
22
+ <description type="desc">Adds Social Counter interface to the page.</description>
23
+ </sociallogin_counter>
24
  </widgets>
app/code/community/Loginradius/Sociallogin/sql/sociallogin_setup/mysql4-install-1.2.1.php DELETED
@@ -1,16 +0,0 @@
1
- <?php
2
-
3
- $installer = $this;
4
-
5
- $installer->startSetup();
6
-
7
- $installer->run("
8
-
9
- CREATE TABLE IF NOT EXISTS {$this->getTable('sociallogin')} (
10
- `sociallogin_id` varchar(50) NULL ,
11
- `entity_id` int(11) NULL
12
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
13
-
14
- ");
15
-
16
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Loginradius/Sociallogin/sql/sociallogin_setup/mysql4-install-2.0.0.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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')} (
10
+ `sociallogin_id` varchar(50) default NULL,
11
+ `entity_id` int(11) default NULL,
12
+ `avatar` varchar(1000) default NULL,
13
+ `verified` enum('0','1') default NULL,
14
+ `vkey` varchar(40) default NULL,
15
+ `provider` varchar(20) default NULL
16
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
17
+
18
+ ");
19
+
20
+ $installer->endSetup();
app/design/frontend/default/default/layout/sociallogin.xml CHANGED
@@ -1,8 +1,19 @@
1
  <?xml version="1.0"?>
2
- <layout version="1.2.1">
3
  <default>
4
- <reference name="right">
5
  <block type="sociallogin/sociallogin" name="sociallogin" template="sociallogin/sociallogin.phtml" />
6
  </reference>
7
- </default>
 
 
 
 
 
 
 
 
 
 
 
8
  </layout>
1
  <?xml version="1.0"?>
2
+ <layout version="2.0.0">
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" />
9
+ </reference>
10
+ </default>
11
+ <catalog_product_view>
12
+ <reference name="alert.urls">
13
+ <block type="sociallogin/sociallogin" name="socialshare" before="-" />
14
+ </reference>
15
+ <reference name="product.info.extrahint">
16
+ <block type="sociallogin/sociallogin" name="socialcounter" template="sociallogin/socialcounter.phtml" />
17
+ </reference>
18
+ </catalog_product_view>
19
  </layout>
app/design/frontend/default/default/template/sociallogin/socialcounter.phtml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ if( $this->counterEnable() == "1" ){
3
+ echo '<div class="lrcounter_simplebox"></div>';
4
+ }
5
+ ?>
app/design/frontend/default/default/template/sociallogin/sociallogin.phtml CHANGED
@@ -1,29 +1,64 @@
1
- <?php
2
- $showdefault = $this->getShowDefault();
3
- $ApiKey = trim($this->getApikey());
4
- $ApiSecrete = trim($this->getApiSecret());
5
- $UserAuth = $this->getApiResult($ApiKey, $ApiSecrete);
6
- if ($showdefault == 1) {
7
- echo '<div class="block"><div class="block-title"><strong><span>Social Login Module</span></strong></div><div class="block-content"><p class="empty">';
8
- if ($this->user_is_already_login()) {
9
- $userName = Mage::getSingleton('customer/session')->getCustomer()->getName();
10
- echo "<span>Welcome! $userName .</span>";
11
- }
12
- else {
13
- if($ApiKey == "" && $ApiSecrete == ""){
14
- 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>';
15
- }elseif ($UserAuth == false) {
16
- 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>';
17
- }
18
- else {
19
- $IsHttps = (!empty($UserAuth->IsHttps)) ? $UserAuth->IsHttps : '';
20
- $iframeHeight = (!empty($UserAuth->height)) ? $UserAuth->height : 50;
21
- $iframeWidth = (!empty($UserAuth->width)) ? $UserAuth->width : 138;
22
- $http = ($IsHttps == 1) ? "https://" : "http://";
23
- $loc = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK)."sociallogin/";
24
- echo '<iframe src="'.$http.'hub.loginradius.com/Control/PluginSlider.aspx?apikey='.$ApiKey.'&callback='.$loc.'" width="'.$iframeWidth.'" height="'.$iframeHeight.'" frameborder="0" scrolling="no" allowtransparency="true"></iframe>';
25
- }
26
- }
27
- echo '</p></div></div>';
28
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  ?>
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
  ?>
app/design/frontend/default/default/template/sociallogin/socialshare.phtml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ if( $this->shareEnable() == "1" ){
3
+ echo '<div class="lrsharecontainer"></div>';
4
+ }
5
+ ?>
app/design/frontend/default/default/template/sociallogin/socialshare_head.phtml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if( $this->shareEnable() == "1" ){
3
+ echo str_replace("islrsocialcounter = false", "islrsocialcounter = true", trim($this->sharingCode()) );
4
+ ?>
5
+ <style type="text/css">
6
+ div.lrsharecontainer{
7
+ z-index : 1000000;
8
+ }
9
+ </style>
10
+ <?php
11
+ }
12
+ if( $this->counterEnable() == "1" ){
13
+ $loginRadiusCounter = str_replace("islrsharing = false", "islrsharing = true", trim($this->counterCode()));
14
+ echo str_replace("$S.left = '50px'", "$S.left = '0px'", $loginRadiusCounter );
15
+ ?>
16
+ <style type="text/css">
17
+ div.lrcounter_simplebox{
18
+ z-index : 1000000;
19
+ }
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>1.2.1</version>
5
  <stability>stable</stability>
6
  <license>GNU General Public License (GPL)</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>Social Login for Magento</summary>
10
- <description>Add Social Login to your Magento website and also get accurate User Profile Data and Social Analytics.</description>
11
- <notes>Fourth 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-10-11</date>
14
- <time>17:16:45</time>
15
- <contents><target name="magecommunity"><dir name="Loginradius"><dir name="Sociallogin"><dir name="Block"><file name="Auth.php" hash="e4563c133d7a52e32a33de71f86e21df"/><file name="Info.php" hash="be7d35ed710f898000f03ae5426d755a"/><file name="Sociallogin.php" hash="9d56ce6a067c2c40907b3c82466598ae"/></dir><dir name="Helper"><file name="Data.php" hash="8a82c0ca3478c9aa5cef4db99003d311"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Sociallogin"><file name="Collection.php" hash="a32296c7f53c420ca655439416771653"/></dir><file name="Sociallogin.php" hash="ed906cba7eb16d8b0a343baf8baa9b42"/></dir><file name="Sociallogin.php" hash="c71f4160bba6b0b26c4cf38b9448b22b"/><dir name="Source"><file name="Uihover.php" hash="6c6ba75ff19328c512dea06b3ce73484"/><file name="Uihover2.php" hash="ce80c1d278040b7e11bb353baf0cc275"/></dir></dir><dir name="controllers"><file name="IndexController.php" hash="52b71377f2312311d48d56f2f4ae5d26"/><file name="inc.php" hash="0268ecb5f1b2e0befc4d1534798a2f51"/></dir><dir name="etc"><file name="config.xml" hash="1f585f48abcfbdc5bafcb24be1c8b6e1"/><file name="system.xml" hash="6f23fd5b68eec18ecab9a981a484daab"/><file name="widget.xml" hash="1e21bd95f5b940dc0d924c86c531c870"/></dir><dir name="sql"><dir name="sociallogin_setup"><file name="mysql4-install-1.2.1.php" hash="6598e12a0948680a0e2826ed7c5486bc"/></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="515c603ee838ba4080e071f9a129c612"/></dir><dir name="template"><dir name="sociallogin"><file name="sociallogin.phtml" hash="854274fd61c7d21517a54b8017fe2701"/></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>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>LoginRadius</name>
4
+ <version>2.0.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>Fifth 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-11-08</date>
14
+ <time>19:33:10</time>
15
+ <contents><target name="magecommunity"><dir name="Loginradius"><dir name="Sociallogin"><dir name="Block"><file name="Auth.php" hash="f1652d151b0ee4ffb9a3bc3edc865523"/><file name="Counter.php" hash="f79411371642a6940fe68f35cf09ef7b"/><file name="Info.php" hash="be7d35ed710f898000f03ae5426d755a"/><file name="Share.php" hash="ea9a80891c1c88f96b4f0a2e337d6d27"/><file name="Sociallogin.php" hash="664a96687a2744f6e3cf35f2fb326a36"/></dir><dir name="Helper"><file name="Data.php" hash="bbd9dd0c965896a65a9abdc38e6c5100"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Sociallogin"><file name="Collection.php" hash="a32296c7f53c420ca655439416771653"/></dir><file name="Sociallogin.php" hash="ed906cba7eb16d8b0a343baf8baa9b42"/></dir><file name="Sociallogin.php" hash="c71f4160bba6b0b26c4cf38b9448b22b"/><dir name="Source"><file name="Uihover.php" hash="6c6ba75ff19328c512dea06b3ce73484"/><file name="Uihover2.php" hash="ce80c1d278040b7e11bb353baf0cc275"/></dir></dir><dir name="controllers"><file name="IndexController.php" hash="f8061a9687c59dfe19568a4f17841671"/><file name="inc.php" hash="43ba98e2ff12538f857120df04410a70"/></dir><dir name="etc"><file name="config.xml" hash="18dcf9d38922bf9be38f0465929f81c5"/><file name="system.xml" hash="bc2fff373d8602be445fd74d16217d50"/><file name="widget.xml" hash="75f4ee0b08fdd001bbd216bd965b644d"/></dir><dir name="sql"><dir name="sociallogin_setup"><file name="mysql4-install-2.0.0.php" hash="1a6e8bfabd46a8fc65284f1718dd918b"/></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="2dde5986752df83dbae49762598b0790"/></dir><dir name="template"><dir name="sociallogin"><file name="sociallogin.phtml" hash="27f4358e5097e0c34e810a3f4526cb56"/><file name="socialshare.phtml" hash="d93ab7c0904ec6688924398f503d6cf5"/><file name="socialshare_head.phtml" hash="f05d5a075a872f79ec3999a422f23179"/><file name="socialcounter.phtml" hash="1c6ec1e3f25dacbb005391e764b9885d"/></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>