Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function admin_index() {
- $this->layout = 'admin';
- $this->User->recursive = 0;
- $this->set('users', $this->paginate());
- }
- function admin_edit($id = null) {
- $this->layout = 'admin';
- if (!$id && empty($this->data)) {
- $this->Session->setFlash(__('Invalid user', true));
- $this->redirect(array('action' => 'index'));
- }
- if (!empty($this->data)) {
- if ($this->User->save($this->data)) {
- debug($this->data);exit();
- if($this->data['User']['password'] == $this->Auth->password($this->data['User']['password_confirm'])){
- $this->User->saveField('role', 'admin');
- $this->redirect(array('action' => 'index'));
- }
- } else {
- $this->Session->setFlash(__('The user could not be saved. Please, try again.', true));
- }
- }
- if (empty($this->data)) {
- $this->data = $this->User->read(null, $id);
- }
- }
- function admin_add() {
- $this->layout = 'admin';
- if (!empty($this->data)){
- if ($this->User->save($this->data)) {
- if($this->data['User']['password'] == $this->Auth->password($this->data['User']['password_confirm'])){
- $this->User->saveField('role', 'admin');
- $this->redirect(array('action' => 'index'));
- }
- }
- }
- }
- function admin_delete($id = null) {
- if (!$id) {
- $this->Session->setFlash(__('Invalid id for user', true));
- $this->redirect(array('action'=>'index'));
- }
- if ($this->User->delete($id)) {
- $this->Session->setFlash(__('User deleted', true));
- $this->redirect(array('action'=>'index'));
- }
- $this->Session->setFlash(__('User was not deleted', true));
- $this->redirect(array('action' => 'index'));
- }
Add Comment
Please, Sign In to add comment