| Line 56... |
Line 56... |
| 56 |
if(empty($this->request->data['user_id']) || empty($this->request->data['gcm_regid'])){
|
56 |
if(empty($this->request->data['user_id']) || empty($this->request->data['gcm_regid'])){
|
| 57 |
$result = array('success'=>false);
|
57 |
$result = array('success'=>false);
|
| 58 |
} else {
|
58 |
} else {
|
| 59 |
$dataForModel = $this->request->data;
|
59 |
$dataForModel = $this->request->data;
|
| 60 |
$this->log('before find '.print_r($dataForModel,1),'gcm');
|
60 |
$this->log('before find '.print_r($dataForModel,1),'gcm');
|
| 61 |
$data = $this->GcmUser->find('first',array('conditions'=>array('user_id'=>$this->request->data['user_id'],'imeinumber'=>$this->request->data['imeinumber'])));
|
61 |
$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 |
$this->log("found row ".print_r($data,1),'gcm');
|
62 |
$this->log("found row ".print_r($data,1),'gcm');
|
| 63 |
if(!empty($data)){
|
63 |
if(!empty($data)){
|
| 64 |
$dataForModel['id'] = $data['GcmUser']['id'];
|
64 |
$dataForModel['id'] = $data['GcmUser']['id'];
|
| - |
|
65 |
$dataForModel['failurecount'] = 0;
|
| 65 |
}else{
|
66 |
}else{
|
| 66 |
$this->GcmUser->create();
|
67 |
$this->GcmUser->create();
|
| 67 |
}
|
68 |
}
|
| 68 |
$this->log('lets save '.print_r($dataForModel,1),'gcm');
|
69 |
$this->log('lets save '.print_r($dataForModel,1),'gcm');
|
| 69 |
if ($this->GcmUser->save($dataForModel)) {
|
70 |
if ($this->GcmUser->save($dataForModel)) {
|
| 70 |
$result = array('success'=>true);
|
71 |
$result = array('success'=>true);
|
| 71 |
// $this->Session->setFlash(__('The gcm user has been saved.'));
|
72 |
// $this->Session->setFlash(__('The gcm user has been saved.'));
|
| 72 |
// return $this->redirect(array('action' => 'index'));
|
73 |
// return $this->redirect(array('action' => 'index'));
|
| 73 |
} else {
|
74 |
} else {
|
| 74 |
$result = array('success'=>false);
|
75 |
$result = array('success'=>false);
|
| - |
|
76 |
$this->log("failure ".print_r($this->GcmUser->validationErrors,1));
|
| 75 |
// $this->Session->setFlash(__('The gcm user could not be saved. Please, try again.'));
|
77 |
// $this->Session->setFlash(__('The gcm user could not be saved. Please, try again.'));
|
| 76 |
}
|
78 |
}
|
| 77 |
}
|
79 |
}
|
| 78 |
}
|
80 |
}
|
| 79 |
$this->set(array(
|
81 |
$this->set(array(
|