3 namespace wcf\acp\form
;
5 use wcf\data\label\group\LabelGroup
;
6 use wcf\data\label\group\LabelGroupAction
;
7 use wcf\form\AbstractForm
;
8 use wcf\system\acl\ACLHandler
;
9 use wcf\system\exception\IllegalLinkException
;
10 use wcf\system\language\I18nHandler
;
14 * Shows the label group edit form.
16 * @author Alexander Ebert
17 * @copyright 2001-2019 WoltLab GmbH
18 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
19 * @package WoltLabSuite\Core\Acp\Form
21 class LabelGroupEditForm
extends LabelGroupAddForm
26 public $activeMenuItem = 'wcf.acp.menu.link.label.group.list';
31 public $neededPermissions = ['admin.content.label.canManageLabel'];
48 public function readParameters()
50 parent
::readParameters();
52 if (isset($_REQUEST['id'])) {
53 $this->groupID
= \
intval($_REQUEST['id']);
55 $this->group
= new LabelGroup($this->groupID
);
56 if (!$this->group
->groupID
) {
57 throw new IllegalLinkException();
64 public function save()
68 $this->groupName
= 'wcf.acp.label.group' . $this->group
->groupID
;
69 if (I18nHandler
::getInstance()->isPlainValue('groupName')) {
70 I18nHandler
::getInstance()->remove($this->groupName
);
71 $this->groupName
= I18nHandler
::getInstance()->getValue('groupName');
73 I18nHandler
::getInstance()->save('groupName', $this->groupName
, 'wcf.acp.label', 1);
77 $this->objectAction
= new LabelGroupAction(
81 'data' => \array_merge
($this->additionalFields
, [
82 'forceSelection' => $this->forceSelection ?
1 : 0,
83 'groupName' => $this->groupName
,
84 'groupDescription' => $this->groupDescription
,
85 'showOrder' => $this->showOrder
,
89 $this->objectAction
->executeAction();
92 ACLHandler
::getInstance()->save($this->groupID
, $this->objectTypeID
);
93 ACLHandler
::getInstance()->disableAssignVariables();
95 // update object type relations
96 $this->saveObjectTypeRelations($this->groupID
);
98 foreach ($this->labelObjectTypes
as $objectTypeID => $labelObjectType) {
99 $labelObjectType->save();
104 // show success message
105 WCF
::getTPL()->assign('success', true);
111 public function readData()
116 I18nHandler
::getInstance()->setOptions('groupName', 1, $this->group
->groupName
, 'wcf.acp.label.group\d+');
118 $this->forceSelection
= ($this->group
->forceSelection ?
true : false);
119 $this->groupName
= $this->group
->groupName
;
120 $this->groupDescription
= $this->group
->groupDescription
;
121 $this->showOrder
= $this->group
->showOrder
;
128 public function assignVariables()
130 parent
::assignVariables();
132 I18nHandler
::getInstance()->assignVariables(!empty($_POST));
134 WCF
::getTPL()->assign([
136 'groupID' => $this->groupID
,
137 'labelGroup' => $this->group
,
144 protected function setObjectTypeRelations($data = null)
147 // read database values
148 $sql = "SELECT objectTypeID, objectID
149 FROM wcf" . WCF_N
. "_label_group_to_object
151 $statement = WCF
::getDB()->prepareStatement($sql);
152 $statement->execute([$this->groupID
]);
155 while ($row = $statement->fetchArray()) {
156 if (!isset($data[$row['objectTypeID']])) {
157 $data[$row['objectTypeID']] = [];
160 // prevent NULL values which confuse isset()
161 $data[$row['objectTypeID']][] = $row['objectID'] ?
: 0;
165 parent
::setObjectTypeRelations($data);