Soft deletes the specified model if their LDAP account is disabled.

@param User  $user
@param Model $model

@return void

@throws Exception
320450
protected function delete(User $user, Model $model)
    {
        if (
            $this->isUsingSoftDeletes($model) &&
            ! $model->trashed() &&
            $user->isDisabled()
        ) {
            // If deleting is enabled, the model supports soft deletes, the model
            // isn't already deleted, and the LDAP user is disabled, we'll
            // go ahead and delete the users model.
            $model->delete();

            if ($this->isLogging()) {
                $type = get_class($user->getSchema());

                logger()->info("Soft-deleted user {$user->getCommonName()}. Their {$type} user account is disabled.");
            }
        }
    }
706184
private function deleteSessions(Entity\Users $user)
    {
        $savePath = $this->sessionStorage->getOptions()->get('save_path');
        try {
            $sessionFiles = $this->filesystem->find()->files()->in($savePath);
        } catch (FileNotFoundException $e) {
            return;
        }

        /** @var \Bolt\Filesystem\Handler\File $sessionFile */
        foreach ($sessionFiles as $sessionFile) {
            $data = Serialization::parse($sessionFile->read());
            if (!isset($data['_sf2_attributes']['authentication'])) {
                continue;
            }
            if (!$data['_sf2_attributes']['authentication'] instanceof Token) {
                continue;
            }
            /** @var \Bolt\AccessControl\Token\Token $token */
            $token = $data['_sf2_attributes']['authentication'];
            if ($token->getUser()->getId() === $user->getId()) {
                $sessionFile->delete();
            }
        }
    }
342999
public function deleteUser($user)
    {

        $sql = "DELETE FROM {$this->dbTableNamePrefix}" . DataConnector::USER_RESULT_TABLE_NAME . ' ' .
               'WHERE (user_pk = :id)';
        $query = $this->db->prepare($sql);
        $query->bindValue('id', $user->getRecordId(), PDO::PARAM_INT);
        $ok = $query->execute();

        if ($ok) {
            $user->initialize();
        }

        return $ok;

    }
843622
public function deleteAction(User $user)
    {
        if ($user === $this->currentUser) {
            $this->addFlashMessage('You can not delete the currently logged in user', 'Current user can\'t be deleted', Message::SEVERITY_WARNING, [], 1412374546);
            $this->redirect('index');
        }
        $this->userService->deleteUser($user);
        $this->addFlashMessage('The user "%s" has been deleted.', 'User deleted', Message::SEVERITY_NOTICE, [htmlspecialchars($user->getName()->getFullName())], 1412374546);
        $this->redirect('index');
    }
59665
public function setPersonalWorkspace(User $user, Workspace $model = null)
    {
        $locale = $this->platformConfigHandler->getParameter('locale_language');
        $this->translator->setLocale($locale);
        $created = $this->workspaceManager->getOneByCode($user->getUsername());
        if ($created) {
            $code = $user->getUsername().'~'.uniqid();
        } else {
            $code = $user->getUsername();
        }

        $personalWorkspaceName = $this->translator->trans('personal_workspace', [], 'platform').' - '.$user->getUsername();
        $workspace = new Workspace();
        $workspace->setCode($code);
        $workspace->setName($personalWorkspaceName);
        $workspace->setCreator($user);

        $workspace = !$model ?
            $this->workspaceManager->copy($this->workspaceManager->getDefaultModel(true), $workspace) :
            $this->workspaceManager->copy($model, $workspace);

        $workspace->setPersonal(true);

        //todo:add public file directory from the pws model

        $user->setPersonalWorkspace($workspace);
        $this->objectManager->persist($user);
        $this->objectManager->flush();
    }
1253614
public function dispatch(
        UserModel $user,
        UserFactory $factory,
        HookFactory $hook
    ) {
        $this->user = $user;
        $this->factory = $factory;
        $this->hook = $hook;
    }
866458
private void postDelete(User user) throws Exception
   {
      for (UserEventListener listener : listeners)
      {
         listener.postDelete(user);
      }
   }
79041
public function setUserWriteAccess($user, $allowed)
    {
        if (!$user->getObjectId())
        {
            throw new \Exception("cannot setWriteAccess for a user with null id");
        }
        $this->setWriteAccess($user->getObjectId(), $allowed);
    }
73589
public function remove(Model $model = null)
    {
        if (func_num_args() === 0) {
            $this->connection->remove($this);
        } else {
            // avoid remove empty model
            if (is_null($model)) {
                throw new \Exception('[Norm/Collection] Cannot remove null model');
            }

            $this->applyHook('removing', $model);
            $result = $this->connection->remove($this, $model);

            if ($result) {
                $model->reset();
            }

            $this->applyHook('removed', $model);
        }
    }
465219
public function deleteUser(User $user)
    {
        $url = self::makeUserUrl($user->tenantId, $user->username);
        $this->service->prepAndSend($url, array(204), 'DELETE', null, false, 'application/json', 'application/json');
	}
336109
public function deleteUserImage(UserInterface $user)
    {
        $file = $this->getUserImage($user);
        if (is_readable($file)) {
            unlink($file);
        }
    }
38196
public function saveUser(User $user, Request $request)
    {
        $user->fill($request->get('user'))
            ->save();

        Alert::info(__('User was saved.'));

        return back();
    }
693620
public function isApiEnabledForUser(User $user)
    {
        $roles = $user->roles->pluck('id')->toArray();
        return !count($roles) ? false : $this->newQuery()->whereIn('role_id', array_values($roles))->where('enabled', 1)->get()->count() > 0;
    }
131707
public function deleteUser(User $user, string $password) : bool {
		if ($user->doesPasswordMatch($password)) {
			$stmt = $this->db->prepare(
				"DELETE FROM accounts " .
				"WHERE id=? AND username=? AND email=?;"
			);
			$stmt->bind_param("iss",
				$user->id, $user->username, $user->email);
			$stmt->execute();
			$this->db->commit();
			return true;
		} else {
			return false;
		}
	}
402738
public function removeUser(\FOM\UserBundle\Entity\User $user)
    {
        $this->users->removeElement($users);
    }
892548
protected function deleteModels(): void
    {
        $model = app($this->modelClass);
        // determine if the model uses `SoftDeletes` trait
        $usesSoftDeletes = in_array(SoftDeletes::class, class_uses($model));

        foreach ($model->all() as $value) {
            try {
                if ($usesSoftDeletes) {
                    $value->forceDelete();
                } else {
                    $value->delete();
                }
            } catch (Exception $exception) {
                Log::warning(sprintf('Error during deleting models. Table: %s. Error: %s', $model->getTable(), $exception->getMessage()));
            }
        }
    }
1213324
public function hasUser( Model $user )
    {
        return $this->users()->where( $user->getKeyName(), "=", $user->getKey() )->first() ? true : false;
    }