16 private $executiveUserId;
17 private $groupIdsToCopy = [];
19 private $changedFields = [];
24 private $features = [];
26 private $ufIgnoreList = [];
28 private $projectTerm = [];
30 private $markerUsers =
true;
33 private $mapIdsCopiedGroups = [];
35 public function __construct($executiveUserId, array $groupIdsToCopy)
37 $this->executiveUserId = $executiveUserId;
38 $this->groupIdsToCopy = $groupIdsToCopy;
40 $this->result =
new Result();
50 $this->features[] = $feature;
60 $this->ufIgnoreList = $ufIgnoreList;
70 $this->projectTerm = $projectTerm;
75 $this->markerUsers = $markerUsers;
80 $this->changedFields = array_merge($this->changedFields, $changedFields);
85 $containerCollection = $this->getContainerCollection();
87 $groupImplementer = $this->getGroupImplementer();
88 $groupCopier = $this->getGroupCopier($groupImplementer);
90 if ($this->markerUsers)
92 $userToGroupImplementer = $this->getUserToGroupImplementer();
93 $groupCopier->addEntityToCopy($this->getUserToGroupCopier($userToGroupImplementer));
96 $this->result = $groupCopier->copy($containerCollection);
97 $this->mapIdsCopiedGroups = $groupCopier->getMapIdsCopiedEntity();
109 return $this->mapIdsCopiedGroups;
112 private function getContainerCollection()
116 foreach ($this->groupIdsToCopy as $groupId)
118 $containerCollection[] =
new Container($groupId);
121 return $containerCollection;
124 private function getGroupImplementer()
126 global $USER_FIELD_MANAGER;
129 $groupImplementer =
new GroupImplementer($this->executiveUserId);
130 $groupImplementer->setChangedFields($this->changedFields);
131 $groupImplementer->setUserFieldManager($USER_FIELD_MANAGER);
132 $groupImplementer->setUfIgnoreList($this->ufIgnoreList);
133 $groupImplementer->setExecutiveUserId($this->executiveUserId);
134 $groupImplementer->setProjectTerm($this->projectTerm);
136 if (!$this->markerUsers && $this->changedFields[
"MODERATORS"])
138 $userGroupHelper =
new UserGroupHelper($this->executiveUserId, $this->changedFields[
"MODERATORS"]);
139 $groupImplementer->setUserGroupHelper($userGroupHelper);
142 foreach ($this->features as $feature)
144 $groupImplementer->setFeature($feature);
147 return $groupImplementer;
150 private function getGroupCopier($groupImplementer)
152 return new EntityCopier($groupImplementer);
155 private function getUserToGroupImplementer()
157 $userGroupImplementer =
new UserToGroup();
158 $userGroupImplementer->setUfIgnoreList($this->ufIgnoreList);
159 if ($this->changedFields[
"MODERATORS"])
161 $userGroupHelper =
new UserGroupHelper($this->executiveUserId, $this->changedFields[
"MODERATORS"]);
162 $userGroupImplementer->setUserGroupHelper($userGroupHelper);
164 return $userGroupImplementer;
167 private function getUserToGroupCopier($userToGroupImplementer)
169 return new UserToGroupCopier($userToGroupImplementer);