ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilAwarenessUserCollector Class Reference

Collects users from all providers. More...

+ Collaboration diagram for ilAwarenessUserCollector:

Public Member Functions

 setRefId ($a_val)
 Set ref id. More...
 
 getRefId ()
 Get ref id. More...
 
 collectUsers ($a_online_only=false)
 Collect users. More...
 

Static Public Member Functions

static getInstance ($a_user_id)
 Get instance (for a user) More...
 
static getOnlineUsers ()
 Get online users. More...
 

Protected Member Functions

 __construct ($a_user_id)
 Constructor. More...
 
 removeUsersFromCollections ($a_remove_users)
 Remove users from collection. More...
 

Protected Attributes

 $collection
 
 $collections
 
 $user_id
 
 $ref_id
 
 $settings
 

Static Protected Attributes

static $instances = array()
 
static $online_users = false
 
static $online_user_ids = array()
 

Detailed Description

Collects users from all providers.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 12 of file class.ilAwarenessUserCollector.php.

Constructor & Destructor Documentation

◆ __construct()

ilAwarenessUserCollector::__construct (   $a_user_id)
protected

Constructor.

Parameters
int$a_user_iduser id

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

References $DIC, and settings().

37  {
38  global $DIC;
39 
40  $this->user_id = $a_user_id;
41  $this->settings = $DIC->settings();
42  }
global $DIC
Definition: saml.php:7
settings()
Definition: settings.php:2
+ Here is the call graph for this function:

Member Function Documentation

◆ collectUsers()

ilAwarenessUserCollector::collectUsers (   $a_online_only = false)

Collect users.

Returns
ilAwarenessUserCollection user collection

Definition at line 109 of file class.ilAwarenessUserCollector.php.

References $collection, $collections, $i, $user_id, array, ilAwarenessUserProviderFactory\getAllProviders(), ilAwarenessUserCollection\getInstance(), ilLoggerFactory\getLogger(), ilObjUser\getUsersAgreed(), ilObjUser\getUserSubsetByPreferenceValue(), ilTermsOfServiceHelper\isEnabled(), ilAwarenessUserProvider\MODE_INACTIVE, ilAwarenessUserProvider\MODE_INCL_OFFLINE, ilAwarenessUserProvider\MODE_ONLINE_ONLY, removeUsersFromCollections(), and settings().

110  {
111  global $rbacreview;
112 
113  $this->collections = array();
114 
115  $awrn_logger = ilLoggerFactory::getLogger('awrn');
116 
117  $awrn_logger->debug("Start, Online Only: " . $a_online_only . ", Current User: " . $this->user_id);
118 
119  self::getOnlineUsers();
120  include_once("./Services/Awareness/classes/class.ilAwarenessUserProviderFactory.php");
121  $all_users = array();
123  $awrn_logger->debug("Provider: " . $prov->getProviderId() . ", Activation Mode: " . $prov->getActivationMode() . ", Current User: " . $this->user_id);
124 
125  // overall collection of users
126  include_once("./Services/Awareness/classes/class.ilAwarenessUserCollection.php");
128 
129  if ($prov->getActivationMode() != ilAwarenessUserProvider::MODE_INACTIVE) {
130  $prov->setUserId($this->user_id);
131  $prov->setRefId($this->ref_id);
132  $prov->setOnlineUserFilter(false);
133  if ($prov->getActivationMode() == ilAwarenessUserProvider::MODE_ONLINE_ONLY || $a_online_only) {
134  $awrn_logger->debug("Provider: " . $prov->getProviderId() . ", Online Filter Users: " . count(self::$online_user_ids) . ", Current User: " . $this->user_id);
135  $prov->setOnlineUserFilter(self::$online_user_ids);
136  }
137 
138  $coll = $prov->collectUsers();
139  $awrn_logger->debug("Provider: " . $prov->getProviderId() . ", Collected Users: " . count($coll) . ", Current User: " . $this->user_id);
140 
141  foreach ($coll->getUsers() as $user_id) {
142  // filter out the anonymous user
143  if ($user_id == ANONYMOUS_USER_ID) {
144  continue;
145  }
146 
147  $awrn_logger->debug("Current User: " . $this->user_id . ", " .
148  "Provider: " . $prov->getProviderId() . ", Collected User: " . $user_id);
149 
150  // cross check online, filter out offline users (if necessary)
151  if ((!$a_online_only && $prov->getActivationMode() == ilAwarenessUserProvider::MODE_INCL_OFFLINE)
152  || in_array($user_id, self::$online_user_ids)) {
153  $collection->addUser($user_id);
154  if (!in_array($user_id, $all_users)) {
155  $all_users[] = $user_id;
156  }
157  }
158  }
159  }
160  $this->collections[] = array(
161  "uc_title" => $prov->getTitle(),
162  "highlighted" => $prov->isHighlighted(),
163  "collection" => $collection
164  );
165  }
166 
167  $remove_users = array();
168 
169  if ($this->settings->get("hide_own_online_status") == "n") {
170  // remove all users with hide_own_online_status "y"
171  foreach (ilObjUser::getUserSubsetByPreferenceValue($all_users, "hide_own_online_status", "y") as $u) {
172  $remove_users[] = $u;
173  }
174  } else {
175  // remove all, except user with hide_own_online_status "n"
176  $show_users = ilObjUser::getUserSubsetByPreferenceValue($all_users, "hide_own_online_status", "n");
177  $remove_users = array_filter($all_users, function ($i) use ($show_users) {
178  return !in_array($i, $show_users);
179  });
180  }
181 
182  // remove all users that have not accepted the terms of service yet
183  require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
185  foreach (ilObjUser::getUsersAgreed(false, $all_users) as $u) {
186  if ($u != SYSTEM_USER_ID && !$rbacreview->isAssigned($u, SYSTEM_ROLE_ID)) {
187  //if ($u != SYSTEM_USER_ID)
188  $remove_users[] = $u;
189  }
190  }
191  }
192 
193  $this->removeUsersFromCollections($remove_users);
194 
195  return $this->collections;
196  }
removeUsersFromCollections($a_remove_users)
Remove users from collection.
static getAllProviders()
Get all awareness providers.
Create styles array
The data for the language used.
static getUserSubsetByPreferenceValue($a_user_ids, $a_keyword, $a_val)
For a given set of user IDs return a subset that has a given user preference set. ...
settings()
Definition: settings.php:2
$i
Definition: disco.tpl.php:19
static getLogger($a_component_id)
Get component logger.
static getUsersAgreed($a_agreed=true, $a_users=null)
Get users that have or have not agreed to the user agreement.
+ Here is the call graph for this function:

◆ getInstance()

static ilAwarenessUserCollector::getInstance (   $a_user_id)
static

Get instance (for a user)

Parameters
int$a_user_iduser id
Returns
ilAwarenessAct actor class

Definition at line 70 of file class.ilAwarenessUserCollector.php.

Referenced by ilAwarenessData\__construct().

71  {
72  if (!isset(self::$instances[$a_user_id])) {
73  self::$instances[$a_user_id] = new ilAwarenessUserCollector($a_user_id);
74  }
75 
76  return self::$instances[$a_user_id];
77  }
Collects users from all providers.
+ Here is the caller graph for this function:

◆ getOnlineUsers()

static ilAwarenessUserCollector::getOnlineUsers ( )
static

Get online users.

Parameters

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

References array, and ilContext\directCall().

Referenced by ilAwarenessData\getData(), and ilAwarenessData\getOnlineUserData().

86  {
87  if (self::$online_users === false) {
88  self::$online_user_ids = array();
89  self::$online_users = array();
90  include_once("./Services/User/classes/class.ilObjUser.php");
91  foreach (ilObjUser::_getUsersOnline() as $u) {
92  // ask context $u["context"] if it supports pushMessages
93  if ($u["context"] &&
94  ilContext::directCall($u["context"], "supportsPushMessages")) {
95  self::$online_users[$u["user_id"]] = $u;
96  self::$online_user_ids[] = $u["user_id"];
97  }
98  }
99  }
100  return self::$online_users;
101  }
static directCall($a_type, $a_method)
Call context method directly without internal handling.
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRefId()

ilAwarenessUserCollector::getRefId ( )

Get ref id.

Returns
int ref id

Definition at line 59 of file class.ilAwarenessUserCollector.php.

References $ref_id.

◆ removeUsersFromCollections()

ilAwarenessUserCollector::removeUsersFromCollections (   $a_remove_users)
protected

Remove users from collection.

Parameters
array$a_remove_usersarray of user IDs

Definition at line 203 of file class.ilAwarenessUserCollector.php.

Referenced by collectUsers().

204  {
205  foreach ($this->collections as $c) {
206  reset($a_remove_users);
207  foreach ($a_remove_users as $u) {
208  $c["collection"]->removeUser($u);
209  }
210  }
211  }
+ Here is the caller graph for this function:

◆ setRefId()

ilAwarenessUserCollector::setRefId (   $a_val)

Set ref id.

Parameters
int$a_valref id

Definition at line 49 of file class.ilAwarenessUserCollector.php.

50  {
51  $this->ref_id = $a_val;
52  }

Field Documentation

◆ $collection

ilAwarenessUserCollector::$collection
protected

Definition at line 21 of file class.ilAwarenessUserCollector.php.

Referenced by collectUsers().

◆ $collections

ilAwarenessUserCollector::$collections
protected

Definition at line 22 of file class.ilAwarenessUserCollector.php.

Referenced by collectUsers().

◆ $instances

ilAwarenessUserCollector::$instances = array()
staticprotected

Definition at line 14 of file class.ilAwarenessUserCollector.php.

◆ $online_user_ids

ilAwarenessUserCollector::$online_user_ids = array()
staticprotected

Definition at line 16 of file class.ilAwarenessUserCollector.php.

◆ $online_users

ilAwarenessUserCollector::$online_users = false
staticprotected

Definition at line 15 of file class.ilAwarenessUserCollector.php.

◆ $ref_id

ilAwarenessUserCollector::$ref_id
protected

Definition at line 24 of file class.ilAwarenessUserCollector.php.

Referenced by getRefId().

◆ $settings

ilAwarenessUserCollector::$settings
protected

Definition at line 29 of file class.ilAwarenessUserCollector.php.

◆ $user_id

ilAwarenessUserCollector::$user_id
protected

Definition at line 23 of file class.ilAwarenessUserCollector.php.

Referenced by collectUsers().


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