Controller_Admin_Users::action_edit PHP Method

action_edit() public method

Edit user details
public action_edit ( )
    public function action_edit()
    {
        Kohana::$log->add(Kohana::DEBUG, 'Executing Controller_Users::action_edit');
        $this->template->content = View::factory('admin/users/form')->set('legend', __('Modify User'))->set('submit', __('Save'))->bind('user', $this->_resource)->bind('errors', $errors);
        // Bind locally
        $user =& $this->_resource;
        // Restrict promotion (change in role)
        if (!$this->a2->allowed($user, 'promote')) {
            isset($_POST['role']) ? $_POST['role'] = $user->role : NULL;
        }
        // Restrict renaming
        if (!$this->a2->allowed($user, 'rename')) {
            isset($_POST['username']) ? $_POST['username'] = $user->username : NULL;
        }
        // Unset password if not changing it
        if (empty($_POST['password'])) {
            unset($_POST['password']);
            unset($_POST['password_confirm']);
        }
        if ($_POST) {
            $user->values($_POST);
            try {
                $user->update();
                Message::instance()->info('The user, :name, has been modified.', array(':name' => $user->username));
                if (!$this->_internal) {
                    $this->request->redirect($this->request->uri(array('action' => 'list')));
                }
            } catch (Validate_Exception $e) {
                $errors = $e->array->errors('admin');
            }
        }
    }