38 'description' =>
'sDesc'
130 ->assocSetter(
'SiteUserAssociation',
'user',
true)
131 ->assocSetter(
'SiteHostAssociation',
'host',
true)
142 'SiteUserAssociation',
143 array(
'siteID' => $this->
get(
'id')),
148 array(
'id' => $associds)
150 $this->
set(
'users', (array)$userids);
159 $userids = array_diff(
160 self::getSubObjectIDs(
'User'),
164 self::$HookManager->processEvent(
166 array(
'types' => &$types)
169 foreach ((array)self::getClass(
'UserManager')
170 ->find(array(
'id' => $userids)) as &$User
172 if (in_array($User->get(
'type'), $types)) {
175 $users[] = $User->get(
'id');
178 unset($userids, $types);
179 $this->
set(
'usersnotinme', (array)$users);
191 $siteIDs = $this->
get(
'id');
196 'SiteHostAssociation',
197 array(
'siteID' => $siteIDs),
202 array(
'id' => $associds)
204 $this->
set(
'hosts', (array)$hostids);
216 $siteIDs = $this->
get(
'id');
221 'SiteHostAssociation',
222 array(
'siteID' => $siteIDs),
227 array(
'id' => $associds)
229 $hostids = array_diff(
230 self::getSubObjectIDs(
'Host'),
233 $this->
set(
'hostsnotinme', (array)$hostids);
245 public function assocSetter($assocItem, $alterItem =
'', $implicitCall =
false)
248 $alterItem = strtolower($alterItem ?: $assocItem);
250 $plural =
"{$alterItem}s";
252 $classCall = ($implicitCall ? $assocItem :
"{$assocItem}Association");
254 $obj = strtolower(get_class($this));
255 $objstr =
"{$obj}ID";
256 $assocstr =
"{$alterItem}ID";
264 $items = $this->
get($plural);
267 [$objstr => $this->
get(
'id')],
276 $delItems = array_diff($cur,
$items);
278 $addItems = array_diff(
$items, $cur);
279 if (count($delItems)) {
283 $objstr => $this->
get(
'id'),
284 $assocstr => $delItems,
289 if (count($addItems)) {
297 if ($assocstr ==
'moduleID') {
298 $insert_fields[] =
'state';
300 foreach (
$items as &$id) {
305 if ($assocstr ==
'moduleID') {
308 $insert_values[] = $insert_val;
309 unset($insert_val, $id);
311 if (count($insert_values ?: []) > 0) {