Subversion Repositories SmartDukaan

Rev

Rev 13532 | Rev 15013 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 13532 Rev 13698
Line 13... Line 13...
13
 *
13
 *
14
 * @var array
14
 * @var array
15
 */
15
 */
16
	public $components = array('Paginator');
16
	public $components = array('Paginator');
17
 
17
 
-
 
18
	public function beforeFilter() {
-
 
19
		parent::beforeFilter();
-
 
20
		$this->Auth->allow('add');
-
 
21
	}
18
/**
22
/**
19
 * index method
23
 * index method
20
 *
24
 *
21
 * @return void
25
 * @return void
22
 */
26
 */
Line 44... Line 48...
44
 * add method
48
 * add method
45
 *
49
 *
46
 * @return void
50
 * @return void
47
 */
51
 */
48
	public function add() {
52
	public function add() {
-
 
53
		$this->layout = 'ajax';
-
 
54
		$this->response->type('json');
-
 
55
		$this->log(print_r($this->request->data,1),'gcm');
49
		if ($this->request->is('post')) {
56
		if ($this->request->is('post')) {
50
			$this->GcmUser->create();
57
			$this->GcmUser->create();
51
			if ($this->GcmUser->save($this->request->data)) {
58
			if ($this->GcmUser->save($this->request->data)) {
-
 
59
				$result = array('success'=>true);
52
				$this->Session->setFlash(__('The gcm user has been saved.'));
60
//				$this->Session->setFlash(__('The gcm user has been saved.'));
53
				return $this->redirect(array('action' => 'index'));
61
//				return $this->redirect(array('action' => 'index'));
54
			} else {
62
			} else {
-
 
63
				$result = array('success'=>false);
55
				$this->Session->setFlash(__('The gcm user could not be saved. Please, try again.'));
64
//				$this->Session->setFlash(__('The gcm user could not be saved. Please, try again.'));
56
			}
65
			}
57
		}
66
		}
-
 
67
		$this->set(array(
-
 
68
		    'result' => $result,
58
		$users = $this->GcmUser->User->find('list');
69
		    '_serialize' => array('result')
-
 
70
		));		
59
		$this->set(compact('users'));
71
		$this->render('/Elements/json');
60
	}
72
	}
61
 
73
 
62
/**
74
/**
63
 * edit method
75
 * edit method
64
 *
76
 *
Line 79... Line 91...
79
			}
91
			}
80
		} else {
92
		} else {
81
			$options = array('conditions' => array('GcmUser.' . $this->GcmUser->primaryKey => $id));
93
			$options = array('conditions' => array('GcmUser.' . $this->GcmUser->primaryKey => $id));
82
			$this->request->data = $this->GcmUser->find('first', $options);
94
			$this->request->data = $this->GcmUser->find('first', $options);
83
		}
95
		}
84
		$users = $this->GcmUser->User->find('list');
-
 
85
		$this->set(compact('users'));
-
 
86
	}
96
	}
87
 
97
 
88
/**
98
/**
89
 * delete method
99
 * delete method
90
 *
100
 *
Line 144... Line 154...
144
				return $this->redirect(array('action' => 'index'));
154
				return $this->redirect(array('action' => 'index'));
145
			} else {
155
			} else {
146
				$this->Session->setFlash(__('The gcm user could not be saved. Please, try again.'));
156
				$this->Session->setFlash(__('The gcm user could not be saved. Please, try again.'));
147
			}
157
			}
148
		}
158
		}
149
		$users = $this->GcmUser->User->find('list');
-
 
150
		$this->set(compact('users'));
-
 
151
	}
159
	}
152
 
160
 
153
/**
161
/**
154
 * admin_edit method
162
 * admin_edit method
155
 *
163
 *
Line 170... Line 178...
170
			}
178
			}
171
		} else {
179
		} else {
172
			$options = array('conditions' => array('GcmUser.' . $this->GcmUser->primaryKey => $id));
180
			$options = array('conditions' => array('GcmUser.' . $this->GcmUser->primaryKey => $id));
173
			$this->request->data = $this->GcmUser->find('first', $options);
181
			$this->request->data = $this->GcmUser->find('first', $options);
174
		}
182
		}
175
		$users = $this->GcmUser->User->find('list');
-
 
176
		$this->set(compact('users'));
-
 
177
	}
183
	}
178
 
184
 
179
/**
185
/**
180
 * admin_delete method
186
 * admin_delete method
181
 *
187
 *