diff --git a/wcfsetup/install/files/lib/command/ad/DisableAd.class.php b/wcfsetup/install/files/lib/command/ad/DisableAd.class.php new file mode 100644 index 00000000000..f868590272a --- /dev/null +++ b/wcfsetup/install/files/lib/command/ad/DisableAd.class.php @@ -0,0 +1,33 @@ + + * @since 6.3 + */ +final class DisableAd +{ + public function __construct( + private readonly Ad $ad + ) {} + + public function __invoke(): void + { + (new AdEditor($this->ad))->update([ + 'isDisabled' => 1, + ]); + + $event = new AdDisabled($this->ad); + EventHandler::getInstance()->fire($event); + } +} diff --git a/wcfsetup/install/files/lib/command/ad/EnableAd.class.php b/wcfsetup/install/files/lib/command/ad/EnableAd.class.php new file mode 100644 index 00000000000..9e5332c71ed --- /dev/null +++ b/wcfsetup/install/files/lib/command/ad/EnableAd.class.php @@ -0,0 +1,33 @@ + + * @since 6.3 + */ +final class EnableAd +{ + public function __construct( + private readonly Ad $ad + ) {} + + public function __invoke(): void + { + (new AdEditor($this->ad))->update([ + 'isDisabled' => 0, + ]); + + $event = new AdEnabled($this->ad); + EventHandler::getInstance()->fire($event); + } +} diff --git a/wcfsetup/install/files/lib/command/bbcode/media/provider/DisableBBCodeMediaProvider.class.php b/wcfsetup/install/files/lib/command/bbcode/media/provider/DisableBBCodeMediaProvider.class.php new file mode 100644 index 00000000000..a0d7d8bfa41 --- /dev/null +++ b/wcfsetup/install/files/lib/command/bbcode/media/provider/DisableBBCodeMediaProvider.class.php @@ -0,0 +1,31 @@ + + * @since 6.3 + */ +final class DisableBBCodeMediaProvider +{ + public function __construct(private readonly BBCodeMediaProvider $mediaProvider) {} + + public function __invoke(): void + { + (new BBCodeMediaProviderEditor($this->mediaProvider))->update([ + 'isDisabled' => 1, + ]); + + $event = new BBCodeMediaProviderDisabled($this->mediaProvider); + EventHandler::getInstance()->fire($event); + } +} diff --git a/wcfsetup/install/files/lib/command/bbcode/media/provider/EnableBBCodeMediaProvider.class.php b/wcfsetup/install/files/lib/command/bbcode/media/provider/EnableBBCodeMediaProvider.class.php new file mode 100644 index 00000000000..6fb7f35bd87 --- /dev/null +++ b/wcfsetup/install/files/lib/command/bbcode/media/provider/EnableBBCodeMediaProvider.class.php @@ -0,0 +1,31 @@ + + * @since 6.3 + */ +final class EnableBBCodeMediaProvider +{ + public function __construct(private readonly BBCodeMediaProvider $mediaProvider) {} + + public function __invoke(): void + { + (new BBCodeMediaProviderEditor($this->mediaProvider))->update([ + 'isDisabled' => 0, + ]); + + $event = new BBCodeMediaProviderEnabled($this->mediaProvider); + EventHandler::getInstance()->fire($event); + } +} diff --git a/wcfsetup/install/files/lib/command/box/DisableBox.class.php b/wcfsetup/install/files/lib/command/box/DisableBox.class.php new file mode 100644 index 00000000000..7611aefc389 --- /dev/null +++ b/wcfsetup/install/files/lib/command/box/DisableBox.class.php @@ -0,0 +1,31 @@ + + * @since 6.3 + */ +final class DisableBox +{ + public function __construct(private readonly Box $box) {} + + public function __invoke(): void + { + (new BoxEditor($this->box))->update([ + 'isDisabled' => 1, + ]); + + $event = new BoxDisabled($this->box); + EventHandler::getInstance()->fire($event); + } +} diff --git a/wcfsetup/install/files/lib/command/box/EnableBox.class.php b/wcfsetup/install/files/lib/command/box/EnableBox.class.php new file mode 100644 index 00000000000..b0d8621ff13 --- /dev/null +++ b/wcfsetup/install/files/lib/command/box/EnableBox.class.php @@ -0,0 +1,31 @@ + + * @since 6.3 + */ +final class EnableBox +{ + public function __construct(private readonly Box $box) {} + + public function __invoke(): void + { + (new BoxEditor($this->box))->update([ + 'isDisabled' => 0, + ]); + + $event = new BoxEnabled($this->box); + EventHandler::getInstance()->fire($event); + } +} diff --git a/wcfsetup/install/files/lib/command/captcha/question/DisableCaptchaQuestion.class.php b/wcfsetup/install/files/lib/command/captcha/question/DisableCaptchaQuestion.class.php new file mode 100644 index 00000000000..b296943cd49 --- /dev/null +++ b/wcfsetup/install/files/lib/command/captcha/question/DisableCaptchaQuestion.class.php @@ -0,0 +1,33 @@ + + * @since 6.3 + */ +final class DisableCaptchaQuestion +{ + public function __construct( + private readonly CaptchaQuestion $captchaQuestion, + ) {} + + public function __invoke(): void + { + (new CaptchaQuestionEditor($this->captchaQuestion))->update([ + 'isDisabled' => 1, + ]); + + $event = new CaptchaQuestionDisabled($this->captchaQuestion); + EventHandler::getInstance()->fire($event); + } +} diff --git a/wcfsetup/install/files/lib/command/captcha/question/EnableCaptchaQuestion.class.php b/wcfsetup/install/files/lib/command/captcha/question/EnableCaptchaQuestion.class.php new file mode 100644 index 00000000000..840e05f9a96 --- /dev/null +++ b/wcfsetup/install/files/lib/command/captcha/question/EnableCaptchaQuestion.class.php @@ -0,0 +1,33 @@ + + * @since 6.3 + */ +final class EnableCaptchaQuestion +{ + public function __construct( + private readonly CaptchaQuestion $captchaQuestion, + ) {} + + public function __invoke(): void + { + (new CaptchaQuestionEditor($this->captchaQuestion))->update([ + 'isDisabled' => 0, + ]); + + $event = new CaptchaQuestionEnabled($this->captchaQuestion); + EventHandler::getInstance()->fire($event); + } +} diff --git a/wcfsetup/install/files/lib/command/contact/option/DisableContactOption.class.php b/wcfsetup/install/files/lib/command/contact/option/DisableContactOption.class.php new file mode 100644 index 00000000000..b12620d621e --- /dev/null +++ b/wcfsetup/install/files/lib/command/contact/option/DisableContactOption.class.php @@ -0,0 +1,33 @@ + + * @since 6.3 + */ +final class DisableContactOption +{ + public function __construct( + private readonly ContactOption $contactOption + ) {} + + public function __invoke(): void + { + (new ContactOptionEditor($this->contactOption))->update([ + 'isDisabled' => 1, + ]); + + $event = new ContactOptionDisabled($this->contactOption); + EventHandler::getInstance()->fire($event); + } +} diff --git a/wcfsetup/install/files/lib/command/contact/option/EnableContactOption.class.php b/wcfsetup/install/files/lib/command/contact/option/EnableContactOption.class.php new file mode 100644 index 00000000000..35a93b14951 --- /dev/null +++ b/wcfsetup/install/files/lib/command/contact/option/EnableContactOption.class.php @@ -0,0 +1,33 @@ + + * @since 6.3 + */ +final class EnableContactOption +{ + public function __construct( + private readonly ContactOption $contactOption + ) {} + + public function __invoke(): void + { + (new ContactOptionEditor($this->contactOption))->update([ + 'isDisabled' => 0, + ]); + + $event = new ContactOptionEnabled($this->contactOption); + EventHandler::getInstance()->fire($event); + } +} diff --git a/wcfsetup/install/files/lib/command/contact/recipient/DisableContactRecipient.class.php b/wcfsetup/install/files/lib/command/contact/recipient/DisableContactRecipient.class.php new file mode 100644 index 00000000000..5d3230c4b25 --- /dev/null +++ b/wcfsetup/install/files/lib/command/contact/recipient/DisableContactRecipient.class.php @@ -0,0 +1,30 @@ + + * @since 6.3 + */ +final class DisableContactRecipient { + public function __construct(private readonly ContactRecipient $recipient) {} + + public function __invoke(): void + { + (new ContactRecipientEditor($this->recipient))->update([ + 'isDisabled' => 1, + ]); + + $event = new ContactRecipientDisabled($this->recipient); + EventHandler::getInstance()->fire($event); + } +} diff --git a/wcfsetup/install/files/lib/command/contact/recipient/EnableContactRecipient.class.php b/wcfsetup/install/files/lib/command/contact/recipient/EnableContactRecipient.class.php new file mode 100644 index 00000000000..ac14a6f24ec --- /dev/null +++ b/wcfsetup/install/files/lib/command/contact/recipient/EnableContactRecipient.class.php @@ -0,0 +1,30 @@ + + * @since 6.3 + */ +final class EnableContactRecipient { + public function __construct(private readonly ContactRecipient $recipient) {} + + public function __invoke(): void + { + (new ContactRecipientEditor($this->recipient))->update([ + 'isDisabled' => 0, + ]); + + $event = new ContactRecipientEnabled($this->recipient); + EventHandler::getInstance()->fire($event); + } +} diff --git a/wcfsetup/install/files/lib/command/cronjob/DisableCronjob.class.php b/wcfsetup/install/files/lib/command/cronjob/DisableCronjob.class.php new file mode 100644 index 00000000000..adba519f6bd --- /dev/null +++ b/wcfsetup/install/files/lib/command/cronjob/DisableCronjob.class.php @@ -0,0 +1,32 @@ + + * @since 6.3 + */ +final class DisableCronjob implements IPsr14Event +{ + public function __construct(private readonly Cronjob $cronjob) {} + + public function __invoke(): void + { + (new CronjobEditor($this->cronjob))->update([ + 'isDisabled' => 1, + ]); + + $event = new CronjobDisabled($this->cronjob); + EventHandler::getInstance()->fire($event); + } +} diff --git a/wcfsetup/install/files/lib/command/cronjob/EnableCronjob.class.php b/wcfsetup/install/files/lib/command/cronjob/EnableCronjob.class.php new file mode 100644 index 00000000000..66d1e6996b0 --- /dev/null +++ b/wcfsetup/install/files/lib/command/cronjob/EnableCronjob.class.php @@ -0,0 +1,32 @@ + + * @since 6.3 + */ +final class EnableCronjob implements IPsr14Event +{ + public function __construct(private readonly Cronjob $cronjob) {} + + public function __invoke(): void + { + (new CronjobEditor($this->cronjob))->update([ + 'isDisabled' => 0, + ]); + + $event = new CronjobEnabled($this->cronjob); + EventHandler::getInstance()->fire($event); + } +} diff --git a/wcfsetup/install/files/lib/command/language/DisableLanguage.class.php b/wcfsetup/install/files/lib/command/language/DisableLanguage.class.php new file mode 100644 index 00000000000..3dbc0889bb4 --- /dev/null +++ b/wcfsetup/install/files/lib/command/language/DisableLanguage.class.php @@ -0,0 +1,31 @@ + + * @since 6.3 + */ +final class DisableLanguage +{ + public function __construct(private readonly Language $language) {} + + public function __invoke(): void + { + (new LanguageEditor($this->language))->update([ + 'isDisabled' => 1, + ]); + + $event = new LanguageDisabled($this->language); + EventHandler::getInstance()->fire($event); + } +} diff --git a/wcfsetup/install/files/lib/command/language/EnableLanguage.class.php b/wcfsetup/install/files/lib/command/language/EnableLanguage.class.php new file mode 100644 index 00000000000..8bec03fede2 --- /dev/null +++ b/wcfsetup/install/files/lib/command/language/EnableLanguage.class.php @@ -0,0 +1,31 @@ + + * @since 6.3 + */ +final class EnableLanguage +{ + public function __construct(private readonly Language $language) {} + + public function __invoke(): void + { + (new LanguageEditor($this->language))->update([ + 'isDisabled' => 0, + ]); + + $event = new LanguageEnabled($this->language); + EventHandler::getInstance()->fire($event); + } +} diff --git a/wcfsetup/install/files/lib/command/notice/DisableNotice.class.php b/wcfsetup/install/files/lib/command/notice/DisableNotice.class.php new file mode 100644 index 00000000000..05392c91c39 --- /dev/null +++ b/wcfsetup/install/files/lib/command/notice/DisableNotice.class.php @@ -0,0 +1,31 @@ + + * @since 6.3 + */ +final class DisableNotice +{ + public function __construct(private readonly Notice $notice) {} + + public function __invoke(): void + { + (new NoticeEditor($this->notice))->update([ + 'isDisabled' => 1, + ]); + + $event = new NoticeDisabled($this->notice); + EventHandler::getInstance()->fire($event); + } +} diff --git a/wcfsetup/install/files/lib/command/notice/EnableNotice.class.php b/wcfsetup/install/files/lib/command/notice/EnableNotice.class.php new file mode 100644 index 00000000000..62f65c687ab --- /dev/null +++ b/wcfsetup/install/files/lib/command/notice/EnableNotice.class.php @@ -0,0 +1,31 @@ + + * @since 6.3 + */ +final class EnableNotice +{ + public function __construct(private readonly Notice $notice) {} + + public function __invoke(): void + { + (new NoticeEditor($this->notice))->update([ + 'isDisabled' => 0, + ]); + + $event = new NoticeEnabled($this->notice); + EventHandler::getInstance()->fire($event); + } +} diff --git a/wcfsetup/install/files/lib/command/package/update/server/DisablePackageUpdateServer.class.php b/wcfsetup/install/files/lib/command/package/update/server/DisablePackageUpdateServer.class.php new file mode 100644 index 00000000000..f0a70907fc4 --- /dev/null +++ b/wcfsetup/install/files/lib/command/package/update/server/DisablePackageUpdateServer.class.php @@ -0,0 +1,31 @@ + + * @since 6.3 + */ +final class DisablePackageUpdateServer +{ + public function __construct(private readonly PackageUpdateServer $server) {} + + public function __invoke(): void + { + (new PackageUpdateServerEditor($this->server))->update([ + 'isDisabled' => 1, + ]); + + $event = new PackageUpdateServerDisabled($this->server); + EventHandler::getInstance()->fire($event); + } +} diff --git a/wcfsetup/install/files/lib/command/package/update/server/EnablePackageUpdateServer.class.php b/wcfsetup/install/files/lib/command/package/update/server/EnablePackageUpdateServer.class.php new file mode 100644 index 00000000000..131c21309c4 --- /dev/null +++ b/wcfsetup/install/files/lib/command/package/update/server/EnablePackageUpdateServer.class.php @@ -0,0 +1,31 @@ + + * @since 6.3 + */ +final class EnablePackageUpdateServer +{ + public function __construct(private readonly PackageUpdateServer $server) {} + + public function __invoke(): void + { + (new PackageUpdateServerEditor($this->server))->update([ + 'isDisabled' => 0, + ]); + + $event = new PackageUpdateServerEnabled($this->server); + EventHandler::getInstance()->fire($event); + } +} diff --git a/wcfsetup/install/files/lib/command/page/DisablePage.class.php b/wcfsetup/install/files/lib/command/page/DisablePage.class.php new file mode 100644 index 00000000000..63e9fbffad2 --- /dev/null +++ b/wcfsetup/install/files/lib/command/page/DisablePage.class.php @@ -0,0 +1,31 @@ + + * @since 6.3 + */ +final class DisablePage +{ + public function __construct(private readonly Page $page) {} + + public function __invoke(): void + { + (new PageEditor($this->page))->update([ + 'isDisabled' => 1, + ]); + + $event = new PageDisabled($this->page); + EventHandler::getInstance()->fire($event); + } +} diff --git a/wcfsetup/install/files/lib/command/page/EnablePage.class.php b/wcfsetup/install/files/lib/command/page/EnablePage.class.php new file mode 100644 index 00000000000..52885382332 --- /dev/null +++ b/wcfsetup/install/files/lib/command/page/EnablePage.class.php @@ -0,0 +1,31 @@ + + * @since 6.3 + */ +final class EnablePage +{ + public function __construct(private readonly Page $page) {} + + public function __invoke(): void + { + (new PageEditor($this->page))->update([ + 'isDisabled' => 0, + ]); + + $event = new PageEnabled($this->page); + EventHandler::getInstance()->fire($event); + } +} diff --git a/wcfsetup/install/files/lib/command/paid/subscription/DisablePaidSubscription.class.php b/wcfsetup/install/files/lib/command/paid/subscription/DisablePaidSubscription.class.php new file mode 100644 index 00000000000..361d1beb48b --- /dev/null +++ b/wcfsetup/install/files/lib/command/paid/subscription/DisablePaidSubscription.class.php @@ -0,0 +1,31 @@ + + * @since 6.3 + */ +final class DisablePaidSubscription +{ + public function __construct(private readonly PaidSubscription $subscription) {} + + public function __invoke(): void + { + (new PaidSubscriptionEditor($this->subscription))->update([ + 'isDisabled' => 1, + ]); + + $event = new PaidSubscriptionDisabled($this->subscription); + EventHandler::getInstance()->fire($event); + } +} diff --git a/wcfsetup/install/files/lib/command/paid/subscription/EnablePaidSubscription.class.php b/wcfsetup/install/files/lib/command/paid/subscription/EnablePaidSubscription.class.php new file mode 100644 index 00000000000..b64d307f035 --- /dev/null +++ b/wcfsetup/install/files/lib/command/paid/subscription/EnablePaidSubscription.class.php @@ -0,0 +1,31 @@ + + * @since 6.3 + */ +final class EnablePaidSubscription +{ + public function __construct(private readonly PaidSubscription $subscription) {} + + public function __invoke(): void + { + (new PaidSubscriptionEditor($this->subscription))->update([ + 'isDisabled' => 0, + ]); + + $event = new PaidSubscriptionEnabled($this->subscription); + EventHandler::getInstance()->fire($event); + } +} diff --git a/wcfsetup/install/files/lib/command/reaction/type/DisableReactionType.class.php b/wcfsetup/install/files/lib/command/reaction/type/DisableReactionType.class.php new file mode 100644 index 00000000000..356577695ef --- /dev/null +++ b/wcfsetup/install/files/lib/command/reaction/type/DisableReactionType.class.php @@ -0,0 +1,31 @@ + + * @since 6.3 + */ +final class DisableReactionType +{ + public function __construct(private readonly ReactionType $reactionType) {} + + public function __invoke(): void + { + (new ReactionTypeEditor($this->reactionType))->update([ + 'isAssignable' => 0, + ]); + + $event = new ReactionTypeDisabled($this->reactionType); + EventHandler::getInstance()->fire($event); + } +} diff --git a/wcfsetup/install/files/lib/command/reaction/type/EnableReactionType.class.php b/wcfsetup/install/files/lib/command/reaction/type/EnableReactionType.class.php new file mode 100644 index 00000000000..d4ecd367a3d --- /dev/null +++ b/wcfsetup/install/files/lib/command/reaction/type/EnableReactionType.class.php @@ -0,0 +1,31 @@ + + * @since 6.3 + */ +final class EnableReactionType +{ + public function __construct(private readonly ReactionType $reactionType) {} + + public function __invoke(): void + { + (new ReactionTypeEditor($this->reactionType))->update([ + 'isAssignable' => 1, + ]); + + $event = new ReactionTypeEnabled($this->reactionType); + EventHandler::getInstance()->fire($event); + } +} diff --git a/wcfsetup/install/files/lib/command/style/DisableStyle.class.php b/wcfsetup/install/files/lib/command/style/DisableStyle.class.php new file mode 100644 index 00000000000..383e7c7f0e6 --- /dev/null +++ b/wcfsetup/install/files/lib/command/style/DisableStyle.class.php @@ -0,0 +1,31 @@ + + * @since 6.3 + */ +final class DisableStyle +{ + public function __construct(private readonly Style $style) {} + + public function __invoke(): void + { + (new StyleEditor($this->style))->update([ + 'isDisabled' => 1, + ]); + + $event = new StyleDisabled($this->style); + EventHandler::getInstance()->fire($event); + } +} diff --git a/wcfsetup/install/files/lib/command/style/EnableStyle.class.php b/wcfsetup/install/files/lib/command/style/EnableStyle.class.php new file mode 100644 index 00000000000..44d8529fa8d --- /dev/null +++ b/wcfsetup/install/files/lib/command/style/EnableStyle.class.php @@ -0,0 +1,31 @@ + + * @since 6.3 + */ +final class EnableStyle +{ + public function __construct(private readonly Style $style) {} + + public function __invoke(): void + { + (new StyleEditor($this->style))->update([ + 'isDisabled' => 0, + ]); + + $event = new StyleEnabled($this->style); + EventHandler::getInstance()->fire($event); + } +} diff --git a/wcfsetup/install/files/lib/command/trophy/DisableTrophy.class.php b/wcfsetup/install/files/lib/command/trophy/DisableTrophy.class.php new file mode 100644 index 00000000000..aa48dea5c5f --- /dev/null +++ b/wcfsetup/install/files/lib/command/trophy/DisableTrophy.class.php @@ -0,0 +1,70 @@ + + * @since 6.3 + */ +final class DisableTrophy +{ + public function __construct(private readonly Trophy $trophy) {} + + public function __invoke(): void + { + (new TrophyEditor($this->trophy))->update([ + 'isDisabled' => 1, + ]); + + $this->deleteSpecialTrophies($this->trophy->trophyID); + $this->updateTrophyPoints($this->trophy->trophyID); + $this->resetUserStorage(); + + $event = new TrophyDisabled($this->trophy); + EventHandler::getInstance()->fire($event); + } + + private function updateTrophyPoints(int $trophyID): void + { + $sql = "SELECT COUNT(*) as count, userID + FROM wcf1_user_trophy + WHERE trophyID = ? + GROUP BY userID"; + $statement = WCF::getDB()->prepare($sql); + $statement->execute([$trophyID]); + + foreach ($statement->fetchMap('userID', 'count') as $userID => $count) { + (new UserEditor(new User(null, ['userID' => $userID])))->updateCounters([ + 'trophyPoints' => $count * -1, + ]); + } + } + + private function deleteSpecialTrophies(int $trophyID): void + { + $sql = "DELETE FROM wcf1_user_special_trophy + WHERE trophyID = ?"; + $statement = WCF::getDB()->prepare($sql); + $statement->execute([ + $trophyID, + ]); + } + + private function resetUserStorage(): void + { + UserStorageHandler::getInstance()->resetAll('specialTrophies'); + } +} diff --git a/wcfsetup/install/files/lib/command/trophy/EnableTrophy.class.php b/wcfsetup/install/files/lib/command/trophy/EnableTrophy.class.php new file mode 100644 index 00000000000..004fb7c6f6f --- /dev/null +++ b/wcfsetup/install/files/lib/command/trophy/EnableTrophy.class.php @@ -0,0 +1,59 @@ + + * @since 6.3 + */ +final class EnableTrophy +{ + public function __construct(private readonly Trophy $trophy) {} + + public function __invoke(): void + { + (new TrophyEditor($this->trophy))->update([ + 'isDisabled' => 0, + ]); + + $this->updateTrophyPoints($this->trophy->trophyID); + $this->resetUserStorage(); + + $event = new TrophyEnabled($this->trophy); + EventHandler::getInstance()->fire($event); + } + + private function updateTrophyPoints(int $trophyID): void + { + $sql = "SELECT COUNT(*) as count, userID + FROM wcf1_user_trophy + WHERE trophyID = ? + GROUP BY userID"; + $statement = WCF::getDB()->prepare($sql); + $statement->execute([$trophyID]); + + foreach ($statement->fetchMap('userID', 'count') as $userID => $count) { + (new UserEditor(new User(null, ['userID' => $userID])))->updateCounters([ + 'trophyPoints' => $count, + ]); + } + } + + private function resetUserStorage(): void + { + UserStorageHandler::getInstance()->resetAll('specialTrophies'); + } +} diff --git a/wcfsetup/install/files/lib/command/user/group/assignment/DisableUserGroupAssignment.class.php b/wcfsetup/install/files/lib/command/user/group/assignment/DisableUserGroupAssignment.class.php new file mode 100644 index 00000000000..617f4160b15 --- /dev/null +++ b/wcfsetup/install/files/lib/command/user/group/assignment/DisableUserGroupAssignment.class.php @@ -0,0 +1,31 @@ + + * @since 6.3 + */ +final class DisableUserGroupAssignment +{ + public function __construct(private readonly UserGroupAssignment $assignment) {} + + public function __invoke(): void + { + (new UserGroupAssignmentEditor($this->assignment))->update([ + 'isDisabled' => 1, + ]); + + $event = new UserGroupAssignmentDisabled($this->assignment); + EventHandler::getInstance()->fire($event); + } +} diff --git a/wcfsetup/install/files/lib/command/user/group/assignment/EnableUserGroupAssignment.class.php b/wcfsetup/install/files/lib/command/user/group/assignment/EnableUserGroupAssignment.class.php new file mode 100644 index 00000000000..064d8d62de8 --- /dev/null +++ b/wcfsetup/install/files/lib/command/user/group/assignment/EnableUserGroupAssignment.class.php @@ -0,0 +1,31 @@ + + * @since 6.3 + */ +final class EnableUserGroupAssignment +{ + public function __construct(private readonly UserGroupAssignment $assignment) {} + + public function __invoke(): void + { + (new UserGroupAssignmentEditor($this->assignment))->update([ + 'isDisabled' => 0, + ]); + + $event = new UserGroupAssignmentEnabled($this->assignment); + EventHandler::getInstance()->fire($event); + } +} diff --git a/wcfsetup/install/files/lib/data/ad/AdAction.class.php b/wcfsetup/install/files/lib/data/ad/AdAction.class.php index c2be75c7b6b..d531d627b28 100644 --- a/wcfsetup/install/files/lib/data/ad/AdAction.class.php +++ b/wcfsetup/install/files/lib/data/ad/AdAction.class.php @@ -2,9 +2,10 @@ namespace wcf\data\ad; +use wcf\command\ad\DisableAd; +use wcf\command\ad\EnableAd; use wcf\data\AbstractDatabaseObjectAction; use wcf\data\IToggleAction; -use wcf\data\TDatabaseObjectToggle; use wcf\system\condition\ConditionHandler; /** @@ -18,8 +19,6 @@ */ class AdAction extends AbstractDatabaseObjectAction implements IToggleAction { - use TDatabaseObjectToggle; - /** * @inheritDoc */ @@ -64,4 +63,26 @@ public function delete() return parent::delete(); } + + /** + * @deprecated 6.3 + */ + public function validateToggle() + { + $this->validateUpdate(); + } + + /** + * @deprecated 6.3 use the `EnableAd` or `DisableAd` commands instead. + */ + public function toggle() + { + foreach ($this->objects as $adEditor) { + if ($adEditor->isDisabled) { + (new EnableAd($adEditor->getDecoratedObject()))(); + } else { + (new DisableAd($adEditor->getDecoratedObject()))(); + } + } + } } diff --git a/wcfsetup/install/files/lib/data/bbcode/media/provider/BBCodeMediaProviderAction.class.php b/wcfsetup/install/files/lib/data/bbcode/media/provider/BBCodeMediaProviderAction.class.php index 3e79c11cea1..11e9794a583 100644 --- a/wcfsetup/install/files/lib/data/bbcode/media/provider/BBCodeMediaProviderAction.class.php +++ b/wcfsetup/install/files/lib/data/bbcode/media/provider/BBCodeMediaProviderAction.class.php @@ -2,9 +2,10 @@ namespace wcf\data\bbcode\media\provider; +use wcf\command\bbcode\media\provider\DisableBBCodeMediaProvider; +use wcf\command\bbcode\media\provider\EnableBBCodeMediaProvider; use wcf\data\AbstractDatabaseObjectAction; use wcf\data\IToggleAction; -use wcf\data\TDatabaseObjectToggle; /** * Executes BBCode media provider-related actions. @@ -17,8 +18,6 @@ */ class BBCodeMediaProviderAction extends AbstractDatabaseObjectAction implements IToggleAction { - use TDatabaseObjectToggle; - /** * @inheritDoc */ @@ -38,4 +37,26 @@ class BBCodeMediaProviderAction extends AbstractDatabaseObjectAction implements * @inheritDoc */ protected $requireACP = ['delete', 'update']; + + /** + * @deprecated 6.3 + */ + public function validateToggle() + { + $this->validateUpdate(); + } + + /** + * @deprecated 6.3 use the `EnableBBCodeMediaProvider` or `DisableBBCodeMediaProvider` commands instead. + */ + public function toggle() + { + foreach ($this->objects as $editor) { + if ($editor->isDisabled) { + (new EnableBBCodeMediaProvider($editor->getDecoratedObject()))(); + } else { + (new DisableBBCodeMediaProvider($editor->getDecoratedObject()))(); + } + } + } } diff --git a/wcfsetup/install/files/lib/data/box/BoxAction.class.php b/wcfsetup/install/files/lib/data/box/BoxAction.class.php index a3a46ee01d2..aba512757c0 100644 --- a/wcfsetup/install/files/lib/data/box/BoxAction.class.php +++ b/wcfsetup/install/files/lib/data/box/BoxAction.class.php @@ -2,13 +2,14 @@ namespace wcf\data\box; +use wcf\command\box\DisableBox; +use wcf\command\box\EnableBox; use wcf\data\AbstractDatabaseObjectAction; use wcf\data\box\content\BoxContent; use wcf\data\box\content\BoxContentEditor; use wcf\data\IToggleAction; use wcf\data\object\type\ObjectType; use wcf\data\object\type\ObjectTypeCache; -use wcf\data\TDatabaseObjectToggle; use wcf\system\box\IConditionBoxController; use wcf\system\exception\PermissionDeniedException; use wcf\system\exception\UserInputException; @@ -29,8 +30,6 @@ */ class BoxAction extends AbstractDatabaseObjectAction implements IToggleAction { - use TDatabaseObjectToggle; - /** * @inheritDoc */ @@ -320,4 +319,26 @@ public function getBoxConditionsTemplate() 'template' => $this->boxController->getProcessor() instanceof IConditionBoxController ? $this->boxController->getProcessor()->getConditionsTemplate() : '', ]; } + + /** + * @deprecated 6.3 + */ + public function validateToggle() + { + $this->validateUpdate(); + } + + /** + * @deprecated 6.3 use the `EnableBox` or `DisableBox` commands instead. + */ + public function toggle() + { + foreach ($this->objects as $editor) { + if ($editor->isDisabled) { + (new EnableBox($editor->getDecoratedObject()))(); + } else { + (new DisableBox($editor->getDecoratedObject()))(); + } + } + } } diff --git a/wcfsetup/install/files/lib/data/captcha/question/CaptchaQuestionAction.class.php b/wcfsetup/install/files/lib/data/captcha/question/CaptchaQuestionAction.class.php index 52651d3201c..79f72ce61df 100644 --- a/wcfsetup/install/files/lib/data/captcha/question/CaptchaQuestionAction.class.php +++ b/wcfsetup/install/files/lib/data/captcha/question/CaptchaQuestionAction.class.php @@ -2,9 +2,10 @@ namespace wcf\data\captcha\question; +use wcf\command\captcha\question\DisableCaptchaQuestion; +use wcf\command\captcha\question\EnableCaptchaQuestion; use wcf\data\AbstractDatabaseObjectAction; use wcf\data\IToggleAction; -use wcf\data\TDatabaseObjectToggle; use wcf\data\TI18nDatabaseObjectAction; /** @@ -18,7 +19,6 @@ */ class CaptchaQuestionAction extends AbstractDatabaseObjectAction implements IToggleAction { - use TDatabaseObjectToggle; use TI18nDatabaseObjectAction; /** @@ -87,4 +87,26 @@ public function delete() return $returnValue; } + + /** + * @deprecated 6.3 + */ + public function validateToggle() + { + $this->validateUpdate(); + } + + /** + * @deprecated 6.3 use the `EnableCaptchaQuestion` or `DisableCaptchaQuestion` commands instead. + */ + public function toggle() + { + foreach ($this->objects as $editor) { + if ($editor->isDisabled) { + (new EnableCaptchaQuestion($editor->getDecoratedObject()))(); + } else { + (new DisableCaptchaQuestion($editor->getDecoratedObject()))(); + } + } + } } diff --git a/wcfsetup/install/files/lib/data/contact/option/ContactOptionAction.class.php b/wcfsetup/install/files/lib/data/contact/option/ContactOptionAction.class.php index dd2a8bdddd4..401e4e5b7d5 100644 --- a/wcfsetup/install/files/lib/data/contact/option/ContactOptionAction.class.php +++ b/wcfsetup/install/files/lib/data/contact/option/ContactOptionAction.class.php @@ -2,9 +2,11 @@ namespace wcf\data\contact\option; +use wcf\command\contact\option\DisableContactOption; +use wcf\command\contact\option\EnableContactOption; use wcf\data\AbstractDatabaseObjectAction; use wcf\data\ISortableAction; -use wcf\data\TDatabaseObjectToggle; +use wcf\data\IToggleAction; use wcf\data\TI18nDatabaseObjectAction; use wcf\system\exception\UserInputException; use wcf\system\WCF; @@ -19,10 +21,9 @@ * * @extends AbstractDatabaseObjectAction */ -class ContactOptionAction extends AbstractDatabaseObjectAction implements ISortableAction +class ContactOptionAction extends AbstractDatabaseObjectAction implements ISortableAction, IToggleAction { use TI18nDatabaseObjectAction; - use TDatabaseObjectToggle; /** * @inheritDoc @@ -141,4 +142,26 @@ public function getPackageID(): int { return 1; } + + /** + * @deprecated 6.3 + */ + public function validateToggle() + { + $this->validateUpdate(); + } + + /** + * @deprecated 6.3 use the `EnableContactOption` or `DisableContactOption` commands instead. + */ + public function toggle() + { + foreach ($this->objects as $editor) { + if ($editor->isDisabled) { + (new EnableContactOption($editor->getDecoratedObject()))(); + } else { + (new DisableContactOption($editor->getDecoratedObject()))(); + } + } + } } diff --git a/wcfsetup/install/files/lib/data/contact/recipient/ContactRecipientAction.class.php b/wcfsetup/install/files/lib/data/contact/recipient/ContactRecipientAction.class.php index 1caf65c5f5b..dceda54393a 100644 --- a/wcfsetup/install/files/lib/data/contact/recipient/ContactRecipientAction.class.php +++ b/wcfsetup/install/files/lib/data/contact/recipient/ContactRecipientAction.class.php @@ -2,9 +2,10 @@ namespace wcf\data\contact\recipient; +use wcf\command\contact\recipient\DisableContactRecipient; +use wcf\command\contact\recipient\EnableContactRecipient; use wcf\data\AbstractDatabaseObjectAction; use wcf\data\IToggleAction; -use wcf\data\TDatabaseObjectToggle; use wcf\data\TI18nDatabaseObjectAction; use wcf\system\exception\PermissionDeniedException; @@ -20,7 +21,6 @@ */ class ContactRecipientAction extends AbstractDatabaseObjectAction implements IToggleAction { - use TDatabaseObjectToggle; use TI18nDatabaseObjectAction; /** @@ -64,6 +64,7 @@ public function validateDelete() /** * @inheritDoc + * @deprecated 6.3 */ public function validateToggle() { @@ -131,4 +132,18 @@ public function getPackageID(): int { return 1; } + + /** + * @deprecated 6.3 use the `EnableContactRecipient` or `DisableContactRecipient` commands instead. + */ + public function toggle() + { + foreach ($this->objects as $editor) { + if ($editor->isDisabled) { + (new EnableContactRecipient($editor->getDecoratedObject()))(); + } else { + (new DisableContactRecipient($editor->getDecoratedObject()))(); + } + } + } } diff --git a/wcfsetup/install/files/lib/data/cronjob/CronjobAction.class.php b/wcfsetup/install/files/lib/data/cronjob/CronjobAction.class.php index 0e110e422a6..2a66017f849 100644 --- a/wcfsetup/install/files/lib/data/cronjob/CronjobAction.class.php +++ b/wcfsetup/install/files/lib/data/cronjob/CronjobAction.class.php @@ -2,10 +2,11 @@ namespace wcf\data\cronjob; +use wcf\command\cronjob\DisableCronjob; +use wcf\command\cronjob\EnableCronjob; use wcf\data\AbstractDatabaseObjectAction; use wcf\data\cronjob\log\CronjobLogEditor; use wcf\data\IToggleAction; -use wcf\data\TDatabaseObjectToggle; use wcf\data\user\User; use wcf\system\cronjob\CronjobScheduler; use wcf\system\cronjob\ICronjob; @@ -24,8 +25,6 @@ */ class CronjobAction extends AbstractDatabaseObjectAction implements IToggleAction { - use TDatabaseObjectToggle; - /** * @inheritDoc */ @@ -86,6 +85,8 @@ public function validateUpdate() /** * @inheritDoc + * + * @deprecated 6.3 */ public function validateToggle() { @@ -242,4 +243,18 @@ public function executeCronjobs() CronjobScheduler::getInstance()->executeCronjobs(); } + + /** + * @deprecated 6.3 use the `EnableCronjob` or `DisableCronjob` commands instead. + */ + public function toggle() + { + foreach ($this->objects as $editor) { + if ($editor->isDisabled) { + (new EnableCronjob($editor->getDecoratedObject()))(); + } else { + (new DisableCronjob($editor->getDecoratedObject()))(); + } + } + } } diff --git a/wcfsetup/install/files/lib/data/language/LanguageAction.class.php b/wcfsetup/install/files/lib/data/language/LanguageAction.class.php index 8896243dc86..f13f78a3244 100644 --- a/wcfsetup/install/files/lib/data/language/LanguageAction.class.php +++ b/wcfsetup/install/files/lib/data/language/LanguageAction.class.php @@ -2,9 +2,10 @@ namespace wcf\data\language; +use wcf\command\language\DisableLanguage; +use wcf\command\language\EnableLanguage; use wcf\data\AbstractDatabaseObjectAction; use wcf\data\IToggleAction; -use wcf\data\TDatabaseObjectToggle; use wcf\system\exception\UserInputException; use wcf\system\language\LanguageFactory; use wcf\system\style\StyleHandler; @@ -21,8 +22,6 @@ */ class LanguageAction extends AbstractDatabaseObjectAction implements IToggleAction { - use TDatabaseObjectToggle; - /** * @inheritDoc */ @@ -103,6 +102,8 @@ public function setAsDefault() /** * @inheritDoc + * + * @deprecated 6.3 */ public function validateToggle() { @@ -115,6 +116,20 @@ public function validateToggle() } } + /** + * @deprecated 6.3 use the `EnableLanguage` or `DisableLanguage` commands instead. + */ + public function toggle() + { + foreach ($this->objects as $editor) { + if ($editor->isDisabled) { + (new EnableLanguage($editor->getDecoratedObject()))(); + } else { + (new DisableLanguage($editor->getDecoratedObject()))(); + } + } + } + /** * @inheritDoc */ diff --git a/wcfsetup/install/files/lib/data/notice/NoticeAction.class.php b/wcfsetup/install/files/lib/data/notice/NoticeAction.class.php index 325174eea6c..11a831d9684 100644 --- a/wcfsetup/install/files/lib/data/notice/NoticeAction.class.php +++ b/wcfsetup/install/files/lib/data/notice/NoticeAction.class.php @@ -2,9 +2,10 @@ namespace wcf\data\notice; +use wcf\command\notice\DisableNotice; +use wcf\command\notice\EnableNotice; use wcf\data\AbstractDatabaseObjectAction; use wcf\data\IToggleAction; -use wcf\data\TDatabaseObjectToggle; use wcf\system\condition\ConditionHandler; use wcf\system\user\storage\UserStorageHandler; use wcf\system\WCF; @@ -20,8 +21,6 @@ */ class NoticeAction extends AbstractDatabaseObjectAction implements IToggleAction { - use TDatabaseObjectToggle; - /** * @inheritDoc */ @@ -134,4 +133,26 @@ public function update() \reset($this->objects)->setShowOrder($this->parameters['data']['showOrder']); } } + + /** + * @deprecated 6.3 + */ + public function validateToggle() + { + $this->validateUpdate(); + } + + /** + * @deprecated 6.3 use the `EnableNotice` or `DisableNotice` commands instead. + */ + public function toggle() + { + foreach ($this->objects as $editor) { + if ($editor->isDisabled) { + (new EnableNotice($editor->getDecoratedObject()))(); + } else { + (new DisableNotice($editor->getDecoratedObject()))(); + } + } + } } diff --git a/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServerAction.class.php b/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServerAction.class.php index 26b510a0b92..2c606c9c468 100644 --- a/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServerAction.class.php +++ b/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServerAction.class.php @@ -2,9 +2,10 @@ namespace wcf\data\package\update\server; +use wcf\command\package\update\server\DisablePackageUpdateServer; +use wcf\command\package\update\server\EnablePackageUpdateServer; use wcf\data\AbstractDatabaseObjectAction; use wcf\data\IToggleAction; -use wcf\data\TDatabaseObjectToggle; use wcf\system\exception\PermissionDeniedException; /** @@ -18,10 +19,6 @@ */ class PackageUpdateServerAction extends AbstractDatabaseObjectAction implements IToggleAction { - use TDatabaseObjectToggle { - validateToggle as traitValidateToggle; - } - /** * @inheritDoc */ @@ -64,10 +61,12 @@ public function validateDelete() /** * @inheritDoc + * + * @deprecated 6.3 */ public function validateToggle() { - $this->traitValidateToggle(); + $this->validateUpdate(); /** @var PackageUpdateServer $updateServer */ foreach ($this->getObjects() as $updateServer) { @@ -76,4 +75,18 @@ public function validateToggle() } } } + + /** + * @deprecated 6.3 use the `EnablePackageUpdateServer` or `DisablePackageUpdateServer` commands instead. + */ + public function toggle() + { + foreach ($this->objects as $editor) { + if ($editor->isDisabled) { + (new EnablePackageUpdateServer($editor->getDecoratedObject()))(); + } else { + (new DisablePackageUpdateServer($editor->getDecoratedObject()))(); + } + } + } } diff --git a/wcfsetup/install/files/lib/data/page/PageAction.class.php b/wcfsetup/install/files/lib/data/page/PageAction.class.php index dcee84d960c..e4eed9a232b 100644 --- a/wcfsetup/install/files/lib/data/page/PageAction.class.php +++ b/wcfsetup/install/files/lib/data/page/PageAction.class.php @@ -2,6 +2,8 @@ namespace wcf\data\page; +use wcf\command\page\DisablePage; +use wcf\command\page\EnablePage; use wcf\data\AbstractDatabaseObjectAction; use wcf\data\box\Box; use wcf\data\ISearchAction; @@ -9,7 +11,6 @@ use wcf\data\IToggleAction; use wcf\data\page\content\PageContent; use wcf\data\page\content\PageContentEditor; -use wcf\data\TDatabaseObjectToggle; use wcf\system\comment\CommentHandler; use wcf\system\database\util\PreparedStatementConditionBuilder; use wcf\system\exception\PermissionDeniedException; @@ -33,8 +34,6 @@ */ class PageAction extends AbstractDatabaseObjectAction implements ISearchAction, ISortableAction, IToggleAction { - use TDatabaseObjectToggle; - /** * @inheritDoc */ @@ -305,6 +304,8 @@ public function validateDelete() /** * @inheritDoc + * + * @deprecated 6.3 */ public function validateToggle() { @@ -530,4 +531,26 @@ public function resetPosition() $statement = WCF::getDB()->prepare($sql); $statement->execute([$this->pageEditor->getDecoratedObject()->pageID]); } + + /** + * @deprecated 6.3 + */ + public function validateToggle() + { + $this->validateUpdate(); + } + + /** + * @deprecated 6.3 use the `EnablePage` or `DisablePage` commands instead. + */ + public function toggle() + { + foreach ($this->objects as $editor) { + if ($editor->isDisabled) { + (new EnablePage($editor->getDecoratedObject()))(); + } else { + (new DisablePage($editor->getDecoratedObject()))(); + } + } + } } diff --git a/wcfsetup/install/files/lib/data/paid/subscription/PaidSubscriptionAction.class.php b/wcfsetup/install/files/lib/data/paid/subscription/PaidSubscriptionAction.class.php index 1936ef14986..9822a2aec8a 100644 --- a/wcfsetup/install/files/lib/data/paid/subscription/PaidSubscriptionAction.class.php +++ b/wcfsetup/install/files/lib/data/paid/subscription/PaidSubscriptionAction.class.php @@ -2,9 +2,10 @@ namespace wcf\data\paid\subscription; +use wcf\command\paid\subscription\DisablePaidSubscription; +use wcf\command\paid\subscription\EnablePaidSubscription; use wcf\data\AbstractDatabaseObjectAction; use wcf\data\IToggleAction; -use wcf\data\TDatabaseObjectToggle; /** * Executes paid subscription-related actions. @@ -17,8 +18,6 @@ */ class PaidSubscriptionAction extends AbstractDatabaseObjectAction implements IToggleAction { - use TDatabaseObjectToggle; - /** * @inheritDoc */ @@ -69,4 +68,26 @@ public function update() \reset($this->objects)->setShowOrder($this->parameters['data']['showOrder']); } } + + /** + * @deprecated 6.3 + */ + public function validateToggle() + { + $this->validateUpdate(); + } + + /** + * @deprecated 6.3 use the `EnablePaidSubscription` or `DisablePaidSubscription` commands instead. + */ + public function toggle() + { + foreach ($this->objects as $editor) { + if ($editor->isDisabled) { + (new EnablePaidSubscription($editor->getDecoratedObject()))(); + } else { + (new DisablePaidSubscription($editor->getDecoratedObject()))(); + } + } + } } diff --git a/wcfsetup/install/files/lib/data/reaction/type/ReactionTypeAction.class.php b/wcfsetup/install/files/lib/data/reaction/type/ReactionTypeAction.class.php index cedece989e2..f535580f3a6 100644 --- a/wcfsetup/install/files/lib/data/reaction/type/ReactionTypeAction.class.php +++ b/wcfsetup/install/files/lib/data/reaction/type/ReactionTypeAction.class.php @@ -2,9 +2,10 @@ namespace wcf\data\reaction\type; +use wcf\command\reaction\type\DisableReactionType; +use wcf\command\reaction\type\EnableReactionType; use wcf\data\AbstractDatabaseObjectAction; use wcf\data\IToggleAction; -use wcf\data\TDatabaseObjectToggle; use wcf\system\file\upload\UploadFile; use wcf\system\language\I18nHandler; use wcf\system\WCF; @@ -21,8 +22,6 @@ */ class ReactionTypeAction extends AbstractDatabaseObjectAction implements IToggleAction { - use TDatabaseObjectToggle; - /** * @inheritDoc */ @@ -201,15 +200,27 @@ public function delete() return $returnValues; } + /** + * @deprecated 6.3 + */ + public function validateToggle() + { + $this->validateUpdate(); + } + /** * @inheritDoc + * + * @deprecated 6.3 use the `DisableReactionType` or `EnableReactionType` command instead. */ public function toggle() { - foreach ($this->getObjects() as $object) { - $object->update([ - 'isAssignable' => $object->isAssignable ? 0 : 1, - ]); + foreach ($this->getObjects() as $editor) { + if ($editor->isAssignable) { + (new DisableReactionType($editor->getDecoratedObject()))(); + } else { + (new EnableReactionType($editor->getDecoratedObject()))(); + } } } } diff --git a/wcfsetup/install/files/lib/data/style/StyleAction.class.php b/wcfsetup/install/files/lib/data/style/StyleAction.class.php index 8575be3fe7b..11200c0fc82 100644 --- a/wcfsetup/install/files/lib/data/style/StyleAction.class.php +++ b/wcfsetup/install/files/lib/data/style/StyleAction.class.php @@ -3,9 +3,10 @@ namespace wcf\data\style; use ParagonIE\ConstantTime\Hex; +use wcf\command\style\DisableStyle; +use wcf\command\style\EnableStyle; use wcf\data\AbstractDatabaseObjectAction; use wcf\data\IToggleAction; -use wcf\data\TDatabaseObjectToggle; use wcf\data\user\UserAction; use wcf\system\exception\PermissionDeniedException; use wcf\system\image\ImageHandler; @@ -28,8 +29,6 @@ */ class StyleAction extends AbstractDatabaseObjectAction implements IToggleAction { - use TDatabaseObjectToggle; - /** * @inheritDoc */ @@ -639,4 +638,26 @@ public function markAsTainted(): void 'packageName' => '', ]); } + + /** + * @deprecated 6.3 + */ + public function validateToggle() + { + $this->validateUpdate(); + } + + /** + * @deprecated 6.3 use the `EnableStyle` or `DisableStyle` commands instead. + */ + public function toggle() + { + foreach ($this->objects as $editor) { + if ($editor->isDisabled) { + (new EnableStyle($editor->getDecoratedObject()))(); + } else { + (new DisableStyle($editor->getDecoratedObject()))(); + } + } + } } diff --git a/wcfsetup/install/files/lib/data/trophy/TrophyAction.class.php b/wcfsetup/install/files/lib/data/trophy/TrophyAction.class.php index b8f10222dff..c262bfb93ca 100644 --- a/wcfsetup/install/files/lib/data/trophy/TrophyAction.class.php +++ b/wcfsetup/install/files/lib/data/trophy/TrophyAction.class.php @@ -2,14 +2,13 @@ namespace wcf\data\trophy; +use wcf\command\trophy\DisableTrophy; +use wcf\command\trophy\EnableTrophy; use wcf\data\AbstractDatabaseObjectAction; use wcf\data\IToggleAction; use wcf\data\IUploadAction; -use wcf\data\TDatabaseObjectToggle; use wcf\data\user\trophy\UserTrophyAction; use wcf\data\user\trophy\UserTrophyList; -use wcf\data\user\UserAction; -use wcf\system\database\util\PreparedStatementConditionBuilder; use wcf\system\exception\IllegalLinkException; use wcf\system\exception\UserInputException; use wcf\system\image\ImageHandler; @@ -30,8 +29,6 @@ */ class TrophyAction extends AbstractDatabaseObjectAction implements IToggleAction, IUploadAction { - use TDatabaseObjectToggle; - /** * @inheritDoc */ @@ -127,74 +124,27 @@ public function update() } } + /** + * @deprecated 6.3 + */ + public function validateToggle() + { + $this->validateUpdate(); + } + /** * @inheritDoc + * @deprecated 6.3 use the `EnableTrophy` or `DisableTrophy` commands instead. */ public function toggle() { - $enabledTrophyIDs = []; - $disabledTrophyIDs = []; - - foreach ($this->getObjects() as $trophy) { - $trophy->update(['isDisabled' => $trophy->isDisabled ? 0 : 1]); - - if (!$trophy->isDisabled) { - $disabledTrophyIDs[] = $trophy->trophyID; + foreach ($this->getObjects() as $editor) { + if ($editor->isDisabled) { + (new EnableTrophy($editor->getDecoratedObject()))(); } else { - $enabledTrophyIDs[] = $trophy->trophyID; + (new DisableTrophy($editor->getDecoratedObject()))(); } } - - if (!empty($disabledTrophyIDs)) { - $conditionBuilder = new PreparedStatementConditionBuilder(); - $conditionBuilder->add('trophyID IN (?)', [$disabledTrophyIDs]); - $sql = "DELETE FROM wcf1_user_special_trophy - " . $conditionBuilder; - $statement = WCF::getDB()->prepare($sql); - $statement->execute($conditionBuilder->getParameters()); - - // update trophy points - $conditionBuilder = new PreparedStatementConditionBuilder(); - $conditionBuilder->add('trophyID IN (?)', [$disabledTrophyIDs]); - $sql = "SELECT COUNT(*) as count, userID - FROM wcf1_user_trophy - " . $conditionBuilder . " - GROUP BY userID"; - $statement = WCF::getDB()->prepare($sql); - $statement->execute($conditionBuilder->getParameters()); - - while ($row = $statement->fetchArray()) { - $userAction = new UserAction([$row['userID']], 'update', [ - 'counters' => [ - 'trophyPoints' => $row['count'] * -1, - ], - ]); - $userAction->executeAction(); - } - } - - if (!empty($enabledTrophyIDs)) { - // update trophy points - $conditionBuilder = new PreparedStatementConditionBuilder(); - $conditionBuilder->add('trophyID IN (?)', [$enabledTrophyIDs]); - $sql = "SELECT COUNT(*) as count, userID - FROM wcf1_user_trophy - " . $conditionBuilder . " - GROUP BY userID"; - $statement = WCF::getDB()->prepare($sql); - $statement->execute($conditionBuilder->getParameters()); - - while ($row = $statement->fetchArray()) { - $userAction = new UserAction([$row['userID']], 'update', [ - 'counters' => [ - 'trophyPoints' => $row['count'], - ], - ]); - $userAction->executeAction(); - } - } - - UserStorageHandler::getInstance()->resetAll('specialTrophies'); } /** diff --git a/wcfsetup/install/files/lib/data/user/group/assignment/UserGroupAssignmentAction.class.php b/wcfsetup/install/files/lib/data/user/group/assignment/UserGroupAssignmentAction.class.php index f900e1b5e2d..df2059dcd7c 100644 --- a/wcfsetup/install/files/lib/data/user/group/assignment/UserGroupAssignmentAction.class.php +++ b/wcfsetup/install/files/lib/data/user/group/assignment/UserGroupAssignmentAction.class.php @@ -2,9 +2,10 @@ namespace wcf\data\user\group\assignment; +use wcf\command\user\group\assignment\DisableUserGroupAssignment; +use wcf\command\user\group\assignment\EnableUserGroupAssignment; use wcf\data\AbstractDatabaseObjectAction; use wcf\data\IToggleAction; -use wcf\data\TDatabaseObjectToggle; use wcf\system\condition\ConditionHandler; /** @@ -18,8 +19,6 @@ */ class UserGroupAssignmentAction extends AbstractDatabaseObjectAction implements IToggleAction { - use TDatabaseObjectToggle; - /** * @inheritDoc */ @@ -47,4 +46,26 @@ public function delete() return parent::delete(); } + + /** + * @deprecated 6.3 + */ + public function validateToggle() + { + $this->validateUpdate(); + } + + /** + * @deprecated 6.3 use the `EnableUserGroupAssignment` or `DisableUserGroupAssignment` commands instead. + */ + public function toggle() + { + foreach ($this->objects as $editor) { + if ($editor->isDisabled) { + (new EnableUserGroupAssignment($editor->getDecoratedObject()))(); + } else { + (new DisableUserGroupAssignment($editor->getDecoratedObject()))(); + } + } + } } diff --git a/wcfsetup/install/files/lib/event/ad/AdDisabled.class.php b/wcfsetup/install/files/lib/event/ad/AdDisabled.class.php new file mode 100644 index 00000000000..02b62715e98 --- /dev/null +++ b/wcfsetup/install/files/lib/event/ad/AdDisabled.class.php @@ -0,0 +1,19 @@ + + * @since 6.3 + */ +final class AdDisabled implements IPsr14Event +{ + public function __construct(public readonly Ad $ad) {} +} diff --git a/wcfsetup/install/files/lib/event/ad/AdEnabled.class.php b/wcfsetup/install/files/lib/event/ad/AdEnabled.class.php new file mode 100644 index 00000000000..4d9159ac0e6 --- /dev/null +++ b/wcfsetup/install/files/lib/event/ad/AdEnabled.class.php @@ -0,0 +1,19 @@ + + * @since 6.3 + */ +final class AdEnabled implements IPsr14Event +{ + public function __construct(public readonly Ad $ad) {} +} diff --git a/wcfsetup/install/files/lib/event/bbcode/media/provider/BBCodeMediaProviderDisabled.class.php b/wcfsetup/install/files/lib/event/bbcode/media/provider/BBCodeMediaProviderDisabled.class.php new file mode 100644 index 00000000000..7a372ca2c70 --- /dev/null +++ b/wcfsetup/install/files/lib/event/bbcode/media/provider/BBCodeMediaProviderDisabled.class.php @@ -0,0 +1,19 @@ + + * @since 6.3 + */ +final class BBCodeMediaProviderDisabled implements IPsr14Event +{ + public function __construct(public readonly BBCodeMediaProvider $mediaProvider) {} +} diff --git a/wcfsetup/install/files/lib/event/bbcode/media/provider/BBCodeMediaProviderEnabled.class.php b/wcfsetup/install/files/lib/event/bbcode/media/provider/BBCodeMediaProviderEnabled.class.php new file mode 100644 index 00000000000..0764308dc94 --- /dev/null +++ b/wcfsetup/install/files/lib/event/bbcode/media/provider/BBCodeMediaProviderEnabled.class.php @@ -0,0 +1,19 @@ + + * @since 6.3 + */ +final class BBCodeMediaProviderEnabled implements IPsr14Event +{ + public function __construct(public readonly BBCodeMediaProvider $mediaProvider) {} +} diff --git a/wcfsetup/install/files/lib/event/box/BoxDisabled.class.php b/wcfsetup/install/files/lib/event/box/BoxDisabled.class.php new file mode 100644 index 00000000000..90b62fbc8cc --- /dev/null +++ b/wcfsetup/install/files/lib/event/box/BoxDisabled.class.php @@ -0,0 +1,19 @@ + + * @since 6.3 + */ +final class BoxDisabled implements IPsr14Event +{ + public function __construct(public readonly Box $box) {} +} diff --git a/wcfsetup/install/files/lib/event/box/BoxEnabled.class.php b/wcfsetup/install/files/lib/event/box/BoxEnabled.class.php new file mode 100644 index 00000000000..51e325ce51f --- /dev/null +++ b/wcfsetup/install/files/lib/event/box/BoxEnabled.class.php @@ -0,0 +1,19 @@ + + * @since 6.3 + */ +final class BoxEnabled implements IPsr14Event +{ + public function __construct(public readonly Box $box) {} +} diff --git a/wcfsetup/install/files/lib/event/captcha/question/CaptchaQuestionDisabled.class.php b/wcfsetup/install/files/lib/event/captcha/question/CaptchaQuestionDisabled.class.php new file mode 100644 index 00000000000..312fec8b4d1 --- /dev/null +++ b/wcfsetup/install/files/lib/event/captcha/question/CaptchaQuestionDisabled.class.php @@ -0,0 +1,19 @@ + + * @since 6.3 + */ +final class CaptchaQuestionDisabled implements IPsr14Event +{ + public function __construct(public readonly CaptchaQuestion $captchaQuestion) {} +} diff --git a/wcfsetup/install/files/lib/event/captcha/question/CaptchaQuestionEnabled.class.php b/wcfsetup/install/files/lib/event/captcha/question/CaptchaQuestionEnabled.class.php new file mode 100644 index 00000000000..d3f8340b7ac --- /dev/null +++ b/wcfsetup/install/files/lib/event/captcha/question/CaptchaQuestionEnabled.class.php @@ -0,0 +1,19 @@ + + * @since 6.3 + */ +final class CaptchaQuestionEnabled implements IPsr14Event +{ + public function __construct(public readonly CaptchaQuestion $captchaQuestion) {} +} diff --git a/wcfsetup/install/files/lib/event/contact/option/ContactOptionDisabled.class.php b/wcfsetup/install/files/lib/event/contact/option/ContactOptionDisabled.class.php new file mode 100644 index 00000000000..673eb81c87b --- /dev/null +++ b/wcfsetup/install/files/lib/event/contact/option/ContactOptionDisabled.class.php @@ -0,0 +1,19 @@ + + * @since 6.3 + */ +final class ContactOptionDisabled implements IPsr14Event +{ + public function __construct(public readonly ContactOption $contactOption) {} +} diff --git a/wcfsetup/install/files/lib/event/contact/option/ContactOptionEnabled.class.php b/wcfsetup/install/files/lib/event/contact/option/ContactOptionEnabled.class.php new file mode 100644 index 00000000000..e65f83dae41 --- /dev/null +++ b/wcfsetup/install/files/lib/event/contact/option/ContactOptionEnabled.class.php @@ -0,0 +1,19 @@ + + * @since 6.3 + */ +final class ContactOptionEnabled implements IPsr14Event +{ + public function __construct(public readonly ContactOption $contactOption) {} +} diff --git a/wcfsetup/install/files/lib/event/contact/recipient/ContactRecipientDisabled.class.php b/wcfsetup/install/files/lib/event/contact/recipient/ContactRecipientDisabled.class.php new file mode 100644 index 00000000000..3c5a32d8d41 --- /dev/null +++ b/wcfsetup/install/files/lib/event/contact/recipient/ContactRecipientDisabled.class.php @@ -0,0 +1,19 @@ + + * @since 6.3 + */ +final class ContactRecipientDisabled implements IPsr14Event +{ + public function __construct(public readonly ContactRecipient $recipient) {} +} diff --git a/wcfsetup/install/files/lib/event/contact/recipient/ContactRecipientEnabled.class.php b/wcfsetup/install/files/lib/event/contact/recipient/ContactRecipientEnabled.class.php new file mode 100644 index 00000000000..014e0e77f8a --- /dev/null +++ b/wcfsetup/install/files/lib/event/contact/recipient/ContactRecipientEnabled.class.php @@ -0,0 +1,19 @@ + + * @since 6.3 + */ +final class ContactRecipientEnabled implements IPsr14Event +{ + public function __construct(public readonly ContactRecipient $recipient) {} +} diff --git a/wcfsetup/install/files/lib/event/cronjob/CronjobDisabled.class.php b/wcfsetup/install/files/lib/event/cronjob/CronjobDisabled.class.php new file mode 100644 index 00000000000..2331a8b28dc --- /dev/null +++ b/wcfsetup/install/files/lib/event/cronjob/CronjobDisabled.class.php @@ -0,0 +1,19 @@ + + * @since 6.3 + */ +final class CronjobDisabled implements IPsr14Event +{ + public function __construct(public readonly Cronjob $cronjob) {} +} diff --git a/wcfsetup/install/files/lib/event/cronjob/CronjobEnabled.class.php b/wcfsetup/install/files/lib/event/cronjob/CronjobEnabled.class.php new file mode 100644 index 00000000000..07ae726f989 --- /dev/null +++ b/wcfsetup/install/files/lib/event/cronjob/CronjobEnabled.class.php @@ -0,0 +1,19 @@ + + * @since 6.3 + */ +final class CronjobEnabled implements IPsr14Event +{ + public function __construct(public readonly Cronjob $cronjob) {} +} diff --git a/wcfsetup/install/files/lib/event/language/LanguageDisabled.class.php b/wcfsetup/install/files/lib/event/language/LanguageDisabled.class.php new file mode 100644 index 00000000000..caec2820a00 --- /dev/null +++ b/wcfsetup/install/files/lib/event/language/LanguageDisabled.class.php @@ -0,0 +1,19 @@ + + * @since 6.3 + */ +final class LanguageDisabled implements IPsr14Event +{ + public function __construct(public readonly Language $language) {} +} diff --git a/wcfsetup/install/files/lib/event/language/LanguageEnabled.class.php b/wcfsetup/install/files/lib/event/language/LanguageEnabled.class.php new file mode 100644 index 00000000000..db348152ed1 --- /dev/null +++ b/wcfsetup/install/files/lib/event/language/LanguageEnabled.class.php @@ -0,0 +1,19 @@ + + * @since 6.3 + */ +final class LanguageEnabled implements IPsr14Event +{ + public function __construct(public readonly Language $language) {} +} diff --git a/wcfsetup/install/files/lib/event/notice/NoticeDisabled.class.php b/wcfsetup/install/files/lib/event/notice/NoticeDisabled.class.php new file mode 100644 index 00000000000..70c28859d79 --- /dev/null +++ b/wcfsetup/install/files/lib/event/notice/NoticeDisabled.class.php @@ -0,0 +1,19 @@ + + * @since 6.3 + */ +final class NoticeDisabled implements IPsr14Event +{ + public function __construct(public readonly Notice $notice) {} +} diff --git a/wcfsetup/install/files/lib/event/notice/NoticeEnabled.class.php b/wcfsetup/install/files/lib/event/notice/NoticeEnabled.class.php new file mode 100644 index 00000000000..c2996d25ed2 --- /dev/null +++ b/wcfsetup/install/files/lib/event/notice/NoticeEnabled.class.php @@ -0,0 +1,19 @@ + + * @since 6.3 + */ +final class NoticeEnabled implements IPsr14Event +{ + public function __construct(public readonly Notice $notice) {} +} diff --git a/wcfsetup/install/files/lib/event/package/update/server/PackageUpdateServerDisabled.class.php b/wcfsetup/install/files/lib/event/package/update/server/PackageUpdateServerDisabled.class.php new file mode 100644 index 00000000000..f455a642e04 --- /dev/null +++ b/wcfsetup/install/files/lib/event/package/update/server/PackageUpdateServerDisabled.class.php @@ -0,0 +1,19 @@ + + * @since 6.3 + */ +final class PackageUpdateServerDisabled implements IPsr14Event +{ + public function __construct(public readonly PackageUpdateServer $server) {} +} diff --git a/wcfsetup/install/files/lib/event/package/update/server/PackageUpdateServerEnabled.class.php b/wcfsetup/install/files/lib/event/package/update/server/PackageUpdateServerEnabled.class.php new file mode 100644 index 00000000000..05d2c7dc936 --- /dev/null +++ b/wcfsetup/install/files/lib/event/package/update/server/PackageUpdateServerEnabled.class.php @@ -0,0 +1,19 @@ + + * @since 6.3 + */ +final class PackageUpdateServerEnabled implements IPsr14Event +{ + public function __construct(public readonly PackageUpdateServer $server) {} +} diff --git a/wcfsetup/install/files/lib/event/page/PageDisabled.class.php b/wcfsetup/install/files/lib/event/page/PageDisabled.class.php new file mode 100644 index 00000000000..f9d9390dcac --- /dev/null +++ b/wcfsetup/install/files/lib/event/page/PageDisabled.class.php @@ -0,0 +1,19 @@ + + * @since 6.3 + */ +final class PageDisabled implements IPsr14Event +{ + public function __construct(public readonly Page $page) {} +} diff --git a/wcfsetup/install/files/lib/event/page/PageEnabled.class.php b/wcfsetup/install/files/lib/event/page/PageEnabled.class.php new file mode 100644 index 00000000000..10ce6a0cc12 --- /dev/null +++ b/wcfsetup/install/files/lib/event/page/PageEnabled.class.php @@ -0,0 +1,19 @@ + + * @since 6.3 + */ +final class PageEnabled implements IPsr14Event +{ + public function __construct(public readonly Page $page) {} +} diff --git a/wcfsetup/install/files/lib/event/paid/subscription/PaidSubscriptionDisabled.class.php b/wcfsetup/install/files/lib/event/paid/subscription/PaidSubscriptionDisabled.class.php new file mode 100644 index 00000000000..0dff8b291a5 --- /dev/null +++ b/wcfsetup/install/files/lib/event/paid/subscription/PaidSubscriptionDisabled.class.php @@ -0,0 +1,19 @@ + + * @since 6.3 + */ +final class PaidSubscriptionDisabled implements IPsr14Event +{ + public function __construct(public readonly PaidSubscription $subscription) {} +} diff --git a/wcfsetup/install/files/lib/event/paid/subscription/PaidSubscriptionEnabled.class.php b/wcfsetup/install/files/lib/event/paid/subscription/PaidSubscriptionEnabled.class.php new file mode 100644 index 00000000000..6074be1f730 --- /dev/null +++ b/wcfsetup/install/files/lib/event/paid/subscription/PaidSubscriptionEnabled.class.php @@ -0,0 +1,19 @@ + + * @since 6.3 + */ +final class PaidSubscriptionEnabled implements IPsr14Event +{ + public function __construct(public readonly PaidSubscription $subscription) {} +} diff --git a/wcfsetup/install/files/lib/event/reaction/type/ReactionTypeDisabled.class.php b/wcfsetup/install/files/lib/event/reaction/type/ReactionTypeDisabled.class.php new file mode 100644 index 00000000000..006aa75da11 --- /dev/null +++ b/wcfsetup/install/files/lib/event/reaction/type/ReactionTypeDisabled.class.php @@ -0,0 +1,19 @@ + + * @since 6.3 + */ +final class ReactionTypeDisabled implements IPsr14Event +{ + public function __construct(public readonly ReactionType $reactionType) {} +} diff --git a/wcfsetup/install/files/lib/event/reaction/type/ReactionTypeEnabled.class.php b/wcfsetup/install/files/lib/event/reaction/type/ReactionTypeEnabled.class.php new file mode 100644 index 00000000000..250e13d2ffd --- /dev/null +++ b/wcfsetup/install/files/lib/event/reaction/type/ReactionTypeEnabled.class.php @@ -0,0 +1,19 @@ + + * @since 6.3 + */ +final class ReactionTypeEnabled implements IPsr14Event +{ + public function __construct(public readonly ReactionType $reactionType) {} +} diff --git a/wcfsetup/install/files/lib/event/style/StyleDisabled.class.php b/wcfsetup/install/files/lib/event/style/StyleDisabled.class.php new file mode 100644 index 00000000000..25549520b6e --- /dev/null +++ b/wcfsetup/install/files/lib/event/style/StyleDisabled.class.php @@ -0,0 +1,19 @@ + + * @since 6.3 + */ +final class StyleDisabled implements IPsr14Event +{ + public function __construct(public readonly Style $style) {} +} diff --git a/wcfsetup/install/files/lib/event/style/StyleEnabled.class.php b/wcfsetup/install/files/lib/event/style/StyleEnabled.class.php new file mode 100644 index 00000000000..adcb4f631fe --- /dev/null +++ b/wcfsetup/install/files/lib/event/style/StyleEnabled.class.php @@ -0,0 +1,19 @@ + + * @since 6.3 + */ +final class StyleEnabled implements IPsr14Event +{ + public function __construct(public readonly Style $style) {} +} diff --git a/wcfsetup/install/files/lib/event/trophy/TrophyDisabled.class.php b/wcfsetup/install/files/lib/event/trophy/TrophyDisabled.class.php new file mode 100644 index 00000000000..7d77767f76f --- /dev/null +++ b/wcfsetup/install/files/lib/event/trophy/TrophyDisabled.class.php @@ -0,0 +1,19 @@ + + * @since 6.3 + */ +final class TrophyDisabled implements IPsr14Event +{ + public function __construct(public readonly Trophy $trophy) {} +} diff --git a/wcfsetup/install/files/lib/event/trophy/TrophyEnabled.class.php b/wcfsetup/install/files/lib/event/trophy/TrophyEnabled.class.php new file mode 100644 index 00000000000..5d2533ac9fc --- /dev/null +++ b/wcfsetup/install/files/lib/event/trophy/TrophyEnabled.class.php @@ -0,0 +1,19 @@ + + * @since 6.3 + */ +final class TrophyEnabled implements IPsr14Event +{ + public function __construct(public readonly Trophy $trophy) {} +} diff --git a/wcfsetup/install/files/lib/event/user/group/assignment/UserGroupAssignmentDisabled.class.php b/wcfsetup/install/files/lib/event/user/group/assignment/UserGroupAssignmentDisabled.class.php new file mode 100644 index 00000000000..c972bdcde5e --- /dev/null +++ b/wcfsetup/install/files/lib/event/user/group/assignment/UserGroupAssignmentDisabled.class.php @@ -0,0 +1,19 @@ + + * @since 6.3 + */ +final class UserGroupAssignmentDisabled implements IPsr14Event +{ + public function __construct(public readonly UserGroupAssignment $assignment) {} +} diff --git a/wcfsetup/install/files/lib/event/user/group/assignment/UserGroupAssignmentEnabled.class.php b/wcfsetup/install/files/lib/event/user/group/assignment/UserGroupAssignmentEnabled.class.php new file mode 100644 index 00000000000..baedfd944c4 --- /dev/null +++ b/wcfsetup/install/files/lib/event/user/group/assignment/UserGroupAssignmentEnabled.class.php @@ -0,0 +1,19 @@ + + * @since 6.3 + */ +final class UserGroupAssignmentEnabled implements IPsr14Event +{ + public function __construct(public readonly UserGroupAssignment $assignment) {} +} diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/ads/DisableAd.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/ads/DisableAd.class.php index 41925f5e099..4dfc515707f 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/ads/DisableAd.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/ads/DisableAd.class.php @@ -6,12 +6,10 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use wcf\data\ad\Ad; -use wcf\data\ad\AdAction; use wcf\http\Helper; use wcf\system\endpoint\IController; use wcf\system\endpoint\PostRequest; use wcf\system\exception\IllegalLinkException; -use wcf\system\exception\PermissionDeniedException; use wcf\system\WCF; /** @@ -29,23 +27,21 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res { $ad = Helper::fetchObjectFromRequestParameter($variables['id'], Ad::class); - $this->assertAdCanBeDisabled($ad); + $this->assertAdCanBeDisabled(); - (new AdAction([$ad], 'toggle'))->executeAction(); + if (!$ad->isDisabled) { + (new \wcf\command\ad\DisableAd($ad))(); + } return new JsonResponse([]); } - private function assertAdCanBeDisabled(Ad $ad): void + private function assertAdCanBeDisabled(): void { if (!\MODULE_WCF_AD) { throw new IllegalLinkException(); } WCF::getSession()->checkPermissions(['admin.ad.canManageAd']); - - if ($ad->isDisabled) { - throw new PermissionDeniedException(); - } } } diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/ads/EnableAd.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/ads/EnableAd.class.php index 7fa293d6275..b5f779afbe7 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/ads/EnableAd.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/ads/EnableAd.class.php @@ -6,12 +6,10 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use wcf\data\ad\Ad; -use wcf\data\ad\AdAction; use wcf\http\Helper; use wcf\system\endpoint\IController; use wcf\system\endpoint\PostRequest; use wcf\system\exception\IllegalLinkException; -use wcf\system\exception\PermissionDeniedException; use wcf\system\WCF; /** @@ -29,23 +27,21 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res { $ad = Helper::fetchObjectFromRequestParameter($variables['id'], Ad::class); - $this->assertAdCanBeEnabled($ad); + $this->assertAdCanBeEnabled(); - (new AdAction([$ad], 'toggle'))->executeAction(); + if ($ad->isDisabled) { + (new \wcf\command\ad\EnableAd($ad))(); + } return new JsonResponse([]); } - private function assertAdCanBeEnabled(Ad $ad): void + private function assertAdCanBeEnabled(): void { if (!\MODULE_WCF_AD) { throw new IllegalLinkException(); } WCF::getSession()->checkPermissions(['admin.ad.canManageAd']); - - if (!$ad->isDisabled) { - throw new PermissionDeniedException(); - } } } diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/bbcodes/media/providers/DisableProvider.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/bbcodes/media/providers/DisableProvider.class.php index 7b04042cecd..79e9a31b810 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/bbcodes/media/providers/DisableProvider.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/bbcodes/media/providers/DisableProvider.class.php @@ -6,11 +6,9 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use wcf\data\bbcode\media\provider\BBCodeMediaProvider; -use wcf\data\bbcode\media\provider\BBCodeMediaProviderAction; use wcf\http\Helper; use wcf\system\endpoint\IController; use wcf\system\endpoint\PostRequest; -use wcf\system\exception\PermissionDeniedException; use wcf\system\WCF; /** @@ -29,19 +27,17 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res { $provider = Helper::fetchObjectFromRequestParameter($variables['id'], BBCodeMediaProvider::class); - $this->assertMediaProviderCanBeDisabled($provider); + $this->assertMediaProviderCanBeDisabled(); - (new BBCodeMediaProviderAction([$provider], 'toggle'))->executeAction(); + if (!$provider->isDisabled) { + (new \wcf\command\bbcode\media\provider\DisableBBCodeMediaProvider($provider))(); + } return new JsonResponse([]); } - private function assertMediaProviderCanBeDisabled(BBCodeMediaProvider $provider): void + private function assertMediaProviderCanBeDisabled(): void { WCF::getSession()->checkPermissions(['admin.content.bbcode.canManageBBCode']); - - if ($provider->isDisabled) { - throw new PermissionDeniedException(); - } } } diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/bbcodes/media/providers/EnableProvider.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/bbcodes/media/providers/EnableProvider.class.php index 205d5efdbc0..4994b333d09 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/bbcodes/media/providers/EnableProvider.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/bbcodes/media/providers/EnableProvider.class.php @@ -6,11 +6,9 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use wcf\data\bbcode\media\provider\BBCodeMediaProvider; -use wcf\data\bbcode\media\provider\BBCodeMediaProviderAction; use wcf\http\Helper; use wcf\system\endpoint\IController; use wcf\system\endpoint\PostRequest; -use wcf\system\exception\PermissionDeniedException; use wcf\system\WCF; /** @@ -29,19 +27,17 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res { $provider = Helper::fetchObjectFromRequestParameter($variables['id'], BBCodeMediaProvider::class); - $this->assertMediaProviderCanBeEnabled($provider); + $this->assertMediaProviderCanBeEnabled(); - (new BBCodeMediaProviderAction([$provider], 'toggle'))->executeAction(); + if ($provider->isDisabled) { + (new \wcf\command\bbcode\media\provider\EnableBBCodeMediaProvider($provider))(); + } return new JsonResponse([]); } - private function assertMediaProviderCanBeEnabled(BBCodeMediaProvider $provider): void + private function assertMediaProviderCanBeEnabled(): void { WCF::getSession()->checkPermissions(['admin.content.bbcode.canManageBBCode']); - - if (!$provider->isDisabled) { - throw new PermissionDeniedException(); - } } } diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/boxes/DisableBox.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/boxes/DisableBox.class.php index c07c9b7aac4..35d29337c7d 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/boxes/DisableBox.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/boxes/DisableBox.class.php @@ -6,11 +6,9 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use wcf\data\box\Box; -use wcf\data\box\BoxAction; use wcf\http\Helper; use wcf\system\endpoint\IController; use wcf\system\endpoint\PostRequest; -use wcf\system\exception\PermissionDeniedException; use wcf\system\WCF; /** @@ -29,19 +27,17 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res { $box = Helper::fetchObjectFromRequestParameter($variables['id'], Box::class); - $this->assertBoxCanBeDisabled($box); + $this->assertBoxCanBeDisabled(); - (new BoxAction([$box], 'toggle'))->executeAction(); + if (!$box->isDisabled) { + (new \wcf\command\box\DisableBox($box))(); + } return new JsonResponse([]); } - private function assertBoxCanBeDisabled(Box $box): void + private function assertBoxCanBeDisabled(): void { WCF::getSession()->checkPermissions(['admin.content.cms.canManageBox']); - - if ($box->isDisabled) { - throw new PermissionDeniedException(); - } } } diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/boxes/EnableBox.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/boxes/EnableBox.class.php index 2368a5b38a1..91d2fced86e 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/boxes/EnableBox.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/boxes/EnableBox.class.php @@ -6,11 +6,9 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use wcf\data\box\Box; -use wcf\data\box\BoxAction; use wcf\http\Helper; use wcf\system\endpoint\IController; use wcf\system\endpoint\PostRequest; -use wcf\system\exception\PermissionDeniedException; use wcf\system\WCF; /** @@ -29,19 +27,17 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res { $box = Helper::fetchObjectFromRequestParameter($variables['id'], Box::class); - $this->assertBoxCanBeEnabled($box); + $this->assertBoxCanBeEnabled(); - (new BoxAction([$box], 'toggle'))->executeAction(); + if ($box->isDisabled) { + (new \wcf\command\box\EnableBox($box))(); + } return new JsonResponse([]); } - private function assertBoxCanBeEnabled(Box $box): void + private function assertBoxCanBeEnabled(): void { WCF::getSession()->checkPermissions(['admin.content.cms.canManageBox']); - - if (!$box->isDisabled) { - throw new PermissionDeniedException(); - } } } diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/captchas/questions/DisableQuestion.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/captchas/questions/DisableQuestion.class.php index 4383d3e7e7f..c32d0bbedc8 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/captchas/questions/DisableQuestion.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/captchas/questions/DisableQuestion.class.php @@ -6,11 +6,9 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use wcf\data\captcha\question\CaptchaQuestion; -use wcf\data\captcha\question\CaptchaQuestionAction; use wcf\http\Helper; use wcf\system\endpoint\IController; use wcf\system\endpoint\PostRequest; -use wcf\system\exception\PermissionDeniedException; use wcf\system\WCF; /** @@ -29,19 +27,17 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res { $question = Helper::fetchObjectFromRequestParameter($variables['id'], CaptchaQuestion::class); - $this->assertQuestionCanBeDisabled($question); + $this->assertQuestionCanBeDisabled(); - (new CaptchaQuestionAction([$question], 'toggle'))->executeAction(); + if (!$question->isDisabled) { + (new \wcf\command\captcha\question\DisableCaptchaQuestion($question))(); + } return new JsonResponse([]); } - private function assertQuestionCanBeDisabled(CaptchaQuestion $question): void + private function assertQuestionCanBeDisabled(): void { WCF::getSession()->checkPermissions(['admin.captcha.canManageCaptchaQuestion']); - - if ($question->isDisabled) { - throw new PermissionDeniedException(); - } } } diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/captchas/questions/EnableQuestion.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/captchas/questions/EnableQuestion.class.php index c8715bb3b6c..28b59703001 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/captchas/questions/EnableQuestion.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/captchas/questions/EnableQuestion.class.php @@ -6,11 +6,9 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use wcf\data\captcha\question\CaptchaQuestion; -use wcf\data\captcha\question\CaptchaQuestionAction; use wcf\http\Helper; use wcf\system\endpoint\IController; use wcf\system\endpoint\PostRequest; -use wcf\system\exception\PermissionDeniedException; use wcf\system\WCF; /** @@ -29,19 +27,17 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res { $question = Helper::fetchObjectFromRequestParameter($variables['id'], CaptchaQuestion::class); - $this->assertQuestionCanBeEnabled($question); + $this->assertQuestionCanBeEnabled(); - (new CaptchaQuestionAction([$question], 'toggle'))->executeAction(); + if ($question->isDisabled) { + (new \wcf\command\captcha\question\EnableCaptchaQuestion($question))(); + } return new JsonResponse([]); } - private function assertQuestionCanBeEnabled(CaptchaQuestion $question): void + private function assertQuestionCanBeEnabled(): void { WCF::getSession()->checkPermissions(['admin.captcha.canManageCaptchaQuestion']); - - if (!$question->isDisabled) { - throw new PermissionDeniedException(); - } } } diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/contact/options/DisableOption.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/contact/options/DisableOption.class.php index 137eb74335c..90ea35209fb 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/contact/options/DisableOption.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/contact/options/DisableOption.class.php @@ -5,8 +5,8 @@ use Laminas\Diactoros\Response\JsonResponse; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use wcf\command\contact\option\DisableContactOption; use wcf\data\contact\option\ContactOption; -use wcf\data\contact\option\ContactOptionAction; use wcf\http\Helper; use wcf\system\endpoint\IController; use wcf\system\endpoint\PostRequest; @@ -31,7 +31,7 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res $option = Helper::fetchObjectFromRequestParameter($variables['id'], ContactOption::class); if (!$option->isDisabled) { - (new ContactOptionAction([$option], 'toggle'))->executeAction(); + (new DisableContactOption($option))(); } return new JsonResponse([]); diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/contact/options/EnableOption.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/contact/options/EnableOption.class.php index 141a2acf33d..1e27dd0b949 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/contact/options/EnableOption.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/contact/options/EnableOption.class.php @@ -5,8 +5,8 @@ use Laminas\Diactoros\Response\JsonResponse; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use wcf\command\contact\option\EnableContactOption; use wcf\data\contact\option\ContactOption; -use wcf\data\contact\option\ContactOptionAction; use wcf\http\Helper; use wcf\system\endpoint\IController; use wcf\system\endpoint\PostRequest; @@ -31,7 +31,7 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res $option = Helper::fetchObjectFromRequestParameter($variables['id'], ContactOption::class); if ($option->isDisabled) { - (new ContactOptionAction([$option], 'toggle'))->executeAction(); + (new EnableContactOption($option))(); } return new JsonResponse([]); diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/contact/recipients/DisableRecipient.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/contact/recipients/DisableRecipient.class.php index f5fff27fad9..88fca8b7381 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/contact/recipients/DisableRecipient.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/contact/recipients/DisableRecipient.class.php @@ -5,8 +5,8 @@ use Laminas\Diactoros\Response\JsonResponse; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use wcf\command\contact\recipient\DisableContactRecipient; use wcf\data\contact\recipient\ContactRecipient; -use wcf\data\contact\recipient\ContactRecipientAction; use wcf\http\Helper; use wcf\system\endpoint\IController; use wcf\system\endpoint\PostRequest; @@ -31,7 +31,7 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res $recipient = Helper::fetchObjectFromRequestParameter($variables['id'], ContactRecipient::class); if (!$recipient->isDisabled) { - (new ContactRecipientAction([$recipient], 'toggle'))->executeAction(); + (new DisableContactRecipient($recipient))(); } return new JsonResponse([]); diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/contact/recipients/EnableRecipient.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/contact/recipients/EnableRecipient.class.php index 977f91858b6..ff9f776a503 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/contact/recipients/EnableRecipient.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/contact/recipients/EnableRecipient.class.php @@ -5,8 +5,8 @@ use Laminas\Diactoros\Response\JsonResponse; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use wcf\command\contact\recipient\EnableContactRecipient; use wcf\data\contact\recipient\ContactRecipient; -use wcf\data\contact\recipient\ContactRecipientAction; use wcf\http\Helper; use wcf\system\endpoint\IController; use wcf\system\endpoint\PostRequest; @@ -31,7 +31,7 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res $recipient = Helper::fetchObjectFromRequestParameter($variables['id'], ContactRecipient::class); if ($recipient->isDisabled) { - (new ContactRecipientAction([$recipient], 'toggle'))->executeAction(); + (new EnableContactRecipient($recipient))(); } return new JsonResponse([]); diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/cronjobs/DisableCronjob.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/cronjobs/DisableCronjob.class.php index 501db5bfc7a..ea73cd947be 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/cronjobs/DisableCronjob.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/cronjobs/DisableCronjob.class.php @@ -6,7 +6,6 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use wcf\data\cronjob\Cronjob; -use wcf\data\cronjob\CronjobAction; use wcf\http\Helper; use wcf\system\endpoint\IController; use wcf\system\endpoint\PostRequest; @@ -32,7 +31,7 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res $this->assertCronjobCanBeDisabled($cronjob); if (!$cronjob->isDisabled) { - (new CronjobAction([$cronjob], 'toggle'))->executeAction(); + (new \wcf\command\cronjob\DisableCronjob($cronjob))(); } return new JsonResponse([]); diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/cronjobs/EnableCronjob.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/cronjobs/EnableCronjob.class.php index 0b36edef41e..938c91c5943 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/cronjobs/EnableCronjob.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/cronjobs/EnableCronjob.class.php @@ -6,7 +6,6 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use wcf\data\cronjob\Cronjob; -use wcf\data\cronjob\CronjobAction; use wcf\http\Helper; use wcf\system\endpoint\IController; use wcf\system\endpoint\PostRequest; @@ -32,7 +31,7 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res $this->assertCronjobCanBeEnabled($cronjob); if ($cronjob->isDisabled) { - (new CronjobAction([$cronjob], 'toggle'))->executeAction(); + (new \wcf\command\cronjob\EnableCronjob($cronjob))(); } return new JsonResponse([]); diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/languages/DisableLanguage.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/languages/DisableLanguage.class.php index 323c65f70b6..5e7f3f912ec 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/languages/DisableLanguage.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/languages/DisableLanguage.class.php @@ -6,7 +6,6 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use wcf\data\language\Language; -use wcf\data\language\LanguageAction; use wcf\http\Helper; use wcf\system\endpoint\IController; use wcf\system\endpoint\PostRequest; @@ -31,7 +30,9 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res $this->assertLanguageCanBeDisabled($language); - (new LanguageAction([$language], 'toggle'))->executeAction(); + if (!$language->isDisabled) { + (new \wcf\command\language\DisableLanguage($language))(); + } return new JsonResponse([]); } @@ -43,9 +44,5 @@ private function assertLanguageCanBeDisabled(Language $language): void if ($language->isDefault) { throw new PermissionDeniedException(); } - - if ($language->isDisabled) { - throw new PermissionDeniedException(); - } } } diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/languages/EnableLanguage.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/languages/EnableLanguage.class.php index 83335932cf2..b4b5fefcb1c 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/languages/EnableLanguage.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/languages/EnableLanguage.class.php @@ -6,7 +6,6 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use wcf\data\language\Language; -use wcf\data\language\LanguageAction; use wcf\http\Helper; use wcf\system\endpoint\IController; use wcf\system\endpoint\PostRequest; @@ -31,7 +30,9 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res $this->assertLanguageCanBeEnabled($language); - (new LanguageAction([$language], 'toggle'))->executeAction(); + if ($language->isDisabled) { + (new \wcf\command\language\EnableLanguage($language))(); + } return new JsonResponse([]); } @@ -43,9 +44,5 @@ private function assertLanguageCanBeEnabled(Language $language): void if ($language->isDefault) { throw new PermissionDeniedException(); } - - if (!$language->isDisabled) { - throw new PermissionDeniedException(); - } } } diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/notices/DisableNotice.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/notices/DisableNotice.class.php index 0b5fec6d68a..29346f5698c 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/notices/DisableNotice.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/notices/DisableNotice.class.php @@ -6,11 +6,9 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use wcf\data\notice\Notice; -use wcf\data\notice\NoticeAction; use wcf\http\Helper; use wcf\system\endpoint\IController; use wcf\system\endpoint\PostRequest; -use wcf\system\exception\PermissionDeniedException; use wcf\system\WCF; /** @@ -28,19 +26,17 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res { $notice = Helper::fetchObjectFromRequestParameter($variables['id'], Notice::class); - $this->assertNoticeCanBeDisabled($notice); + $this->assertNoticeCanBeDisabled(); - (new NoticeAction([$notice], 'toggle'))->executeAction(); + if (!$notice->isDisabled) { + (new \wcf\command\notice\DisableNotice($notice))(); + } return new JsonResponse([]); } - private function assertNoticeCanBeDisabled(Notice $notice): void + private function assertNoticeCanBeDisabled(): void { WCF::getSession()->checkPermissions(['admin.notice.canManageNotice']); - - if ($notice->isDisabled) { - throw new PermissionDeniedException(); - } } } diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/notices/EnableNotice.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/notices/EnableNotice.class.php index 1466c557189..047e40d769d 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/notices/EnableNotice.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/notices/EnableNotice.class.php @@ -6,11 +6,9 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use wcf\data\notice\Notice; -use wcf\data\notice\NoticeAction; use wcf\http\Helper; use wcf\system\endpoint\IController; use wcf\system\endpoint\PostRequest; -use wcf\system\exception\PermissionDeniedException; use wcf\system\WCF; /** @@ -28,19 +26,17 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res { $notice = Helper::fetchObjectFromRequestParameter($variables['id'], Notice::class); - $this->assertNoticeCanBeEnabled($notice); + $this->assertNoticeCanBeEnabled(); - (new NoticeAction([$notice], 'toggle'))->executeAction(); + if ($notice->isDisabled) { + (new \wcf\command\notice\EnableNotice($notice))(); + } return new JsonResponse([]); } - private function assertNoticeCanBeEnabled(Notice $notice): void + private function assertNoticeCanBeEnabled(): void { WCF::getSession()->checkPermissions(['admin.notice.canManageNotice']); - - if (!$notice->isDisabled) { - throw new PermissionDeniedException(); - } } } diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/packages/updates/servers/DisableServer.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/packages/updates/servers/DisableServer.class.php index 877cb54459f..daf12b694da 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/packages/updates/servers/DisableServer.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/packages/updates/servers/DisableServer.class.php @@ -5,8 +5,8 @@ use Laminas\Diactoros\Response\JsonResponse; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use wcf\command\package\update\server\DisablePackageUpdateServer; use wcf\data\package\update\server\PackageUpdateServer; -use wcf\data\package\update\server\PackageUpdateServerAction; use wcf\http\Helper; use wcf\system\endpoint\IController; use wcf\system\endpoint\PostRequest; @@ -31,7 +31,9 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res $this->assertServerCanBeDisabled($server); - (new PackageUpdateServerAction([$server], 'toggle'))->executeAction(); + if (!$server->isDisabled) { + (new DisablePackageUpdateServer($server))(); + } return new JsonResponse([]); } @@ -43,8 +45,5 @@ private function assertServerCanBeDisabled(PackageUpdateServer $server): void if (!$server->canDisable()) { throw new PermissionDeniedException(); } - if ($server->isDisabled) { - throw new PermissionDeniedException(); - } } } diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/packages/updates/servers/EnableServer.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/packages/updates/servers/EnableServer.class.php index 8b9e0d5c6ea..37804ac2b2c 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/packages/updates/servers/EnableServer.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/packages/updates/servers/EnableServer.class.php @@ -5,8 +5,8 @@ use Laminas\Diactoros\Response\JsonResponse; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use wcf\command\package\update\server\EnablePackageUpdateServer; use wcf\data\package\update\server\PackageUpdateServer; -use wcf\data\package\update\server\PackageUpdateServerAction; use wcf\http\Helper; use wcf\system\endpoint\IController; use wcf\system\endpoint\PostRequest; @@ -31,7 +31,9 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res $this->assertServerCanBeEnabled($server); - (new PackageUpdateServerAction([$server], 'toggle'))->executeAction(); + if ($server->isDisabled) { + (new EnablePackageUpdateServer($server))(); + } return new JsonResponse([]); } @@ -43,8 +45,5 @@ private function assertServerCanBeEnabled(PackageUpdateServer $server): void if (!$server->canDisable()) { throw new PermissionDeniedException(); } - if (!$server->isDisabled) { - throw new PermissionDeniedException(); - } } } diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/pages/DisablePage.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/pages/DisablePage.class.php index 1466e20dcc9..d2e60126e1c 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/pages/DisablePage.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/pages/DisablePage.class.php @@ -6,7 +6,6 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use wcf\data\page\Page; -use wcf\data\page\PageAction; use wcf\http\Helper; use wcf\system\endpoint\IController; use wcf\system\endpoint\PostRequest; @@ -31,7 +30,9 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res $this->assertPageCanBeDisabled($page); - (new PageAction([$page], 'toggle'))->executeAction(); + if (!$page->isDisabled) { + (new \wcf\command\page\DisablePage($page))(); + } return new JsonResponse([]); } @@ -43,9 +44,5 @@ private function assertPageCanBeDisabled(Page $page): void if (!$page->canDisable()) { throw new PermissionDeniedException(); } - - if ($page->isDisabled) { - throw new PermissionDeniedException(); - } } } diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/pages/EnablePage.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/pages/EnablePage.class.php index 787a32eac86..48e4d9d52c9 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/pages/EnablePage.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/pages/EnablePage.class.php @@ -6,7 +6,6 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use wcf\data\page\Page; -use wcf\data\page\PageAction; use wcf\http\Helper; use wcf\system\endpoint\IController; use wcf\system\endpoint\PostRequest; @@ -31,7 +30,9 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res $this->assertPageCanBeEnabled($page); - (new PageAction([$page], 'toggle'))->executeAction(); + if ($page->isDisabled) { + (new \wcf\command\page\EnablePage($page))(); + } return new JsonResponse([]); } @@ -43,9 +44,5 @@ private function assertPageCanBeEnabled(Page $page): void if (!$page->canDisable()) { throw new PermissionDeniedException(); } - - if (!$page->isDisabled) { - throw new PermissionDeniedException(); - } } } diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/paid/subscriptions/DisableSubscription.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/paid/subscriptions/DisableSubscription.class.php index f91a4c1ade9..1b69b61f798 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/paid/subscriptions/DisableSubscription.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/paid/subscriptions/DisableSubscription.class.php @@ -5,12 +5,11 @@ use Laminas\Diactoros\Response\JsonResponse; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use wcf\command\paid\subscription\DisablePaidSubscription; use wcf\data\paid\subscription\PaidSubscription; -use wcf\data\paid\subscription\PaidSubscriptionAction; use wcf\http\Helper; use wcf\system\endpoint\IController; use wcf\system\endpoint\PostRequest; -use wcf\system\exception\PermissionDeniedException; use wcf\system\WCF; /** @@ -29,19 +28,17 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res { $subscription = Helper::fetchObjectFromRequestParameter($variables['id'], PaidSubscription::class); - $this->assertSubscriptionCanBeDisabled($subscription); + $this->assertSubscriptionCanBeDisabled(); - (new PaidSubscriptionAction([$subscription], 'toggle'))->executeAction(); + if (!$subscription->isDisabled) { + (new DisablePaidSubscription($subscription))(); + } return new JsonResponse([]); } - private function assertSubscriptionCanBeDisabled(PaidSubscription $subscription): void + private function assertSubscriptionCanBeDisabled(): void { WCF::getSession()->checkPermissions(['admin.paidSubscription.canManageSubscription']); - - if ($subscription->isDisabled) { - throw new PermissionDeniedException(); - } } } diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/paid/subscriptions/EnableSubscription.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/paid/subscriptions/EnableSubscription.class.php index 8827fe1f566..b03edcbc7cc 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/paid/subscriptions/EnableSubscription.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/paid/subscriptions/EnableSubscription.class.php @@ -5,12 +5,11 @@ use Laminas\Diactoros\Response\JsonResponse; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use wcf\command\paid\subscription\EnablePaidSubscription; use wcf\data\paid\subscription\PaidSubscription; -use wcf\data\paid\subscription\PaidSubscriptionAction; use wcf\http\Helper; use wcf\system\endpoint\IController; use wcf\system\endpoint\PostRequest; -use wcf\system\exception\PermissionDeniedException; use wcf\system\WCF; /** @@ -29,19 +28,17 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res { $subscription = Helper::fetchObjectFromRequestParameter($variables['id'], PaidSubscription::class); - $this->assertSubscriptionCanBeEnabled($subscription); + $this->assertSubscriptionCanBeEnabled(); - (new PaidSubscriptionAction([$subscription], 'toggle'))->executeAction(); + if ($subscription->isDisabled) { + (new EnablePaidSubscription($subscription))(); + } return new JsonResponse([]); } - private function assertSubscriptionCanBeEnabled(PaidSubscription $subscription): void + private function assertSubscriptionCanBeEnabled(): void { WCF::getSession()->checkPermissions(['admin.paidSubscription.canManageSubscription']); - - if (!$subscription->isDisabled) { - throw new PermissionDeniedException(); - } } } diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/reactions/types/DisableType.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/reactions/types/DisableType.class.php index c53a36b0aab..4ec74ca974d 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/reactions/types/DisableType.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/reactions/types/DisableType.class.php @@ -5,13 +5,12 @@ use Laminas\Diactoros\Response\JsonResponse; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use wcf\command\reaction\type\DisableReactionType; use wcf\data\reaction\type\ReactionType; -use wcf\data\reaction\type\ReactionTypeAction; use wcf\http\Helper; use wcf\system\endpoint\IController; use wcf\system\endpoint\PostRequest; use wcf\system\exception\IllegalLinkException; -use wcf\system\exception\PermissionDeniedException; use wcf\system\WCF; /** @@ -29,23 +28,21 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res { $reactionType = Helper::fetchObjectFromRequestParameter($variables['id'], ReactionType::class); - $this->assertReactionTypeCanBeDisabled($reactionType); + $this->assertReactionTypeCanBeDisabled(); - (new ReactionTypeAction([$reactionType], 'toggle'))->executeAction(); + if ($reactionType->isAssignable) { + (new DisableReactionType($reactionType))(); + } return new JsonResponse([]); } - private function assertReactionTypeCanBeDisabled(ReactionType $reactionType): void + private function assertReactionTypeCanBeDisabled(): void { if (!\MODULE_LIKE) { throw new IllegalLinkException(); } WCF::getSession()->checkPermissions(["admin.content.reaction.canManageReactionType"]); - - if (!$reactionType->isAssignable) { - throw new PermissionDeniedException(); - } } } diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/reactions/types/EnableType.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/reactions/types/EnableType.class.php index ed8d2fe9d14..46efa33a9f9 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/reactions/types/EnableType.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/reactions/types/EnableType.class.php @@ -5,13 +5,12 @@ use Laminas\Diactoros\Response\JsonResponse; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use wcf\command\reaction\type\EnableReactionType; use wcf\data\reaction\type\ReactionType; -use wcf\data\reaction\type\ReactionTypeAction; use wcf\http\Helper; use wcf\system\endpoint\IController; use wcf\system\endpoint\PostRequest; use wcf\system\exception\IllegalLinkException; -use wcf\system\exception\PermissionDeniedException; use wcf\system\WCF; /** @@ -29,23 +28,21 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res { $reactionType = Helper::fetchObjectFromRequestParameter($variables['id'], ReactionType::class); - $this->assertReactionTypeCanBeEnabled($reactionType); + $this->assertReactionTypeCanBeEnabled(); - (new ReactionTypeAction([$reactionType], 'toggle'))->executeAction(); + if (!$reactionType->isAssignable) { + (new EnableReactionType($reactionType))(); + } return new JsonResponse([]); } - private function assertReactionTypeCanBeEnabled(ReactionType $reactionType): void + private function assertReactionTypeCanBeEnabled(): void { if (!\MODULE_LIKE) { throw new IllegalLinkException(); } WCF::getSession()->checkPermissions(["admin.content.reaction.canManageReactionType"]); - - if ($reactionType->isAssignable) { - throw new PermissionDeniedException(); - } } } diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/styles/DisableStyle.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/styles/DisableStyle.class.php index 5b065d57cea..caa4f1570d3 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/styles/DisableStyle.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/styles/DisableStyle.class.php @@ -6,7 +6,6 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use wcf\data\style\Style; -use wcf\data\style\StyleEditor; use wcf\http\Helper; use wcf\system\endpoint\IController; use wcf\system\endpoint\PostRequest; @@ -32,9 +31,7 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res $this->assertStyleCanBeDisabled($style); if (!$style->isDisabled) { - (new StyleEditor($style))->update([ - 'isDisabled' => 1, - ]); + (new \wcf\command\style\DisableStyle($style))(); } return new JsonResponse([]); diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/styles/EnableStyle.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/styles/EnableStyle.class.php index 5e832d48d08..70be3e6bd19 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/styles/EnableStyle.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/styles/EnableStyle.class.php @@ -6,7 +6,6 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use wcf\data\style\Style; -use wcf\data\style\StyleEditor; use wcf\http\Helper; use wcf\system\endpoint\IController; use wcf\system\endpoint\PostRequest; @@ -31,9 +30,7 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res $this->assertStyleCanBeEnabled(); if ($style->isDisabled) { - (new StyleEditor($style))->update([ - 'isDisabled' => 0, - ]); + (new \wcf\command\style\EnableStyle($style))(); } return new JsonResponse([]); diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/trophies/DisableTrophy.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/trophies/DisableTrophy.class.php index d1043b604d0..73488a192e1 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/trophies/DisableTrophy.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/trophies/DisableTrophy.class.php @@ -6,12 +6,10 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use wcf\data\trophy\Trophy; -use wcf\data\trophy\TrophyAction; use wcf\http\Helper; use wcf\system\endpoint\IController; use wcf\system\endpoint\PostRequest; use wcf\system\exception\IllegalLinkException; -use wcf\system\exception\PermissionDeniedException; use wcf\system\WCF; /** @@ -29,23 +27,21 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res { $trophy = Helper::fetchObjectFromRequestParameter($variables['id'], Trophy::class); - $this->assertTrophyCanBeDisabled($trophy); + $this->assertTrophyCanBeDisabled(); - (new TrophyAction([$trophy], 'toggle'))->executeAction(); + if (!$trophy->isDisabled) { + (new \wcf\command\trophy\DisableTrophy($trophy))(); + } return new JsonResponse([]); } - private function assertTrophyCanBeDisabled(Trophy $trophy): void + private function assertTrophyCanBeDisabled(): void { if (!\MODULE_TROPHY) { throw new IllegalLinkException(); } WCF::getSession()->checkPermissions(['admin.trophy.canManageTrophy']); - - if ($trophy->isDisabled) { - throw new PermissionDeniedException(); - } } } diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/trophies/EnableTrophy.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/trophies/EnableTrophy.class.php index 086946aab0b..f5cf328a514 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/trophies/EnableTrophy.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/trophies/EnableTrophy.class.php @@ -6,12 +6,10 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use wcf\data\trophy\Trophy; -use wcf\data\trophy\TrophyAction; use wcf\http\Helper; use wcf\system\endpoint\IController; use wcf\system\endpoint\PostRequest; use wcf\system\exception\IllegalLinkException; -use wcf\system\exception\PermissionDeniedException; use wcf\system\WCF; /** @@ -29,23 +27,21 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res { $trophy = Helper::fetchObjectFromRequestParameter($variables['id'], Trophy::class); - $this->assertTrophyCanBeEnabled($trophy); + $this->assertTrophyCanBeEnabled(); - (new TrophyAction([$trophy], 'toggle'))->executeAction(); + if ($trophy->isDisabled) { + (new \wcf\command\trophy\EnableTrophy($trophy))(); + } return new JsonResponse([]); } - private function assertTrophyCanBeEnabled(Trophy $trophy): void + private function assertTrophyCanBeEnabled( ): void { if (!\MODULE_TROPHY) { throw new IllegalLinkException(); } WCF::getSession()->checkPermissions(['admin.trophy.canManageTrophy']); - - if (!$trophy->isDisabled) { - throw new PermissionDeniedException(); - } } } diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/users/groups/assignment/DisableAssignment.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/users/groups/assignment/DisableAssignment.class.php index 5aaaff39601..4e8f39eefb8 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/users/groups/assignment/DisableAssignment.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/users/groups/assignment/DisableAssignment.class.php @@ -5,12 +5,11 @@ use Laminas\Diactoros\Response\JsonResponse; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use wcf\command\user\group\assignment\DisableUserGroupAssignment; use wcf\data\user\group\assignment\UserGroupAssignment; -use wcf\data\user\group\assignment\UserGroupAssignmentAction; use wcf\http\Helper; use wcf\system\endpoint\IController; use wcf\system\endpoint\PostRequest; -use wcf\system\exception\PermissionDeniedException; use wcf\system\WCF; /** @@ -28,19 +27,17 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res { $assignment = Helper::fetchObjectFromRequestParameter($variables['id'], UserGroupAssignment::class); - $this->assertAssignmentCanBeDisabled($assignment); + $this->assertAssignmentCanBeDisabled(); - (new UserGroupAssignmentAction([$assignment], 'toggle'))->executeAction(); + if (!$assignment->isDisabled) { + (new DisableUserGroupAssignment($assignment))(); + } return new JsonResponse([]); } - private function assertAssignmentCanBeDisabled(UserGroupAssignment $assignment): void + private function assertAssignmentCanBeDisabled(): void { WCF::getSession()->checkPermissions(['admin.management.canManageCronjob']); - - if ($assignment->isDisabled) { - throw new PermissionDeniedException(); - } } } diff --git a/wcfsetup/install/files/lib/system/endpoint/controller/core/users/groups/assignment/EnableAssignment.class.php b/wcfsetup/install/files/lib/system/endpoint/controller/core/users/groups/assignment/EnableAssignment.class.php index bab07319dd4..46c06087bf8 100644 --- a/wcfsetup/install/files/lib/system/endpoint/controller/core/users/groups/assignment/EnableAssignment.class.php +++ b/wcfsetup/install/files/lib/system/endpoint/controller/core/users/groups/assignment/EnableAssignment.class.php @@ -5,12 +5,11 @@ use Laminas\Diactoros\Response\JsonResponse; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use wcf\command\user\group\assignment\EnableUserGroupAssignment; use wcf\data\user\group\assignment\UserGroupAssignment; -use wcf\data\user\group\assignment\UserGroupAssignmentAction; use wcf\http\Helper; use wcf\system\endpoint\IController; use wcf\system\endpoint\PostRequest; -use wcf\system\exception\PermissionDeniedException; use wcf\system\WCF; /** @@ -28,19 +27,17 @@ public function __invoke(ServerRequestInterface $request, array $variables): Res { $assignment = Helper::fetchObjectFromRequestParameter($variables['id'], UserGroupAssignment::class); - $this->assertAssignmentCanBeEnabled($assignment); + $this->assertAssignmentCanBeEnabled(); - (new UserGroupAssignmentAction([$assignment], 'toggle'))->executeAction(); + if ($assignment->isDisabled) { + (new EnableUserGroupAssignment($assignment))(); + } return new JsonResponse([]); } - private function assertAssignmentCanBeEnabled(UserGroupAssignment $assignment): void + private function assertAssignmentCanBeEnabled(): void { WCF::getSession()->checkPermissions(['admin.management.canManageCronjob']); - - if (!$assignment->isDisabled) { - throw new PermissionDeniedException(); - } } }