ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilAwarenessAct Class Reference

High level business class, interface to front ends. More...

+ Collaboration diagram for ilAwarenessAct:

Public Member Functions

 setRefId ($a_val)
 Set ref id. More...
 
 getRefId ()
 Get ref id. More...
 
 getAwarenessData ($a_filter)
 Get awareness data. More...
 
 getAwarenessUserCounter ()
 Get awareness data. More...
 
 notifyOnNewOnlineContacts ()
 Send OSD notification on new users. 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

 $lng
 
 $user_id
 
 $ref_id = 0
 

Static Protected Attributes

static $instances = array()
 
static $collector
 

Detailed Description

High level business class, interface to front ends.

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

Constructor & Destructor Documentation

◆ __construct()

ilAwarenessAct::__construct (   $a_user_id)
protected

Constructor.

Parameters
int$a_user_iduser ud

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

References $DIC.

30  {
31  global $DIC;
32 
33  $this->lng = $DIC->language();
34  $this->user_id = $a_user_id;
35  }
global $DIC
Definition: saml.php:7

Member Function Documentation

◆ getAwarenessData()

ilAwarenessAct::getAwarenessData (   $a_filter)

Get awareness data.

Returns
ilAwarenessData awareness data

Definition at line 77 of file class.ilAwarenessAct.php.

References $data, ilAwarenessData\getInstance(), and getRefId().

78  {
79  include_once("./Services/Awareness/classes/class.ilAwarenessData.php");
80  $data = ilAwarenessData::getInstance($this->user_id);
81  $data->setRefId($this->getRefId());
82  $data->setFilter($a_filter);
83  return $data->getData();
84  }
getRefId()
Get ref id.
static getInstance($a_user_id)
Get instance (for a user)
$data
Definition: bench.php:6
+ Here is the call graph for this function:

◆ getAwarenessUserCounter()

ilAwarenessAct::getAwarenessUserCounter ( )

Get awareness data.

Returns
ilAwarenessData awareness data

Definition at line 91 of file class.ilAwarenessAct.php.

References $data, ilAwarenessData\getInstance(), and getRefId().

92  {
93  include_once("./Services/Awareness/classes/class.ilAwarenessData.php");
94  $data = ilAwarenessData::getInstance($this->user_id);
95  $data->setRefId($this->getRefId());
96  return $data->getUserCounter();
97  }
getRefId()
Get ref id.
static getInstance($a_user_id)
Get instance (for a user)
$data
Definition: bench.php:6
+ Here is the call graph for this function:

◆ getInstance()

static ilAwarenessAct::getInstance (   $a_user_id)
static

Get instance (for a user)

Parameters
int$a_user_iduser id
Returns
ilAwarenessAct actor class

Definition at line 63 of file class.ilAwarenessAct.php.

Referenced by ilAwarenessGUI\getAwarenessList(), and ilAwarenessGUI\getMainMenuHTML().

64  {
65  if (!isset(self::$instances[$a_user_id])) {
66  self::$instances[$a_user_id] = new ilAwarenessAct($a_user_id);
67  }
68 
69  return self::$instances[$a_user_id];
70  }
High level business class, interface to front ends.
+ Here is the caller graph for this function:

◆ getRefId()

ilAwarenessAct::getRefId ( )

Get ref id.

Returns
int ref id

Definition at line 52 of file class.ilAwarenessAct.php.

References $ref_id.

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

53  {
54  return $this->ref_id;
55  }
+ Here is the caller graph for this function:

◆ notifyOnNewOnlineContacts()

ilAwarenessAct::notifyOnNewOnlineContacts ( )

Send OSD notification on new users.

Definition at line 102 of file class.ilAwarenessAct.php.

References $d, $data, $lng, ilNotificationConfig\DEFAULT_TTS, ilSession\get(), ilAwarenessData\getInstance(), getRefId(), ilSession\set(), and ilNotificationConfig\TTL_SHORT.

103  {
104  $lng = $this->lng;
105 
106  $awrn_set = new ilSetting("awrn");
107  if (!$awrn_set->get("use_osd", true)) {
108  return;
109  }
110 
111  $ts = ilSession::get("awr_online_user_ts");
112 
113  $data = ilAwarenessData::getInstance($this->user_id);
114  $data->setRefId($this->getRefId());
115  $d = $data->getOnlineUserData($ts);
116 
117  $new_online_users = array();
118  $no_ids = array();
119  foreach ($d as $u) {
120  $uname = "[" . $u->login . "]";
121  if ($u->public_profile) {
122  $uname = "<a href='./goto.php?target=usr_" . $u->id . "'>" . $u->lastname . ", " . $u->firstname . " " . $uname . "</a>";
123  }
124  if (!in_array($u->id, $no_ids)) {
125  $new_online_users[] = $uname;
126  $no_ids[] = $u->id;
127  }
128  }
129 
130  if (count($new_online_users) == 0) {
131  return;
132  }
133  //var_dump($d); exit;
134  $lng->loadLanguageModule('mail');
135 
136  include_once("./Services/Object/classes/class.ilObjectFactory.php");
137  //$recipient = ilObjectFactory::getInstanceByObjId($this->user_id);
138  $bodyParams = array(
139  'online_user_names' => implode("<br />", $new_online_users)
140  );
141  //var_dump($bodyParams); exit;
142  require_once 'Services/Notifications/classes/class.ilNotificationConfig.php';
143  $notification = new ilNotificationConfig('osd_main');
144  $notification->setTitleVar('awareness_now_online', $bodyParams, 'awrn');
145  $notification->setShortDescriptionVar('awareness_now_online_users', $bodyParams, 'awrn');
146  $notification->setLongDescriptionVar('', $bodyParams, '');
147  $notification->setAutoDisable(false);
148  //$notification->setLink();
149  $notification->setIconPath('templates/default/images/icon_usr.svg');
150  $notification->setValidForSeconds(ilNotificationConfig::TTL_SHORT);
151  $notification->setVisibleForSeconds(ilNotificationConfig::DEFAULT_TTS);
152 
153  //$notification->setHandlerParam('mail.sender', $sender_id);
154 
155  ilSession::set("awr_online_user_ts", date("Y-m-d H:i:s", time()));
156 
157  $notification->notifyByUsers(array($this->user_id));
158  }
getRefId()
Get ref id.
static get($a_var)
Get a value.
static set($a_var, $a_val)
Set a value.
Describes a notification and provides methods for publishing this notification.
static getInstance($a_user_id)
Get instance (for a user)
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
$data
Definition: bench.php:6
+ Here is the call graph for this function:

◆ setRefId()

ilAwarenessAct::setRefId (   $a_val)

Set ref id.

Parameters
int$a_valref id

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

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

Field Documentation

◆ $collector

ilAwarenessAct::$collector
staticprotected

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

◆ $instances

ilAwarenessAct::$instances = array()
staticprotected

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

◆ $lng

ilAwarenessAct::$lng
protected

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

Referenced by notifyOnNewOnlineContacts().

◆ $ref_id

ilAwarenessAct::$ref_id = 0
protected

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

Referenced by getRefId().

◆ $user_id

ilAwarenessAct::$user_id
protected

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


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