| Line 50... |
Line 50... |
| 50 |
* @return void
|
50 |
* @return void
|
| 51 |
*/
|
51 |
*/
|
| 52 |
public function add() {
|
52 |
public function add() {
|
| 53 |
if ($this->request->is('post')) {
|
53 |
if ($this->request->is('post')) {
|
| 54 |
$this->log(print_r($this->request->data,1),'devices');
|
54 |
$this->log(print_r($this->request->data,1),'devices');
|
| 55 |
$count = $this->Device->find('count',array('conditions'=>$this->request->data));
|
55 |
$device = $this->Device->find('first',array('conditions'=>$this->request->data));
|
| 56 |
if(!$count) {
|
56 |
if(!$device) {
|
| 57 |
$cachekey = 'webnotifications-'.$this->request->data['user_id'];
|
57 |
$cachekey = 'webnotifications-'.$this->request->data['user_id'];
|
| 58 |
$activeNotifications = Cache::read($cachekey,$config = 'hour');
|
58 |
$activeNotifications = Cache::read($cachekey,$config = 'hour');
|
| 59 |
$this->log(print_r($activeNotifications,1),'checknotification');
|
59 |
$this->log(print_r($activeNotifications,1),'checknotification');
|
| 60 |
if(!empty($activeNotifications)){
|
60 |
if(!empty($activeNotifications)){
|
| 61 |
Cache::delete($cachekey, $config = 'hour');
|
61 |
Cache::delete($cachekey, $config = 'hour');
|
| Line 65... |
Line 65... |
| 65 |
$result = array('success'=>true,'message'=>__('Record Saved.'));
|
65 |
$result = array('success'=>true,'message'=>__('Record Saved.'));
|
| 66 |
} else {
|
66 |
} else {
|
| 67 |
$result = array('success'=>false,'message'=>print_r($this->Device->validationErrors,1));
|
67 |
$result = array('success'=>false,'message'=>print_r($this->Device->validationErrors,1));
|
| 68 |
}
|
68 |
}
|
| 69 |
} else {
|
69 |
} else {
|
| - |
|
70 |
$device->modified=time();
|
| - |
|
71 |
$this->Device->save($device);
|
| 70 |
$result = array('success'=>false,'message'=>__('Identical record found. Ignoring.'));
|
72 |
$result = array('success'=>false,'message'=>__('Identical record found. Updating.'));
|
| 71 |
}
|
73 |
}
|
| 72 |
$this->response->type('json');
|
74 |
$this->response->type('json');
|
| 73 |
$this->layout = 'ajax';
|
75 |
$this->layout = 'ajax';
|
| 74 |
$this->set(array(
|
76 |
$this->set(array(
|
| 75 |
'result' => $response,
|
77 |
'result' => $response,
|