| Line 61... |
Line 61... |
| 61 |
$this->log('before find '.print_r($dataForModel,1),'gcm');
|
61 |
$this->log('before find '.print_r($dataForModel,1),'gcm');
|
| 62 |
$data = $this->GcmUser->find('first',array('conditions'=>array('user_id'=>$this->request->data['user_id'],'imeinumber'=>$this->request->data['imeinumber']),'order'=>array('id'=>'desc')));
|
62 |
$data = $this->GcmUser->find('first',array('conditions'=>array('user_id'=>$this->request->data['user_id'],'imeinumber'=>$this->request->data['imeinumber']),'order'=>array('id'=>'desc')));
|
| 63 |
$this->log("found row ".print_r($data,1),'gcm');
|
63 |
$this->log("found row ".print_r($data,1),'gcm');
|
| 64 |
if(!empty($data)){
|
64 |
if(!empty($data)){
|
| 65 |
$dataForModel['id'] = $data['GcmUser']['id'];
|
65 |
$dataForModel['id'] = $data['GcmUser']['id'];
|
| 66 |
$dataForModel['failurecount'] = 0;
|
66 |
$dataForModel['failurecount'] = 0;
|
| 67 |
}else{
|
67 |
}else{
|
| 68 |
$this->GcmUser->create();
|
68 |
$this->GcmUser->create();
|
| 69 |
}
|
69 |
}
|
| 70 |
$this->log('lets save '.print_r($dataForModel,1),'gcm');
|
70 |
$this->log('lets save '.print_r($dataForModel,1),'gcm');
|
| 71 |
if ($this->GcmUser->save($dataForModel)) {
|
71 |
if ($this->GcmUser->save($dataForModel)) {
|
| 72 |
$result = array('success'=>true);
|
72 |
$result = array('success'=>true);
|
| 73 |
// $this->Session->setFlash(__('The gcm user has been saved.'));
|
73 |
if(!empty($dataForModel['androidid'])){
|
| - |
|
74 |
$url = Configure::read('nodeurl')."/addingTopNotifications?user_id=".$dataForModel['user_id']."&android_id=".$dataForModel['androidid'];
|
| 74 |
// return $this->redirect(array('action' => 'index'));
|
75 |
$this->make_request($url,null);
|
| - |
|
76 |
}
|
| 75 |
} else {
|
77 |
} else {
|
| 76 |
$result = array('success'=>false);
|
78 |
$result = array('success'=>false);
|
| 77 |
$this->log("failure ".print_r($this->GcmUser->validationErrors,1));
|
79 |
$this->log("failure ".print_r($this->GcmUser->validationErrors,1));
|
| 78 |
// $this->Session->setFlash(__('The gcm user could not be saved. Please, try again.'));
|
- |
|
| 79 |
}
|
80 |
}
|
| 80 |
}
|
81 |
}
|
| 81 |
}
|
82 |
}
|
| 82 |
$this->set(array(
|
83 |
$this->set(array(
|
| 83 |
'result' => $result,
|
84 |
'result' => $result,
|