Create user data deletion request when the user is deleted.

@param \core\event\user_deleted $event
970145
public static function create_delete_data_request(\core\event\user_deleted $event) {
        // Automatic creation of deletion requests must be enabled.
        if (get_config('tool_dataprivacy', 'automaticdeletionrequests')) {
            $requesttypes = [api::DATAREQUEST_TYPE_DELETE];
            $requeststatuses = [api::DATAREQUEST_STATUS_COMPLETE, api::DATAREQUEST_STATUS_DELETED];

            $hasongoingdeleterequests = api::has_ongoing_request($event->objectid, $requesttypes[0]);
            $hascompleteddeleterequest = (api::get_data_requests_count($event->objectid, $requeststatuses,
                    $requesttypes) > 0) ? true : false;

            if (!$hasongoingdeleterequests && !$hascompleteddeleterequest) {
                api::create_data_request($event->objectid, $requesttypes[0],
                        get_string('datarequestcreatedupondelete', 'tool_dataprivacy'),
                        data_request::DATAREQUEST_CREATION_AUTO);
            }
        }
    }
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');
	}
783915
public function onStorageEventPreDelete(StorageEvent $event)
    {
        /** @var Entity\Users $userEntity */
        $userEntity = $event->getContent();
        if (!$userEntity instanceof Entity\Users) {
            return;
        }

        $this->deleteAuthtokens($userEntity);
        $this->deleteSessions($userEntity);
    }
818315
public function onUsersDelete(GenericDatasEvent $event)
    {
        $users = $event->getDatas();
        $ids = array();

        foreach ($users as $user) {
            $ids[] = $user->getId();
        }
        $this->tagManager->removeTaggedObjectsByClassAndIds(
            'Claroline\CoreBundle\Entity\User',
            $ids
        );
    }
438884
public function beforePrepare(Event $event)
	{
		$command = $event['command'];
		$operation = $command->getOperation();
		$client = $command->getClient();

		if ($command->getName() !== 'updateEntity') return;
		if ($operation->getParam('collection')->getDefault() !== 'user') return;

		// Attempt to get the model's deleted at value from the array of values passed
		// to the command.
		$statusValue = false;

		if ($command->offsetExists(Model::DELETED_AT))
		{
			$statusValue = $command->offsetGet(Model::DELETED_AT);
		}
		elseif ($command->offsetExists('_kmd'))
		{
			$_kmd = array_dot($command->offsetGet('_kmd'));

			$statusField = MODEL::DELETED_AT;
			$statusField = str_replace('_kmd.', '', MODEL::DELETED_AT);

			if (array_key_exists($statusField, $_kmd))
			{
				$statusValue = $_kmd[$statusField];
			}
		}

		// Could not determine the status field.
		if ($statusValue === false)
		{
			return;
		}
		// Suspend the user.
		elseif (!is_null($statusValue))
		{
			$event->stopPropagation();

			$suspendCommand = $client->getCommand('deleteEntity', array(
				'collection' => 'user',
				'_id' => $command->offsetGet('_id'),
			));
			$suspendCommand->execute();
		}
		// Restore.
		else
		{
			$event->stopPropagation();

			$restoreCommand = $client->getCommand('restore', array(
				'_id' => $command->offsetGet('_id'),
			));
			$restoreCommand->execute();
		}
	}
180098
public static function delete($event)
    {
        $desc = '<br>';
        foreach ($event->sender->getAttributes() as $name => $value) {
            $desc .= $event->sender->getAttributeLabel($name) . '(' . $name . ') => ' . $value . ',<br>';
        }
        $desc = substr($desc, 0, -5);
        $model = new AdminLogModel();
        $class = $event->sender->className();
        $id_des = '';
        if (isset($event->sender->id)) {
            $id_des = '{{%ID%}} ' . $event->sender->id;
        }
        $model->description = '{{%ADMIN_USER%}} [ ' . yii::$app->getUser()->getIdentity()->username . ' ] {{%BY%}} ' . $class . ' [ ' . $class::tableName() . ' ] ' . " {{%DELETED%}} {$id_des} {{%RECORD%}}: " . $desc;
        $model->route = Yii::$app->controller->id . '/' . Yii::$app->controller->action->id;
        $model->user_id = yii::$app->getUser()->id;
        $model->save();
    }
1317854
public function deleteUser(Request $request, $user_id)
    {

        if ($request->user()->id == $user_id)
            return redirect()->back()
                ->with('warning', trans('web::seat.self_delete_warning'));

        $user = $this->getUser($user_id);
        $group = $user->group;

        // Delete the user.
        $user->delete();

        // Ensure the orphan group is cleaned up.
        if ($group->users->isEmpty()) $group->delete();

        return redirect()->back()
            ->with('success', trans('web::seat.user_deleted'));
    }
195226
public function onDelete(Event\Delete $event)
    {
        $success = $event->getUser()->delete();
        $event->setResult( (bool)$success );
        if( $event->getResult() === false )
        {
            $event->stopPropagation(true);
        }
        return $event;
    }
137386
public function onEndRequest($event)
    {
        if (!$this->_ended) {
            $this->_ended = true;
            $this->raiseEvent('endRequest', $event);
        }
    }
1348087
public function onQuit(Event $event)
    {
        $msg = $event->getMessage();

        if (!isset($msg['nick'])) {
            return;
        }

        $nick = $msg['nick'];

        $this->storage->removeUser($nick);
    }
77276
public function Delete($UserID = '', $Method = '') {
      $this->Permission('Garden.Users.Delete');
      $Session = Gdn::Session();
      if($Session->User->UserID == $UserID)
         trigger_error(ErrorMessage("You cannot delete the user you are logged in as.", $this->ClassName, 'FetchViewLocation'), E_USER_ERROR);
      $this->AddSideMenu('dashboard/user');
      $this->Title(T('Delete User'));

      $RoleModel = new RoleModel();
      $AllRoles = $RoleModel->GetArray();
      
      // By default, people with access here can freely assign all roles
      $this->RoleData = $AllRoles;
      
      $UserModel = new UserModel();
      $this->User = $UserModel->GetID($UserID);
      
      try {
         
         $CanDelete = TRUE;
         $this->EventArguments['CanDelete'] = &$CanDelete;
         $this->EventArguments['TargetUser'] = &$this->User;
         
         // These are all the 'effective' roles for this delete action. This list can
         // be trimmed down from the real list to allow subsets of roles to be
         // edited.
         $this->EventArguments['RoleData'] = &$this->RoleData;
         
         $UserRoleData = $UserModel->GetRoles($UserID)->ResultArray();
         $RoleIDs = ConsolidateArrayValuesByKey($UserRoleData, 'RoleID');
         $RoleNames = ConsolidateArrayValuesByKey($UserRoleData, 'Name');
         $this->UserRoleData = ArrayCombine($RoleIDs, $RoleNames);
         $this->EventArguments['UserRoleData'] = &$this->UserRoleData;
         
         $this->FireEvent("BeforeUserDelete");
         $this->SetData('CanDelete', $CanDelete);
         
         $Method = in_array($Method, array('delete', 'keep', 'wipe')) ? $Method : '';
         $this->Method = $Method;
         if ($Method != '')
            $this->View = 'deleteconfirm';

         if ($this->Form->AuthenticatedPostBack() && $Method != '') {
            $UserModel->Delete($UserID, array('DeleteMethod' => $Method));
            $this->View = 'deletecomplete';
         }

      } catch (Exception $Ex) {
         $this->Form->AddError($Ex);
      }
      $this->Render();
   }
1099686
public function guestDeleteAction(Event $event)
    {
        $invitation = $this->checkGuestAccess($event);

        $invitation->setStatus(EventInvitation::RESIGN);
        $this->om->flush();

        return new JsonResponse($event->jsonSerialize(), 200);
    }
1053009
public function beforeDelete(Delete $event)
    {
        $pmkVal = $event->primaryKey;
        $entFrk = $this->getForeignKey();
        Sql::createSql($this->getEntity()->getAdapter())
            ->delete($this->getRelationTable())
            ->where(
                [
                    "{$entFrk} = :id" => [
                        ":id" => $pmkVal
                    ]
                ]
            )
            ->execute();
    }
433996
public function onDeleteUser(LogGenericEvent $event)
    {
        if ($event instanceof LogUserDeleteEvent) {
            $receiver = $event->getReceiver();
            if (null !== $receiver) {
                $this->externalSyncUserManager->deleteExternalUserByUserId($receiver->getId());
            }
        }
    }
644417
public function handle(MemberCreated $event)
    {
        if (is_null($event->actor)) {
            return;
        }

        $data = [
            'ip' => request()->ip(),
            'ua' => request()->header('User-Agent'),
        ];

        $event->actor->log('member.create', $data);
    }
1143911
public function onKernelView(GetResponseForControllerResultEvent $event): void
    {
        $request = $event->getRequest();
        if (!RequestAttributesExtractor::extractAttributes($request)) {
            return;
        }

        $user = $event->getControllerResult();
        if (!$user instanceof UserInterface || $request->isMethodSafe(false)) {
            return;
        }

        if ('DELETE' === $request->getMethod()) {
            $this->userManager->deleteUser($user);
            $event->setControllerResult(null);
        } else {
            $this->userManager->updateUser($user);
        }
    }
946335
public function eventAfterDelete($event)
    {
        if ($this->isLoggable()) {
            Yii::$app->db->createCommand()->insert('{{%admin_ngrest_log}}', [
                'user_id' => $this->getUserId(),
                'timestamp_create' => time(),
                'route' => $this->route,
                'api' => $this->api,
                'is_insert' => false,
                'is_update' => false,
                'is_delete' => true,
                'attributes_json' => $this->toJson($event->sender->getAttributes()),
                'table_name' => $event->sender->tableName(),
                'pk_value' => implode("-", $event->sender->getPrimaryKey(true)),
            ])->execute();
        }
    }