ILIAS  release_8 Revision v8.23
class.ilUsersGalleryContacts.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
21 {
25  protected function getRelationSequence(): Generator
26  {
27  yield ilBuddyList::getInstanceByGlobalUser()->getRequestRelationsForOwner()->toArray();
28  yield ilBuddyList::getInstanceByGlobalUser()->getLinkedRelations()->toArray();
29  yield ilBuddyList::getInstanceByGlobalUser()->getRequestRelationsByOwner()->toArray() + ilBuddyList::getInstanceByGlobalUser()->getIgnoredRelationsByOwner()->toArray();
30  yield ilBuddyList::getInstanceByGlobalUser()->getIgnoredRelationsForOwner()->toArray();
31  }
32 
33  public function getGroupedCollections(bool $ignore_myself = false): array
34  {
35  global $DIC;
36 
37  $groups = [];
38 
39  foreach ($this->getRelationSequence() as $relations) {
40  $user_data = [];
41 
42  foreach ($relations as $usr_id => $relation) {
43  if (!($user = ilObjectFactory::getInstanceByObjId($usr_id, false)) || !($user instanceof ilObjUser)) {
44  continue;
45  }
46 
47  if (!$user->getActive()) {
48  continue;
49  }
50 
51  if ($ignore_myself && $user->getId() === $DIC->user()->getId()) {
52  continue;
53  }
54 
55  $user_data[$user->getId()] = $user;
56  }
57 
58  $groups[] = $this->getPopulatedGroup($user_data);
59  }
60 
61  return $groups;
62  }
63 
64  public function hasRemovableUsers(): bool
65  {
66  return true;
67  }
68 }
static getInstanceByGlobalUser()
getGroupedCollections(bool $ignore_myself=false)
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...