ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Awareness\User\Collector Class Reference

Collects users from all providers. More...

+ Collaboration diagram for ILIAS\Awareness\User\Collector:

Public Member Functions

 __construct (int $user_id, int $ref_id, InternalDataService $data_service, InternalRepoService $repo_service, InternalDomainService $domain_service)
 
 collectUsers (bool $a_online_only=false)
 Collect users. More...
 
 collectUsersFromProvider (Provider $prov, ?array $online_users)
 

Static Public Member Functions

static getOnlineUsers ()
 

Protected Member Functions

 removeUsersFromCollections (array $a_remove_users)
 Remove users from collection. More...
 

Protected Attributes

ilRbacReview $rbacreview
 
Awareness AdminManager $admin_manager
 
Awareness InternalDataService $data_service
 
ProviderFactory $provider_factory
 
Collection $collection
 
array $collections
 
int $user_id
 
int $ref_id
 
ilSetting $settings
 
InternalRepoService $repo_service
 

Static Protected Attributes

static array $online_users = null
 
static array $online_user_ids = array()
 

Detailed Description

Collects users from all providers.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 30 of file class.Collector.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Awareness\User\Collector::__construct ( int  $user_id,
int  $ref_id,
InternalDataService  $data_service,
InternalRepoService  $repo_service,
InternalDomainService  $domain_service 
)

Definition at line 46 of file class.Collector.php.

52 {
53 $this->user_id = $user_id;
54 $this->settings = $domain_service->settings();
55 $this->provider_factory = $domain_service
56 ->userProvider();
57 $this->data_service = $data_service;
58 $this->admin_manager = $domain_service
59 ->admin($ref_id);
60 $this->rbacreview = $domain_service->rbac()->review();
61 $this->repo_service = $repo_service;
62 }
Awareness InternalDataService $data_service
InternalRepoService $repo_service

References ILIAS\Awareness\User\Collector\$data_service, ILIAS\Awareness\User\Collector\$ref_id, ILIAS\Awareness\User\Collector\$repo_service, ILIAS\Awareness\User\Collector\$user_id, ILIAS\Awareness\InternalDomainService\admin(), ILIAS\Repository\settings(), and ILIAS\Awareness\InternalDomainService\userProvider().

+ Here is the call graph for this function:

Member Function Documentation

◆ collectUsers()

ILIAS\Awareness\User\Collector::collectUsers ( bool  $a_online_only = false)

Collect users.

Definition at line 85 of file class.Collector.php.

85 : array
86 {
88
89 $this->collections = array();
90
91 $awrn_logger = \ilLoggerFactory::getLogger('awrn');
92
93 $awrn_logger->debug("Start, Online Only: " . $a_online_only . ", Current User: " . $this->user_id);
94
96 $all_users = array();
97 foreach ($this->provider_factory->getAllProviders() as $prov) {
98 $awrn_logger->debug("Provider: " . $prov->getProviderId() . ", Activation Mode: " . $this->admin_manager->getActivationMode($prov->getProviderId()) . ", Current User: " . $this->user_id);
99
100 // overall collection of users
101 $collection = $this->data_service->userCollection();
102
103 $provider_active = $this->admin_manager->isProviderActivated($prov->getProviderId());
104 $provider_includes_offline = $this->admin_manager->includesProviderOfflineUsers($prov->getProviderId());
105
106 if ($provider_active) {
107 $online_users = null;
108 if (!$provider_includes_offline || $a_online_only) {
109 $awrn_logger->debug("Provider: " . $prov->getProviderId() . ", Online Filter Users: " . count(self::$online_user_ids) . ", Current User: " . $this->user_id);
111 }
112
113 $coll = $this->collectUsersFromProvider($prov, $online_users);
114 $awrn_logger->debug("Provider: " . $prov->getProviderId() . ", Collected Users: " . count($coll) . ", Current User: " . $this->user_id);
115
116 foreach ($coll->getUsers() as $user_id) {
117 // filter out the anonymous user
119 continue;
120 }
121 // filter out current user
122 if ($user_id == $this->user_id) {
123 continue;
124 }
125
126 $awrn_logger->debug("Current User: " . $this->user_id . ", " .
127 "Provider: " . $prov->getProviderId() . ", Collected User: " . $user_id);
128
129 // cross check online, filter out offline users (if necessary)
130 if ((!$a_online_only && $provider_includes_offline)
131 || in_array($user_id, self::$online_user_ids)) {
133 if (!in_array($user_id, $all_users)) {
134 $all_users[] = $user_id;
135 }
136 }
137 }
138 }
139 $this->collections[] = array(
140 "uc_title" => $prov->getTitle(),
141 "highlighted" => $prov->isHighlighted(),
142 "collection" => $collection
143 );
144 }
145
146 $remove_users = array();
147
148 if ($this->settings->get("hide_own_online_status") === "n") {
149 // remove all users with hide_own_online_status "y"
150 foreach (\ilObjUser::getUserSubsetByPreferenceValue($all_users, "hide_own_online_status", "y") as $u) {
151 $remove_users[] = $u;
152 }
153 } else {
154 // remove all, except user with hide_own_online_status "n"
155 $show_users = \ilObjUser::getUserSubsetByPreferenceValue($all_users, "hide_own_online_status", "n");
156 $remove_users = array_filter($all_users, function ($i) use ($show_users) {
157 return !in_array($i, $show_users);
158 });
159 }
160
161 global $DIC;
162 $remove_users = array_merge($remove_users, $DIC['legalDocuments']->usersWithHiddenOnlineStatus($all_users));
163
164 $this->removeUsersFromCollections($remove_users);
165
166 return $this->collections;
167 }
removeUsersFromCollections(array $a_remove_users)
Remove users from collection.
collectUsersFromProvider(Provider $prov, ?array $online_users)
static getLogger(string $a_component_id)
Get component logger.
static getUserSubsetByPreferenceValue(array $a_user_ids, string $a_keyword, string $a_val)
const ANONYMOUS_USER_ID
Definition: constants.php:27
global $DIC
Definition: shib_login.php:26

References ILIAS\Awareness\User\Collector\$collection, ILIAS\Awareness\User\Collector\$collections, $DIC, ILIAS\Awareness\User\Collector\$online_user_ids, ILIAS\Awareness\User\Collector\$online_users, ILIAS\Awareness\User\Collector\$rbacreview, ILIAS\Awareness\User\Collector\$user_id, ILIAS\Awareness\User\Collection\addUser(), ANONYMOUS_USER_ID, ILIAS\Awareness\User\Collector\collectUsersFromProvider(), ilLoggerFactory\getLogger(), ILIAS\Awareness\User\Collector\getOnlineUsers(), ilObjUser\getUserSubsetByPreferenceValue(), ILIAS\Awareness\User\Collector\removeUsersFromCollections(), and ILIAS\Repository\settings().

+ Here is the call graph for this function:

◆ collectUsersFromProvider()

ILIAS\Awareness\User\Collector::collectUsersFromProvider ( Provider  $prov,
?array  $online_users 
)

Definition at line 169 of file class.Collector.php.

169 : Collection
170 {
171 $coll = $this->data_service->userCollection();
172 foreach ($prov->getInitialUserSet($online_users) as $user_id) {
173 if ((is_null($online_users) || in_array($user_id, $online_users))) {
174 $coll->addUser($user_id);
175 }
176 }
177 return $coll;
178 }
Represents a set of collected users.
getInitialUserSet(?array $user_ids=null)
Get initial set of users.

References ILIAS\Awareness\User\Collector\$online_users, ILIAS\Awareness\User\Collector\$user_id, ILIAS\Awareness\User\Collection\addUser(), and ILIAS\Awareness\User\Provider\getInitialUserSet().

Referenced by ILIAS\Awareness\User\Collector\collectUsers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getOnlineUsers()

static ILIAS\Awareness\User\Collector::getOnlineUsers ( )
static

Definition at line 64 of file class.Collector.php.

64 : array
65 {
66 if (self::$online_users === null) {
67 self::$online_user_ids = array();
68 self::$online_users = array();
69 foreach (\ilObjUser::_getUsersOnline() as $u) {
70 // ask context $u["context"] if it supports pushMessages
71 if ($u["context"] &&
72 \ilContext::directCall($u["context"], "supportsPushMessages")) {
73 self::$online_users[$u["user_id"]] = $u;
74 self::$online_user_ids[] = $u["user_id"];
75 }
76 }
77 }
79 }
static directCall(string $a_type, string $a_method)
Call context method directly without internal handling.
static _getUsersOnline(int $a_user_id=0, bool $a_no_anonymous=false)

References ILIAS\Awareness\User\Collector\$online_users, ilObjUser\_getUsersOnline(), and ilContext\directCall().

Referenced by ILIAS\Awareness\User\Collector\collectUsers(), and ILIAS\Notifications\Provider\AwarenessToastProvider\getToasts().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeUsersFromCollections()

ILIAS\Awareness\User\Collector::removeUsersFromCollections ( array  $a_remove_users)
protected

Remove users from collection.

Parameters
int[]$a_remove_usersarray of user IDs

Definition at line 184 of file class.Collector.php.

184 : void
185 {
186 foreach ($this->collections as $c) {
187 reset($a_remove_users);
188 foreach ($a_remove_users as $u) {
189 $c["collection"]->removeUser($u);
190 }
191 }
192 }
$c
Definition: deliver.php:25

References $c.

Referenced by ILIAS\Awareness\User\Collector\collectUsers().

+ Here is the caller graph for this function:

Field Documentation

◆ $admin_manager

Awareness AdminManager ILIAS\Awareness\User\Collector::$admin_manager
protected

Definition at line 36 of file class.Collector.php.

◆ $collection

Collection ILIAS\Awareness\User\Collector::$collection
protected

Definition at line 39 of file class.Collector.php.

Referenced by ILIAS\Awareness\User\Collector\collectUsers().

◆ $collections

array ILIAS\Awareness\User\Collector::$collections
protected

Definition at line 40 of file class.Collector.php.

Referenced by ILIAS\Awareness\User\Collector\collectUsers().

◆ $data_service

Awareness InternalDataService ILIAS\Awareness\User\Collector::$data_service
protected

Definition at line 37 of file class.Collector.php.

Referenced by ILIAS\Awareness\User\Collector\__construct().

◆ $online_user_ids

array ILIAS\Awareness\User\Collector::$online_user_ids = array()
staticprotected

Definition at line 34 of file class.Collector.php.

Referenced by ILIAS\Awareness\User\Collector\collectUsers().

◆ $online_users

array ILIAS\Awareness\User\Collector::$online_users = null
staticprotected

◆ $provider_factory

ProviderFactory ILIAS\Awareness\User\Collector::$provider_factory
protected

Definition at line 38 of file class.Collector.php.

◆ $rbacreview

ilRbacReview ILIAS\Awareness\User\Collector::$rbacreview
protected

Definition at line 35 of file class.Collector.php.

Referenced by ILIAS\Awareness\User\Collector\collectUsers().

◆ $ref_id

int ILIAS\Awareness\User\Collector::$ref_id
protected

Definition at line 42 of file class.Collector.php.

Referenced by ILIAS\Awareness\User\Collector\__construct().

◆ $repo_service

InternalRepoService ILIAS\Awareness\User\Collector::$repo_service
protected

Definition at line 44 of file class.Collector.php.

Referenced by ILIAS\Awareness\User\Collector\__construct().

◆ $settings

ilSetting ILIAS\Awareness\User\Collector::$settings
protected

Definition at line 43 of file class.Collector.php.

◆ $user_id


The documentation for this class was generated from the following file: