User update form processing page.

@param  int      $id
@return Redirect
17529
public function postAdminEdit($id = null)
    {
        // Get the user information
        $user = Sentinel::findById($id);

        if ($user == null)
        {
            // Prepare the error message
            $error = Lang::get('base.auth.not_found');

            // Redirect to the user management page
            return Redirect::route('admin.users.show')->with('error', $error);
        }

        $this->validationRulesAdmin['email'] = "required|email|unique:User,email,{$user->email},email,status,3|max:255";
        $this->validationRulesAdmin['username'] = "required|min:3|unique:User,username,{$user->username},username|max:25";

        // Do we want to update the user password?
        if (!$password = Input::get('password')) {
            unset($this->validationRulesAdmin['password']);
            unset($this->validationRulesAdmin['password_confirm']);
        }

        // Create a new validator instance from our validation rules
        $validator = Validator::make(Input::all(), $this->validationRulesAdmin);

        // If validation fails, we'll exit the operation now.
        if ($validator->fails()) {
            // Ooops.. something went wrong
            return Redirect::back()->withInput()->withErrors($validator);
        }

        try {
            // Update the user
            $user->gender   = Input::get('gender');
            $user->first_name  = Input::get('first_name');
            $user->last_name   = Input::get('last_name');
            $user->username    = Input::get('username');
            $user->email       = Input::get('email');
            $user->description = Input::get('description');

            if (Input::get('force_new_password'))
                $user->force_new_password = 1;
            else
                $user->force_new_password = 0;

            if (Input::get('birthday') != null)
                $user->birthday = \Carbon\Carbon::createFromFormat('d/m/Y', Input::get('birthday'));

            $password_changed = false;

            // Do we want to update the user password?
            if ($password)
            {
                $user->password = Hash::make($password);
                $password_changed = true;
            }

            // is new image uploaded?
            if ($file = Input::file('pic'))
            {
                $fileName        = $file->getClientOriginalName();
                $extension       = $file->getClientOriginalExtension() ?: 'png';

                if ($extension == 'png' || $extension == 'PNG' || $extension == 'JGP' || $extension == 'jpg' || $extension == 'gif')
                {
                    $folderName      = '/uploads/users/';
                    $destinationPath = public_path() . $folderName;
                    $safeName        = str_random(10).'.'.$extension;
                    $file->move($destinationPath, $safeName);

                    //delete old pic if exists
                    if(File::exists(public_path() . $folderName . $user->pic))
                        File::delete(public_path() . $folderName . $user->pic);

                    //save new file path into db
                    $user->pic   = $safeName;
                }
            }

            /*
            // Get the current user groups
            $userRoles = $user->roles()->lists('id')->all();

            // Get the selected groups
            $selectedRoles = Input::get('groups', array());

            // Groups comparison between the groups the user currently
            // have and the groups the user wish to have.
            $rolesToAdd    = array_diff($selectedRoles, $userRoles);
            $rolesToRemove = array_diff($userRoles, $selectedRoles);

            // Assign the user to groups
            foreach ($rolesToAdd as $roleId) {
                $role = Sentinel::findRoleById($roleId);

                $role->users()->attach($user);
            }

            // Remove the user from groups
            foreach ($rolesToRemove as $roleId) {
                $role = Sentinel::findRoleById($roleId);

                $role->users()->detach($user);
            }
            */

            // Activate / De-activate user
            $status = $activation = Activation::completed($user);
            $currentStatus = Input::get('status');

            if($currentStatus != $status)
            {
                if ($currentStatus == 0)
                    // Remove existing activation record
                    Activation::remove($user);
                else
                {
                    $activation = Activation::exists($user);

                    if (!$activation)
                    {
                        Activation::create($user);

                        $activation = Activation::exists($user);
                    }

                    if($activation)
                        Activation::complete($user, $activation->code);
                }

                $user->status = $currentStatus;
            }
            else
                $user->status = $currentStatus;

            // Was the user updated?
            if ($user->save())
            {
                if ($password_changed && Input::get('send_new_password_email'))
                {
                    Mail::queue('emails.account.password-changed-by-admin', [ 'user' => $user, 'new_password' => $password ], function ($m) use ($user) {
                        $m->to($user->email, $user->first_name . ' ' . $user->last_name);
                        $m->subject(Lang::get('base.mails.password_changed'));
                    });
                }

                if ($password_changed)
                    Base::TargettedLog($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') password was changed by an admin. ', $user->id);

                Base::TargettedLog($user->username . ' (' . $user->first_name . ' ' . $user->last_name . ') profile was changed by an admin. ', $user->id);

                // Prepare the success message
                $success = Lang::get('base.auth.user_changed');

                // Redirect to the user page
                return Redirect::route('users.update', $id)->with('success', $success);
            }

        } catch (Exception $e) {
        }
        $error = Lang::get('base.base.error');

        // Redirect to the user page
        return Redirect::route('users.update', $id)->withInput()->with('error', $error);
    }
203441
public function actionDelete($id)
    {
        $this->findModel($id)->delete();
        Helper::invalidate();

        return $this->redirect(['index']);
    }
889465
public function update($id)
    {
        // Get the model instance
        $item = $this->findOrFail($id);

        // Remove nested model data from input and prepare to insert on save
        $input = (new NestedModels)->relateTo($item);

        // Hydrate for drag-and-drop sorting
        if (Request::ajax()
            && ($position = new Position($item, $this->self_to_parent))
            && $position->has()) {
            $position->fill();
        }

        // ... else hydrate normally
        else {
            $item->fill($input);
            if (isset($item::$rules['slug'])) {
                $pattern = '#(unique:\w+)(,slug)?(,(NULL|\d+))?#';
                $item::$rules['slug'] = preg_replace($pattern, '$1,slug,'.$id, $item::$rules['slug']);
            }
        }

        // Save the record
        $this->validate($item);
        $item->save();

        // Redirect to the edit view
        if (Request::ajax()) {
            return Response::json();
        } else {
            return Redirect::to(URL::current())
            ->with('success', $this->successMessage($item));
        }
    }
376614
public function update(Request $request, $id)
    {
        $this->validate(request(), [
            'name' => 'required|min:3|max:15',
            'email' => 'required|email',
            'password' => 'required|min:4'
        ]);

        $user = Admin::find($id);
        $user->name = request('name');
        $user->email = request('email');
        $user->password = bcrypt(request('password'));
        $user->save();

        session()->flash('success', 'Usuario actualizado con éxito!');
        return redirect()->route('usuarios.index');
    }
476140
public function actionUpdate($id)
    {
        $model = $this->findModel($id);
        if (!empty($this->module->params['pageSizeAdmin'])) {
            $model->pageSize = intval($this->module->params['pageSizeAdmin']);
        }
        $post = Yii::$app->request->post();
        if ($model->load($post) && $model->save()) {
            return $this->redirect(['index', 'page' => $model->page, 'id' => $model->id]);
        } else {
            $rolesModels = [];
            if ($this->showRoles && !$model->isNewRecord) {
                $authItemModel = $this->module->model('AuthItem');
                $allRoles = $authItemModel::find()->where(['like', 'name', 'role'])->all();
                foreach ($allRoles as $role) {
                    $data = [
                        'item_name' => $role->name,
                        'user_id'   => $model->id,
                    ];
                    
                    $authAssignmentModel = $this->module->model('AuthAssignment');
                    $next = $authAssignmentModel::find()->where($data)->one();
                    if (empty($next)) {
                        $data['value'] = false;
                        $next = $this->module->model('AuthAssignment', [$data]);
                    } else {
                        $next->value = true;
                    }
                    $rolesModels[] = $next;
                }
            }
            return $this->render('update', [
                'model' => $model,
                'rolesModels' => $rolesModels,
            ]);
        }
    }
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,
        ));
    }
264682
public function actionUpdate($id)
    {
        $this->layout = static::FORM_LAYOUT;
        $model = $this->findModel($id);

        if ($model->load(Yii::$app->request->post()) && $model->validate()) {
            $current_model = $this->findModel($id);
            if($current_model->Menu_id != $model->Menu_id){
                if($model->Menu_id) {
                    $parent_node = Menu::findOne($model->Menu_id);
                    $model->appendTo($parent_node);
                } else {
                    $model->makeRoot();
                }
            } else {
                $model->save(false);
            }

            $this->saveHistory($model, $this->historyField);
            return $this->redirect(['index']);
        } else {
            return $this->render('update', [
                'model' => $model,
            ]);
        }
    }
858354
public function update(Request $request, $id)
    {
        $this->validate($request, ['name' => 'required']);

        $permission = Permission::findOrFail($id);
        $permission->update($request->all());

        return redirect('admin/permissions')->with('flash_message', 'Permission updated!');
    }
1134711
public function update(Request $request, $id)
    {
        $this->validate(
            $request,
            [
                'name' => 'required',
                'email' => 'required|string|max:255|email|unique:users,email,' . $id,
                'roles' => 'required'
            ]
        );

        $data = $request->except('password');
        if ($request->has('password')) {
            $data['password'] = bcrypt($request->password);
        }

        $user = User::findOrFail($id);
        $user->update($data);

        $user->roles()->detach();
        foreach ($request->roles as $role) {
            $user->assignRole($role);
        }

        return redirect('admin/users')->with('flash_message', 'User updated!');
    }
30260
public function editAction($id)
    {
        $instance = $this->getManager()->find($id);
        if(!$instance) {
            return new RedirectResponse($this->generateUrl('ringo_php_redmon'));
        }
        $form = $this->getForm($instance);
        return $this->render(
            $this->getTemplatePath().'edit.html.twig',
            array(
                'form' => $form->createView(),
                'id'   => $id,
                'errors' => array()
            )
        );
    }
938922
public function update($id)
    {
        $input = Binput::only(['first_name', 'last_name', 'email']);

        $val = UserRepository::validate($input, array_keys($input));
        if ($val->fails()) {
            return Redirect::route('users.edit', ['users' => $id])
                ->withInput()->withErrors($val->errors());
        }

        $user = UserRepository::find($id);
        $this->checkUser($user);

        $email = $user['email'];

        $user->update($input);

        $groups = GroupRepository::index();

        $changed = false;

        foreach ($groups as $group) {
            if ($user->inGroup($group)) {
                if (Binput::get('group_'.$group->id) !== 'on') {
                    $user->removeGroup($group);
                    $changed = true;
                }
            } else {
                if (Binput::get('group_'.$group->id) === 'on') {
                    $user->addGroup($group);
                    $changed = true;
                }
            }
        }

        if ($email !== $input['email']) {
            $mail = [
                'old'     => $email,
                'new'     => $input['email'],
                'url'     => URL::to(Config::get('credentials.home', '/')),
                'subject' => Config::get('app.name').' - New Email Information',
            ];

            Mail::queue('credentials::emails.newemail', $mail, function ($message) use ($mail) {
                $message->to($mail['old'])->subject($mail['subject']);
            });

            Mail::queue('credentials::emails.newemail', $mail, function ($message) use ($mail) {
                $message->to($mail['new'])->subject($mail['subject']);
            });
        }

        if ($changed) {
            $mail = [
                'url'     => URL::to(Config::get('credentials.home', '/')),
                'email'   => $input['email'],
                'subject' => Config::get('app.name').' - Group Membership Changes',
            ];

            Mail::queue('credentials::emails.groups', $mail, function ($message) use ($mail) {
                $message->to($mail['email'])->subject($mail['subject']);
            });
        }

        return Redirect::route('users.show', ['users' => $user->id])
            ->with('success', 'The user has been updated successfully.');
    }
31031
public function update(Request $request, $id)
    {
        $this->model = $this->model->findOrFail($id);

        $request = $this->processRequest($request);

        if ($request === true) {
            return $this->redirection();
        }

        $this->validate($request, $this->model->rules());

        $this->model->update($request->all());

        $saved = $this->afterSaving($request);

        if ($saved) {
            return $this->redirection();
        }
    }
750310
public function actionUpdate($id)
    {
        if (request()->post('_asnew') == '1') {
            $model = new AuthItem();
        }else{
            $model = $this->findModel($id);
        }

        if ($model->loadAll(request()->post()) && $model->saveAll()) {
            return $this->redirect(['view', 'id' => $model->name]);
        } else {
            return $this->render('update', [
                'model' => $model,
            ]);
        }
    }
64301
public function update($id, $data)
    {
        $routeMatch = $this->getEvent()->getRouteMatch();
        $mode = $routeMatch->getParam('mode', false);
        $type = $routeMatch->getParam('type', false);
        $endpoint = $routeMatch->getParam('endpoint', false);
        $annee = $routeMatch->getParam('annee', 0);
        
        $processStateHandler = $this->getProcessStateHandler();
        $process = $processStateHandler->getProcess($mode, $type, $endpoint, $annee);
        
        if (is_null($process)) {
            $process = $processStateHandler->getDefaultProcess($mode, $type, $endpoint, $annee);
            $processStateHandler->saveProcess($process);
        }
        if (array_key_exists('force-execution-stop', $data)) {
            $process->setInterrupted(true);
        } else {
            $active = array_key_exists('active', $data) && $data['active'] === 'true';
            $process->setActive($active);
            $shedule = $data['shedule'] === 'true' && $data['active'] === 'true';
            $process->setShedule($shedule);
            $process->setCron($shedule ? $data['cron'] : null);
        }
        
        $processStateHandler->saveProcess($process);
        $response = $this->getResponse();
        $response->getHeaders()->addHeaderLine('Content-Type', 'application/json');
        $serializer = $this->getSerializer();
        $processJson = $serializer->serialize($process, 'json');
        $response->setContent($processJson);
        return $response;
    }
434530
public function actionView($id)
    {
        $record = $this->findRecord($id);
        if ($record->lastExec && $record->lastExec->isFailed()) {
            return $this->redirect(['view-attempts', 'id' => $record->id]);
        }
        return $this->redirect(['view-details', 'id' => $record->id]);
    }
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,
        ]);

    }
421490
public function update(AdminUpdateRequest $request, $id)
    {

        $admin = $this->adminRepository->find($id);

        if (!is_null($admin)) {
            $this->adminRepository->update($admin, $request->all());
        }

        return Redirect::route('admin.admin.index');
    }