ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilAwarenessAct.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
13 {
14  protected static $instances = array();
15  protected $user_id;
16  protected $ref_id = 0;
17  protected static $collector;
18 
24  protected function __construct($a_user_id)
25  {
26  $this->user_id = $a_user_id;
27  }
28 
34  function setRefId($a_val)
35  {
36  $this->ref_id = $a_val;
37  }
38 
44  function getRefId()
45  {
46  return $this->ref_id;
47  }
48 
55  static function getInstance($a_user_id)
56  {
57  if (!isset(self::$instances[$a_user_id]))
58  {
59  self::$instances[$a_user_id] = new ilAwarenessAct($a_user_id);
60  }
61 
62  return self::$instances[$a_user_id];
63  }
64 
70  function getAwarenessData($a_filter)
71  {
72  include_once("./Services/Awareness/classes/class.ilAwarenessData.php");
73  $data = ilAwarenessData::getInstance($this->user_id);
74  $data->setRefId($this->getRefId());
75  $data->setFilter($a_filter);
76  return $data->getData();
77  }
78 
85  {
86  include_once("./Services/Awareness/classes/class.ilAwarenessData.php");
87  $data = ilAwarenessData::getInstance($this->user_id);
88  $data->setRefId($this->getRefId());
89  return $data->getUserCounter();
90  }
91 
96  {
97  global $lng;
98 
99  $awrn_set = new ilSetting("awrn");
100  if (!$awrn_set->get("use_osd", true))
101  {
102  return;
103  }
104 
105  $ts = ilSession::get("awr_online_user_ts");
106 
107  $data = ilAwarenessData::getInstance($this->user_id);
108  $data->setRefId($this->getRefId());
109  $d = $data->getOnlineUserData($ts);
110 
111  $new_online_users = array();
112  $no_ids = array();
113  foreach ($d as $u)
114  {
115  $uname = "[".$u->login."]";
116  if ($u->public_profile)
117  {
118  $uname = "<a href='./goto.php?target=usr_".$u->id."'>".$u->lastname.", ".$u->firstname." ".$uname."</a>";
119  }
120  if (!in_array($u->id, $no_ids))
121  {
122  $new_online_users[] = $uname;
123  $no_ids[] = $u->id;
124  }
125  }
126 
127  if (count($new_online_users) == 0)
128  {
129  return;
130  }
131 //var_dump($d); exit;
132  $lng->loadLanguageModule('mail');
133 
134  include_once("./Services/Object/classes/class.ilObjectFactory.php");
135  //$recipient = ilObjectFactory::getInstanceByObjId($this->user_id);
136  $bodyParams = array(
137  'online_user_names' => implode("<br />", $new_online_users)
138  );
139 //var_dump($bodyParams); exit;
140  require_once 'Services/Notifications/classes/class.ilNotificationConfig.php';
141  $notification = new ilNotificationConfig('osd_main');
142  $notification->setTitleVar('awareness_now_online', $bodyParams, 'awrn');
143  $notification->setShortDescriptionVar('awareness_now_online_users', $bodyParams, 'awrn');
144  $notification->setLongDescriptionVar('', $bodyParams, '');
145  $notification->setAutoDisable(false);
146  //$notification->setLink();
147  $notification->setIconPath('templates/default/images/icon_usr.svg');
148  $notification->setValidForSeconds(ilNotificationConfig::TTL_SHORT);
149  $notification->setVisibleForSeconds(ilNotificationConfig::DEFAULT_TTS);
150 
151  //$notification->setHandlerParam('mail.sender', $sender_id);
152 
153  ilSession::set("awr_online_user_ts", date("Y-m-d H:i:s", time()));
154 
155  $notification->notifyByUsers(array($this->user_id));
156  }
157 
158 
159 }
160 
161 ?>
ILIAS Setting Class.
static getInstance($a_user_id)
Get instance (for a user)
getRefId()
Get ref id.
static get($a_var)
Get a value.
static set($a_var, $a_val)
Set a value.
for($col=0; $col< 50; $col++) $d
Describes a notification and provides methods for publishing this notification.
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Create styles array
The data for the language used.
High level business class, interface to front ends.
getAwarenessUserCounter()
Get awareness data.
global $lng
Definition: privfeed.php:17
static getInstance($a_user_id)
Get instance (for a user)
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
setRefId($a_val)
Set ref id.
__construct($a_user_id)
Constructor.
notifyOnNewOnlineContacts()
Send OSD notification on new users.
getAwarenessData($a_filter)
Get awareness data.