ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
ilAwarenessData Class Reference
+ Collaboration diagram for ilAwarenessData:

Public Member Functions

 setRefId ($a_val)
 Set ref id. More...
 
 getRefId ()
 Get ref id. More...
 
 setFilter ($a_val)
 Set filter. More...
 
 getFilter ()
 Get filter. More...
 
 getMaxOnlineUserCnt ()
 Maximum for online user data. More...
 
 getUserCollections ($a_online_only=false)
 Get user collections. More...
 
 getUserCounter ()
 Get user counter. More...
 
 getOnlineUserData ($a_ts="")
 Get online user data. More...
 
 getData ()
 Get data. More...
 

Static Public Member Functions

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

Protected Member Functions

 __construct ($a_user_id)
 Constructor. More...
 

Protected Attributes

 $user_id
 
 $ref_id = 0
 
 $user_collector
 
 $feature_collector
 
 $user_collection
 
 $data = null
 
 $online_user_data = null
 
 $filter = ""
 

Static Protected Attributes

static $instances = array()
 

Detailed Description

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.ilAwarenessData.php.

Constructor & Destructor Documentation

◆ __construct()

ilAwarenessData::__construct (   $a_user_id)
protected

Constructor.

Parameters

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

References ilAwarenessFeatureCollector\getInstance(), and ilAwarenessUserCollector\getInstance().

31  {
32  $this->user_id = $a_user_id;
33 
34  include_once("./Services/Awareness/classes/class.ilAwarenessUserCollector.php");
35  $this->user_collector = ilAwarenessUserCollector::getInstance($a_user_id);
36  include_once("./Services/Awareness/classes/class.ilAwarenessFeatureCollector.php");
37  $this->feature_collector = ilAwarenessFeatureCollector::getInstance($a_user_id);
38  }
static getInstance($a_user_id)
Get instance (for a user)
static getInstance($a_user_id)
Get instance (for a user)
+ Here is the call graph for this function:

Member Function Documentation

◆ getData()

ilAwarenessData::getData ( )

Get data.

Returns
array array of data objects

Definition at line 234 of file class.ilAwarenessData.php.

References $filter, $n, $user_collection, ilObjUser\_getPersonalPicturePath(), getFilter(), ilUserUtil\getNamePresentation(), ilAwarenessUserCollector\getOnlineUsers(), getUserCollections(), and ilUtil\sortArray().

235  {
236  $awrn_set = new ilSetting("awrn");
237  $max = $awrn_set->get("max_nr_entries");
238 
239  $all_user_ids = array();
240  $hall_user_ids = array();
241 
242  if ($this->data == null)
243  {
245 
246  $user_collections = $this->getUserCollections();
247 
248  $this->data = array();
249 
250  foreach ($user_collections as $uc)
251  {
252 
253  // limit part 1
254  if (count($this->data) >= $max)
255  {
256  continue;
257  }
258 
259  $user_collection = $uc["collection"];
260  $user_ids = $user_collection->getUsers();
261 
262  foreach ($user_ids as $uid)
263  {
264  if (!in_array($uid, $all_user_ids))
265  {
266  if ($uc["highlighted"])
267  {
268  $hall_user_ids[] = $uid;
269  }
270  else
271  {
272  $all_user_ids[] = $uid;
273  }
274  }
275  }
276 
277  include_once("./Services/User/classes/class.ilUserUtil.php");
278  $names = ilUserUtil::getNamePresentation($user_ids, true,
279  false, "", false, false, true, true);
280 
281  // sort and add online information
282  foreach ($names as $k => $n)
283  {
284  if (isset($online_users[$n["id"]]))
285  {
286  $names[$k]["online"] = true;
287  $names[$k]["last_login"] = $online_users[$n["id"]]["last_login"];
288  $sort_str = "1";
289  }
290  else
291  {
292  $names[$k]["online"] = false;
293  $names[$k]["last_login"] = "";
294  $sort_str = "2";
295  }
296  if ($n["public_profile"])
297  {
298  $sort_str.= $n["lastname"]." ".$n["firstname"];
299  }
300  else
301  {
302  $sort_str.= $n["login"];
303  }
304  $names[$k]["sort_str"] = $sort_str;
305  }
306 
307  $names = ilUtil::sortArray($names, "sort_str", "asc", false, true);
308 
309  foreach ($names as $n)
310  {
311  // limit part 2
312  if (count($this->data) >= $max)
313  {
314  continue;
315  }
316 
317  // filter
318  $filter = trim($this->getFilter());
319  if ($filter != "" &&
320  !is_int(stripos($n["login"], $filter)) &&
321  (!$n["public_profile"] || (
322  !is_int(stripos($n["firstname"], $filter)) &&
323  !is_int(stripos($n["lastname"], $filter))
324  )
325  )
326  )
327  {
328  continue;
329  }
330 
331  $obj = new stdClass;
332  $obj->lastname = $n["lastname"];
333  $obj->firstname = $n["firstname"];
334  $obj->login = $n["login"];
335  $obj->id = $n["id"];
336  $obj->collector = $uc["uc_title"];
337  $obj->highlighted = $uc["highlighted"];
338 
339  //$obj->img = $n["img"];
340  $obj->img = ilObjUser::_getPersonalPicturePath($n["id"], "xsmall");
341  $obj->public_profile = $n["public_profile"];
342 
343  $obj->online = $n["online"];
344  $obj->last_login = $n["last_login"];;
345 
346  // get features
347  $feature_collection = $this->feature_collector->getFeaturesForTargetUser($n["id"]);
348  $obj->features = array();
349  foreach ($feature_collection->getFeatures() as $feature)
350  {
351  $f = new stdClass;
352  $f->text = $feature->getText();
353  $f->href = $feature->getHref();
354  $f->data = $feature->getData();
355  $obj->features[] = $f;
356  }
357 
358  $this->data[] = $obj;
359  }
360  }
361  }
362 
363  return array("data" => $this->data, "cnt" => count($all_user_ids).":".count($hall_user_ids));
364  }
ILIAS Setting Class.
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static getNamePresentation($a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false)
Default behaviour is:
$n
Definition: RandomTest.php:80
getUserCollections($a_online_only=false)
Get user collections.
static _getPersonalPicturePath($a_usr_id, $a_size="small", $a_force_pic=false, $a_prevent_no_photo_image=false)
Get path to personal picture.
static getOnlineUsers()
Get online users.
+ Here is the call graph for this function:

◆ getFilter()

ilAwarenessData::getFilter ( )

Get filter.

Returns
string filter string

Definition at line 75 of file class.ilAwarenessData.php.

References $filter.

Referenced by getData().

76  {
77  return $this->filter;
78  }
+ Here is the caller graph for this function:

◆ getInstance()

static ilAwarenessData::getInstance (   $a_user_id)
static

Get instance (for a user)

Parameters
int$a_user_iduser id
Returns
ilAwarenessData actor class

Definition at line 95 of file class.ilAwarenessData.php.

Referenced by ilAwarenessAct\getAwarenessData(), ilAwarenessAct\getAwarenessUserCounter(), and ilAwarenessAct\notifyOnNewOnlineContacts().

96  {
97  if (!isset(self::$instances[$a_user_id]))
98  {
99  self::$instances[$a_user_id] = new ilAwarenessData($a_user_id);
100  }
101 
102  return self::$instances[$a_user_id];
103  }
+ Here is the caller graph for this function:

◆ getMaxOnlineUserCnt()

ilAwarenessData::getMaxOnlineUserCnt ( )

Maximum for online user data.

Definition at line 83 of file class.ilAwarenessData.php.

Referenced by getOnlineUserData().

84  {
85  return 20;
86  }
+ Here is the caller graph for this function:

◆ getOnlineUserData()

ilAwarenessData::getOnlineUserData (   $a_ts = "")

Get online user data.

Parameters
string$a_tstimestamp
Returns
array array of data objects

Definition at line 164 of file class.ilAwarenessData.php.

References $n, $online_user_data, $user_collection, getMaxOnlineUserCnt(), ilUserUtil\getNamePresentation(), ilAwarenessUserCollector\getOnlineUsers(), getUserCollections(), and ilUtil\sortArray().

165  {
166  $online_user_data = array();
168  $user_collections = $this->getUserCollections(true); // get user collections with online users only
169  $all_online_user_ids = array();
170 
171  foreach ($user_collections as $uc)
172  {
173  $user_collection = $uc["collection"];
174  $user_ids = $user_collection->getUsers();
175 
176  foreach ($user_ids as $u)
177  {
178  if (!in_array($u, $all_online_user_ids))
179  {
180  // check timestamp and limit the max number of user data records received
181  if (($a_ts == "" || $online_users[$u]["last_login"] > $a_ts)
182  && count($all_online_user_ids) < $this->getMaxOnlineUserCnt())
183  {
184  $all_online_user_ids[] = $u;
185  }
186  }
187  }
188  }
189  include_once("./Services/User/classes/class.ilUserUtil.php");
190  $names = ilUserUtil::getNamePresentation($all_online_user_ids, true,
191  false, "", false, false, true, true);
192 
193  // sort and add online information
194  foreach ($names as $k => $n)
195  {
196  $names[$k]["online"] = true;
197  $names[$k]["last_login"] = $online_users[$n["id"]]["last_login"];
198  $sort_str = "";
199  if ($n["public_profile"])
200  {
201  $sort_str.= $n["lastname"]." ".$n["firstname"];
202  }
203  else
204  {
205  $sort_str.= $n["login"];
206  }
207  $names[$k]["sort_str"] = $sort_str;
208  }
209 
210  $names = ilUtil::sortArray($names, "sort_str", "asc", false, true);
211 
212  foreach ($names as $n)
213  {
214  $obj = new stdClass;
215  $obj->lastname = $n["lastname"];
216  $obj->firstname = $n["firstname"];
217  $obj->login = $n["login"];
218  $obj->id = $n["id"];
219  $obj->public_profile = $n["public_profile"];
220  $obj->online = $n["online"];
221  $obj->last_login = $n["last_login"];;
222 
223  $online_user_data[] = $obj;
224  }
225 
226  return $online_user_data;
227  }
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static getNamePresentation($a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false)
Default behaviour is:
$n
Definition: RandomTest.php:80
getUserCollections($a_online_only=false)
Get user collections.
static getOnlineUsers()
Get online users.
getMaxOnlineUserCnt()
Maximum for online user data.
+ Here is the call graph for this function:

◆ getRefId()

ilAwarenessData::getRefId ( )

Get ref id.

Returns
int ref id

Definition at line 55 of file class.ilAwarenessData.php.

References $ref_id.

Referenced by getUserCollections().

56  {
57  return $this->ref_id;
58  }
+ Here is the caller graph for this function:

◆ getUserCollections()

ilAwarenessData::getUserCollections (   $a_online_only = false)

Get user collections.

Parameters
bool$a_online_onlytrue, if only online users should be collected
Returns
array array of collections

Definition at line 113 of file class.ilAwarenessData.php.

References getRefId().

Referenced by getData(), getOnlineUserData(), and getUserCounter().

114  {
115  if (!isset($this->user_collections[(int) $a_online_only]))
116  {
117  $this->user_collector->setRefId($this->getRefId());
118  $this->user_collections[(int) $a_online_only] = $this->user_collector->collectUsers($a_online_only);
119  }
120 
121  return $this->user_collections[(int) $a_online_only];
122  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUserCounter()

ilAwarenessData::getUserCounter ( )

Get user counter.

Definition at line 127 of file class.ilAwarenessData.php.

References $user_collection, and getUserCollections().

128  {
129  $all_user_ids = array();
130  $hall_user_ids = array();
131 
132  $user_collections = $this->getUserCollections();
133 
134  foreach ($user_collections as $uc)
135  {
136  $user_collection = $uc["collection"];
137  $user_ids = $user_collection->getUsers();
138 
139  foreach ($user_ids as $uid)
140  {
141  if (!in_array($uid, $all_user_ids))
142  {
143  if ($uc["highlighted"])
144  {
145  $hall_user_ids[] = $uid;
146  }
147  else
148  {
149  $all_user_ids[] = $uid;
150  }
151  }
152  }
153  }
154 
155  return count($all_user_ids).":".count($hall_user_ids);
156  }
getUserCollections($a_online_only=false)
Get user collections.
+ Here is the call graph for this function:

◆ setFilter()

ilAwarenessData::setFilter (   $a_val)

Set filter.

Parameters
string$a_valfilter string

Definition at line 65 of file class.ilAwarenessData.php.

66  {
67  $this->filter = $a_val;
68  }

◆ setRefId()

ilAwarenessData::setRefId (   $a_val)

Set ref id.

Parameters
int$a_valref id

Definition at line 45 of file class.ilAwarenessData.php.

46  {
47  $this->ref_id = $a_val;
48  }

Field Documentation

◆ $data

ilAwarenessData::$data = null
protected

Definition at line 19 of file class.ilAwarenessData.php.

◆ $feature_collector

ilAwarenessData::$feature_collector
protected

Definition at line 17 of file class.ilAwarenessData.php.

◆ $filter

ilAwarenessData::$filter = ""
protected

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

Referenced by getData(), and getFilter().

◆ $instances

ilAwarenessData::$instances = array()
staticprotected

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

◆ $online_user_data

ilAwarenessData::$online_user_data = null
protected

Definition at line 20 of file class.ilAwarenessData.php.

Referenced by getOnlineUserData().

◆ $ref_id

ilAwarenessData::$ref_id = 0
protected

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

Referenced by getRefId().

◆ $user_collection

ilAwarenessData::$user_collection
protected

Definition at line 18 of file class.ilAwarenessData.php.

Referenced by getData(), getOnlineUserData(), and getUserCounter().

◆ $user_collector

ilAwarenessData::$user_collector
protected

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

◆ $user_id

ilAwarenessData::$user_id
protected

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


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