public function editAction() { $request = $this->getRequest(); $userId = $request->getParam('user_id'); $user = Modules_Core_Services_User::getById($userId); if (null == $user) { throw new Exception(); } /** * Hide user password */ $user['password'] = null; $this->view->userData = $user; $roles = Modules_Core_Services_Role::getAllRoles(); $this->view->roles = $roles; if ($request->isPost()) { $userData = $request->getPost('user'); $userData = Modules_Core_Services_User::validate($userData); /** * Check user exist */ if ($userData['username'] && Modules_Core_Services_User::getByUsername($userData['username'], $userId)) { $userData['messages_error'] = true; $userData['messages']['username'] = '******'; } /** * Check user exist */ if ($userData['email'] && Modules_Core_Services_User::getByEmail($userData['email'], $userId)) { $userData['messages_error'] = true; $userData['messages']['email'] = 'user_email_exist'; } if (isset($userData['messages_error']) && $userData['messages_error']) { $this->view->errorMessages = $userData['messages']; $userData['user_id'] = $userId; $this->view->userData = $userData; return; } $salt = $user['salt']; $user = array('user_id' => $userId, 'username' => $userData['username'], 'password' => md5(md5($userData['password']) . $salt), 'email' => $this->view->STRING->escape($userData['email']), 'fullname' => $this->view->STRING->escape($userData['fullname']), 'salt' => $salt, 'status' => $this->view->STRING->escape($userData['status']), 'role_id' => $userData['role_id']); Modules_Core_Services_User::update($user); Gio_Core_Messenger::getInstance()->addMessage($this->view->TRANSLATOR->translator('user_actions_edit_success')); $this->redirect($this->view->url('core_user_edit', $user)); } }