| Line 258... |
Line 258... |
| 258 |
* @param string $id
|
258 |
* @param string $id
|
| 259 |
* @return void
|
259 |
* @return void
|
| 260 |
*/
|
260 |
*/
|
| 261 |
|
261 |
|
| 262 |
public function edit($id = null) {
|
262 |
public function edit($id = null) {
|
| 263 |
$this->log(print_r($this->request->data,1),'mydetails');
|
263 |
$this->log(print_r($this->request->data,1),'mydetails');
|
| 264 |
$this->response->type('json');
|
264 |
$this->response->type('json');
|
| 265 |
$this->layout = 'ajax';
|
265 |
$this->layout = 'ajax';
|
| 266 |
$this->User->recursive = -1;
|
266 |
$this->User->recursive = -1;
|
| - |
|
267 |
$updateRequired = true;
|
| 267 |
if (!$this->User->exists($id)) {
|
268 |
if (!$this->User->exists($id)) {
|
| 268 |
$result = array('success'=>false,'message'=>'Invalid user');
|
269 |
$result = array('success'=>false,'message'=>'Invalid user');
|
| 269 |
} else {
|
270 |
} else {
|
| 270 |
if ($this->request->is('post') || $this->request->is('put')) {
|
271 |
if ($this->request->is('post') || $this->request->is('put')) {
|
| 271 |
if(!empty($this->request->data['mobile_number']) && empty($this->request->data['mobile_verified'])) {
|
272 |
if(!empty($this->request->data['mobile_number']) && empty($this->request->data['mobile_verified'])) {
|
| Line 273... |
Line 274... |
| 273 |
$oldMobile = $this->User->find('first',$options);
|
274 |
$oldMobile = $this->User->find('first',$options);
|
| 274 |
if($this->request->data['mobile_number'] != $oldMobile['User']['mobile_number']) {
|
275 |
if($this->request->data['mobile_number'] != $oldMobile['User']['mobile_number']) {
|
| 275 |
$this->request->data['mobile_verified'] = 0;
|
276 |
$this->request->data['mobile_verified'] = 0;
|
| 276 |
}
|
277 |
}
|
| 277 |
}
|
278 |
}
|
| 278 |
if(!empty($this->request->data['referrer']) {
|
279 |
if(!empty($this->request->data['referrer'])) {
|
| 279 |
$referrer = $this->request->data['referrer'];
|
280 |
$referrer = $this->request->data['referrer'];
|
| 280 |
$this->loadModel('ActivationCode');
|
281 |
$this->loadModel('ActivationCode');
|
| 281 |
$exists = $this->ActivationCode->findByCode($referrer);
|
282 |
$exists = $this->ActivationCode->findByCode($referrer);
|
| 282 |
if(empty($exists)){
|
283 |
if(empty($exists)){
|
| 283 |
$result = array('success'=>false,'message'=>'Invalid referral code');
|
284 |
$result = array('success'=>false,'message'=>'Invalid referral code');
|
| 284 |
unset($this->request->data['referrer']);
|
285 |
unset($this->request->data['referrer']);
|
| - |
|
286 |
$updateRequired = false;
|
| 285 |
}
|
287 |
}
|
| 286 |
}
|
288 |
}
|
| - |
|
289 |
if($updateRequired){
|
| 287 |
if ($this->User->save($this->request->data)) {
|
290 |
if ($this->User->save($this->request->data)) {
|
| 288 |
$result = array('success'=>true,'message'=>'Your profile has been saved');
|
291 |
$result = array('success'=>true,'message'=>'Your profile has been saved');
|
| 289 |
} else {
|
292 |
} else {
|
| 290 |
$result = array('success'=>false,'message'=> 'The user could not be saved. Please, try again.');
|
293 |
$result = array('success'=>false,'message'=> 'The user could not be saved. Please, try again.');
|
| 291 |
}
|
294 |
}
|
| - |
|
295 |
}
|
| 292 |
}
|
296 |
}
|
| 293 |
}
|
297 |
}
|
| 294 |
$this->set(array(
|
298 |
$this->set(array(
|
| 295 |
'result' => $result,
|
299 |
'result' => $result,
|
| 296 |
'_serialize' => array('result')
|
300 |
'_serialize' => array('result')
|
| Line 363... |
Line 367... |
| 363 |
$this->loadModel('Store');
|
367 |
$this->loadModel('Store');
|
| 364 |
$store = $this->Store->getByUrl($url);
|
368 |
$store = $this->Store->getByUrl($url);
|
| 365 |
}
|
369 |
}
|
| 366 |
$this->loadModel('GcmUser');
|
370 |
$this->loadModel('GcmUser');
|
| 367 |
foreach ($this->request->data['userIds'] as $key => $value) {
|
371 |
foreach ($this->request->data['userIds'] as $key => $value) {
|
| 368 |
$options = array('conditions'=>array('user_id'=>$value),'fields'=>array('gcm_regid'),'order'=>array('id'=>'desc'),'group'=>array('user_id'));
|
372 |
$options = array('conditions'=>array('user_id'=>$value),'fields'=>array('gcm_regid'),'order'=>array('id'=>'desc'));
|
| 369 |
$gcmUser = $this->GcmUser->find('first',$options);
|
373 |
$gcmUser = $this->GcmUser->find('first',$options);
|
| 370 |
$regIds = array($gcmUser['GcmUser']['gcm_regid']);
|
374 |
$regIds = array($gcmUser['GcmUser']['gcm_regid']);
|
| 371 |
// $message = array('message'=>$this->request->data['User']['message']);
|
375 |
// $message = array('message'=>$this->request->data['User']['message']);
|
| 372 |
if($message['type'] == 'url' && !empty($message['url'])) {
|
376 |
if($message['type'] == 'url' && !empty($message['url'])) {
|
| 373 |
$message['url'] = $this->generateAffiliateUrl($url,$value,$store);
|
377 |
$message['url'] = $this->generateAffiliateUrl($url,$value,$store);
|
| Line 421... |
Line 425... |
| 421 |
die('Curl failed: ' . curl_error($ch));
|
425 |
die('Curl failed: ' . curl_error($ch));
|
| 422 |
}
|
426 |
}
|
| 423 |
|
427 |
|
| 424 |
// Close connection
|
428 |
// Close connection
|
| 425 |
curl_close($ch);
|
429 |
curl_close($ch);
|
| 426 |
$this->log("For $user_id ".print_r($result,1),'notifiactions');
|
430 |
$this->log("For $user_id ".$registatoin_ids[0]." ".print_r($result,1),'notifiactions');
|
| 427 |
}
|
431 |
}
|
| 428 |
|
432 |
|
| 429 |
public function admin_index() {
|
433 |
public function admin_index() {
|
| 430 |
$this->User->recursive = 0;
|
434 |
$this->User->recursive = 0;
|
| 431 |
$options = array('limit'=>100,'order'=>array('id'=>'desc'));
|
435 |
$options = array('limit'=>100,'order'=>array('id'=>'desc'));
|