Subversion Repositories SmartDukaan

Rev

Rev 15403 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 15403 Rev 15655
Line 24... Line 24...
24
 * index method
24
 * index method
25
 *
25
 *
26
 * @return void
26
 * @return void
27
 */
27
 */
28
	public function index() {
28
	public function index() {
-
 
29
		throw new NotFoundException(__('Unauthorized access'));
29
		$this->Store->recursive = 0;
30
		$this->Store->recursive = 0;
30
		$this->set('stores', $this->Paginator->paginate());		
31
		$this->set('stores', $this->Paginator->paginate());		
31
	}
32
	}
32
 
33
 
33
/**
34
/**
Line 36... Line 37...
36
 * @throws NotFoundException
37
 * @throws NotFoundException
37
 * @param string $id
38
 * @param string $id
38
 * @return void
39
 * @return void
39
 */
40
 */
40
	public function view($id = null) {
41
	public function view($id = null) {
-
 
42
		throw new NotFoundException(__('Unauthorized access'));
41
		if (!$this->Store->exists($id)) {
43
		if (!$this->Store->exists($id)) {
42
			throw new NotFoundException(__('Invalid store'));
44
			throw new NotFoundException(__('Invalid store'));
43
		}
45
		}
44
		$options = array('conditions' => array('Store.' . $this->Store->primaryKey => $id));
46
		$options = array('conditions' => array('Store.' . $this->Store->primaryKey => $id));
45
		$this->set('store', $this->Store->find('first', $options));
47
		$this->set('store', $this->Store->find('first', $options));
Line 94... Line 96...
94
 * add method
96
 * add method
95
 *
97
 *
96
 * @return void
98
 * @return void
97
 */
99
 */
98
	public function add() {
100
	public function add() {
-
 
101
		throw new NotFoundException(__('Unauthorized access'));
99
		if ($this->request->is('post')) {
102
		if ($this->request->is('post')) {
100
			$this->Store->create();
103
			$this->Store->create();
101
			if ($this->Store->save($this->request->data)) {
104
			if ($this->Store->save($this->request->data)) {
102
				$this->Session->setFlash(__('The store has been saved.'));
105
				$this->Session->setFlash(__('The store has been saved.'));
103
				return $this->redirect(array('action' => 'index'));
106
				return $this->redirect(array('action' => 'index'));
Line 115... Line 118...
115
 * @throws NotFoundException
118
 * @throws NotFoundException
116
 * @param string $id
119
 * @param string $id
117
 * @return void
120
 * @return void
118
 */
121
 */
119
	public function edit($id = null) {
122
	public function edit($id = null) {
-
 
123
		throw new NotFoundException(__('Unauthorized access'));
120
		if (!$this->Store->exists($id)) {
124
		if (!$this->Store->exists($id)) {
121
			throw new NotFoundException(__('Invalid store'));
125
			throw new NotFoundException(__('Invalid store'));
122
		}
126
		}
123
		if ($this->request->is(array('post', 'put'))) {
127
		if ($this->request->is(array('post', 'put'))) {
124
			if ($this->Store->save($this->request->data)) {
128
			if ($this->Store->save($this->request->data)) {
Line 141... Line 145...
141
 * @throws NotFoundException
145
 * @throws NotFoundException
142
 * @param string $id
146
 * @param string $id
143
 * @return void
147
 * @return void
144
 */
148
 */
145
	public function delete($id = null) {
149
	public function delete($id = null) {
-
 
150
		throw new NotFoundException(__('Unauthorized access'));
146
		$this->Store->id = $id;
151
		$this->Store->id = $id;
147
		if (!$this->Store->exists()) {
152
		if (!$this->Store->exists()) {
148
			throw new NotFoundException(__('Invalid store'));
153
			throw new NotFoundException(__('Invalid store'));
149
		}
154
		}
150
		$this->request->onlyAllow('post', 'delete');
155
		$this->request->onlyAllow('post', 'delete');
Line 160... Line 165...
160
 * admin_index method
165
 * admin_index method
161
 *
166
 *
162
 * @return void
167
 * @return void
163
 */
168
 */
164
	public function admin_index() {
169
	public function admin_index() {
-
 
170
		throw new NotFoundException(__('Unauthorized access'));
165
		$this->Store->recursive = 0;
171
		$this->Store->recursive = 0;
166
		$this->set('stores', $this->Paginator->paginate());
172
		$this->set('stores', $this->Paginator->paginate());
167
	}
173
	}
168
 
174
 
169
/**
175
/**
Line 172... Line 178...
172
 * @throws NotFoundException
178
 * @throws NotFoundException
173
 * @param string $id
179
 * @param string $id
174
 * @return void
180
 * @return void
175
 */
181
 */
176
	public function admin_view($id = null) {
182
	public function admin_view($id = null) {
-
 
183
		throw new NotFoundException(__('Unauthorized access'));
177
		if (!$this->Store->exists($id)) {
184
		if (!$this->Store->exists($id)) {
178
			throw new NotFoundException(__('Invalid store'));
185
			throw new NotFoundException(__('Invalid store'));
179
		}
186
		}
180
		$options = array('conditions' => array('Store.' . $this->Store->primaryKey => $id));
187
		$options = array('conditions' => array('Store.' . $this->Store->primaryKey => $id));
181
		$this->set('store', $this->Store->find('first', $options));
188
		$this->set('store', $this->Store->find('first', $options));
Line 185... Line 192...
185
 * admin_add method
192
 * admin_add method
186
 *
193
 *
187
 * @return void
194
 * @return void
188
 */
195
 */
189
	public function admin_add() {
196
	public function admin_add() {
-
 
197
		throw new NotFoundException(__('Unauthorized access'));
190
		if ($this->request->is('post')) {
198
		if ($this->request->is('post')) {
191
			$this->Store->create();
199
			$this->Store->create();
192
			if ($this->Store->save($this->request->data)) {
200
			if ($this->Store->save($this->request->data)) {
193
				$this->Session->setFlash(__('The store has been saved.'));
201
				$this->Session->setFlash(__('The store has been saved.'));
194
				return $this->redirect(array('action' => 'index'));
202
				return $this->redirect(array('action' => 'index'));
Line 207... Line 215...
207
 * @throws NotFoundException
215
 * @throws NotFoundException
208
 * @param string $id
216
 * @param string $id
209
 * @return void
217
 * @return void
210
 */
218
 */
211
	public function admin_edit($id = null) {
219
	public function admin_edit($id = null) {
-
 
220
		throw new NotFoundException(__('Unauthorized access'));
212
		if (!$this->Store->exists($id)) {
221
		if (!$this->Store->exists($id)) {
213
			throw new NotFoundException(__('Invalid store'));
222
			throw new NotFoundException(__('Invalid store'));
214
		}
223
		}
215
		if ($this->request->is(array('post', 'put'))) {
224
		if ($this->request->is(array('post', 'put'))) {
216
			if ($this->Store->save($this->request->data)) {
225
			if ($this->Store->save($this->request->data)) {
Line 234... Line 243...
234
 * @throws NotFoundException
243
 * @throws NotFoundException
235
 * @param string $id
244
 * @param string $id
236
 * @return void
245
 * @return void
237
 */
246
 */
238
	public function admin_delete($id = null) {
247
	public function admin_delete($id = null) {
-
 
248
		throw new NotFoundException(__('Unauthorized access'));
239
		$this->Store->id = $id;
249
		$this->Store->id = $id;
240
		if (!$this->Store->exists()) {
250
		if (!$this->Store->exists()) {
241
			throw new NotFoundException(__('Invalid store'));
251
			throw new NotFoundException(__('Invalid store'));
242
		}
252
		}
243
		$this->request->onlyAllow('post', 'delete');
253
		$this->request->onlyAllow('post', 'delete');
Line 245... Line 255...
245
			$this->Session->setFlash(__('The store has been deleted.'));
255
			$this->Session->setFlash(__('The store has been deleted.'));
246
		} else {
256
		} else {
247
			$this->Session->setFlash(__('The store could not be deleted. Please, try again.'));
257
			$this->Session->setFlash(__('The store could not be deleted. Please, try again.'));
248
		}
258
		}
249
		return $this->redirect(array('action' => 'index'));
259
		return $this->redirect(array('action' => 'index'));
250
	}}
260
	}
-
 
261
}