Subversion Repositories SmartDukaan

Rev

Rev 13673 | Rev 13768 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 13673 Rev 13683
Line 94... Line 94...
94
				} else {
94
				} else {
95
					$result = array('success' => false, 'message' => "Email is missing");
95
					$result = array('success' => false, 'message' => "Email is missing");
96
					break;
96
					break;
97
				}				
97
				}				
98
			} else {
98
			} else {
-
 
99
				$data['user_id'] = $socialProfile['SocialProfile']['user_id'];
99
				$result = array('success' => true, 'message' => 'Existing Social Profile','id' => $socialProfile['SocialProfile']['user_id']);
100
				$result = array('success' => true, 'message' => 'Existing Social Profile','id' => $socialProfile['SocialProfile']['user_id']);
100
			}
101
			}
101
		}
102
		}
102
		$this->updateSaholicUser($data['user_id'],$this->request->data['email']);
103
		$this->updateSaholicUser($data['user_id'],$this->request->data['email']);
103
		$this->set(array(
104
		$this->set(array(
Line 112... Line 113...
112
	private function updateSaholicUser($userId,$email=null) {
113
	private function updateSaholicUser($userId,$email=null) {
113
		if(!$email){
114
		if(!$email){
114
			//Handle it properly
115
			//Handle it properly
115
			return;
116
			return;
116
		}
117
		}
-
 
118
		$this->log('userId '.$userId,'registration');
-
 
119
		$this->log('email '.$email ,'registration');
117
		$this->loadModel('UserAccount');
120
		$this->loadModel('UserAccount');
118
		$options = array('conditions'=>array('user_id' => $userId,'account_type' => 'saholic'),'recursive'=>-1);
121
		$options = array('conditions'=>array('user_id' => $userId,'account_type' => 'saholic'),'recursive'=>-1);
119
		$exists = $this->UserAccount->find('count',$options);
122
		$exists = $this->UserAccount->find('count',$options);
120
		if(!$exists){
123
		if(!$exists){
121
			$url = $this->saholicapihost."/register/?email=$email";
124
			$url = $this->apihost."register?email=$email";
122
			$response = $this->make_request($url,null);
125
			$response = $this->make_request($url,null);
-
 
126
			$this->log('response '.print_r($response,1),'registration');
123
			if(!empty($response)){
127
			if(!empty($response)){
124
				$data = array('account_type'=>'saholic','user_id'=>$userId,'account_key'=>$response['userId']);
128
				$data = array('account_type'=>'saholic','user_id'=>$userId,'account_key'=>$response['userId']);
125
				$this->UserAccount->create();
129
				$this->UserAccount->create();
126
				$this->UserAccount-save($data);
130
				$this->UserAccount->save($data);
127
			}
131
			}
128
		}
132
		}
129
	}
133
	}
130
/**
134
/**
131
 * edit method
135
 * edit method