Skip to content

Commit

Permalink
[Community] fixes users delete
Browse files Browse the repository at this point in the history
  • Loading branch information
Elorfin committed Oct 11, 2023
1 parent bf4d9bf commit 3a9bf7e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/community/Subscriber/Crud/UserSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public function preDelete(DeleteEvent $event)

// soft delete~
$user->setRemoved(true);
$user->setEmail('email#'.$user->getId());
$user->setEmail('email'.$user->getId().'@deleted.com');
$user->setFirstName('firstname#'.$user->getId());
$user->setLastName('lastname#'.$user->getId());
$user->setPlainPassword(uniqid());
Expand Down
2 changes: 2 additions & 0 deletions src/main/core/Installation/ClarolineCoreInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Claroline\CoreBundle\Installation;

use Claroline\CoreBundle\Installation\Updater\Updater140000;
use Claroline\CoreBundle\Installation\Updater\Updater140010;
use Claroline\CoreBundle\Library\Configuration\PlatformConfigurationHandler;
use Claroline\CoreBundle\Library\Normalizer\DateNormalizer;
use Claroline\InstallationBundle\Additional\AdditionalInstaller;
Expand All @@ -22,6 +23,7 @@ public static function getUpdaters(): array
{
return [
'14.0.0' => Updater140000::class,
'14.0.10' => Updater140010::class,
];
}

Expand Down
26 changes: 26 additions & 0 deletions src/main/core/Installation/Updater/Updater140010.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Claroline\CoreBundle\Installation\Updater;

use Claroline\InstallationBundle\Updater\Updater;
use Doctrine\DBAL\Connection;

class Updater140010 extends Updater
{
private Connection $connection;

public function __construct(
Connection $connection
) {
$this->connection = $connection;
}

public function postUpdate()
{
$updateUsers = $this->connection->prepare("
UPDATE claro_user AS u SET u.mail = CONCAT('email', CONCAT(u.id, '@deleted.com')) WHERE u.is_removed = true
");

$updateUsers->executeQuery();
}
}
4 changes: 4 additions & 0 deletions src/main/core/Resources/config/services/updater.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ services:
arguments:
- '@kernel'
- '@doctrine.dbal.default_connection'

Claroline\CoreBundle\Installation\Updater\Updater140010:
arguments:
- '@doctrine.dbal.default_connection'

0 comments on commit 3a9bf7e

Please sign in to comment.