Remove the owner group promotion functionality
authorTim Düsterhus <duesterhus@woltlab.com>
Fri, 6 Nov 2020 08:45:05 +0000 (09:45 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 6 Nov 2020 16:27:25 +0000 (17:27 +0100)
By now every instance should have an owner group.

com.woltlab.wcf/package.xml
wcfsetup/install/files/acp/templates/footer.tpl
wcfsetup/install/files/acp/templates/userGroupPromoteOwner.tpl [deleted file]
wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_checkOwnerGroup.php [new file with mode: 0644]
wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_removeFiles.php
wcfsetup/install/files/lib/acp/form/UserGroupPromoteOwnerForm.class.php [deleted file]
wcfsetup/install/files/lib/data/user/group/UserGroupAction.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index cc98eb4b10d96683d88d40fd752f1d9bdbcdbde0..075aa03d1d687993d38dd1318f4394544122a81a 100644 (file)
@@ -51,6 +51,8 @@
        </instructions>
        
        <instructions type="update" fromversion="5.3.*">
+               <instruction type="script" run="standalone">acp/update_com.woltlab.wcf_5.4_checkOwnerGroup.php</instruction>
+               
                <instruction type="file" />
                <instruction type="acpTemplate" />
                <instruction type="template" />
index b348d669dc1607747a5066434bbcd13d7528e3cf..da3b6ece2ca362a0259d032bdf4c45fab42df5cd 100644 (file)
@@ -8,10 +8,6 @@
 
 {if $__isRescueMode|empty}{include file='pageMenuMobile'}{/if}
 
-{if !$__wscMissingOwnerGroup|empty}
-       <div id="wscMissingOwnerGroup" role="alert">{lang}wcf.acp.group.missingOwnerGroup{/lang}</div>
-{/if}
-
 {event name='footer'}
 
 <!-- JAVASCRIPT_RELOCATE_POSITION -->
diff --git a/wcfsetup/install/files/acp/templates/userGroupPromoteOwner.tpl b/wcfsetup/install/files/acp/templates/userGroupPromoteOwner.tpl
deleted file mode 100644 (file)
index a1eebfb..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-{include file='header' pageTitle='wcf.acp.group.promoteOwner'}
-
-<header class="contentHeader">
-       <div class="contentHeaderTitle">
-               <h1 class="contentTitle">{lang}wcf.acp.group.promoteOwner{/lang}</h1>
-       </div>
-</header>
-
-<div class="warning">{lang}wcf.acp.group.promoteOwner.warning{/lang}</div>
-
-{@$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 (file)
index 0000000..36bf3bd
--- /dev/null
@@ -0,0 +1,15 @@
+<?php
+
+use wcf\data\user\group\UserGroup;
+use wcf\system\WCF;
+
+if (UserGroup::getOwnerGroupID() === null) {
+       if (WCF::getLanguage()->getFixedLanguageCode() === 'de') { 
+               $message = "Es wurde noch keine Besitzer-Gruppe festgelegt."; 
+       } 
+       else { 
+               $message = "No owner group was specified yet."; 
+       } 
+       
+       throw new \RuntimeException($message); 
+}
index df79c3b432a5986125e9989ebe778cd70435d17f..c1087e8b5e62a38a077328e5bd5d82a90152c34f 100644 (file)
@@ -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 (file)
index 010e02b..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-<?php
-namespace wcf\acp\form;
-use wcf\data\user\group\UserGroup;
-use wcf\data\user\group\UserGroupAction;
-use wcf\form\AbstractForm;
-use wcf\form\AbstractFormBuilderForm;
-use wcf\system\exception\IllegalLinkException;
-use wcf\system\form\builder\container\FormContainer;
-use wcf\system\form\builder\field\RadioButtonFormField;
-use wcf\system\request\LinkHandler;
-use wcf\system\WCF;
-use wcf\util\HeaderUtil;
-
-/**
- * Promotes a user group to be the owner group.
- * 
- * @author      ALexander Ebert
- * @copyright   2001-2019 WoltLab GmbH
- * @license     GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @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,
-               ]);
-       }
-}
index 30d03db4a6391f5e6ee8f6f5a807b6f73ed6f865..ea9d8e2380373e4706e642f26d9448a36219aa3d 100644 (file)
@@ -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();
-       }
 }
index b0d6293e2c1b59a51dcdffe2df42815485583fd8..97ceff7f38f540112fb023ee237484d533e5bc8f 100644 (file)
@@ -900,10 +900,6 @@ ACHTUNG: Die oben genannten Meldungen sind stark gekürzt. Sie können Details z
                <item name="wcf.acp.group.type.owner"><![CDATA[Besitzer]]></item>
                <item name="wcf.acp.group.type.owner.description"><![CDATA[Die Besitzer-Gruppe verfügt über nicht entziehbare Berechtigungen und kann von anderen Gruppen nicht bearbeitet werden, diese Gruppe kann nur durch die Besitzer-Gruppe selbst bearbeitet werden. Mitglieder dieser Gruppe können andere Benutzer zu dieser Gruppe hinzufügen, sich aber selbst nicht daraus entfernen.]]></item>
                <item name="wcf.acp.group.ownerGroupPermission"><![CDATA[Die Besitzer-Gruppe verfügt immer über diese Berechtigung, sie kann nicht entzogen werden.]]></item>
-               <item name="wcf.acp.group.missingOwnerGroup"><![CDATA[Es wurde noch keine Besitzer-Gruppe festgelegt, <a href="{link controller='UserGroupPromoteOwner'}{/link}">bitte {if LANGUAGE_USE_INFORMAL_VARIANT}lege{else}legen Sie{/if} diese umgehend fest</a>.]]></item>
-               <item name="wcf.acp.group.promoteOwner"><![CDATA[Besitzer-Gruppe festlegen]]></item>
-               <item name="wcf.acp.group.promoteOwner.group"><![CDATA[Besitzer-Gruppe auswählen]]></item>
-               <item name="wcf.acp.group.promoteOwner.warning"><![CDATA[Die Besitzer-Gruppe kann, einmal festgelegt, nicht mehr geändert werden. Diese Gruppe verfügt über besondere Berechtigungen und wird vor Änderungen durch andere Gruppen geschützt, Mitglieder dieser Gruppe können nicht mehr gesperrt werden.]]></item>
                <item name="wcf.acp.group.option.user.signature.attachment.canUpload"><![CDATA[Kann Dateianhänge hochladen]]></item>
                <item name="wcf.acp.group.option.user.signature.attachment.maxSize"><![CDATA[Maximale Dateianhangsgröße]]></item>
                <item name="wcf.acp.group.option.user.signature.attachment.allowedExtensions"><![CDATA[Erlaubte Dateiendungen]]></item>
index c27e75bb8abb7a5f8bf9560bcaa539181a35b680..de6610797701a41894923f86dc7cf8468166c44b 100644 (file)
@@ -877,10 +877,6 @@ ATTENTION: The messages listed above are greatly shortened. You can view details
                <item name="wcf.acp.group.type.owner"><![CDATA[Owner]]></item>
                <item name="wcf.acp.group.type.owner.description"><![CDATA[The owner group features a few irrevocable permissions and is protected from edits by other groups, only the owner group can edit itself. Members of this group can add other users to this group, but cannot remove themselves.]]></item>
                <item name="wcf.acp.group.ownerGroupPermission"><![CDATA[The owner group always has this permission, it cannot be revoked.]]></item>
-               <item name="wcf.acp.group.missingOwnerGroup"><![CDATA[No owner group has been configured yet, <a href="{link controller='UserGroupPromoteOwner'}{/link}">please set it up now</a>.]]></item>
-               <item name="wcf.acp.group.promoteOwner"><![CDATA[Set Up the Owner Group]]></item>
-               <item name="wcf.acp.group.promoteOwner.group"><![CDATA[Select the owner group]]></item>
-               <item name="wcf.acp.group.promoteOwner.warning"><![CDATA[The owner group cannot be modified once it has been set up. This group has special privileges and is protected from modifications by any other group, its members cannot be banned.]]></item>
                <item name="wcf.acp.group.option.user.signature.attachment.canUpload"><![CDATA[Can Upload Attachments]]></item>
                <item name="wcf.acp.group.option.user.signature.attachment.maxSize"><![CDATA[Maximum Attachment File Size]]></item>
                <item name="wcf.acp.group.option.user.signature.attachment.allowedExtensions"><![CDATA[Allowed Attachment File Extensions]]></item>