public function action_submit($param = null) { $user = $this->user; $data = $this->model; // echo "<pre>";var_dump($user);exit; $username = get($data, 'username'); $password = get($data, 'password'); $role = get($data, 'role', false); $realName = get($data, 'realName'); // Is the user being saved the logged-in user? $isSelf = $user->idField() == $this->session->user()->idField(); // If the user active checkbox is not shown, $active is always true. $showActive = !$isSelf && $this->adminSettings->enableUsersDisabling(); $active = get($data, 'active', !$showActive); if ($username == '') { throw new ValidationException(ValidationException::REQUIRED_FIELD, '$LOGIN_USERNAME'); } if ($password == self::DUMMY_PASS) { $password = ''; } if ($password == '') { if (!$user->exists) { throw new ValidationException(ValidationException::REQUIRED_FIELD, '$LOGIN_PASSWORD'); } // Do not change the password if the user already exists and the password field was not modified (or left empty) // on the form. } else { $user->passwordField($password); } // Check if the username has been changed if ($username != $user->usernameField()) { $tmp = clone $user; if ($tmp->findByName($username)) { throw new ValidationException(ValidationException::DUPLICATE_RECORD, '$LOGIN_USERNAME'); } $user->usernameField($username); } $user->activeField($active); $user->roleField($role); $user->realNameField($realName ?: ucfirst($username)); if ($user->save()) { $this->session->flashMessage('$APP_MSG_SAVED'); } if ($isSelf) { return $this->redirection->to($this->session->previousUrl()); } }
function intended($defaultUrl = '', $status = 302) { $this->validate(); $url = $this->session->previousUrl() ?: $this->normalizeUrl($defaultUrl); return $this->to($url, $status); }