Skip to content

Commit 91017fb

Browse files
committed
Re-add old copy method for backward compatibility
1 parent 45d74b9 commit 91017fb

File tree

1 file changed

+54
-1
lines changed

1 file changed

+54
-1
lines changed

wcfsetup/install/files/lib/data/user/group/UserGroupAction.class.php

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
namespace wcf\data\user\group;
44

55
use wcf\data\AbstractDatabaseObjectAction;
6+
use wcf\system\exception\PermissionDeniedException;
7+
use wcf\system\request\LinkHandler;
8+
use wcf\system\user\group\command\CopyUserGroup;
9+
use wcf\system\WCF;
610

711
/**
812
* Executes user group-related actions.
@@ -20,6 +24,12 @@ class UserGroupAction extends AbstractDatabaseObjectAction
2024
*/
2125
public $className = UserGroupEditor::class;
2226

27+
/**
28+
* editor object for the copied user group
29+
* @var UserGroupEditor
30+
*/
31+
public $groupEditor;
32+
2333
/**
2434
* @inheritDoc
2535
*/
@@ -38,7 +48,7 @@ class UserGroupAction extends AbstractDatabaseObjectAction
3848
/**
3949
* @inheritDoc
4050
*/
41-
protected $requireACP = ['create', 'delete', 'update'];
51+
protected $requireACP = ['copy', 'create', 'delete', 'update'];
4252

4353
/**
4454
* @inheritDoc
@@ -71,4 +81,47 @@ public function update()
7181
$object->updateGroupOptions($this->parameters['options']);
7282
}
7383
}
84+
85+
/**
86+
* Validates the 'copy' action.
87+
* @deprecated 6.2 Use `CopyUserGroup` instead.
88+
*/
89+
public function validateCopy()
90+
{
91+
WCF::getSession()->checkPermissions([
92+
'admin.user.canAddGroup',
93+
'admin.user.canEditGroup',
94+
]);
95+
96+
$this->readBoolean('copyACLOptions');
97+
$this->readBoolean('copyMembers');
98+
$this->readBoolean('copyUserGroupOptions');
99+
100+
$this->groupEditor = $this->getSingleObject();
101+
if (!$this->groupEditor->canCopy()) {
102+
throw new PermissionDeniedException();
103+
}
104+
}
105+
106+
/**
107+
* Copies a user group.
108+
* @deprecated 6.2 Use `CopyUserGroup` instead.
109+
*/
110+
public function copy()
111+
{
112+
$command = new CopyUserGroup(
113+
$this->groupEditor->getDecoratedObject(),
114+
$this->parameters['copyUserGroupOptions'],
115+
$this->parameters['copyMembers'],
116+
$this->parameters['copyACLOptions']
117+
);
118+
$group = $command();
119+
120+
return [
121+
'groupID' => $group->groupID,
122+
'redirectURL' => LinkHandler::getInstance()->getLink('UserGroupEdit', [
123+
'id' => $group->groupID,
124+
]),
125+
];
126+
}
74127
}

0 commit comments

Comments
 (0)