ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
 

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 31 of file class.ilAwarenessUserCollector.php.

32  {
33  $this->user_id = $a_user_id;
34  }

Member Function Documentation

◆ collectUsers()

ilAwarenessUserCollector::collectUsers (   $a_online_only = false)

Collect users.

Returns
ilAwarenessUserCollection user collection

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

References $collection, $collections, $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, and removeUsersFromCollections().

100  {
101  global $rbacreview;
102 
103  $this->collections = array();
104 
105  $awrn_logger = ilLoggerFactory::getLogger('awrn');
106 
107  self::getOnlineUsers();
108  include_once("./Services/Awareness/classes/class.ilAwarenessUserProviderFactory.php");
109  $all_users = array();
111  {
112  // overall collection of users
113  include_once("./Services/Awareness/classes/class.ilAwarenessUserCollection.php");
115 
116  if ($prov->getActivationMode() != ilAwarenessUserProvider::MODE_INACTIVE)
117  {
118  $prov->setUserId($this->user_id);
119  $prov->setRefId($this->ref_id);
120  $prov->setOnlineUserFilter(false);
121  if ($prov->getActivationMode() == ilAwarenessUserProvider::MODE_ONLINE_ONLY || $a_online_only)
122  {
123  $prov->setOnlineUserFilter(self::$online_user_ids);
124  }
125 
126  $coll = $prov->collectUsers();
127  foreach ($coll->getUsers() as $user_id)
128  {
129  // filter out the anonymous user
130  if ($user_id == ANONYMOUS_USER_ID)
131  {
132  continue;
133  }
134 
135  $awrn_logger->debug("AwarenessUserCollector: Current User: ".$this->user_id.", ".
136  "Provider: ".$prov->getProviderId().", Collected User: ".$user_id);
137 
138  // cross check online, filter out offline users (if necessary)
139  if ((!$a_online_only && $prov->getActivationMode() == ilAwarenessUserProvider::MODE_INCL_OFFLINE)
140  || in_array($user_id, self::$online_user_ids))
141  {
142  $collection->addUser($user_id);
143  if (!in_array($user_id, $all_users))
144  {
145  $all_users[] = $user_id;
146  }
147  }
148  }
149  }
150  $this->collections[] = array(
151  "uc_title" => $prov->getTitle(),
152  "highlighted" => $prov->isHighlighted(),
153  "collection" => $collection
154  );
155  }
156 
157  $remove_users = array();
158 
159  // remove all users that hide their online status
160  foreach (ilObjUser::getUserSubsetByPreferenceValue($all_users, "hide_own_online_status", "y") as $u)
161  {
162  $remove_users[] = $u;
163  }
164 
165  // remove all users that have not accepted the terms of service yet
166  require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
168  {
169  foreach (ilObjUser::getUsersAgreed(false, $all_users) as $u)
170  {
171  if ($u != SYSTEM_USER_ID && !$rbacreview->isAssigned($u, SYSTEM_ROLE_ID))
172  //if ($u != SYSTEM_USER_ID)
173  {
174  $remove_users[] = $u;
175  }
176  }
177  }
178 
179  $this->removeUsersFromCollections($remove_users);
180 
181  return $this->collections;
182  }
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. ...
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 62 of file class.ilAwarenessUserCollector.php.

Referenced by ilAwarenessData\__construct().

63  {
64  if (!isset(self::$instances[$a_user_id]))
65  {
66  self::$instances[$a_user_id] = new ilAwarenessUserCollector($a_user_id);
67  }
68 
69  return self::$instances[$a_user_id];
70  }
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 78 of file class.ilAwarenessUserCollector.php.

References array.

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

79  {
80  if (self::$online_users === false)
81  {
82  self::$online_user_ids = array();
83  include_once("./Services/User/classes/class.ilObjUser.php");
84  self::$online_users = ilObjUser::_getUsersOnline();
85  foreach (self::$online_users as $u)
86  {
87  self::$online_user_ids[] = $u["user_id"];
88  }
89  }
90  return self::$online_users;
91  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getRefId()

ilAwarenessUserCollector::getRefId ( )

Get ref id.

Returns
int ref id

Definition at line 51 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 189 of file class.ilAwarenessUserCollector.php.

Referenced by collectUsers().

190  {
191  foreach ($this->collections as $c)
192  {
193  reset($a_remove_users);
194  foreach ($a_remove_users as $u)
195  {
196  $c["collection"]->removeUser($u);
197  }
198  }
199  }
+ Here is the caller graph for this function:

◆ setRefId()

ilAwarenessUserCollector::setRefId (   $a_val)

Set ref id.

Parameters
int$a_valref id

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

42  {
43  $this->ref_id = $a_val;
44  }

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().

◆ $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: