ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
 
 $action_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

return

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

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/User/Actions/classes/class.ilUserActionCollector.php");
37 include_once("./Services/Awareness/classes/class.ilAwarenessUserActionContext.php");
38 $this->action_collector = ilUserActionCollector::getInstance($a_user_id, new ilAwarenessUserActionContext());
39 }
Awareness context for user actions.
static getInstance($a_user_id)
Get instance (for a user)
static getInstance($a_user_id, ilUserActionContext $a_context)
Get instance (for a user)

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

+ 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 227 of file class.ilAwarenessData.php.

228 {
229 if ($this->user_id == ANONYMOUS_USER_ID) {
230 return [
231 "data" => [],
232 "cnt" => "0:0"
233 ];
234 }
235 $awrn_set = new ilSetting("awrn");
236 $max = $awrn_set->get("max_nr_entries");
237
238 $all_user_ids = array();
239 $hall_user_ids = array();
240
241 if ($this->data == null) {
243
244 $user_collections = $this->getUserCollections();
245
246 $this->data = array();
247
248 foreach ($user_collections as $uc) {
249
250 // limit part 1
251 if (count($this->data) >= $max) {
252 continue;
253 }
254
255 $user_collection = $uc["collection"];
256 $user_ids = $user_collection->getUsers();
257
258 foreach ($user_ids as $uid) {
259 if (!in_array($uid, $all_user_ids)) {
260 if ($uc["highlighted"]) {
261 $hall_user_ids[] = $uid;
262 } else {
263 $all_user_ids[] = $uid;
264 }
265 }
266 }
267
268 include_once("./Services/User/classes/class.ilUserUtil.php");
270 $user_ids,
271 true,
272 false,
273 "",
274 false,
275 false,
276 true,
277 true
278 );
279
280 // sort and add online information
281 foreach ($names as $k => $n) {
282 if (isset($online_users[$n["id"]])) {
283 $names[$k]["online"] = true;
284 $names[$k]["last_login"] = $online_users[$n["id"]]["last_login"];
285 $sort_str = "1";
286 } else {
287 $names[$k]["online"] = false;
288 $names[$k]["last_login"] = "";
289 $sort_str = "2";
290 }
291 if ($n["public_profile"]) {
292 $sort_str.= $n["lastname"] . " " . $n["firstname"];
293 } else {
294 $sort_str.= $n["login"];
295 }
296 $names[$k]["sort_str"] = $sort_str;
297 }
298
299 $names = ilUtil::sortArray($names, "sort_str", "asc", false, true);
300
301 foreach ($names as $n) {
302 // limit part 2
303 if (count($this->data) >= $max) {
304 continue;
305 }
306
307 // filter
308 $filter = trim($this->getFilter());
309 if ($filter != "" &&
310 !is_int(stripos($n["login"], $filter)) &&
311 (
312 !$n["public_profile"] || (
313 !is_int(stripos($n["firstname"], $filter)) &&
314 !is_int(stripos($n["lastname"], $filter))
315 )
316 )
317 ) {
318 continue;
319 }
320
321 $obj = new stdClass;
322 $obj->lastname = $n["lastname"];
323 $obj->firstname = $n["firstname"];
324 $obj->login = $n["login"];
325 $obj->id = $n["id"];
326 $obj->collector = $uc["uc_title"];
327 $obj->highlighted = $uc["highlighted"];
328
329 //$obj->img = $n["img"];
330 $obj->img = ilObjUser::_getPersonalPicturePath($n["id"], "xsmall");
331 $obj->public_profile = $n["public_profile"];
332
333 $obj->online = $n["online"];
334 $obj->last_login = $n["last_login"];
335 ;
336
337 // get actions
338 $action_collection = $this->action_collector->getActionsForTargetUser($n["id"]);
339 $obj->actions = array();
340 foreach ($action_collection->getActions() as $action) {
341 $f = new stdClass;
342 $f->text = $action->getText();
343 $f->href = $action->getHref();
344 $f->data = $action->getData();
345 $obj->actions[] = $f;
346 }
347
348 $this->data[] = $obj;
349 }
350 }
351 }
352
353 return array("data" => $this->data, "cnt" => count($all_user_ids) . ":" . count($hall_user_ids));
354 }
$n
Definition: RandomTest.php:85
getUserCollections($a_online_only=false)
Get user collections.
static getOnlineUsers()
Get online users.
ILIAS Setting Class.
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, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
$action
$this data['403_header']

References $action, $filter, $n, $names, $user_collection, data, getFilter(), ilUserUtil\getNamePresentation(), ilAwarenessUserCollector\getOnlineUsers(), getUserCollections(), and ilUtil\sortArray().

+ Here is the call graph for this function:

◆ getFilter()

ilAwarenessData::getFilter ( )

Get filter.

Returns
string filter string

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

77 {
78 return $this->filter;
79 }

References $filter.

Referenced by getData().

+ 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 96 of file class.ilAwarenessData.php.

97 {
98 if (!isset(self::$instances[$a_user_id])) {
99 self::$instances[$a_user_id] = new ilAwarenessData($a_user_id);
100 }
101
102 return self::$instances[$a_user_id];
103 }

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

+ Here is the caller graph for this function:

◆ getMaxOnlineUserCnt()

ilAwarenessData::getMaxOnlineUserCnt ( )

Maximum for online user data.

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

85 {
86 return 20;
87 }

Referenced by getOnlineUserData().

+ 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 157 of file class.ilAwarenessData.php.

158 {
159 $online_user_data = array();
161 $user_collections = $this->getUserCollections(true); // get user collections with online users only
162 $all_online_user_ids = array();
163
164 foreach ($user_collections as $uc) {
165 $user_collection = $uc["collection"];
166 $user_ids = $user_collection->getUsers();
167 foreach ($user_ids as $u) {
168 if (!in_array($u, $all_online_user_ids)) {
169 // check timestamp and limit the max number of user data records received
170 if (($a_ts == "" || $online_users[$u]["last_login"] > $a_ts)
171 && count($all_online_user_ids) < $this->getMaxOnlineUserCnt()) {
172 $all_online_user_ids[] = $u;
173 }
174 }
175 }
176 }
177
178 include_once("./Services/User/classes/class.ilUserUtil.php");
180 $all_online_user_ids,
181 true,
182 false,
183 "",
184 false,
185 false,
186 true,
187 true
188 );
189
190 // sort and add online information
191 foreach ($names as $k => $n) {
192 $names[$k]["online"] = true;
193 $names[$k]["last_login"] = $online_users[$n["id"]]["last_login"];
194 $sort_str = "";
195 if ($n["public_profile"]) {
196 $sort_str.= $n["lastname"] . " " . $n["firstname"];
197 } else {
198 $sort_str.= $n["login"];
199 }
200 $names[$k]["sort_str"] = $sort_str;
201 }
202
203 $names = ilUtil::sortArray($names, "sort_str", "asc", false, true);
204
205 foreach ($names as $n) {
206 $obj = new stdClass;
207 $obj->lastname = $n["lastname"];
208 $obj->firstname = $n["firstname"];
209 $obj->login = $n["login"];
210 $obj->id = $n["id"];
211 $obj->public_profile = $n["public_profile"];
212 $obj->online = $n["online"];
213 $obj->last_login = $n["last_login"];
214 ;
215
216 $online_user_data[] = $obj;
217 }
218
219 return $online_user_data;
220 }
getMaxOnlineUserCnt()
Maximum for online user data.

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

+ Here is the call graph for this function:

◆ getRefId()

ilAwarenessData::getRefId ( )

Get ref id.

Returns
int ref id

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

57 {
58 return $this->ref_id;
59 }

References $ref_id.

Referenced by getUserCollections().

+ 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.

114 {
115 if (!isset($this->user_collections[(int) $a_online_only])) {
116 $this->user_collector->setRefId($this->getRefId());
117 $this->user_collections[(int) $a_online_only] = $this->user_collector->collectUsers($a_online_only);
118 }
119
120 return $this->user_collections[(int) $a_online_only];
121 }

References getRefId().

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

+ 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 126 of file class.ilAwarenessData.php.

127 {
128 $all_user_ids = array();
129 $hall_user_ids = array();
130
131 $user_collections = $this->getUserCollections();
132
133 foreach ($user_collections as $uc) {
134 $user_collection = $uc["collection"];
135 $user_ids = $user_collection->getUsers();
136
137 foreach ($user_ids as $uid) {
138 if (!in_array($uid, $all_user_ids)) {
139 if ($uc["highlighted"]) {
140 $hall_user_ids[] = $uid;
141 } else {
142 $all_user_ids[] = $uid;
143 }
144 }
145 }
146 }
147
148 return count($all_user_ids) . ":" . count($hall_user_ids);
149 }

References $user_collection, and getUserCollections().

+ Here is the call graph for this function:

◆ setFilter()

ilAwarenessData::setFilter (   $a_val)

Set filter.

Parameters
string$a_valfilter string

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

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

◆ setRefId()

ilAwarenessData::setRefId (   $a_val)

Set ref id.

Parameters
int$a_valref id

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

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

Field Documentation

◆ $action_collector

ilAwarenessData::$action_collector
protected

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

◆ $data

ilAwarenessData::$data = null
protected

Definition at line 19 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: