From 14a74b2ea4292f23612de89aa929be15996e7bab Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Fri, 6 Nov 2020 09:45:05 +0100 Subject: [PATCH] Remove the owner group promotion functionality By now every instance should have an owner group. --- com.woltlab.wcf/package.xml | 2 + .../install/files/acp/templates/footer.tpl | 4 - .../acp/templates/userGroupPromoteOwner.tpl | 13 --- ...te_com.woltlab.wcf_5.4_checkOwnerGroup.php | 15 +++ ...update_com.woltlab.wcf_5.4_removeFiles.php | 1 + .../form/UserGroupPromoteOwnerForm.class.php | 107 ------------------ .../data/user/group/UserGroupAction.class.php | 16 --- wcfsetup/install/lang/de.xml | 4 - wcfsetup/install/lang/en.xml | 4 - 9 files changed, 18 insertions(+), 148 deletions(-) delete mode 100644 wcfsetup/install/files/acp/templates/userGroupPromoteOwner.tpl create mode 100644 wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_checkOwnerGroup.php delete mode 100644 wcfsetup/install/files/lib/acp/form/UserGroupPromoteOwnerForm.class.php diff --git a/com.woltlab.wcf/package.xml b/com.woltlab.wcf/package.xml index cc98eb4b10..075aa03d1d 100644 --- a/com.woltlab.wcf/package.xml +++ b/com.woltlab.wcf/package.xml @@ -51,6 +51,8 @@ + acp/update_com.woltlab.wcf_5.4_checkOwnerGroup.php + diff --git a/wcfsetup/install/files/acp/templates/footer.tpl b/wcfsetup/install/files/acp/templates/footer.tpl index b348d669dc..da3b6ece2c 100644 --- a/wcfsetup/install/files/acp/templates/footer.tpl +++ b/wcfsetup/install/files/acp/templates/footer.tpl @@ -8,10 +8,6 @@ {if $__isRescueMode|empty}{include file='pageMenuMobile'}{/if} -{if !$__wscMissingOwnerGroup|empty} - -{/if} - {event name='footer'} diff --git a/wcfsetup/install/files/acp/templates/userGroupPromoteOwner.tpl b/wcfsetup/install/files/acp/templates/userGroupPromoteOwner.tpl deleted file mode 100644 index a1eebfba78..0000000000 --- a/wcfsetup/install/files/acp/templates/userGroupPromoteOwner.tpl +++ /dev/null @@ -1,13 +0,0 @@ -{include file='header' pageTitle='wcf.acp.group.promoteOwner'} - -
-
-

{lang}wcf.acp.group.promoteOwner{/lang}

-
-
- -
{lang}wcf.acp.group.promoteOwner.warning{/lang}
- -{@$form->getHtml()} - -{include file='footer'} diff --git a/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_checkOwnerGroup.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_checkOwnerGroup.php new file mode 100644 index 0000000000..36bf3bddf1 --- /dev/null +++ b/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_checkOwnerGroup.php @@ -0,0 +1,15 @@ +getFixedLanguageCode() === 'de') { + $message = "Es wurde noch keine Besitzer-Gruppe festgelegt."; + } + else { + $message = "No owner group was specified yet."; + } + + throw new \RuntimeException($message); +} diff --git a/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_removeFiles.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_removeFiles.php index df79c3b432..c1087e8b5e 100644 --- a/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_removeFiles.php +++ b/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_removeFiles.php @@ -3,6 +3,7 @@ use wcf\data\package\PackageCache; use wcf\system\WCF; $files = [ + 'lib/acp/form/UserGroupPromoteOwnerForm.class.php', 'lib/system/database/table/DatabaseTableUtil.class.php', ]; diff --git a/wcfsetup/install/files/lib/acp/form/UserGroupPromoteOwnerForm.class.php b/wcfsetup/install/files/lib/acp/form/UserGroupPromoteOwnerForm.class.php deleted file mode 100644 index 010e02b5e3..0000000000 --- a/wcfsetup/install/files/lib/acp/form/UserGroupPromoteOwnerForm.class.php +++ /dev/null @@ -1,107 +0,0 @@ - - * @package WoltLabSuite\Core\Acp\Form - * @since 5.2 - */ -class UserGroupPromoteOwnerForm extends AbstractFormBuilderForm { - /** - * @inheritDoc - */ - public $activeMenuItem = 'wcf.acp.menu.link.group.list'; - - /** - * user groups that can be promoted to owner group - * @var UserGroup[] - */ - public $groups = []; - - /** - * @inheritDoc - */ - public $neededPermissions = ['admin.configuration.package.canInstallPackage']; - - /** - * @inheritDoc - */ - public function readParameters() { - parent::readParameters(); - - // owner user groups cannot be modified - if (UserGroup::getOwnerGroupID() !== null) { - throw new IllegalLinkException(); - } - - $this->groups = UserGroup::getSortedGroupsByType([UserGroup::OTHER]); - $this->groups = array_filter($this->groups, function (UserGroup $group) { - return $group->isAdminGroup(); - }); - - if (empty($this->groups)) { - // fallback for broken installations without an admin group - $this->groups = UserGroup::getSortedGroupsByType([UserGroup::OTHER]); - } - } - - /** - * @inheritDoc - */ - protected function createForm() { - parent::createForm(); - - $this->form->appendChild( - FormContainer::create('groupSection') - ->appendChild( - RadioButtonFormField::create('groupID') - ->label('wcf.acp.group.promoteOwner.group') - ->required() - ->options($this->groups) - ) - ); - } - - /** - * @inheritDoc - */ - public function save() { - AbstractForm::save(); - - $groupID = $this->form->getData()['data']['groupID']; - - $this->objectAction = new UserGroupAction([$this->groups[$groupID]], 'promoteOwner'); - $this->objectAction->executeAction(); - - AbstractForm::saved(); - - HeaderUtil::redirect(LinkHandler::getInstance()->getLink()); - exit; - } - - /** - * @inheritDoc - */ - public function assignVariables() { - parent::assignVariables(); - - WCF::getTPL()->assign([ - // Hide the notice on this page only. - '__wscMissingOwnerGroup' => false, - ]); - } -} diff --git a/wcfsetup/install/files/lib/data/user/group/UserGroupAction.class.php b/wcfsetup/install/files/lib/data/user/group/UserGroupAction.class.php index 30d03db4a6..ea9d8e2380 100644 --- a/wcfsetup/install/files/lib/data/user/group/UserGroupAction.class.php +++ b/wcfsetup/install/files/lib/data/user/group/UserGroupAction.class.php @@ -220,20 +220,4 @@ class UserGroupAction extends AbstractDatabaseObjectAction { ]), ]; } - - public function promoteOwner() { - if (UserGroup::getOwnerGroupID() !== null) { - throw new \LogicException('There is already an owner group.'); - } - else if (count($this->objects) !== 1) { - throw new \InvalidArgumentException('Only a single group can be promoted to be the owner group.'); - } - - $groupEditor = reset($this->objects); - $groupEditor->update([ - 'groupType' => UserGroup::OWNER, - ]); - - UserGroupEditor::resetCache(); - } } diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index b0d6293e2c..97ceff7f38 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -900,10 +900,6 @@ ACHTUNG: Die oben genannten Meldungen sind stark gekürzt. Sie können Details z - bitte {if LANGUAGE_USE_INFORMAL_VARIANT}lege{else}legen Sie{/if} diese umgehend fest.]]> - - - diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index c27e75bb8a..de66107977 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -877,10 +877,6 @@ ATTENTION: The messages listed above are greatly shortened. You can view details - please set it up now.]]> - - - -- 2.20.1