Skip to content

Commit 33ce117

Browse files
committed
Use UserAction directly so that the events continue to function.
1 parent 9a4f8d3 commit 33ce117

File tree

12 files changed

+51
-159
lines changed

12 files changed

+51
-159
lines changed

wcfsetup/install/files/lib/system/endpoint/controller/core/users/EnableUserAvatar.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
use Psr\Http\Message\ServerRequestInterface;
88
use wcf\data\user\group\UserGroup;
99
use wcf\data\user\User;
10+
use wcf\data\user\UserAction;
1011
use wcf\http\Helper;
1112
use wcf\system\endpoint\IController;
1213
use wcf\system\endpoint\PostRequest;
1314
use wcf\system\exception\IllegalLinkException;
1415
use wcf\system\exception\PermissionDeniedException;
15-
use wcf\system\user\command\EnableAvatar;
1616
use wcf\system\WCF;
1717

1818
/**
@@ -34,7 +34,7 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res
3434
$this->assertAvatarCanBeEnabled($user);
3535

3636
if ($user->disableAvatar) {
37-
(new EnableAvatar($user))();
37+
(new UserAction([$user], 'enableAvatar'))->executeAction();
3838
}
3939

4040
return new JsonResponse([]);

wcfsetup/install/files/lib/system/endpoint/controller/core/users/EnableUserCoverPhoto.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
use Psr\Http\Message\ServerRequestInterface;
88
use wcf\data\user\group\UserGroup;
99
use wcf\data\user\User;
10+
use wcf\data\user\UserAction;
1011
use wcf\http\Helper;
1112
use wcf\system\endpoint\IController;
1213
use wcf\system\endpoint\PostRequest;
1314
use wcf\system\exception\IllegalLinkException;
1415
use wcf\system\exception\PermissionDeniedException;
15-
use wcf\system\user\command\EnableCoverPhoto;
1616
use wcf\system\WCF;
1717

1818
/**
@@ -34,7 +34,7 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res
3434
$this->assertCoverPhotoCanBeEnabled($user);
3535

3636
if ($user->disableCoverPhoto) {
37-
(new EnableCoverPhoto($user))();
37+
(new UserAction([$user], 'enableCoverPhoto'))->executeAction();
3838
}
3939

4040
return new JsonResponse([]);

wcfsetup/install/files/lib/system/endpoint/controller/core/users/EnableUserSignature.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
use Psr\Http\Message\ServerRequestInterface;
88
use wcf\data\user\group\UserGroup;
99
use wcf\data\user\User;
10+
use wcf\data\user\UserAction;
1011
use wcf\http\Helper;
1112
use wcf\system\endpoint\IController;
1213
use wcf\system\endpoint\PostRequest;
1314
use wcf\system\exception\IllegalLinkException;
1415
use wcf\system\exception\PermissionDeniedException;
15-
use wcf\system\user\command\EnableSignature;
1616
use wcf\system\WCF;
1717

1818
/**
@@ -34,7 +34,7 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res
3434
$this->assertSignatureCanBeEnabled($user);
3535

3636
if ($user->disableSignature) {
37-
(new EnableSignature($user))();
37+
(new UserAction([$user], 'enableSignature'))->executeAction();
3838
}
3939

4040
return new JsonResponse([]);

wcfsetup/install/files/lib/system/endpoint/controller/core/users/UnbanUser.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
use Psr\Http\Message\ServerRequestInterface;
88
use wcf\data\user\group\UserGroup;
99
use wcf\data\user\User;
10+
use wcf\data\user\UserAction;
1011
use wcf\http\Helper;
1112
use wcf\system\endpoint\IController;
1213
use wcf\system\endpoint\PostRequest;
1314
use wcf\system\exception\IllegalLinkException;
1415
use wcf\system\exception\PermissionDeniedException;
15-
use wcf\system\user\command\Unban;
1616
use wcf\system\WCF;
1717

1818
/**
@@ -34,7 +34,7 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res
3434
$this->assertUserCanUnbanned($user);
3535

3636
if ($user->banned) {
37-
(new Unban($user))();
37+
(new UserAction([$user], 'unban'))->executeAction();
3838
}
3939

4040
return new JsonResponse([]);

wcfsetup/install/files/lib/system/user/command/Ban.class.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
namespace wcf\system\user\command;
44

55
use wcf\data\user\User;
6-
use wcf\data\user\UserEditor;
6+
use wcf\data\user\UserAction;
7+
use wcf\util\DateUtil;
78

89
/**
910
* Ban a user.
@@ -24,11 +25,14 @@ public function __construct(
2425

2526
public function __invoke(): void
2627
{
27-
$editor = new UserEditor($this->user);
28-
$editor->update([
29-
'banned' => 1,
28+
$banExpires = null;
29+
if ($this->banExpires !== null) {
30+
$banExpires = DateUtil::getDateTimeByTimestamp($this->banExpires)->format('Y-m-d');
31+
}
32+
33+
(new UserAction([$this->user], 'ban', [
3034
'banReason' => $this->reason,
31-
'banExpires' => $this->banExpires ?? 0,
32-
]);
35+
'banExpires' => $banExpires,
36+
]))->executeAction();
3337
}
3438
}

wcfsetup/install/files/lib/system/user/command/DisableAvatar.class.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
namespace wcf\system\user\command;
44

55
use wcf\data\user\User;
6-
use wcf\data\user\UserEditor;
6+
use wcf\data\user\UserAction;
7+
use wcf\util\DateUtil;
78

89
/**
910
* Disable a user's avatar.
@@ -18,17 +19,20 @@ final class DisableAvatar
1819
public function __construct(
1920
private readonly User $user,
2021
private readonly string $reason,
21-
private readonly ?int $banExpires = null,
22+
private readonly ?int $expires = null,
2223
) {
2324
}
2425

2526
public function __invoke(): void
2627
{
27-
$editor = new UserEditor($this->user);
28-
$editor->update([
29-
'disableAvatar' => 1,
28+
$expires = null;
29+
if ($this->expires !== null) {
30+
$expires = DateUtil::getDateTimeByTimestamp($this->expires)->format('Y-m-d');
31+
}
32+
33+
(new UserAction([$this->user], 'disableAvatar', [
3034
'disableAvatarReason' => $this->reason,
31-
'disableAvatarExpires' => $this->banExpires ?? 0,
32-
]);
35+
'disableAvatarExpires' => $expires,
36+
]))->executeAction();
3337
}
3438
}

wcfsetup/install/files/lib/system/user/command/DisableCoverPhoto.class.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
namespace wcf\system\user\command;
44

55
use wcf\data\user\User;
6-
use wcf\data\user\UserEditor;
6+
use wcf\data\user\UserAction;
7+
use wcf\util\DateUtil;
78

89
/**
910
* Disable a user's cover photo.
@@ -18,17 +19,20 @@ final class DisableCoverPhoto
1819
public function __construct(
1920
private readonly User $user,
2021
private readonly string $reason,
21-
private readonly ?int $banExpires = null,
22+
private readonly ?int $expires = null,
2223
) {
2324
}
2425

2526
public function __invoke(): void
2627
{
27-
$editor = new UserEditor($this->user);
28-
$editor->update([
29-
'disableCoverPhoto' => 1,
28+
$expires = null;
29+
if ($this->expires !== null) {
30+
$expires = DateUtil::getDateTimeByTimestamp($this->expires)->format('Y-m-d');
31+
}
32+
33+
(new UserAction([$this->user], 'disableCoverPhoto', [
3034
'disableCoverPhotoReason' => $this->reason,
31-
'disableCoverPhotoExpires' => $this->banExpires ?? 0,
32-
]);
35+
'disableCoverPhotoExpires' => $expires,
36+
]))->executeAction();
3337
}
3438
}

wcfsetup/install/files/lib/system/user/command/DisableSignature.class.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
namespace wcf\system\user\command;
44

55
use wcf\data\user\User;
6-
use wcf\data\user\UserEditor;
6+
use wcf\data\user\UserAction;
7+
use wcf\util\DateUtil;
78

89
/**
910
* Disable a user's signature.
@@ -18,17 +19,20 @@ final class DisableSignature
1819
public function __construct(
1920
private readonly User $user,
2021
private readonly string $reason,
21-
private readonly ?int $banExpires = null,
22+
private readonly ?int $expires = null,
2223
) {
2324
}
2425

2526
public function __invoke(): void
2627
{
27-
$editor = new UserEditor($this->user);
28-
$editor->update([
29-
'disableSignature' => 1,
28+
$expires = null;
29+
if ($this->expires !== null) {
30+
$expires = DateUtil::getDateTimeByTimestamp($this->expires)->format('Y-m-d');
31+
}
32+
33+
(new UserAction([$this->user], 'disableSignature', [
3034
'disableSignatureReason' => $this->reason,
31-
'disableSignatureExpires' => $this->banExpires ?? 0,
32-
]);
35+
'disableSignatureExpires' => $expires,
36+
]))->executeAction();
3337
}
3438
}

wcfsetup/install/files/lib/system/user/command/EnableAvatar.class.php

Lines changed: 0 additions & 31 deletions
This file was deleted.

wcfsetup/install/files/lib/system/user/command/EnableCoverPhoto.class.php

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)