Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions ts/WoltLabSuite/Core/Acp/Component/User/Group/Copy.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async function handleFormBuilderDialogAction(
interactionEffect: InteractionEffect = InteractionEffect.ReloadItem,
detail: Payload,
): Promise<void> {
const { ok } = await dialogFactory().usingFormBuilder().fromEndpoint(endpoint);
const { ok, result } = await dialogFactory().usingFormBuilder().fromEndpoint<Payload>(endpoint);

if (!ok) {
return;
Expand All @@ -32,6 +32,7 @@ async function handleFormBuilderDialogAction(
bubbles: true,
detail: {
...detail,
...result,
_reloadPage: String(interactionEffect === InteractionEffect.ReloadPage),
},
}),
Expand All @@ -41,6 +42,7 @@ async function handleFormBuilderDialogAction(
new CustomEvent<Payload>("interaction:invalidate-all", {
detail: {
...detail,
...result,
},
}),
);
Expand All @@ -50,6 +52,7 @@ async function handleFormBuilderDialogAction(
bubbles: true,
detail: {
...detail,
...result,
},
}),
);
Expand Down
22 changes: 12 additions & 10 deletions wcfsetup/install/files/acp/templates/userGroupAdd.tpl
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
{include file='header' pageTitle='wcf.acp.group.'|concat:$action}

<script data-relocate="true">
{if $action == 'edit' && $group->canCopy()}
require(['WoltLabSuite/Core/Acp/Component/User/Group/Copy'], ({ init }) => {
init();
});
{/if}

$(function() {
{if $action === 'add' && $isBlankForm}
elBySelAll('.jsBbcodeSelectOptionHtml input[type="checkbox"]', undefined, function (checkbox) {
Expand Down Expand Up @@ -43,12 +37,20 @@
</li>
{/if}

{if $group->canCopy()}
<li><button type="button" class="jsButtonUserGroupCopy button" data-endpoint="{link controller="UserGroupCopy" id=$groupID}{/link}">{icon name='copy'} <span>{lang}wcf.acp.group.button.copy{/lang}</span></button></li>
{/if}

<li>
{unsafe:$interactionContextMenu->render()}
<script data-relocate="true">
{
const container = document.getElementById('{unsafe:$interactionContextMenu->getContainerID()|encodeJS}');
container.addEventListener('interaction:invalidate-all', (event) => {
if (event.detail.interaction === 'copy') {
setTimeout(() => {
window.location.href = event.detail.redirectURL;
}, 2000);
}
});
}
</script>
</li>
{/if}

Expand Down

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private function getForm(): Psr15DialogForm
{
$form = new Psr15DialogForm(
UserGroupCopyAction::class,
WCF::getLanguage()->get('wcf.acp.dashboard.configure')
WCF::getLanguage()->get('wcf.acp.group.copy')
);
$form->appendChildren([
FormContainer::create('section')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
namespace wcf\data\user\group;

use wcf\data\AbstractDatabaseObjectAction;
use wcf\system\exception\PermissionDeniedException;
use wcf\system\request\LinkHandler;
use wcf\system\user\group\command\CopyUserGroup;
use wcf\system\WCF;

/**
* Executes user group-related actions.
Expand All @@ -20,6 +24,12 @@ class UserGroupAction extends AbstractDatabaseObjectAction
*/
public $className = UserGroupEditor::class;

/**
* editor object for the copied user group
* @var UserGroupEditor
*/
public $groupEditor;

/**
* @inheritDoc
*/
Expand All @@ -38,7 +48,7 @@ class UserGroupAction extends AbstractDatabaseObjectAction
/**
* @inheritDoc
*/
protected $requireACP = ['create', 'delete', 'update'];
protected $requireACP = ['copy', 'create', 'delete', 'update'];

/**
* @inheritDoc
Expand Down Expand Up @@ -71,4 +81,47 @@ public function update()
$object->updateGroupOptions($this->parameters['options']);
}
}

/**
* Validates the 'copy' action.
* @deprecated 6.2 Use `CopyUserGroup` instead.
*/
public function validateCopy()
{
WCF::getSession()->checkPermissions([
'admin.user.canAddGroup',
'admin.user.canEditGroup',
]);

$this->readBoolean('copyACLOptions');
$this->readBoolean('copyMembers');
$this->readBoolean('copyUserGroupOptions');

$this->groupEditor = $this->getSingleObject();
if (!$this->groupEditor->canCopy()) {
throw new PermissionDeniedException();
}
}

/**
* Copies a user group.
* @deprecated 6.2 Use `CopyUserGroup` instead.
*/
public function copy()
{
$command = new CopyUserGroup(
$this->groupEditor->getDecoratedObject(),
$this->parameters['copyUserGroupOptions'],
$this->parameters['copyMembers'],
$this->parameters['copyACLOptions']
);
$group = $command();

return [
'groupID' => $group->groupID,
'redirectURL' => LinkHandler::getInstance()->getLink('UserGroupEdit', [
'id' => $group->groupID,
]),
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

namespace wcf\system\interaction\admin;

use wcf\acp\action\UserGroupCopyAction;
use wcf\data\user\group\UserGroup;
use wcf\event\interaction\admin\UserGroupInteractionCollecting;
use wcf\system\event\EventHandler;
use wcf\system\interaction\AbstractInteractionProvider;
use wcf\system\interaction\DeleteInteraction;
use wcf\system\interaction\FormBuilderDialogInteraction;
use wcf\system\interaction\InteractionEffect;
use wcf\system\request\LinkHandler;

/**
* Interaction provider for user groups.
Expand All @@ -21,7 +25,16 @@ final class UserGroupInteractions extends AbstractInteractionProvider
public function __construct()
{
$this->addInteractions([
new DeleteInteraction("core/users/groups/%s", static fn(UserGroup $group) => $group->isDeletable())
new DeleteInteraction("core/users/groups/%s", static fn(UserGroup $group) => $group->isDeletable()),
new FormBuilderDialogInteraction(
'copy',
LinkHandler::getInstance()->getControllerLink(UserGroupCopyAction::class, ['id' => '%s']),
'wcf.acp.group.button.copy',
static function (UserGroup $group): bool {
return $group->canCopy();
},
InteractionEffect::ReloadList
)
]);

EventHandler::getInstance()->fire(
Expand Down
Loading