Subversion Repositories SmartDukaan

Rev

Rev 14776 | Rev 14781 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
14776 anikendra 1
<?php
2
App::uses('AppController', 'Controller');
3
/**
4
 * Pushnotifications Controller
5
 *
6
 * @property Pushnotification $Pushnotification
7
 * @property PaginatorComponent $Paginator
8
 */
9
class PushnotificationsController extends AppController {
10
 
11
/**
12
 * Components
13
 *
14
 * @var array
15
 */
16
	public $components = array('Paginator');
17
 
14778 anikendra 18
	public function beforeFilter() {
19
		parent::beforeFilter();
20
		$this->Auth->allow('add');
21
	}
14776 anikendra 22
/**
23
 * index method
24
 *
25
 * @return void
26
 */
27
	public function index() {
28
		$this->Pushnotification->recursive = 0;
29
		$this->set('pushnotifications', $this->Paginator->paginate());
30
	}
31
 
32
/**
33
 * view method
34
 *
35
 * @throws NotFoundException
36
 * @param string $id
37
 * @return void
38
 */
39
	public function view($id = null) {
40
		if (!$this->Pushnotification->exists($id)) {
41
			throw new NotFoundException(__('Invalid pushnotification'));
42
		}
43
		$options = array('conditions' => array('Pushnotification.' . $this->Pushnotification->primaryKey => $id));
44
		$this->set('pushnotification', $this->Pushnotification->find('first', $options));
45
	}
46
 
47
/**
48
 * add method
49
 *
50
 * @return void
51
 */
52
	public function add() {
53
		if ($this->request->is('post')) {
14778 anikendra 54
			$this->log(print_r($this->request->data,1),'pushnotifications');
14776 anikendra 55
			$this->Pushnotification->create();
56
			if ($this->Pushnotification->save($this->request->data)) {
57
				$this->Session->setFlash(__('The pushnotification has been saved.'));
58
				return $this->redirect(array('action' => 'index'));
59
			} else {
60
				$this->Session->setFlash(__('The pushnotification could not be saved. Please, try again.'));
61
			}
62
		}
63
		$users = $this->Pushnotification->User->find('list');
64
		$this->set(compact('users'));
65
	}
66
 
67
/**
68
 * edit method
69
 *
70
 * @throws NotFoundException
71
 * @param string $id
72
 * @return void
73
 */
74
	public function edit($id = null) {
75
		if (!$this->Pushnotification->exists($id)) {
76
			throw new NotFoundException(__('Invalid pushnotification'));
77
		}
78
		if ($this->request->is(array('post', 'put'))) {
79
			if ($this->Pushnotification->save($this->request->data)) {
80
				$this->Session->setFlash(__('The pushnotification has been saved.'));
81
				return $this->redirect(array('action' => 'index'));
82
			} else {
83
				$this->Session->setFlash(__('The pushnotification could not be saved. Please, try again.'));
84
			}
85
		} else {
86
			$options = array('conditions' => array('Pushnotification.' . $this->Pushnotification->primaryKey => $id));
87
			$this->request->data = $this->Pushnotification->find('first', $options);
88
		}
89
		$users = $this->Pushnotification->User->find('list');
90
		$this->set(compact('users'));
91
	}
92
 
93
/**
94
 * delete method
95
 *
96
 * @throws NotFoundException
97
 * @param string $id
98
 * @return void
99
 */
100
	public function delete($id = null) {
101
		$this->Pushnotification->id = $id;
102
		if (!$this->Pushnotification->exists()) {
103
			throw new NotFoundException(__('Invalid pushnotification'));
104
		}
105
		$this->request->onlyAllow('post', 'delete');
106
		if ($this->Pushnotification->delete()) {
107
			$this->Session->setFlash(__('The pushnotification has been deleted.'));
108
		} else {
109
			$this->Session->setFlash(__('The pushnotification could not be deleted. Please, try again.'));
110
		}
111
		return $this->redirect(array('action' => 'index'));
112
	}
113
 
114
/**
115
 * admin_index method
116
 *
117
 * @return void
118
 */
119
	public function admin_index() {
120
		$this->Pushnotification->recursive = 0;
121
		$this->set('pushnotifications', $this->Paginator->paginate());
122
	}
123
 
124
/**
125
 * admin_view method
126
 *
127
 * @throws NotFoundException
128
 * @param string $id
129
 * @return void
130
 */
131
	public function admin_view($id = null) {
132
		if (!$this->Pushnotification->exists($id)) {
133
			throw new NotFoundException(__('Invalid pushnotification'));
134
		}
135
		$options = array('conditions' => array('Pushnotification.' . $this->Pushnotification->primaryKey => $id));
136
		$this->set('pushnotification', $this->Pushnotification->find('first', $options));
137
	}
138
 
139
/**
140
 * admin_add method
141
 *
142
 * @return void
143
 */
144
	public function admin_add() {
145
		if ($this->request->is('post')) {
146
			$this->Pushnotification->create();
147
			if ($this->Pushnotification->save($this->request->data)) {
148
				$this->Session->setFlash(__('The pushnotification has been saved.'));
149
				return $this->redirect(array('action' => 'index'));
150
			} else {
151
				$this->Session->setFlash(__('The pushnotification could not be saved. Please, try again.'));
152
			}
153
		}
154
		$users = $this->Pushnotification->User->find('list');
155
		$this->set(compact('users'));
156
	}
157
 
158
/**
159
 * admin_edit method
160
 *
161
 * @throws NotFoundException
162
 * @param string $id
163
 * @return void
164
 */
165
	public function admin_edit($id = null) {
166
		if (!$this->Pushnotification->exists($id)) {
167
			throw new NotFoundException(__('Invalid pushnotification'));
168
		}
169
		if ($this->request->is(array('post', 'put'))) {
170
			if ($this->Pushnotification->save($this->request->data)) {
171
				$this->Session->setFlash(__('The pushnotification has been saved.'));
172
				return $this->redirect(array('action' => 'index'));
173
			} else {
174
				$this->Session->setFlash(__('The pushnotification could not be saved. Please, try again.'));
175
			}
176
		} else {
177
			$options = array('conditions' => array('Pushnotification.' . $this->Pushnotification->primaryKey => $id));
178
			$this->request->data = $this->Pushnotification->find('first', $options);
179
		}
180
		$users = $this->Pushnotification->User->find('list');
181
		$this->set(compact('users'));
182
	}
183
 
184
/**
185
 * admin_delete method
186
 *
187
 * @throws NotFoundException
188
 * @param string $id
189
 * @return void
190
 */
191
	public function admin_delete($id = null) {
192
		$this->Pushnotification->id = $id;
193
		if (!$this->Pushnotification->exists()) {
194
			throw new NotFoundException(__('Invalid pushnotification'));
195
		}
196
		$this->request->onlyAllow('post', 'delete');
197
		if ($this->Pushnotification->delete()) {
198
			$this->Session->setFlash(__('The pushnotification has been deleted.'));
199
		} else {
200
			$this->Session->setFlash(__('The pushnotification could not be deleted. Please, try again.'));
201
		}
202
		return $this->redirect(array('action' => 'index'));
203
	}}