</div>
</form>
+{if $action === 'edit' && $ownerGroupID}
+ <script data-relocate="true">
+ (function() {
+ var input = elBySel('input[name="groupIDs[]"][value="{@$ownerGroupID}"]');
+ if (input) {
+ var icon = elCreate('span');
+ icon.className = 'icon icon16 fa-shield jsTooltip';
+ icon.title = '{lang}wcf.acp.group.type.owner{/lang}';
+ input.parentNode.appendChild(icon);
+
+ {if $user->userID == $__wcf->user->userID}
+ var shadow = elCreate('input');
+ shadow.name = input.name;
+ shadow.type = 'hidden';
+ shadow.value = input.value;
+
+ input.parentNode.appendChild(shadow);
+ input.disabled = true;
+ {/if}
+ }
+ })();
+ </script>
+{/if}
+
{include file='footer'}
'disableCoverPhoto' => $this->disableCoverPhoto,
'disableCoverPhotoReason' => $this->disableCoverPhotoReason,
'disableCoverPhotoExpires' => $this->disableCoverPhotoExpires,
- 'deleteCoverPhoto' => $this->deleteCoverPhoto
+ 'deleteCoverPhoto' => $this->deleteCoverPhoto,
+ 'ownerGroupID' => UserGroup::getOwnerGroupID(),
]);
}
* @inheritDoc
*/
public function validate() {
+ if ($this->user->userID == WCF::getUser()->userID && WCF::getUser()->hasOwnerAccess()) {
+ $ownerGroupID = UserGroup::getOwnerGroupID();
+ if ($ownerGroupID && !in_array($ownerGroupID, $this->groupIDs)) {
+ // Members of the owner group cannot remove themselves.
+ throw new PermissionDeniedException();
+ }
+ }
+
$this->validateAvatar();
parent::validate();
*/
protected static $accessibleGroups = null;
+ /**
+ * @var UserGroup|null
+ */
+ protected static $ownerGroup = false;
+
/**
* group options of this group
* @var mixed[][]
'admin.user.canSearchUser',
];
}
+
+ /**
+ * Returns the owner group's id unless no group was promoted yet due to backwards compatibility.
+ *
+ * @return int|null
+ * @since 5.2
+ */
+ public static function getOwnerGroupID() {
+ if (self::$ownerGroup === false) {
+ self::$ownerGroup = self::getGroupByType(self::OWNER);
+ }
+
+ return self::$ownerGroup ? self::$ownerGroup->groupID : null;
+ }
}