Updates a user role
@param string $role_id
974588
protected function updateRole($role_id)
    {
        if (!$this->isError() && !$this->role->update($role_id, $this->getSubmitted())) {
            $this->errorAndExit($this->text('Unexpected result'));
        }
    }
602498
public function updateRole(RoleUpdateStruct $role)
    {
        try {
            return $this->innerGateway->updateRole($role);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
342723
public function editRole($role_id)
    {

        // Get the role. We don't get the full one
        // as we need to mangle some of the data to
        // arrays for easier processing in the view
        $role = $this->getRole($role_id);

        $role_permissions = $role->permissions()->get()->pluck('title')->toArray();
        $role_affiliations = $role->affiliations();
        $role_groups = $role->groups()->get()->pluck('id')->toArray();
        $all_groups = $this->getAllGroups();
        $all_characters = $this->getAllCharacters();
        $all_corporations = $this->getAllCorporations();

        return view(
            'web::configuration.access.edit',
            compact(
                'role', 'role_permissions', 'role_groups', 'all_groups',
                'role_affiliations', 'all_characters', 'all_corporations'
            ));
    }
742084
public function updateRole(RoleUpdateStruct $role)
    {
        $query = $this->handler->createUpdateQuery();
        $query
            ->update($this->handler->quoteTable('ezrole'))
            ->set(
                $this->handler->quoteColumn('name'),
                $query->bindValue($role->identifier)
            )->where(
                $query->expr->eq(
                    $this->handler->quoteColumn('id'),
                    $query->bindValue($role->id, null, \PDO::PARAM_INT)
                )
            );
        $statement = $query->prepare();
        $statement->execute();

        // Commented due to EZP-24698: Role update leads to NotFoundException
        // Should be fixed with PDO::MYSQL_ATTR_FOUND_ROWS instead
        /*if ($statement->rowCount() < 1) {
            throw new NotFoundException('role', $role->id);
        }*/
    }
720560
public function updateWithRoles(array $data, $roles, $id)
    {
        $user = $this->update((array) $data, $id);

        if (! empty($roles)) {
            $user->roles()->sync($roles);
        } else {
            $user->roles()->detach();
        }
    }
458213
public function publishRoleDraft($roleId)
    {
        try {
            // First try to load the draft for given role.
            $roleDraft = $this->roleService->loadRoleDraftByRoleId($roleId);
        } catch (NotFoundException $e) {
            // We might want a newly created role, so try to load it by its ID.
            // loadRoleDraft() might throw a NotFoundException (wrong $roleId). If so, let it bubble up.
            $roleDraft = $this->roleService->loadRoleDraft($roleId);
        }

        $this->roleService->publishRoleDraft($roleDraft);

        $role = $this->roleService->loadRole($roleId);

        return new Values\PublishedRole(['role' => new Values\RestRole($role)]);
    }
1366823
public function Delete($RoleID = FALSE) {
		if(!$this->_Permission())
			return;

		$this->Title(T('Delete Role'));
      $this->AddSideMenu('dashboard/role');
      
      $Role = $this->RoleModel->GetByRoleID($RoleID);
      if ($Role->Deletable == '0')
         $this->Form->AddError('You cannot delete this role.');
      
      // Make sure the form knows which item we are deleting.
      $this->Form->AddHidden('RoleID', $RoleID);
      
      // Figure out how many users will be affected by this deletion
      $this->AffectedUsers = $this->RoleModel->GetUserCount($RoleID);
      
      // Figure out how many users will be orphaned by this deletion
      $this->OrphanedUsers = $this->RoleModel->GetUserCount($RoleID, TRUE);

      // Get a list of roles other than this one that can act as a replacement
      $this->ReplacementRoles = $this->RoleModel->GetByNotRoleID($RoleID);
      
      if ($this->Form->AuthenticatedPostBack()) {
         // Make sure that a replacement role has been selected if there were going to be orphaned users
         if ($this->OrphanedUsers > 0) {
            $Validation = new Gdn_Validation();
            $Validation->ApplyRule('ReplacementRoleID', 'Required', 'You must choose a replacement role for orphaned users.');
            $Validation->Validate($this->Form->FormValues());
            $this->Form->SetValidationResults($Validation->Results());
         }
         if ($this->Form->ErrorCount() == 0) {
            // Go ahead and delete the Role
            $this->RoleModel->Delete($RoleID, $this->Form->GetValue('ReplacementRoleID'));
            $this->RedirectUrl = Url('dashboard/role');
            $this->InformMessage(T('Deleting role...'));
         }
      }
      $this->Render();
   }
1016946
public function retrieveEmployeeRole($role_id)
    {
        list($response, $statusCode, $httpHeader) = $this->retrieveEmployeeRoleWithHttpInfo ($role_id);
        return $response; 
    }
874279
def delete_role(role_id)
      @roles.reject! { |r| r.id == role_id }
      @members.each do |_, member|
        new_roles = member.roles.reject { |r| r.id == role_id }
        member.update_roles(new_roles)
      end
      @channels.each do |channel|
        overwrites = channel.permission_overwrites.reject { |id, _| id == role_id }
        channel.update_overwrites(overwrites)
      end
    end
1098915
public function updateRole($roleId, Request $request)
    {
        $createStruct = $this->inputDispatcher->parse(
            new Message(
                array('Content-Type' => $request->headers->get('Content-Type')),
                $request->getContent()
            )
        );

        return $this->roleService->updateRole(
            $this->roleService->loadRole($roleId),
            $this->mapToUpdateStruct($createStruct)
        );
    }
173138
public function update(RoleRequest $request, $id)
    {
        $input = $request->except('permissions');

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

        $record->syncPermissions($request->permissions);

        $record->update($input);

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

        return redirect()->back();
    }
106928
def update_role(role,**kwargs):
    
    #check_perm(kwargs.get('user_id'), 'edit_role')
    try:
        role_i = db.DBSession.query(Role).filter(Role.id==role.id).one()
        role_i.name = role.name
        role_i.code = role.code
    except NoResultFound:
        raise ResourceNotFoundError("Role (role_id=%s) does not exist"%(role.id))

    for perm in role.permissions:
        _get_perm(perm.id)
        roleperm_i = RolePerm(role_id=role.id,
                              perm_id=perm.id
                              )

        db.DBSession.add(roleperm_i)

    for user in role.users:
        _get_user(user.id)
        roleuser_i = RoleUser(user_id=user.id,
                                         perm_id=perm.id
                                        )

        db.DBSession.add(roleuser_i)

    db.DBSession.flush()
    return role_i
46631
public function editUser($user_id = null)
    {
        $this->setUser($user_id);
        $this->setTitleEditUser();
        $this->setBreadcrumbEditUser();
        $this->controlAccessEditUser($user_id);

        $this->setData('user', $this->data_user);
        $this->setData('roles', $this->role->getList());
        $this->setData('can_delete', $this->canDeleteUser());
        $this->setData('is_superadmin', $this->isSuperadminUser());
        $this->setData('password_limit', $this->user->getPasswordLength());

        $this->submitEditUser();
        $this->outputEditUser();
    }
813878
protected function updateRoles()
    {
        foreach ($this->roles() as $Role) {
            $this->authManager->add($Role);

            echo sprintf('    > role `%s` added.', $Role->name) . PHP_EOL;
        }
    }
641775
def update_guild_role(data)
      role_data = data['role']
      server_id = data['guild_id'].to_i
      server = @servers[server_id]
      new_role = Role.new(role_data, self, server)
      role_id = role_data['id'].to_i
      old_role = server.roles.find { |r| r.id == role_id }
      old_role.update_from(new_role)
    end
414987
public function update(Request $request, Role $role)
    {
        $this->authorize('update', Role::class);
        $this->validate($request, [
            'name'        => 'required|max:255',
            'color'       => 'required|size:7',
            'description' => 'required|max:500',
        ]);
        $role->update($request->all());

        return redirect()->route('laralum::roles.index')->with('success', __('laralum_roles::general.role_updated', ['id' => $role->id]));
    }
1338186
protected function check_role_update( $user_id, $roles ) {
		global $wp_roles;

		foreach ( $roles as $role ) {

			if ( ! isset( $wp_roles->role_objects[ $role ] ) ) {
				return new WP_Error( 'rest_user_invalid_role', sprintf( __( 'The role %s does not exist.' ), $role ), array( 'status' => 400 ) );
			}

			$potential_role = $wp_roles->role_objects[ $role ];
			// Don't let anyone with 'edit_users' (admins) edit their own role to something without it.
			// Multisite super admins can freely edit their blog roles -- they possess all caps.
			if ( ! ( is_multisite() && current_user_can( 'manage_sites' ) ) && get_current_user_id() === $user_id && ! $potential_role->has_cap( 'edit_users' ) ) {
				return new WP_Error( 'rest_user_invalid_role', __( 'You cannot give resource that role.' ), array( 'status' => rest_authorization_required_code() ) );
			}

			// The new role must be editable by the logged-in user.

			/** Include admin functions to get access to get_editable_roles() */
			require_once ABSPATH . 'wp-admin/includes/admin.php';

			$editable_roles = get_editable_roles();
			if ( empty( $editable_roles[ $role ] ) ) {
				return new WP_Error( 'rest_user_invalid_role', __( 'You cannot give resource that role.' ), array( 'status' => 403 ) );
			}
		}

		return true;

	}