Updates an existing Users model.
If update is successful, the browser will be redirected to the 'view' page.
@param integer $id
@return mixed
181145
public function actionUpdate($id)
    {
        $roles = ArrayHelper::map(Yii::$app->authManager->getRoles(), 'name', 'description');
        $user_permit = array_keys(Yii::$app->authManager->getRolesByUser($id));
        $user = $this->findUser($id);
        //return $this->render('view', [
        //    'user' => $user,
        //    'roles' => $roles,
        //    'user_permit' => $user_permit,
         //   'moduleName' => Yii::$app->controller->module->id
        //]);


        return $this->render('update', [
            'user' => $user,
            'roles' => $roles,
           'user_permit' => $user_permit,
           'moduleName' => Yii::$app->controller->module->id
        ]);


/*        $user = $this->findUser($id);

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            return $this->redirect(['view', 'id' => $model->id]);
        } else {
            return $this->render('update', [
                'model' => $model,
            ]);
        }

        //роли
        Yii::$app->authManager->revokeAll($user->getId());
        if(Yii::$app->request->post('roles')){
            foreach(Yii::$app->request->post('roles') as $role)
            {
                $new_role = Yii::$app->authManager->getRole($role);
                Yii::$app->authManager->assign($new_role, $user->getId());
            }
        }
        return $this->redirect(Url::to(["/".Yii::$app->controller->module->id."/user/view", 'id' => $user->getId()]));*/
    }
238986
public function update($id)
	{
		$messages = $this->posts->validForUpdate($id, Input::get('title'), Input::get('slug'));

		if (count($messages) > 0)
		{
			return Response::json($messages->all(), 400);
		}

		$post = $this->posts->update(
			$id,
			Input::get('title'),
			Input::get('content'),
			Input::get('slug'),
			explode(',', Input::get('tags')),
			(bool) Input::get('active'),
			(int) Input::get('user_id'),
			Carbon::createFromTimestamp(strtotime(Input::get('publish_date')))
		);

		return (string) $this->posts->find($id);
	}
646525
public function edit($id)
    {
        $record = $this->model->findOrFail($id);

        $this->viewData['record'] = $record;

        $this->viewData['formMethod'] = 'PUT';
        $this->viewData['formAction'] = 'user.update';

        return view($this->defaultFormView, $this->viewData);
    }
521408
public function actionUpdateProfile($id)
    {
        Url::remember('', 'actions-redirect');
        $model = $this->findModel($id);
        $profile = $model->profile;
        if ($profile == null) {
            $profile = Yii::createObject(UserProfile::class);
            $profile->link('user', $model);
        }
        if (Yii::$app->request->isAjax && $profile->load(Yii::$app->request->post())) {
            Yii::$app->response->format = Response::FORMAT_JSON;
            return ActiveForm::validate($profile);
        }
        if ($profile->load(Yii::$app->request->post()) && $profile->save()) {
            Yii::$app->getSession()->setFlash('success', Yii::t('yuncms', 'Profile details have been updated'));
            return $this->refresh();
        }

        return $this->render('_profile', [
            'model' => $model,
            'profile' => $profile,
        ]);
    }
1335941
public function actionUpdate($id)
    {
        $model = $this->findModel($id);
        if (!\Yii::$app->user->can('update'))
            return $this->alert(Module::t('core', 'Access denied.'));

        $this->_tag = $model->name;
        
        if ($model->load(\Yii::$app->request->post()) && $model->save()) {
            // replace all tags in all posts
            \Yii::$app->db->createCommand("UPDATE {{%post}} SET tags = REPLACE(tags, '{$this->_tag}', '{$model->name}') WHERE tags LIKE '%{$this->_tag}%'")
                ->execute();
            return YII_DEBUG 
                ? $this->redirect(['index'])
                : $this->redirect(\Yii::$app->request->referrer);
        } else {
            return $this->renderAjax('update', [
                'model' => $model,
            ]);
        }
    }
553385
public function actionUpdate($id)
    {
        $model = $this->findModel($id);

        // if the model has an anonymousUsername value
        // we will consider it as an anonymous message
        if (!is_null($model->anonymousUsername))
        {
            $model->scenario = $model::SCENARIO_ANONYMOUS;
        }


        if ($model->load(Yii::$app->request->post()) && $model->save())
        {
            Yii::$app->session->setFlash('success', Yii::t('app', 'Comment has been saved.'));

            return $this->redirect(['index']);
        }

        return $this->render($this->updateView, [
            'model' => $model,
        ]);

    }
1173890
public function update(UserUpdateRequest $request, $id)
    {
        $input = $request->except('roles');

        if ($request->has('password')) {
            $input['password'] = bcrypt($request->password);
        } else {
            unset($input['password']);
        }

        $record = $this->model->findOrFail($id);

        if ($request->has('roles')) {
            $record->syncRoles($request->roles);
        }

        $record->update($input);

        $this->notify([
            'type' => 'success',
            'title' => 'Successful update!',
            'description' => 'This user is updated successfully.',
        ]);

        return redirect()->back();
    }
1161226
public function update($id)
	{
		$messages = $this->users->validForUpdate(
			$id,
			Input::get('first_name'),
			Input::get('last_name'),
			Input::get('email'),
			Input::get('password')
		);

		if (count($messages) > 0)
		{
			return Response::json($messages->all(), 400);
		}

		return $this->users->update(
			$id,
			Input::get('first_name'),
			Input::get('last_name'),
			Input::get('email'),
			(bool) Input::get('active'),
			Input::get('password')
		);
	}
1240833
public function actionUpdate($id) {
    Url::remember('', 'actions-redirect');
    $user = $this->findModel($id);
    $user->scenario = User::SCENARIO_UPDATE;
    $event = $this->getUserEvent($user);
    $this->performAjaxValidation($user);

    $this->trigger(self::EVENT_BEFORE_UPDATE, $event);
    if ($user->load(Yii::$app->request->post()) && $user->save()) {
      Yii::$app->getSession()->setFlash('success', Yii::t('users', 'Account details have been updated'));
      $this->trigger(self::EVENT_AFTER_UPDATE, $event);
      return $this->refresh();
    }

    return $this->render('_account', [
      'user' => $user,
    ]);
  }
568600
public function actionUpdate($id)
    {
        $emailTemplate = $this->loadModel($id);

        if (isset($_POST['EmailTemplate'])) {
            $emailTemplate->attributes = $_POST['EmailTemplate'];
            if ($emailTemplate->save()) {
                $this->redirect(array('template/view', 'id' => $emailTemplate->id));
            }
        }

        $this->render('update', array(
            'emailTemplate' => $emailTemplate,
        ));
    }
806405
public function actionDelete($id)
    {
        if (Yii::$app->request->isPost) {
            $this->findModel($id)->delete();
        }
        return $this->redirect(['index']);
    }
1288946
public function actionUpdate($id)
    {
        $model = $this->findModel($id);
        $oldSubmodulesParentUid = $model->parent_uid . '/{' . $model->id . '}';

        $post = Yii::$app->request->post();
        $loaded = $model->load($post);
        if ($loaded && $model->save()) {
            $newSubmodulesParentUid = $model->parent_uid . '/{' . $model->id . '}';
            $model->correctParents($oldSubmodulesParentUid, $newSubmodulesParentUid);

            //return $this->redirect(['view', 'id' => $model->id]);
            return $this->redirect(['index', 'id' => $model->id]);
        } else {
            return $this->render('update', [
                'model' => $model,
            ]);
        }
    }
88008
public function update($id = null): Model
	{
		$instance = $this->read($id);
		$this->fill($instance);

		return $this->read($instance->getKey());
	}
633152
public function actionUpdateProfile($id) {
    Url::remember('', 'actions-redirect');
    $user = $this->findModel($id);
    $profile = $user->profile;

    if ($profile == null) {
      $profile = new Profile();
      $profile->link('user', $user);
    }
    $event = $this->getProfileEvent($profile);

    $this->performAjaxValidation($profile);

    $this->trigger(self::EVENT_BEFORE_PROFILE_UPDATE, $event);

    if ($profile->load(Yii::$app->request->post()) && $profile->save()) {
      Yii::$app->getSession()->setFlash('success', Yii::t('users', 'Profile details have been updated'));
      $this->trigger(self::EVENT_AFTER_PROFILE_UPDATE, $event);
      return $this->refresh();
    }

    return $this->render('_profile', [
      'user' => $user,
      'profile' => $profile,
    ]);
  }
348863
public function actionUpdate($id)
    {
        $model = $this->findModel($id);

        // check permissions
        if (!Yii::$app->user->can('roleContentModerator') // user is not moderator
         &&  Yii::$app->user->can('roleContentAuthor')    // but is author ...
         && !Yii::$app->user->can('updateOwnContent', [   // ... can edit only own article
                'content' => $model,                      //     - if article unvisible - always can
                'canEditVisible'                          //     - but if not visible - see this param
                    => $this->canAuthorEditOwnVisibleArticle,
            ])
        ) {
            if ($this->canAuthorEditOwnVisibleArticle) {
                throw new ForbiddenHttpException(Yii::t($this->tcModule, 'You can update only your own article'));
            } else {
                throw new ForbiddenHttpException(Yii::t($this->tcModule, 'You can update only your own article still unvisible'));
            }
        }

        $post = Yii::$app->request->post();
        $loaded = $model->load($post);

        $attributes = $model->attributes;
        if (!$this->canAuthorEditOwnVisibleArticle) unset($attributes['is_visible']);
        $attributeNames = array_keys($attributes);

        if ($loaded && $model->save(true, $attributeNames)) {
            if ($model->aftersave != $model::AFTERSAVE_LIST) {
                return $this->redirect(['view', 'id' => $model->id]);
            } else {
                $model->orderBy = $model::$defaultOrderBy;
                $model->page = $model->calcPage($model::find()->where(['parent_id' => $model->parent_id]));
                return $this->redirect(['index',
                    'parent' => $model->parent_id,
                    'page'   => $model->page,
                    'id'     => $model->id,
                    'sort'   => $model->orderByToSort(),
                ]);
            }
        } else {
            return $this->render('update', compact('model'));
        }
    }
1210143
public function update($id)
    {
        $content = $this->repository->getById($id);
        if (!empty($content)) {
            $this->authorize('update', $content);
            $input   = $this->validator->validate('update');
            $content = $this->repository->update($content, $input, auth()->user());
            return $this->respondWithSuccess($content, new ContentTransformer);
        }
        return $this->respondNotFound();
    }
866508
public function getPostUpdateUser($id)
    {
        $loggedInUser = $this->userService->getCurrentLoggedInUser();

        if (!$loggedInUser) {
            $this->response->redirect("user/login");
            return false;
        }

        if ($loggedInUser->id != $id) {
            if (!$loggedInUser->administrator) {
                $this->response->redirect("");
            }
        }

        $title      = "Uppdatera användaren";
        $form       = new UpdateUserForm($this->di, $id);

        $form->check();

        $data = [
            "content" => $form->getHTML(),
        ];

        $this->view->add("default2/article", $data);

        $this->pageRender->renderPage(["title" => $title]);
    }