From: Tim Düsterhus Date: Wed, 19 Aug 2020 12:52:18 +0000 (+0200) Subject: Disallow deleting official update servers X-Git-Tag: 5.3.0_Alpha_1~22^2~10 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=8ce3e768fee33aafd765e188ae80635942a913d0;p=GitHub%2FWoltLab%2FWCF.git Disallow deleting official update servers --- diff --git a/wcfsetup/install/files/acp/templates/packageUpdateServerList.tpl b/wcfsetup/install/files/acp/templates/packageUpdateServerList.tpl index a4027cdbcd..4684b62a1f 100644 --- a/wcfsetup/install/files/acp/templates/packageUpdateServerList.tpl +++ b/wcfsetup/install/files/acp/templates/packageUpdateServerList.tpl @@ -49,7 +49,7 @@ - + {event name='itemButtons'} diff --git a/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServer.class.php b/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServer.class.php index 5cd2294177..45b06e43f9 100644 --- a/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServer.class.php +++ b/wcfsetup/install/files/lib/data/package/update/server/PackageUpdateServer.class.php @@ -238,6 +238,15 @@ class PackageUpdateServer extends DatabaseObject { return false; } + /** + * Returns whether the current user may delete this update server. + * + * @return boolean + */ + public final function canDelete() { + return !$this->isWoltLabUpdateServer() && !$this->isWoltLabStoreServer(); + } + /** * Returns true if the host is `update.woltlab.com`. * 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 897ef73de3..51be70377a 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 @@ -3,6 +3,7 @@ namespace wcf\data\package\update\server; use wcf\data\AbstractDatabaseObjectAction; use wcf\data\IToggleAction; use wcf\data\TDatabaseObjectToggle; +use wcf\system\exception\PermissionDeniedException; /** * Executes package update server-related actions. @@ -43,4 +44,16 @@ class PackageUpdateServerAction extends AbstractDatabaseObjectAction implements * @inheritDoc */ protected $requireACP = ['create', 'delete', 'toggle', 'update']; + + /** + * @inheritDoc + */ + public function validateDelete() { + parent::validateDelete(); + + /** @var PackageUpdateServer $updateServer */ + foreach ($this->getObjects() as $updateServer) { + if (!$updateServer->canDelete()) throw new PermissionDeniedException(); + } + } }