Subversion Repositories SmartDukaan

Rev

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

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