modify user page
546601
def modify(self, user=None, **params):
        
        self._check_auth(must_admin=True)
        is_admin = self._check_admin()

        if cherrypy.request.method.upper() == 'POST':
            params = self._parse_params(params)
            self._modify(params)
            self._add_notification("User modified")
            try:
                referer = cherrypy.request.headers['Referer']
            except Exception as e:
                referer = '/'
            raise cherrypy.HTTPRedirect(referer)

        graph = {}
        for r in self.roles.graph:
            s = list(self.roles.graph[r]['sub_roles'])
            p = list(self.roles.graph[r]['parent_roles'])
            graph[r] = {'sub_roles': s, 'parent_roles': p}
        graph_js = json.dumps(graph, separators=(',', ':'))
        display_names = {}
        for r in self.roles.flatten:
            display_names[r] = self.roles.flatten[r]['display_name']

        if user is None:
            cherrypy.response.status = 400
            return self.temp['error.tmpl'].render(
                is_admin=is_admin,
                alert='warning',
                message="No user requested"
                )

        user_attrs = self._get_user(user)
        if user_attrs == {}:
            cherrypy.response.status = 400
            return self.temp['error.tmpl'].render(
                is_admin=is_admin,
                alert='warning',
                message="User '" + user + "' does not exist"
                )
        tmp = self._get_roles(user)
        user_roles = tmp['roles']
        standalone_groups = tmp['unusedgroups']
        roles_js = json.dumps(display_names, separators=(',', ':'))
        key = self.attributes.get_key()

        try:
            form = self.temp['form.tmpl'].render(
                attributes=self.attributes.attributes,
                values=user_attrs,
                modify=True,
                keyattr=key,
                autofill=False
                )

            roles = self.temp['roles.tmpl'].render(
                roles=self.roles.flatten,
                graph=self.roles.graph,
                graph_js=graph_js,
                roles_js=roles_js,
                current_roles=user_roles,
            )

            glued_template = self.temp['modify.tmpl'].render(
                form=form,
                roles=roles,
                is_admin=is_admin,
                standalone_groups=standalone_groups,
                backends_display_names=self.backends_display_names,
                custom_js=self.custom_js,
                notifications=self._empty_notification(),
            )
        except NameError:
            raise TemplateRenderError(
                    exceptions.text_error_template().render()
                    )

        return glued_template
805228
function(member) {
            users = $module.data('users');
            if(member !== undefined && member.id !== 'anonymous') {
              delete users[ member.id ];
              $module
                .data('users', users)
              ;
              $userList
                .find('[data-id='+ member.id + ']')
                  .remove()
              ;
              if(settings.partingMessages) {
                $log
                  .append( settings.templates.left(member.info) )
                ;
                module.message.scroll.test();
              }
              module.user.updateCount();
            }
          }
390808
public function edit()
    {
        $id = $this->Auth->user('id');
        $user = $this->Users->find()->where(['id' => $id])->first();
        if (!$user) {
            throw new NotFoundException('User could not be found');
        }
            
        $user->accessible('password', true);
        if ($this->request->is(['post', 'put'])) {
            $user = $this->Users->patchEntity($user, $this->request->data);
            $this->Users->save($user);
        }
        $this->set(compact('user'));
    }
541619
def add_user(self, nick, prefixes=None):
        """"""
        if nick not in self._user_nicks:
            self._user_nicks.append(nick)

        self.prefixes[nick] = prefixes
1196797
protected function changePage($page)
    {
        $this->currentPage = $page;
        $this->manialinkFactory->update($this->manialink->getUserGroup());
    }
454584
public function Edit($UserID) {
      $this->Permission('Garden.Users.Edit');
      
      // Page setup
      $this->AddJsFile('user.js');
      $this->Title(T('Edit User'));
      $this->AddSideMenu('dashboard/user');

      // By default, people with access here can freely assign all roles
      $RoleModel = new RoleModel();
      $RoleData = $AllRoles = $RoleModel->GetArray();

      // Hide personal info roles
      if (!CheckPermission('Garden.PersonalInfo.View')) {
         $RoleData = array_filter($RoleData, 'RoleModel::FilterPersonalInfo');
      }

      $UserModel = new UserModel();
      $User = $UserModel->GetID($UserID, DATASET_TYPE_ARRAY);
      
      // Determine if username can be edited
      $CanEditUsername = (bool)C("Garden.Profile.EditUsernames") || Gdn::Session()->CheckPermission('Garden.Users.Edit');
      $this->SetData('_CanEditUsername', $CanEditUsername);
      
      // Determine if emails can be edited
      $CanEditEmail = (
              Gdn::Session()->CheckPermission('Garden.Users.Edit') && 
              Gdn::Session()->CheckPermission('Garden.PersonalInfo.View')
           );
      $this->SetData('_CanEditEmail', $CanEditEmail);
      
      // Decide if they have ability to confirm users
      $Confirmed = (bool)GetValueR('Confirmed', $User);
      $CanConfirmEmail = (
              UserModel::RequireConfirmEmail() &&
              Gdn::Session()->CheckPermission('Garden.Users.Edit') && 
              Gdn::Session()->CheckPermission('Garden.PersonalInfo.View'));
      $this->SetData('_CanConfirmEmail', $CanConfirmEmail);
      $this->SetData('_EmailConfirmed', $Confirmed);
      $User['ConfirmEmail'] = (int)$Confirmed;

      // Set the model on the form.
      $this->Form->SetModel($UserModel);

      // Make sure the form knows which item we are editing.
      $this->Form->AddHidden('UserID', $UserID);

      try {
         
         $AllowEditing = TRUE;
         $this->EventArguments['AllowEditing'] = &$AllowEditing;
         $this->EventArguments['TargetUser'] = &$User;
         
         // These are all the 'effective' roles for this edit action. This list can
         // be trimmed down from the real list to allow subsets of roles to be
         // edited.
         $this->EventArguments['RoleData'] = &$RoleData;
         
         $UserRoleData = $UserModel->GetRoles($UserID)->ResultArray();
         $RoleIDs = ConsolidateArrayValuesByKey($UserRoleData, 'RoleID');
         $RoleNames = ConsolidateArrayValuesByKey($UserRoleData, 'Name');
         $UserRoleData = ArrayCombine($RoleIDs, $RoleNames);
         $this->EventArguments['UserRoleData'] = &$UserRoleData;
         
         $this->FireEvent("BeforeUserEdit");
         $this->SetData('AllowEditing', $AllowEditing);
         
         $this->Form->SetData($User);
         if ($this->Form->AuthenticatedPostBack()) {
            
            if (!$CanEditUsername)
               $this->Form->SetFormValue("Name", $User['Name']);
            
            // Allow mods to confirm/unconfirm emails
            $this->Form->RemoveFormValue('Confirmed');
            $Confirmation = $this->Form->GetFormValue('ConfirmEmail', null);
            $Confirmation = !is_null($Confirmation) ? (bool)$Confirmation : null;

            if ($CanConfirmEmail && is_bool($Confirmation))
               $this->Form->SetFormValue('Confirmed', (int)$Confirmation);
            
            // If a new password was specified, add it to the form's collection
            $ResetPassword = $this->Form->GetValue('ResetPassword', FALSE);
            $NewPassword = $this->Form->GetValue('NewPassword', '');
            if ($ResetPassword == 'Manual') 
               $this->Form->SetFormValue('Password', $NewPassword);
            
            // Role changes
            
            // These are the new roles the editing user wishes to apply to the target
            // user, adjusted for his ability to affect those roles
            $RequestedRoles = $this->Form->GetFormValue('RoleID');
            
            if (!is_array($RequestedRoles)) $RequestedRoles = array();
            $RequestedRoles = array_flip($RequestedRoles);
            $UserNewRoles = array_intersect_key($RoleData, $RequestedRoles);
            
            // These roles will stay turned on regardless of the form submission contents 
            // because the editing user does not have permission to modify them
            $ImmutableRoles = array_diff_key($AllRoles, $RoleData);
            $UserImmutableRoles = array_intersect_key($ImmutableRoles, $UserRoleData);
            
            // Apply immutable roles
            foreach ($UserImmutableRoles as $IMRoleID => $IMRoleName)
               $UserNewRoles[$IMRoleID] = $IMRoleName;
            
            // Put the data back into the forum object as if the user had submitted 
            // this themselves
            $this->Form->SetFormValue('RoleID', array_keys($UserNewRoles));
            
            if ($this->Form->Save(array('SaveRoles' => TRUE)) !== FALSE) {
               if ($this->Form->GetValue('ResetPassword', '') == 'Auto') {
                  $UserModel->PasswordRequest($User['Email']);
                  $UserModel->SetField($UserID, 'HashMethod', 'Reset'); 
               }

               $this->InformMessage(T('Your changes have been saved.'));
            }
            
            $UserRoleData = $UserNewRoles;
         }
      } catch (Exception $Ex) {
         $this->Form->AddError($Ex);
      }
      
      $this->SetData('User', $User);
      $this->SetData('Roles', $RoleData);
      $this->SetData('UserRoles', $UserRoleData);
      
      $this->Render();
   }
718623
def put(self, user_id):
        """"""
        self.reqparse.add_argument('roles', type=str, action='append')
        args = self.reqparse.parse_args()
        auditlog(event='user.create', actor=session['user'].username, data=args)

        user = db.User.find_one(User.user_id == user_id)
        roles = db.Role.find(Role.name.in_(args['roles']))
        if not user:
            return self.make_response('No such user found: {}'.format(user_id), HTTP.NOT_FOUND)

        if user.username == 'admin' and user.auth_system == 'builtin':
            return self.make_response('You cannot modify the built-in admin user', HTTP.FORBIDDEN)

        user.roles = []
        for role in roles:
            if role in args['roles']:
                user.roles.append(role)

        db.session.add(user)
        db.session.commit()

        return self.make_response({'message': 'User roles updated'}, HTTP.OK)
1037456
def setup_user_page(self, ):
        
        self.user_prj_tablev.horizontalHeader().setResizeMode(QtGui.QHeaderView.ResizeToContents)
        self.user_task_treev.header().setResizeMode(QtGui.QHeaderView.ResizeToContents)
249176
def to_modify(self, uid):
        '''
        
        '''

        kwd = {
            'pager': '',

        }
        self.render('wiki_page/page_edit.html',
                    postinfo=MWiki.get_by_uid(uid),
                    kwd=kwd,
                    cfg=CMS_CFG,
                    userinfo=self.userinfo)
1172789
def change_view(self, request, object_id, extra_context=None):
        """"""
        language = get_language_from_request(request)
        extra_context = {
            'language': language,
            # don't see where it's used
            #'lang': current_lang,
            'page_languages': settings.PAGE_LANGUAGES,
        }
        try:
            int(object_id)
        except ValueError:
            raise Http404('The "%s" part of the location is invalid.'
                % str(object_id))
        try:
            obj = self.model.objects.get(pk=object_id)
        except self.model.DoesNotExist:
            # Don't raise Http404 just yet, because we haven't checked
            # permissions yet. We don't want an unauthenticated user to be able
            # to determine whether a given object exists.
            obj = None
        else:
            template = get_template_from_request(request, obj)
            extra_context['placeholders'] = get_placeholders(template)
            extra_context['traduction_languages'] = [l for l in
                settings.PAGE_LANGUAGES if Content.objects.get_content(obj,
                                    l[0], "title") and l[0] != language]
        extra_context['page'] = obj
        return super(PageAdmin, self).change_view(request, object_id,
                                                        extra_context=extra_context)
355025
def update
      if @user.update_attributes(permitted_params.user.merge({:password_required => true}))
        redirect_to new_session_url, :notice => t(:signed_up_successfully)
      else
        render :action => 'edit'
      end
    end
445902
def expand_user(path, user=None):
    """"""

    def _replace(m):
        m_user = m.group(1) or user
        return pwd.getpwnam(m_user).pw_dir if m_user else pwd.getpwuid(os.getuid()).pw_dir

    return re.sub(r'~(\w*)', _replace, path)
115900
def modify(self, **params):
        """"""
        data = self.api_client.update_account(self.id, **params)
        self.update(data)
        return data
1116359
def modify_profile_request_view(request, request_pk):
    '''  '''
    page_name = "Admin - Profile Request"
    profile_request = get_object_or_404(ProfileRequest, pk=request_pk)
    mod_form = ModifyProfileRequestForm(
        request.POST if "add_user" in request.POST else None,
        instance=profile_request,
        )
    addendum = ""
    if 'delete_request' in request.POST:
        if settings.SEND_EMAILS and (profile_request.email not in settings.EMAIL_BLACKLIST):
            deletion_subject = DELETION_SUBJECT.format(house=settings.HOUSE_NAME)
            deletion_email = DELETION_EMAIL.format(house=settings.HOUSE_NAME, full_name=profile_request.first_name + " " + profile_request.last_name,
                admin_name=settings.ADMINS[0][0], admin_email=settings.ADMINS[0][1])
            try:
                send_mail(deletion_subject, deletion_email, settings.EMAIL_HOST_USER, [profile_request.email], fail_silently=False)
                addendum = MESSAGES['PROFILE_REQUEST_DELETION_EMAIL'].format(full_name=profile_request.first_name + ' ' + profile_request.last_name,
                    email=profile_request.email)
            except SMTPException as e:
                message = MESSAGES['EMAIL_FAIL'].format(email=profile_request.email, error=e)
                messages.add_message(request, messages.ERROR, message)
        profile_request.delete()
        message = MESSAGES['PREQ_DEL'].format(first_name=profile_request.first_name, last_name=profile_request.last_name, username=profile_request.username)
        messages.add_message(request, messages.SUCCESS, message + addendum)
        return HttpResponseRedirect(reverse('manage_profile_requests'))
    if mod_form.is_valid():
        new_user = mod_form.save(profile_request)
        if new_user.is_active and settings.SEND_EMAILS and (new_user.email not in settings.EMAIL_BLACKLIST):
            approval_subject = APPROVAL_SUBJECT.format(house=settings.HOUSE_NAME)
            if profile_request.provider:
                username_bit = profile_request.provider.title()
            elif new_user.username == profile_request.username:
                username_bit = "the username and password you selected"
            else:
                username_bit = "the username {0} and the password you selected".format(new_user.username)
            login_url = request.build_absolute_uri(reverse('login'))
            approval_email = APPROVAL_EMAIL.format(house=settings.HOUSE_NAME, full_name=new_user.get_full_name(), admin_name=settings.ADMINS[0][0],
                admin_email=settings.ADMINS[0][1], login_url=login_url, username_bit=username_bit, request_date=profile_request.request_date)
            try:
                send_mail(approval_subject, approval_email, settings.EMAIL_HOST_USER, [new_user.email], fail_silently=False)
                addendum = MESSAGES['PROFILE_REQUEST_APPROVAL_EMAIL'].format(full_name="{0} {1}".format(new_user.first_name, new_user.last_name),
                    email=new_user.email)
            except SMTPException as e:
                message = MESSAGES['EMAIL_FAIL'].format(email=new_user.email, error=e)
                messages.add_message(request, messages.ERROR, message)
        message = MESSAGES['USER_ADDED'].format(username=new_user.username)
        messages.add_message(request, messages.SUCCESS, message + addendum)
        return HttpResponseRedirect(reverse('manage_profile_requests'))
    return render_to_response('modify_profile_request.html', {
        'page_name': page_name,
        'add_user_form': mod_form,
        'provider': profile_request.provider,
        'uid': profile_request.uid,
        'affiliation_message': profile_request.message,
        'members': User.objects.all().exclude(username=ANONYMOUS_USERNAME),
        }, context_instance=RequestContext(request))
804671
def add_user(self, user, **kwargs):
        """"""
        if isinstance(user, User):
            user = user['id']

        assert isinstance(user, six.string_types)

        endpoint = '{0}/{1}/users/{2}'.format(
            self.endpoint,
            self['id'],
            user,
        )
        result = self.request('PUT', endpoint=endpoint, query_params=kwargs)
        return result
383300
public function editUserForgot()
    {
        $this->controlAccessUserForgot();

        $this->setUserForgot();
        $this->setTitleEditUserForgot();
        $this->setBreadcrumbEditUserForgot();

        $this->setData('forgetful_user', $this->data_user);
        $this->setData('password_limit', $this->user->getPasswordLength());

        $this->submitUserForgot();
        $this->outputEditUserForgot();
    }
946258
def _modify(self, **patch):
        """"""
        if 'state' in patch:
            if patch['state'] != 'user-up' and patch['state'] != 'user-down':
                msg = "The members resource does not support a modify with " \
                      "the value of the 'state' attribute as %s. " \
                      "The accepted values are 'user-up' or " \
                      "'user-down'" % patch['state']
                raise MemberStateModifyUnsupported(msg)
        if 'session' in patch:
            if patch['session'] != 'user-enabled' and patch['session'] != \
                    'user-disabled':
                msg = "The members resource does not support a modify with " \
                      "the value of the 'session' attribute as %s. " \
                      "The accepted values are 'user-enabled' or " \
                      "'user-disabled'" % patch['session']
                raise MemberStateModifyUnsupported(msg)
        super(Members, self)._modify(**patch)