ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilNotificationOSDHandler Class Reference

Notification handler for senden a notification popup to the recipients browser. More...

+ Inheritance diagram for ilNotificationOSDHandler:
+ Collaboration diagram for ilNotificationOSDHandler:

Public Member Functions

 notify (ilNotificationObject $notification)
 
 showSettings ($item)
 
- Public Member Functions inherited from ilNotificationEchoHandler
 notify (ilNotificationObject $notification)
 
- Public Member Functions inherited from ilNotificationHandler
 notify (ilNotificationObject $notification)
 
 showSettings ($form)
 

Static Public Member Functions

static getNotificationsForUser ($user_id, $append_osd_id_to_link=true, $max_age_seconds=0)
 
static removeNotification ($notification_osd_id)
 Removes a notifcation and triggers a follow up notification to remove the notification from the browser view of the original recipient. More...
 
static cleanup ()
 Remove orphaned notifications. More...
 
static cleanupOnRandom ()
 Exec self::clean with a probability of 1%. More...
 

Static Private Member Functions

static appendOsdIdToLinks ($subject, $osd_id)
 
static appendParamToLink ($link, $param, $value)
 Helper to append an additional parameter to an existing url. More...
 

Detailed Description

Notification handler for senden a notification popup to the recipients browser.

Definition at line 10 of file class.ilNotificationOSDHandler.php.

Member Function Documentation

◆ appendOsdIdToLinks()

static ilNotificationOSDHandler::appendOsdIdToLinks (   $subject,
  $osd_id 
)
staticprivate

Definition at line 80 of file class.ilNotificationOSDHandler.php.

References array.

81  {
82  $matches = array();
83  preg_match_all('/href="(.*?)"/', $subject, $matches);
84  if ($matches[1]) {
85  foreach ($matches[1] as $match) {
86  $match_appended = self::appendParamToLink($match, 'osd_id', $osd_id);
87  $subject = str_replace($match, $match_appended, $subject);
88  }
89  }
90  return $subject;
91  }
Create styles array
The data for the language used.

◆ appendParamToLink()

static ilNotificationOSDHandler::appendParamToLink (   $link,
  $param,
  $value 
)
staticprivate

Helper to append an additional parameter to an existing url.

Parameters
string$link
string$param
scalar$value
Returns
string

Definition at line 161 of file class.ilNotificationOSDHandler.php.

162  {
163  if (strpos($link, '?') !== false) {
164  $link .= '&' . $param . '=' . $value;
165  } else {
166  $link .= '?' . $param . '=' . $value;
167  }
168  return $link;
169  }

◆ cleanup()

static ilNotificationOSDHandler::cleanup ( )
static

Remove orphaned notifications.

ilDB $ilDB

Definition at line 135 of file class.ilNotificationOSDHandler.php.

References $ilDB, $query, ilNotificationSetupHelper\$tbl_notification_osd_handler, and time.

136  {
137  global $ilDB;
138  $query = 'DELETE FROM ' . ilNotificationSetupHelper::$tbl_notification_osd_handler . ' WHERE valid_until < ' . $ilDB->quote(time(), 'integer');
139  $ilDB->manipulate($query);
140  }
$query
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.

◆ cleanupOnRandom()

static ilNotificationOSDHandler::cleanupOnRandom ( )
static

Exec self::clean with a probability of 1%.

Definition at line 145 of file class.ilNotificationOSDHandler.php.

146  {
147  $rnd = rand(0, 10000);
148  if ($rnd == 500) {
149  self::cleanup();
150  }
151  }

◆ getNotificationsForUser()

static ilNotificationOSDHandler::getNotificationsForUser (   $user_id,
  $append_osd_id_to_link = true,
  $max_age_seconds = 0 
)
static

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

References $ilDB, $query, $row, ilNotificationSetupHelper\$tbl_notification_osd_handler, array, and time.

Referenced by ilNotificationGUI\getOSDNotificationsObject(), and ilNotificationOSDGUI\render().

46  {
47  global $ilDB;
48 
49  $query = 'SELECT notification_osd_id, serialized, valid_until, visible_for, type FROM ' . ilNotificationSetupHelper::$tbl_notification_osd_handler
50  . ' WHERE usr_id = %s AND (valid_until = 0 OR valid_until > ' . $ilDB->quote(time(), 'integer') . ') AND time_added > %s';
51 
52  $types = array('integer', 'integer');
53  $values = array($user_id, $max_age_seconds ? (time() - $max_age_seconds) : 0);
54 
55  $rset = $ilDB->queryF($query, $types, $values);
56  $notifications = array();
57 
58  while ($row = $ilDB->fetchAssoc($rset)) {
59  $row['data'] = unserialize($row['serialized']);
60  unset($row['serialized']);
61 
62  $row['data']->handlerParams = array('general' => $row['data']->handlerParams[''], 'osd' => $row['data']->handlerParams['osd']);
63 
64  if ($append_osd_id_to_link) {
65  if ($row['data']->link) {
66  $row['data']->link = self::appendParamToLink($row['data']->link, 'osd_id', $row['notification_osd_id']);
67  }
68 
69  $row['data']->shortDescription = self::appendOsdIdToLinks($row['data']->shortDescription, $row['notification_osd_id']);
70  $row['data']->longDescription = self::appendOsdIdToLinks($row['data']->longDescription, $row['notification_osd_id']);
71  }
72  $notifications[] = $row;
73  }
74 
75  self::cleanupOnRandom();
76 
77  return $notifications;
78  }
$query
Create styles array
The data for the language used.
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the caller graph for this function:

◆ notify()

ilNotificationOSDHandler::notify ( ilNotificationObject  $notification)

Definition at line 12 of file class.ilNotificationOSDHandler.php.

References $id, $ilDB, ilNotificationSetupHelper\$tbl_notification_osd_handler, array, and time.

13  {
14  global $ilDB;
15 
17 
18  $ilDB->insert(
20  array(
21  'notification_osd_id' => array('integer', $id),
22  'usr_id' => array('integer', $notification->user->getId()),
23  'serialized' => array('text', serialize($notification)),
24  'valid_until' => array('integer', $notification->baseNotification->getValidForSeconds() ? ($notification->baseNotification->getValidForSeconds() + time()) : 0),
25  'visible_for' => array('integer', $notification->baseNotification->getVisibleForSeconds() ? $notification->baseNotification->getVisibleForSeconds() : 0),
26  'type' => array('text', $notification->baseNotification->getType()),
27  'time_added' => array('integer', time()),
28  )
29  );
30  }
if(!array_key_exists('StateId', $_REQUEST)) $id
Create styles array
The data for the language used.
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.

◆ removeNotification()

static ilNotificationOSDHandler::removeNotification (   $notification_osd_id)
static

Removes a notifcation and triggers a follow up notification to remove the notification from the browser view of the original recipient.

ilDB $ilDB

Parameters
integer$notification_osd_id

Definition at line 100 of file class.ilNotificationOSDHandler.php.

References $ilDB, $query, $row, ilNotificationSetupHelper\$tbl_notification_osd_handler, and array.

Referenced by ilPublicUserProfileGUI\executeCommand(), and ilNotificationGUI\removeOSDNotificationsObject().

101  {
102  global $ilDB;
103 
104  $query = 'SELECT usr_id FROM ' . ilNotificationSetupHelper::$tbl_notification_osd_handler . ' WHERE notification_osd_id = %s';
105  $types = array('integer');
106  $values = array($notification_osd_id);
107 
108  $rset = $ilDB->queryF($query, $types, $values);
109 
110  if ($row = $ilDB->fetchAssoc($rset)) {
111  $query = 'DELETE FROM ' . ilNotificationSetupHelper::$tbl_notification_osd_handler . ' WHERE notification_osd_id = %s';
112  $types = array('integer');
113  $values = array($notification_osd_id);
114 
115  $ilDB->manipulateF($query, $types, $values);
116 
117  // sends a "delete the given notification" notification using the
118  // osd_maint channel
119  /*$deletedNotification = new ilNotificationConfig('osd_maint');
120  $deletedNotification->setValidForSeconds(120);
121  $deletedNotification->setTitleVar('deleted');
122  $deletedNotification->setShortDescriptionVar($notification_osd_id);
123  $deletedNotification->setLongDescriptionVar('dummy');
124 
125  require_once 'Services/Notifications/classes/class.ilNotificationSystem.php';
126  ilNotificationSystem::sendNotificationToUsers($deletedNotification, array($row['usr_id']));*/
127  }
128  }
$query
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ showSettings()

ilNotificationOSDHandler::showSettings (   $item)

Definition at line 32 of file class.ilNotificationOSDHandler.php.

References $lng, $txt, and array.

33  {
34  global $lng;
35  $txt = new ilTextInputGUI($lng->txt('polling_intervall'), 'osd_polling_intervall');
36  $txt->setRequired(true);
37  $txt->setInfo($lng->txt('polling_in_seconds'));
38  $txt->setValue('300');
39 
40  $item->addSubItem($txt);
41 
42  return array('osd_polling_intervall');
43  }
This class represents a text property in a property form.
$txt
Definition: error.php:11
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17

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