| Line 53... |
Line 53... |
| 53 |
* add method
|
53 |
* add method
|
| 54 |
*
|
54 |
*
|
| 55 |
* @return void
|
55 |
* @return void
|
| 56 |
*/
|
56 |
*/
|
| 57 |
public function add() {
|
57 |
public function add() {
|
| - |
|
58 |
$mobileRequired = true;
|
| 58 |
if ($this->request->is('post')) {
|
59 |
if ($this->request->is('post')) {
|
| 59 |
$this->log(print_r($this->request->data,1),'registration');
|
60 |
$this->log(print_r($this->request->data,1),'registration');
|
| 60 |
$data = $this->request->data;
|
61 |
$data = $this->request->data;
|
| 61 |
$data['social_id'] = $this->request->data['id'];
|
62 |
$data['social_id'] = $this->request->data['id'];
|
| 62 |
$data['access_token'] = $this->request->data['token'];
|
63 |
$data['access_token'] = $this->request->data['token'];
|
| Line 72... |
Line 73... |
| 72 |
if(!empty($this->request->data['email'])) {
|
73 |
if(!empty($this->request->data['email'])) {
|
| 73 |
$conditions = array('email'=>$this->request->data['email']);
|
74 |
$conditions = array('email'=>$this->request->data['email']);
|
| 74 |
$user = $this->SocialProfile->User->find('first',array('conditions'=>$conditions));
|
75 |
$user = $this->SocialProfile->User->find('first',array('conditions'=>$conditions));
|
| 75 |
|
76 |
|
| 76 |
if(!empty($user)) {
|
77 |
if(!empty($user)) {
|
| - |
|
78 |
//Existing user
|
| - |
|
79 |
if(!empty($user['User']['mobile_number'])){
|
| - |
|
80 |
$mobileRequired = false;
|
| - |
|
81 |
}
|
| 77 |
$userData = array('id'=>$user['User']['id'],'email'=>$this->request->data['email'],'username'=>$this->request->data['email'],'first_name'=>$this->request->data['name'],'gender'=>$this->request->data['gender'],'referrer'=>$this->request->data['referrer'],'profile_pic'=> $this->request->data['profile_pic']);
|
82 |
$userData = array('id'=>$user['User']['id'],'email'=>$this->request->data['email'],'username'=>$this->request->data['email'],'first_name'=>$this->request->data['name'],'gender'=>$this->request->data['gender'],'referrer'=>$this->request->data['referrer'],'profile_pic'=> $this->request->data['profile_pic']);
|
| 78 |
$this->SocialProfile->User->save($userData);
|
83 |
$this->SocialProfile->User->save($userData);
|
| 79 |
$data['user_id'] = $user['User']['id'];
|
84 |
$data['user_id'] = $user['User']['id'];
|
| 80 |
}else{
|
85 |
}else{
|
| 81 |
//Create a new user and then insert user_id in social_profiles table
|
86 |
//Create a new user and then insert user_id in social_profiles table
|
| 82 |
$userData = array('profile_pic'=> $this->request->data['profile_pic'], 'email'=>$this->request->data['email'],'username'=>$this->request->data['email'],'first_name'=>$this->request->data['name'],'gender'=>$this->request->data['gender'],'referrer'=>$this->request->data['referrer']);
|
87 |
$userData = array('profile_pic'=> $this->request->data['profile_pic'], 'email'=>$this->request->data['email'],'username'=>$this->request->data['email'],'first_name'=>$this->request->data['name'],'gender'=>$this->request->data['gender'],'referrer'=>$this->request->data['referrer']);
|
| 83 |
if($this->SocialProfile->User->save($userData)) {
|
88 |
if($this->SocialProfile->User->save($userData)) {
|
| 84 |
$data['user_id'] = $this->SocialProfile->User->getLastInsertId();
|
89 |
$data['user_id'] = $this->SocialProfile->User->getLastInsertId();
|
| 85 |
}else{
|
90 |
} else{
|
| 86 |
$result = array('success' => false, 'message' => $this->SocialProfile->User->validationErrors);
|
91 |
$result = array('success' => false, 'message' => $this->SocialProfile->User->validationErrors,'mobileRequired'=>$mobileRequired);
|
| 87 |
break;
|
92 |
break;
|
| 88 |
}
|
93 |
}
|
| 89 |
}
|
94 |
}
|
| 90 |
$this->SocialProfile->create();
|
95 |
$this->SocialProfile->create();
|
| 91 |
if ($this->SocialProfile->save($data)) {
|
96 |
if ($this->SocialProfile->save($data)) {
|
| 92 |
$result = array('success' => true, 'message' => 'Social Profile Created','id' => $data['user_id']);
|
97 |
$result = array('success' => true, 'message' => 'Social Profile Created','id' => $data['user_id'],'mobileRequired'=>$mobileRequired);
|
| 93 |
} else {
|
98 |
} else {
|
| 94 |
$result = array('success' => false, 'message' => 'Social Profile Could Not Be Created','id' => -1);
|
99 |
$result = array('success' => false, 'message' => 'Social Profile Could Not Be Created','id' => -1,'mobileRequired'=>$mobileRequired);
|
| 95 |
}
|
100 |
}
|
| 96 |
} else {
|
101 |
} else {
|
| 97 |
$result = array('success' => false, 'message' => "Email is missing");
|
102 |
$result = array('success' => false, 'message' => "Email is missing",'mobileRequired'=>$mobileRequired);
|
| 98 |
break;
|
103 |
break;
|
| 99 |
}
|
104 |
}
|
| 100 |
} else {
|
105 |
} else {
|
| - |
|
106 |
//Check for mobile number
|
| 101 |
$userData = array('id'=>$socialProfile['SocialProfile']['user_id'],'email'=>$this->request->data['email'],'username'=>$this->request->data['email'],'first_name'=>$this->request->data['name'],'gender'=>$this->request->data['gender'],'referrer'=>$this->request->data['referrer'],'profile_pic'=> $this->request->data['profile_pic']);
|
107 |
$userData = array('id'=>$socialProfile['SocialProfile']['user_id'],'email'=>$this->request->data['email'],'username'=>$this->request->data['email'],'first_name'=>$this->request->data['name'],'gender'=>$this->request->data['gender'],'referrer'=>$this->request->data['referrer'],'profile_pic'=> $this->request->data['profile_pic']);
|
| 102 |
$this->SocialProfile->User->save($userData);
|
108 |
$this->SocialProfile->User->save($userData);
|
| 103 |
$data['user_id'] = $socialProfile['SocialProfile']['user_id'];
|
109 |
$data['user_id'] = $socialProfile['SocialProfile']['user_id'];
|
| 104 |
$result = array('success' => true, 'message' => 'Existing Social Profile','id' => $socialProfile['SocialProfile']['user_id']);
|
110 |
$result = array('success' => true, 'message' => 'Existing Social Profile','id' => $socialProfile['SocialProfile']['user_id'],'mobileRequired'=>$mobileRequired);
|
| 105 |
}
|
111 |
}
|
| 106 |
}
|
112 |
}
|
| 107 |
$this->updateSaholicUser($data['user_id'],$this->request->data['email']);
|
113 |
$this->updateSaholicUser($data['user_id'],$this->request->data['email']);
|
| 108 |
$this->set(array(
|
114 |
$this->set(array(
|
| 109 |
'result' => $result,
|
115 |
'result' => $result,
|