$(function() {
new WCF.Option.Handler();
- {if $action == 'edit' && $group->groupType == 4 && $__wcf->session->getPermission('admin.user.canAddGroup')}
+ {if $action == 'edit' && $group->canCopy()}
WCF.Language.addObject({
'wcf.acp.group.copy.confirmMessage': '{lang}wcf.acp.group.copy.confirmMessage{/lang}',
'wcf.acp.group.copy.copyACLOptions': '{lang}wcf.acp.group.copy.copyACLOptions{/lang}',
</li>
{/if}
- {if $__wcf->session->getPermission('admin.user.canAddGroup') && $group->groupType == 4}
+ {if $group->canCopy()}
<li><a class="jsButtonUserGroupCopy button"><span class="icon icon16 fa-copy"></span> <span>{lang}wcf.acp.group.button.copy{/lang}</span></a></li>
{/if}
{/if}
$this->readBoolean('copyUserGroupOptions');
$this->groupEditor = $this->getSingleObject();
- if (!$this->groupEditor->isAccessible() || $this->groupEditor->groupType != UserGroup::OTHER) {
+ if (!$this->groupEditor->canCopy()) {
throw new PermissionDeniedException();
}
}
$optionValues = $statement->fetchMap('optionID', 'optionValue');
- $groupAction = new UserGroupAction([], 'create', [
+ $groupType = $this->groupEditor->groupType;
+ // When copying special user groups of which only one may exist,
+ // change the group type to 'other'.
+ if (in_array($groupType, [UserGroup::EVERYONE, UserGroup::GUESTS, UserGroup::USERS, UserGroup::OWNER])) {
+ $groupType = UserGroup::OTHER;
+ }
+
+ /** @var UserGroup $group */
+ $group = (new UserGroupAction([], 'create', [
'data' => [
'groupName' => $this->groupEditor->groupName,
'groupDescription' => $this->groupEditor->groupDescription,
'priority' => $this->groupEditor->priority,
'userOnlineMarking' => $this->groupEditor->userOnlineMarking,
- 'showOnTeamPage' => $this->groupEditor->showOnTeamPage
+ 'showOnTeamPage' => $this->groupEditor->showOnTeamPage,
+ 'groupType' => $groupType,
],
- 'options' => $optionValues
- ]);
- $returnValues = $groupAction->executeAction();
- $group = $returnValues['returnValues'];
+ 'options' => $optionValues,
+ ]))->executeAction()['returnValues'];
$groupEditor = new UserGroupEditor($group);
// update group name
$groupEditor->update([
'groupDescription' => $groupDescription,
- 'groupName' => $groupName
+ 'groupName' => $groupName,
]);
// copy members
return [
'groupID' => $group->groupID,
'redirectURL' => LinkHandler::getInstance()->getLink('UserGroupEdit', [
- 'id' => $group->groupID
- ])
+ 'id' => $group->groupID,
+ ]),
];
}