| Line 53... |
Line 53... |
| 53 |
*/
|
53 |
*/
|
| 54 |
public function add() {
|
54 |
public function add() {
|
| 55 |
if ($this->request->is('post')) {
|
55 |
if ($this->request->is('post')) {
|
| 56 |
$this->log(print_r($this->request->data,1),'pushnotifications');
|
56 |
$this->log(print_r($this->request->data,1),'pushnotifications');
|
| 57 |
$data = $this->request->data;
|
57 |
$data = $this->request->data;
|
| - |
|
58 |
$data['pushed_by'] = 'php';
|
| - |
|
59 |
$url = Configure::read('nodeurl')."/addPushNotificationByApk";//remove hardcoded value
|
| - |
|
60 |
$response = $this->post_request($url,$data);
|
| - |
|
61 |
$this->log(print_r($response,1),'pushnotifications');
|
| - |
|
62 |
if(!empty($response)){
|
| - |
|
63 |
$result = array('success' => true,'message'=>'The pushnotification has been saved.');
|
| - |
|
64 |
} else {
|
| - |
|
65 |
$result = array('success' => false,'message'=>'The pushnotification could not be saved. Please, try again.');
|
| - |
|
66 |
}
|
| 58 |
$data['type'] = $data['result'];
|
67 |
/*$data['type'] = $data['result'];
|
| 59 |
$data['status'] = 1;
|
68 |
$data['status'] = 1;
|
| 60 |
$data['response_time'] = date('Y-m-d H:i:s',strtotime($data['timestamp']));
|
69 |
$data['response_time'] = date('Y-m-d H:i:s',strtotime($data['timestamp']));
|
| 61 |
$data['notification_campaign_id'] = $data['cid'];
|
70 |
$data['notification_campaign_id'] = $data['cid'];
|
| 62 |
unset($data['result']);
|
71 |
unset($data['result']);
|
| 63 |
unset($data['cid']);
|
72 |
unset($data['cid']);
|
| 64 |
unset($data['timestamp']);
|
73 |
unset($data['timestamp']);
|
| 65 |
if(empty($data['user_id'])){
|
74 |
if(empty($data['user_id'])){
|
| 66 |
unset($data['user_id']);
|
75 |
unset($data['user_id']);
|
| 67 |
}
|
76 |
}
|
| 68 |
$this->log(print_r($data,1),'pushnotifications');
|
- |
|
| 69 |
$this->Pushnotification->create();
|
77 |
$this->Pushnotification->create();
|
| 70 |
if ($this->Pushnotification->save($data)) {
|
78 |
if ($this->Pushnotification->save($data)) {
|
| 71 |
// $this->Session->setFlash(__('The pushnotification has been saved.'));
|
- |
|
| 72 |
// return $this->redirect(array('action' => 'index'));
|
- |
|
| 73 |
$result = array('success' => true,'message'=>'The pushnotification has been saved.');
|
79 |
$result = array('success' => true,'message'=>'The pushnotification has been saved.');
|
| 74 |
} else {
|
80 |
} else {
|
| 75 |
$result = array('success' => false,'message'=>'The pushnotification could not be saved. Please, try again.');
|
81 |
$result = array('success' => false,'message'=>'The pushnotification could not be saved. Please, try again.');
|
| 76 |
// $this->Session->setFlash(__('The pushnotification could not be saved. Please, try again.'));
|
- |
|
| 77 |
}
|
82 |
}*/
|
| 78 |
}
|
83 |
}
|
| 79 |
$this->set(array(
|
84 |
$this->set(array(
|
| 80 |
'result' => $result,
|
85 |
'result' => $result,
|
| 81 |
'_serialize' => array('result')
|
86 |
'_serialize' => array('result')
|
| 82 |
));
|
87 |
));
|