Disable form to promote group to owner if owner is already set
authorMatthias Schmidt <gravatronics@live.com>
Sun, 14 Apr 2019 15:01:54 +0000 (17:01 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 14 Apr 2019 15:01:54 +0000 (17:01 +0200)
See #2890

wcfsetup/install/files/lib/acp/form/UserGroupPromoteOwnerForm.class.php

index ddbd1677695326aa01c0b64a736ee046b28528b4..e78aff11c50d8d0d8ed63d6ae416afdfce39b0c1 100644 (file)
@@ -3,6 +3,7 @@ namespace wcf\acp\form;
 use wcf\data\user\group\UserGroup;
 use wcf\data\user\group\UserGroupAction;
 use wcf\form\AbstractForm;
+use wcf\system\exception\IllegalLinkException;
 use wcf\system\form\builder\container\FormContainer;
 use wcf\system\form\builder\field\RadioButtonFormField;
 use wcf\system\form\builder\FormDocument;
@@ -47,6 +48,11 @@ class UserGroupPromoteOwnerForm extends AbstractForm {
        public function readParameters() {
                parent::readParameters();
                
+               // owner user groups cannot be modified
+               if (UserGroup::getOwnerGroupID() !== null) {
+                       throw new IllegalLinkException();
+               }
+               
                $this->groups = UserGroup::getGroupsByType([UserGroup::OTHER]);
                $this->groups = array_filter($this->groups, function (UserGroup $group) {
                        return $group->isAdminGroup();