Changes file owner
@param mixed $user
@return boolean
963543
public function chown($user) {

		if(false !== $this -> file -> getExists()) {
			return @chown($this -> file -> getBasepath(), $user);
		}

		return false;
	}
318648
public function edit(User $user)
    {
        return $this->appShellView('user.edit', [
            'user'  => $user,
            'types' => UserTypeProxy::choices(),
            'roles' => RoleProxy::all()
        ]);
    }
826337
public function remove(User $user) : bool
    {
        if (!$user->delete()) {
            throw new \RuntimeException($this->i18n->t('setrun/user', 'Removing error'));
        }
        return true;
    }
679772
public function defaultFileChanger()
    {
        $files = [
            base_path('config/auth.php'),
            base_path('config/services.php'),
        ];

        foreach ($files as $file) {
            $contents = file_get_contents($file);
            $contents = str_replace('App\User::class', 'App\Models\User::class', $contents);
            file_put_contents($file, $contents);
        }
    }
960467
private function update_picture($user) {
        global $CFG, $DB, $USER;

        require_once($CFG->libdir . '/filelib.php');
        require_once($CFG->libdir . '/gdlib.php');
        require_once($CFG->dirroot . '/user/lib.php');

        $fs = get_file_storage();
        $userid = $user->id;
        if (!empty($user->picture)) {
            return false;
        }
        if (!empty($CFG->enablegravatar)) {
            return false;
        }

        $picture = $this->get_static_user_picture();
        if (empty($picture)) {
            return false;
        }

        $context = \context_user::instance($userid, MUST_EXIST);
        $fs->delete_area_files($context->id, 'user', 'newicon');

        $filerecord = array(
            'contextid' => $context->id,
            'component' => 'user',
            'filearea' => 'newicon',
            'itemid' => 0,
            'filepath' => '/',
            'filename' => 'image'
        );

        try {
            $fs->create_file_from_string($filerecord, $picture);
        } catch (\file_exception $e) {
            return get_string($e->errorcode, $e->module, $e->a);
        }

        $iconfile = $fs->get_area_files($context->id, 'user', 'newicon', false, 'itemid', false);

        // There should only be one.
        $iconfile = reset($iconfile);

        // Something went wrong while creating temp file - remove the uploaded file.
        if (!$iconfile = $iconfile->copy_content_to_temp()) {
            $fs->delete_area_files($context->id, 'user', 'newicon');
            return false;
        }

        // Copy file to temporary location and the send it for processing icon.
        $newpicture = (int) process_new_icon($context, 'user', 'icon', 0, $iconfile);
        // Delete temporary file.
        @unlink($iconfile);
        // Remove uploaded file.
        $fs->delete_area_files($context->id, 'user', 'newicon');
        // Set the user's picture.
        $updateuser = new stdClass();
        $updateuser->id = $userid;
        $updateuser->picture = $newpicture;
        $USER->picture = $newpicture;
        user_update_user($updateuser);
        return true;
    }
648151
public function user(string $user): Builder
    {
        $this->claims[Claims::USER] = $user;

        return $this;
    }
475840
protected function _setCurrentUser($user = null)
    {
        if ($user === null && !empty($this->Auth)) {
            $user = $this->Auth->user();
        }

        if (!$user) {
            return false;
        }

        $this->_currentUserInstance = $this->_getUserInstance($user);

        return $this->_currentUserInstance;
    }
639178
public function updateUser(User $user)
    {
        $request = $user->toJson();
        $this->client->put(sprintf('/v2/user/%s', $user->getId()), $request);
    }
1135462
public function update(User $user, User $entity)
    {
        if ($entity->id === $user->id) {
            return true;
        }
        return $user->hasPermission('user-update');
    }
458023
public function loadUser($user)
    {

        $now = time();
        $user->created = $now;
        $user->updated = $now;

        return true;

    }
1173382
public function persistUser(User $user)
    {
        $this->objectManager->persist($user);
        $this->objectManager->flush();

        return $user;
    }
441344
public function updateAccount(User $user)
    {
        if ($this->client === null) {
            throw new LogicException("Client property must be set before update an account");
        }

        if (null === $account = $this->app['repo.api-accounts']->findByUserAndApplication($user, $this->client)) {
            $account = $this->app['manipulator.api-account']->create($this->client, $user, $this->getVariable('api_version', V2::VERSION));
        }

        return $account;
    }
1181406
public function updateAction(User $user)
    {
        $this->userService->updateUser($user);
        $this->addFlashMessage('Your user has been updated.', 'User updated', Message::SEVERITY_OK);
        $this->redirect('edit');
    }
568060
protected function changeOwner($path, $newOwner)
    {
        $ownerUid = fileowner($path);
        $ownerData = posix_getpwuid($ownerUid);
        $oldOwner = $ownerData['name'];
        if ($oldOwner !== $this->user) {
            if(!@chown($path, $newOwner)) {
                throw new CException(sprintf('Unable to change owner for %s, permission denied', $path));
            }
            echo sprintf("Changing owner for %s (%s => %s)... ", $path, $oldOwner, $newOwner);
            echo "done\n";
        }
    }
98799
static function changeUser($user)
    {
        if (!function_exists('posix_getpwnam'))
        {
            trigger_error(__METHOD__ . ": require posix extension.");

            return false;
        }
        $user = posix_getpwnam($user);
        if ($user)
        {
            posix_setuid($user['uid']);
            posix_setgid($user['gid']);
            return true;
        }
        else
        {
            return false;
        }
    }
994857
public function removeUser($user)
    {
        if ($this->getUsers()->contains($user))
        {
            $this->getUsers()->removeElement($user);
            $user->removeGroup($this);
        }
        return $this;
    }
1112492
public static function changeScriptOwner($user, $group = '')
    {
        $uInfo = posix_getpwnam($user);

        if (!$uInfo || !isset($uInfo['uid'])) {
            throw new \RuntimeException("User ({$user}) not found.");
        }

        $uid = (int)$uInfo['uid'];

        // Get gid.
        if ($group) {
            if (!$gInfo = posix_getgrnam($group)) {
                throw new \RuntimeException("Group {$group} not exists", -300);
            }

            $gid = (int)$gInfo['gid'];
        } else {
            $gid = (int)$uInfo['gid'];
        }

        if (!posix_initgroups($uInfo['name'], $gid)) {
            throw new \RuntimeException("The user [{$user}] is not in the user group ID [GID:{$gid}]", -300);
        }

        posix_setgid($gid);

        if (posix_geteuid() !== $gid) {
            throw new \RuntimeException("Unable to change group to {$user} (UID: {$gid}).", -300);
        }

        posix_setuid($uid);

        if (posix_geteuid() !== $uid) {
            throw new \RuntimeException("Unable to change user to {$user} (UID: {$uid}).", -300);
        }
    }