<?php
namespace wcf\acp\form;
use wcf\data\user\group\UserGroup;
+use wcf\data\user\UserAction;
use wcf\data\user\UserEditor;
use wcf\form\AbstractForm;
use wcf\system\clipboard\ClipboardHandler;
$groupsIDs = array_merge($groups[$user->userID], $this->groupIDs);
$groupsIDs = array_unique($groupsIDs);
- $userEditor = new UserEditor($user);
- $userEditor->addToGroups($groupsIDs, true, false);
+ $action = new UserAction(array(new UserEditor($user)), 'addToGroups', array(
+ 'groups' => $groupsIDs,
+ 'addDefaultGroups' => false
+ ));
+ $action->executeAction();
}
ClipboardHandler::getInstance()->removeItems($this->objectTypeID);
$removeGroups = (isset($this->parameters['removeGroups'])) ? $this->parameters['removeGroups'] : array();
$userOptions = (isset($this->parameters['options'])) ? $this->parameters['options'] : array();
+ if (!empty($groupIDs)) {
+ $action = new UserAction($this->objects, 'addToGroups', array('groups' => $groupIDs));
+ $action->executeAction();
+ }
+
foreach ($this->objects as $userEditor) {
- if (!empty($groupIDs)) {
- $userEditor->addToGroups($groupIDs);
- }
-
if (!empty($removeGroups)) {
$userEditor->removeFromGroups($removeGroups);
}
}
}
+
+ public function addToGroups() {
+ if (empty($this->objects)) {
+ $this->readObjects();
+ }
+
+ $groupIDs = $this->parameters['groups'];
+ $deleteOldGroups = $addDefaultGroups = true;
+ if (isset($this->parameters['deleteOldGroups'])) $deleteOldGroups = $this->parameters['deleteOldGroups'];
+ if (isset($this->parameters['addDefaultGroups'])) $addDefaultGroups = $this->parameters['addDefaultGroups'];
+
+ foreach ($this->objects as $userEditor) {
+ $userEditor->addToGroups($groupIDs, $deleteOldGroups, $addDefaultGroups);
+ }
+ }
+
/**
* @see wcf\data\ISearchAction::validateGetSearchResultList()
*/