| 13591 |
anikendra |
1 |
<?php
|
|
|
2 |
App::uses('AppController', 'Controller');
|
|
|
3 |
/**
|
|
|
4 |
* Mobileappsettings Controller
|
|
|
5 |
*
|
|
|
6 |
* @property Mobileappsetting $Mobileappsetting
|
|
|
7 |
* @property PaginatorComponent $Paginator
|
|
|
8 |
*/
|
|
|
9 |
class MobileappsettingsController extends AppController {
|
|
|
10 |
|
|
|
11 |
/**
|
|
|
12 |
* Components
|
|
|
13 |
*
|
|
|
14 |
* @var array
|
|
|
15 |
*/
|
|
|
16 |
public $components = array('Paginator');
|
| 20126 |
naman |
17 |
|
|
|
18 |
public function beforeFilter() {
|
|
|
19 |
parent::beforeFilter();
|
|
|
20 |
$this->Auth->allow();
|
|
|
21 |
}
|
| 13591 |
anikendra |
22 |
|
| 13593 |
anikendra |
23 |
public function index() {
|
|
|
24 |
$this->layout = 'ajax';
|
| 14662 |
anikendra |
25 |
$t = $this->request->query('t');
|
| 15530 |
anikendra |
26 |
$imeinumber = $this->request->query('imeinumber');
|
| 14662 |
anikendra |
27 |
if(!empty($t) && $t >0){
|
|
|
28 |
$options = array('conditions'=>array("unix_timestamp(modified) > "=>$t));
|
|
|
29 |
}else{
|
|
|
30 |
$options = null;
|
|
|
31 |
}
|
|
|
32 |
$settings = $this->Mobileappsetting->find('all',$options);
|
|
|
33 |
$options = array('fields'=>array("unix_timestamp(modified) t"),'order'=>array('modified'=>'desc'));
|
| 15530 |
anikendra |
34 |
$lasttimestamp = $this->Mobileappsetting->find('first',$options);
|
|
|
35 |
$failureCount = 0;
|
| 22468 |
amit.gupta |
36 |
/*if(isset($imeinumber) && !empty($imeinumber)) {
|
| 15530 |
anikendra |
37 |
$this->loadModel('GcmUser');
|
|
|
38 |
$options = array('conditions'=>array('imeinumber'=>$imeinumber),'fields'=>array('failurecount'),'order'=>array('id'=>'desc'));
|
|
|
39 |
$data = $this->GcmUser->find('first',$options);
|
|
|
40 |
if(!empty($data)){
|
|
|
41 |
$failureCount = $data['GcmUser']['failurecount'];
|
|
|
42 |
}
|
| 22468 |
amit.gupta |
43 |
}*/
|
| 15530 |
anikendra |
44 |
$result = array('settings' => $settings,'t'=>$lasttimestamp[0]['t'],'failureCount'=>$failureCount);
|
| 13593 |
anikendra |
45 |
$this->set(array(
|
|
|
46 |
'result' => $result,
|
|
|
47 |
'_serialize' => array('result')
|
|
|
48 |
));
|
|
|
49 |
$this->render('/Elements/json');
|
|
|
50 |
}
|
| 13591 |
anikendra |
51 |
/**
|
|
|
52 |
* admin_index method
|
|
|
53 |
*
|
|
|
54 |
* @return void
|
|
|
55 |
*/
|
|
|
56 |
public function admin_index() {
|
|
|
57 |
$this->Mobileappsetting->recursive = 0;
|
|
|
58 |
$this->set('mobileappsettings', $this->Paginator->paginate());
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
/**
|
|
|
62 |
* admin_view method
|
|
|
63 |
*
|
|
|
64 |
* @throws NotFoundException
|
|
|
65 |
* @param string $id
|
|
|
66 |
* @return void
|
|
|
67 |
*/
|
|
|
68 |
public function admin_view($id = null) {
|
|
|
69 |
if (!$this->Mobileappsetting->exists($id)) {
|
|
|
70 |
throw new NotFoundException(__('Invalid mobileappsetting'));
|
|
|
71 |
}
|
|
|
72 |
$options = array('conditions' => array('Mobileappsetting.' . $this->Mobileappsetting->primaryKey => $id));
|
|
|
73 |
$this->set('mobileappsetting', $this->Mobileappsetting->find('first', $options));
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
/**
|
|
|
77 |
* admin_add method
|
|
|
78 |
*
|
|
|
79 |
* @return void
|
|
|
80 |
*/
|
|
|
81 |
public function admin_add() {
|
|
|
82 |
if ($this->request->is('post')) {
|
|
|
83 |
$this->Mobileappsetting->create();
|
|
|
84 |
if ($this->Mobileappsetting->save($this->request->data)) {
|
|
|
85 |
$this->Session->setFlash(__('The mobileappsetting has been saved.'));
|
|
|
86 |
return $this->redirect(array('action' => 'index'));
|
|
|
87 |
} else {
|
|
|
88 |
$this->Session->setFlash(__('The mobileappsetting could not be saved. Please, try again.'));
|
|
|
89 |
}
|
|
|
90 |
}
|
|
|
91 |
}
|
|
|
92 |
|
|
|
93 |
/**
|
|
|
94 |
* admin_edit method
|
|
|
95 |
*
|
|
|
96 |
* @throws NotFoundException
|
|
|
97 |
* @param string $id
|
|
|
98 |
* @return void
|
|
|
99 |
*/
|
|
|
100 |
public function admin_edit($id = null) {
|
|
|
101 |
if (!$this->Mobileappsetting->exists($id)) {
|
|
|
102 |
throw new NotFoundException(__('Invalid mobileappsetting'));
|
|
|
103 |
}
|
|
|
104 |
if ($this->request->is(array('post', 'put'))) {
|
|
|
105 |
if ($this->Mobileappsetting->save($this->request->data)) {
|
|
|
106 |
$this->Session->setFlash(__('The mobileappsetting has been saved.'));
|
|
|
107 |
return $this->redirect(array('action' => 'index'));
|
|
|
108 |
} else {
|
|
|
109 |
$this->Session->setFlash(__('The mobileappsetting could not be saved. Please, try again.'));
|
|
|
110 |
}
|
|
|
111 |
} else {
|
|
|
112 |
$options = array('conditions' => array('Mobileappsetting.' . $this->Mobileappsetting->primaryKey => $id));
|
|
|
113 |
$this->request->data = $this->Mobileappsetting->find('first', $options);
|
|
|
114 |
}
|
|
|
115 |
}
|
|
|
116 |
|
|
|
117 |
/**
|
|
|
118 |
* admin_delete method
|
|
|
119 |
*
|
|
|
120 |
* @throws NotFoundException
|
|
|
121 |
* @param string $id
|
|
|
122 |
* @return void
|
|
|
123 |
*/
|
|
|
124 |
public function admin_delete($id = null) {
|
|
|
125 |
$this->Mobileappsetting->id = $id;
|
|
|
126 |
if (!$this->Mobileappsetting->exists()) {
|
|
|
127 |
throw new NotFoundException(__('Invalid mobileappsetting'));
|
|
|
128 |
}
|
|
|
129 |
$this->request->onlyAllow('post', 'delete');
|
|
|
130 |
if ($this->Mobileappsetting->delete()) {
|
|
|
131 |
$this->Session->setFlash(__('The mobileappsetting has been deleted.'));
|
|
|
132 |
} else {
|
|
|
133 |
$this->Session->setFlash(__('The mobileappsetting could not be deleted. Please, try again.'));
|
|
|
134 |
}
|
|
|
135 |
return $this->redirect(array('action' => 'index'));
|
|
|
136 |
}}
|