From 0374c1c9b64116ab619e03bdc589ed507aa8c56d Mon Sep 17 00:00:00 2001 From: Andrzej Dereszowski Date: Mon, 2 Apr 2012 17:21:17 +0200 Subject: [PATCH] Bug fixes in the admin view - password changing for other users - corrected admin_view --- app/Controller/UsersController.php | 14 ++++++++++++-- app/View/Users/admin_view.ctp | 17 ++++++----------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/app/Controller/UsersController.php b/app/Controller/UsersController.php index f34659fb0..d6fdd0e02 100644 --- a/app/Controller/UsersController.php +++ b/app/Controller/UsersController.php @@ -180,14 +180,24 @@ class UsersController extends AppController { throw new NotFoundException(__('Invalid user')); } if ($this->request->is('post') || $this->request->is('put')) { - if ($this->User->save($this->request->data)) { + $fields = array(); + foreach (array_keys($this->request->data['User']) as $field) { + if($field != 'password') array_push($fields, $field); + } + if ("" != $this->request->data['User']['password']) + $fields[] = 'password'; + if ($this->User->save($this->request->data, true, $fields)) { $this->Session->setFlash(__('The user has been saved')); $this->redirect(array('action' => 'index')); } else { $this->Session->setFlash(__('The user could not be saved. Please, try again.')); } } else { - $this->request->data = $this->User->read(null, $id); + $this->User->recursive=0; + $this->User->read(null, $id); + $this->User->set('password', ''); + $this->request->data = $this->User->data; + } } diff --git a/app/View/Users/admin_view.ctp b/app/View/Users/admin_view.ctp index c72d7b4d6..4f9aa6798 100644 --- a/app/View/Users/admin_view.ctp +++ b/app/View/Users/admin_view.ctp @@ -40,10 +40,12 @@  
-
- -   -
+ +
+ +   +
+
@@ -109,11 +111,4 @@ -
-
    -
  • Form->postLink(__('Delete'), array('action' => 'delete', $this->Form->value('User.id')), null, __('Are you sure you want to delete # %s?', $this->Form->value('User.id'))); ?>
  • -
  •  
  • - element('actions_menu'); ?> -
-