LoginRadius - Version 1.2.0

Version Notes

Third release of social login

Download this release

Release Info

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


Code changes from version 1.1.0 to 1.2.0

app/code/community/Loginradius/Sociallogin/Block/Info.php CHANGED
@@ -1,24 +1,24 @@
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://loginradius.com/" target="_blank">Documentation</a> on how to install and configure this extension.</p>';
19
- $content.= '<p>Copyright &copy ' . date("Y") . ' <a href="http://loginradius.com/" target="_blank">LoginRadius, Inc.</a></p>';
20
-
21
- return $content;
22
- }
23
-
24
- }
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 &copy ' . date("Y") . ' <a href="http://loginradius.com/" target="_blank">LoginRadius, Inc.</a></p>';
20
+
21
+ return $content;
22
+ }
23
+
24
+ }
app/code/community/Loginradius/Sociallogin/controllers/IndexController.php CHANGED
@@ -1,264 +1,270 @@
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
- $select = $connection->query("select entity_id from $customerTbl where entity_id = (select entity_id from $tbl_sociallog where sociallogin_id= '$id')");
34
- $rowArray = $select->fetch();
35
- $sociallogin_id = $rowArray['entity_id'];
36
- if(!empty($sociallogin_id)){//user is in database
37
- $this->socialLoginUserLogin( $sociallogin_id, $blockObj);
38
- return;
39
- }
40
-
41
- if( !empty($user_obj->Email) ){
42
- //if email is provided by provider then check if it's in table
43
- $email = $user_obj->Email['0']->Value;
44
- $select = $connection->query("select * from $customerTbl where email = '$email' ");
45
-
46
-
47
- if( $rowArray = $select->fetch() ) {
48
- $sociallogin_id = $rowArray['entity_id'];
49
-
50
- if(!empty($sociallogin_id)) {
51
- //user is in customer table
52
- $this->socialLoginUserLogin( $sociallogin_id, $blockObj);
53
- return;
54
- }
55
- }
56
-
57
- $socialloginProfileData = $this->socialLoginFilterData( $email, $user_obj );
58
- $socialloginProfileData['lrId'] = $user_obj->ID;
59
- $this->socialLoginAddNewUser( $socialloginProfileData, $email, $blockObj );
60
- return;
61
- }
62
- // empty email
63
- if( $blockObj->getEmailRequired() == 0 ) { // dummy email
64
- $email = $this->loginradius_get_randomEmail( $user_obj );
65
- $socialloginProfileData = $this->socialLoginFilterData( $email, $user_obj );
66
- $socialloginProfileData['lrId'] = $user_obj->ID;
67
- $this->socialLoginAddNewUser( $socialloginProfileData, $email, $blockObj );
68
- return;
69
- }else { // show popup
70
- $id = $user_obj->ID;
71
- $socialloginProfileData = $this->socialLoginFilterData( $email, $user_obj );
72
- $this->setInSession($id, $socialloginProfileData);
73
- SL_popUpWindow();
74
- return;
75
- }
76
- }
77
-
78
- function loginradius_get_randomEmail( $user_obj ) {
79
- switch ( $user_obj->Provider ) {
80
- case 'twitter':
81
- $email = $user_obj->ID. '@' . $user_obj->Provider . '.com';
82
- break;
83
-
84
- case 'linkedin':
85
- $email = $user_obj->ID. '@' . $user_obj->Provider . '.com';
86
- break;
87
-
88
- default:
89
- $Email_id = substr( $user_obj->ID, 7 );
90
- $Email_id2 = str_replace("/", "_", $Email_id);
91
- $email = str_replace(".", "_", $Email_id2) . '@' . $user_obj->Provider . '.com';
92
- break;
93
- }
94
-
95
- return $email;
96
- }
97
-
98
- function socialLoginFilterData( $email, $user_obj ) {
99
- $socialloginProfileData = array();
100
-
101
- $socialloginProfileData['Provider'] = empty($user_obj->Provider) ? "" : $user_obj->Provider;
102
- $socialloginProfileData['FirstName'] = empty($user_obj->FirstName) ? "" : $user_obj->FirstName;
103
- $socialloginProfileData['FullName'] = empty($user_obj->FullName) ? "" : $user_obj->FullName;
104
- $socialloginProfileData['NickName'] = empty($user_obj->NickName) ? "" : $user_obj->NickName;
105
- $socialloginProfileData['LastName'] = empty($user_obj->LastName) ? "" : $user_obj->LastName;
106
- $socialloginProfileData['Addresses'] = empty($user_obj->Addresses['0']->Address1) ? "" : $user_obj->Addresses['0']->Address1;
107
- $socialloginProfileData['PhoneNumbers'] = empty( $user_obj->PhoneNumbers['0']->PhoneNumber ) ? "" : $user_obj->PhoneNumbers['0']->PhoneNumber;
108
- $socialloginProfileData['State'] = empty($user_obj->State) ? "" : $user_obj->State;
109
- $socialloginProfileData['City'] = empty($user_obj->City) ? "" : $user_obj->City;
110
- $socialloginProfileData['Industry'] = empty($user_obj->Positions['0']->Comapny->Name) ? "" : $user_obj->Positions['0']->Comapny->Name;
111
- $socialloginProfileData['Country'] = empty($user_obj->Country) ? "" : $user_obj->Country;
112
-
113
- $explode= explode("@",$email);
114
- if( empty( $socialloginProfileData['FirstName'] ) && !empty( $socialloginProfileData['FullName'] ) ){
115
- $socialloginProfileData['FirstName'] = $socialloginProfileData['FullName'];
116
- }elseif(empty($socialloginProfileData['FirstName'] ) && !empty( $socialloginProfileData['NickName'] )){
117
- $socialloginProfileData['FirstName'] = $socialloginProfileData['NickName'];
118
- }elseif(empty($socialloginProfileData['FirstName'] ) && empty($socialloginProfileData['NickName'] ) && !empty($socialloginProfileData['FullName'] ) ){
119
- $socialloginProfileData['FirstName'] = $explode[0];
120
- }
121
- if($socialloginProfileData['FirstName'] == '' ){
122
- $letters = range('a', 'z');
123
- for($i=0;$i<5;$i++){
124
- $socialloginProfileData['FirstName'] .= $letters[rand(0,26)];
125
- }
126
- }
127
-
128
- return $socialloginProfileData;
129
- }
130
-
131
- function socialLoginUserLogin( $sociallogin_id, $blockObj ) {
132
- $session = Mage::getSingleton("customer/session");
133
- $session->loginById($sociallogin_id);
134
- $write_url = $blockObj->getCallBack();
135
- $Hover = $blockObj->getRedirectOption();
136
- $url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
137
- if($Hover=='account' ){
138
- header( 'Location: '.$url.'customer/account' );
139
- return;
140
- }elseif($Hover=='index' ){
141
- header( 'Location: '.$url.'') ;
142
- return;
143
- }elseif( $Hover=='custom' && $write_url != '' ) {
144
- header( 'Location: '.$write_url.'' );
145
- return;
146
- } else {
147
- $currentUrl = Mage::helper('core/url')->getCurrentUrl();
148
- header( 'Location: '.$currentUrl.'' );
149
- return;
150
- }
151
- }
152
-
153
- function setInSession( $id, $socialloginProfileData ){
154
- $socialloginProfileData['lrId'] = $id;
155
- Mage::getSingleton('core/session')->setSocialLoginData( $socialloginProfileData );
156
- }
157
-
158
- function socialLoginAddNewUser( $socialloginProfileData, $email, $blockObj ) {
159
- // add new user magento way
160
- $websiteId = Mage::app()->getWebsite()->getId();
161
- $store = Mage::app()->getStore();
162
-
163
- //$customer = new Mage_Customer_Model_Customer();
164
- $customer = Mage::getModel("customer/customer");
165
- $customer->website_id = $websiteId;
166
- $customer->setStore($store);
167
-
168
- $customer->firstname = $socialloginProfileData['FirstName'];
169
- $customer->lastname = $socialloginProfileData['LastName'];
170
- $customer->email = $email;
171
-
172
- $customer->password_hash = md5( $customer->generatePassword(10) );
173
- $customer->save();
174
-
175
- //$address = new Mage_Customer_Model_Address();
176
- $address = Mage::getModel("customer/address");
177
- $address->setCustomerId($customer->getId());
178
- $address->firstname = $customer->firstname;
179
- $address->lastname = $customer->lastname;
180
- $address->country_id = ucfirst( $socialloginProfileData['Country'] ); //Country code here
181
- // $address->postcode = "31000";
182
- $address->city = ucfirst( $socialloginProfileData['City'] );
183
- /* NOTE: If country is USA, please set up $address->region also */
184
- $address->telephone = $socialloginProfileData['PhoneNumbers'];
185
- $address->company = ucfirst( $socialloginProfileData['Industry'] );
186
- $address->street = ucfirst( $socialloginProfileData['Addresses'] );
187
-
188
- $address->save();
189
-
190
- // add info in sociallogin table
191
- $connection = Mage::getSingleton('core/resource')
192
- ->getConnection('core_write');
193
- $connection->beginTransaction();
194
- $fields = array();
195
- $fields['sociallogin_id'] = $socialloginProfileData['lrId'] ;
196
- $fields['entity_id'] = $customer->getId();
197
- $sociallogin = getMazeTable("sociallogin");
198
-
199
- $socialLoginSelect = $connection->query("select sociallogin_id from $sociallogin where sociallogin_id = '".$socialloginProfileData['lrId']."' limit 1");
200
-
201
- if( $rowArray = $socialLoginSelect->fetch() ) {
202
- $socialLoginUpdate = $connection->query("update $sociallogin set entity_id = ".$fields['entity_id']." where sociallogin_id = '".$socialloginProfileData['lrId']."'");
203
- }else {
204
- $connection->insert($sociallogin, $fields);
205
- }
206
-
207
- $connection->commit();
208
-
209
- //login user
210
- $this->socialLoginUserLogin( $customer->getId(), $blockObj );
211
- }
212
-
213
- private function SocialLoginShowLayout() {
214
- $this->loadLayout();
215
- $this->renderLayout();
216
- }
217
-
218
- public function indexAction() {
219
- if(isset($_REQUEST['token'])) {
220
- $this->tokenHandle();
221
- $this->loadLayout();
222
- $this->renderLayout();
223
- return;
224
- }
225
-
226
- $socialLoginProfileData = Mage::getSingleton('core/session')->getSocialLoginData();
227
- $session_user_id = $socialLoginProfileData['lrId'];
228
-
229
- if( isset($_POST['LoginRadiusRedSliderClick']) ) {
230
- if( !empty($session_user_id) ){
231
- $email = trim($_POST['SL_EMAIL']);
232
-
233
- if( !preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/", $email) ){
234
- SL_popUpWindow( "Please enter a valid email address" );
235
- $this->SocialLoginShowLayout();
236
- return false;
237
- }
238
-
239
- // check if email already exists
240
- $socialLoginConn = Mage::getSingleton('core/resource')
241
- ->getConnection('core_read');
242
- $customerTbl = getMazeTable("customer_entity"); // customer_entity
243
- $select = $socialLoginConn->query("select * from $customerTbl where email = '$email' ");
244
-
245
- if( $rowArray = $select->fetch() ) { // email exists
246
- SL_popUpWindow( "This email already exists. Please enter valid email address." );
247
- $this->SocialLoginShowLayout();
248
- return false;
249
- }
250
-
251
- $socialloginProfileData = Mage::getSingleton('core/session')->getSocialLoginData();
252
- Mage::getSingleton('core/session')->unsSocialLoginData(); // unset session
253
-
254
- $blockObj = new Loginradius_Sociallogin_Block_Sociallogin(); //object to get api key and secrets, url etc
255
- $this->socialLoginAddNewUser($socialloginProfileData, $email, $blockObj);
256
- }
257
- }elseif( isset($_POST['LoginRadiusPopupCancel']) ) { // popup cancelled
258
- Mage::getSingleton('core/session')->unsSocialLoginData(); // unset session
259
- $url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
260
- header("Location:".$url); // redirect to index page
261
- }
262
- $this->SocialLoginShowLayout();
263
- }
 
 
 
 
 
 
264
  }
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
  }
app/code/community/Loginradius/Sociallogin/etc/config.xml CHANGED
@@ -1,137 +1,137 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <Loginradius_Sociallogin>
5
- <version>1.0.0</version>
6
- </Loginradius_Sociallogin>
7
- </modules>
8
- <frontend>
9
- <layout>
10
- <updates>
11
- <sociallogin>
12
- <file>sociallogin.xml</file>
13
- </sociallogin>
14
- </updates>
15
- </layout>
16
- <translate>
17
- <modules>
18
- <Loginradius_Sociallogin>
19
- <files>
20
- <default>Loginradius_Sociallogin.csv</default>
21
- </files>
22
- </Loginradius_Sociallogin>
23
- </modules>
24
- </translate>
25
- <routers>
26
- <sociallogin>
27
- <use>standard</use>
28
- <args>
29
- <module>Loginradius_Sociallogin</module>
30
- <frontName>sociallogin</frontName>
31
- </args>
32
- </sociallogin>
33
- </routers>
34
- </frontend>
35
- <admin>
36
- <routers>
37
- <sociallogin>
38
- <use>admin</use>
39
- <args>
40
- <module>Loginradius_Sociallogin</module>
41
- <frontName>sociallogin admin</frontName>
42
- </args>
43
- </sociallogin>
44
- </routers>
45
- </admin>
46
- <adminhtml>
47
- <acl>
48
- <resources>
49
- <admin>
50
- <children>
51
- <system>
52
- <children>
53
- <config>
54
- <children>
55
- <sociallogin_options>
56
- <title>Store Social login Module Section</title>
57
- </sociallogin_options>
58
- </children>
59
- </config>
60
- </children>
61
- </system>
62
- </children>
63
- </admin>
64
- </resources>
65
- </acl>
66
-
67
- <acl>
68
- <resources>
69
- <all>
70
- <title>Allow Everything</title>
71
- </all>
72
- <admin>
73
- <children>
74
- <Loginradius_Sociallogin>
75
- <title>Sociallogin Module</title>
76
- <sort_order>10</sort_order>
77
- </Loginradius_Sociallogin>
78
- </children>
79
- </admin>
80
- </resources>
81
- </acl>
82
- <layout>
83
- <updates>
84
- <sociallogin>
85
- <file>sociallogin.xml</file>
86
- </sociallogin>
87
- </updates>
88
- </layout>
89
- </adminhtml>
90
- <global>
91
- <models>
92
- <sociallogin>
93
- <class>Loginradius_Sociallogin_Model</class>
94
- <resourceModel>sociallogin_mysql4</resourceModel>
95
- </sociallogin>
96
- <sociallogin_mysql4>
97
- <class>Loginradius_Sociallogin_Model_Mysql4</class>
98
- <entities>
99
- <sociallogin>
100
- <table>sociallogin</table>
101
- </sociallogin>
102
- </entities>
103
- </sociallogin_mysql4>
104
- </models>
105
- <resources>
106
- <sociallogin_setup>
107
- <setup>
108
- <module>Loginradius_Sociallogin</module>
109
- </setup>
110
- <connection>
111
- <use>core_setup</use>
112
- </connection>
113
- </sociallogin_setup>
114
- <sociallogin_write>
115
- <connection>
116
- <use>core_write</use>
117
- </connection>
118
- </sociallogin_write>
119
- <sociallogin_read>
120
- <connection>
121
- <use>core_read</use>
122
- </connection>
123
- </sociallogin_read>
124
- </resources>
125
-
126
- <blocks>
127
- <sociallogin>
128
- <class>Loginradius_Sociallogin_Block</class>
129
- </sociallogin>
130
- </blocks>
131
- <helpers>
132
- <sociallogin>
133
- <class>Loginradius_Sociallogin_Helper</class>
134
- </sociallogin>
135
- </helpers>
136
- </global>
137
- </config>
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Loginradius_Sociallogin>
5
+ <version>1.2.0</version>
6
+ </Loginradius_Sociallogin>
7
+ </modules>
8
+ <frontend>
9
+ <layout>
10
+ <updates>
11
+ <sociallogin>
12
+ <file>sociallogin.xml</file>
13
+ </sociallogin>
14
+ </updates>
15
+ </layout>
16
+ <translate>
17
+ <modules>
18
+ <Loginradius_Sociallogin>
19
+ <files>
20
+ <default>Loginradius_Sociallogin.csv</default>
21
+ </files>
22
+ </Loginradius_Sociallogin>
23
+ </modules>
24
+ </translate>
25
+ <routers>
26
+ <sociallogin>
27
+ <use>standard</use>
28
+ <args>
29
+ <module>Loginradius_Sociallogin</module>
30
+ <frontName>sociallogin</frontName>
31
+ </args>
32
+ </sociallogin>
33
+ </routers>
34
+ </frontend>
35
+ <admin>
36
+ <routers>
37
+ <sociallogin>
38
+ <use>admin</use>
39
+ <args>
40
+ <module>Loginradius_Sociallogin</module>
41
+ <frontName>sociallogin admin</frontName>
42
+ </args>
43
+ </sociallogin>
44
+ </routers>
45
+ </admin>
46
+ <adminhtml>
47
+ <acl>
48
+ <resources>
49
+ <admin>
50
+ <children>
51
+ <system>
52
+ <children>
53
+ <config>
54
+ <children>
55
+ <sociallogin_options>
56
+ <title>Store Social login Module Section</title>
57
+ </sociallogin_options>
58
+ </children>
59
+ </config>
60
+ </children>
61
+ </system>
62
+ </children>
63
+ </admin>
64
+ </resources>
65
+ </acl>
66
+
67
+ <acl>
68
+ <resources>
69
+ <all>
70
+ <title>Allow Everything</title>
71
+ </all>
72
+ <admin>
73
+ <children>
74
+ <Loginradius_Sociallogin>
75
+ <title>Sociallogin Module</title>
76
+ <sort_order>10</sort_order>
77
+ </Loginradius_Sociallogin>
78
+ </children>
79
+ </admin>
80
+ </resources>
81
+ </acl>
82
+ <layout>
83
+ <updates>
84
+ <sociallogin>
85
+ <file>sociallogin.xml</file>
86
+ </sociallogin>
87
+ </updates>
88
+ </layout>
89
+ </adminhtml>
90
+ <global>
91
+ <models>
92
+ <sociallogin>
93
+ <class>Loginradius_Sociallogin_Model</class>
94
+ <resourceModel>sociallogin_mysql4</resourceModel>
95
+ </sociallogin>
96
+ <sociallogin_mysql4>
97
+ <class>Loginradius_Sociallogin_Model_Mysql4</class>
98
+ <entities>
99
+ <sociallogin>
100
+ <table>sociallogin</table>
101
+ </sociallogin>
102
+ </entities>
103
+ </sociallogin_mysql4>
104
+ </models>
105
+ <resources>
106
+ <sociallogin_setup>
107
+ <setup>
108
+ <module>Loginradius_Sociallogin</module>
109
+ </setup>
110
+ <connection>
111
+ <use>core_setup</use>
112
+ </connection>
113
+ </sociallogin_setup>
114
+ <sociallogin_write>
115
+ <connection>
116
+ <use>core_write</use>
117
+ </connection>
118
+ </sociallogin_write>
119
+ <sociallogin_read>
120
+ <connection>
121
+ <use>core_read</use>
122
+ </connection>
123
+ </sociallogin_read>
124
+ </resources>
125
+
126
+ <blocks>
127
+ <sociallogin>
128
+ <class>Loginradius_Sociallogin_Block</class>
129
+ </sociallogin>
130
+ </blocks>
131
+ <helpers>
132
+ <sociallogin>
133
+ <class>Loginradius_Sociallogin_Helper</class>
134
+ </sociallogin>
135
+ </helpers>
136
+ </global>
137
+ </config>
app/code/community/Loginradius/Sociallogin/sql/sociallogin_setup/{mysql4-install-0.1.0.php → mysql4-install-1.2.0.php} RENAMED
File without changes
app/design/frontend/default/default/layout/sociallogin.xml CHANGED
@@ -1,8 +1,8 @@
1
- <?xml version="1.0"?>
2
- <layout version="1.0.0">
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="1.2.0">
3
+ <default>
4
+ <reference name="right">
5
+ <block type="sociallogin/sociallogin" name="sociallogin" template="sociallogin/sociallogin.phtml" />
6
+ </reference>
7
+ </default>
8
  </layout>
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>LoginRadius</name>
4
- <version>1.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 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>Second 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-08-29</date>
14
- <time>05:01:24</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="4d421932d1304c740cec6fc7ce6469c2"/><file name="Sociallogin.php" hash="2cf4e433fd2abe40c418436f7a03fd7e"/></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="622010b3b8bfb0cd187c118d78d92d81"/><file name="inc.php" hash="0268ecb5f1b2e0befc4d1534798a2f51"/></dir><dir name="etc"><file name="config.xml" hash="ceba1c14782ee35024d62bb1743c9469"/><file name="system.xml" hash="6f23fd5b68eec18ecab9a981a484daab"/><file name="widget.xml" hash="1e21bd95f5b940dc0d924c86c531c870"/></dir><dir name="sql"><dir name="sociallogin_setup"><file name="mysql4-install-0.1.0.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=""/></dir><dir name="template"><dir name="sociallogin"><file name="sociallogin.phtml" hash=""/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Loginradius_Sociallogin.xml" hash=""/></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>1.2.0</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>Third 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-09-05</date>
14
+ <time>01:05:12</time>
15
+ <contents><target name="mageetc"><dir name="modules"><file name="Loginradius_Sociallogin.xml" hash="6c5bb03c460936006692aa1d01d142ba"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="sociallogin.xml" hash="98019223ef93f4dba25bb76b1b27ac15"/></dir><dir name="template"><dir name="sociallogin"><file name="sociallogin.phtml" hash="854274fd61c7d21517a54b8017fe2701"/></dir></dir></dir></dir></dir></target><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="2cf4e433fd2abe40c418436f7a03fd7e"/></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="ff678d3782c88ac16f87515d6a3cee46"/><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.0.php" hash="6598e12a0948680a0e2826ed7c5486bc"/></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>