ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 78 of file class.ilNotificationOSDHandler.php.

References array.

78  {
79  $matches = array();
80  preg_match_all('/href="(.*?)"/', $subject, $matches);
81  if($matches[1]) {
82  foreach($matches[1] as $match) {
83  $match_appended = self::appendParamToLink($match, 'osd_id', $osd_id);
84  $subject = str_replace($match, $match_appended, $subject);
85  }
86  }
87  return $subject;
88  }
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 156 of file class.ilNotificationOSDHandler.php.

156  {
157  if (strpos($link, '?') !== false) {
158  $link .= '&' . $param . '=' . $value;
159  }
160  else {
161  $link .= '?' . $param . '=' . $value;
162  }
163  return $link;
164  }

◆ cleanup()

static ilNotificationOSDHandler::cleanup ( )
static

Remove orphaned notifications.

ilDB $ilDB

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

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

132  {
133  global $ilDB;
134  $query = 'DELETE FROM ' . ilNotificationSetupHelper::$tbl_notification_osd_handler . ' WHERE valid_until < ' . $ilDB->quote( time() ,'integer');
135  $ilDB->manipulate($query);
136  }
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 141 of file class.ilNotificationOSDHandler.php.

141  {
142  $rnd = rand(0, 10000);
143  if ($rnd == 500) {
144  self::cleanup();
145  }
146  }

◆ getNotificationsForUser()

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

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

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

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

42  {
43  global $ilDB;
44 
45  $query = 'SELECT notification_osd_id, serialized, valid_until, visible_for, type FROM ' . ilNotificationSetupHelper::$tbl_notification_osd_handler
46  . ' WHERE usr_id = %s AND (valid_until = 0 OR valid_until > ' . $ilDB->quote( time() ,'integer') . ') AND time_added > %s';
47 
48  $types = array('integer', 'integer');
49  $values = array($user_id, $max_age_seconds ? (time() - $max_age_seconds) : 0);
50 
51  $rset = $ilDB->queryF($query, $types, $values);
52  $notifications = array();
53 
54  while($row = $ilDB->fetchAssoc($rset)) {
55  $row['data'] = unserialize($row['serialized']);
56  unset($row['serialized']);
57 
58  $row['data']->handlerParams = array('general' => $row['data']->handlerParams[''], 'osd' => $row['data']->handlerParams['osd']);
59 
60  if ($append_osd_id_to_link) {
61 
62  if ($row['data']->link) {
63  $row['data']->link = self::appendParamToLink($row['data']->link, 'osd_id', $row['notification_osd_id']);
64  }
65 
66  $row['data']->shortDescription = self::appendOsdIdToLinks($row['data']->shortDescription, $row['notification_osd_id']);
67  $row['data']->longDescription = self::appendOsdIdToLinks($row['data']->longDescription, $row['notification_osd_id']);
68 
69  }
70  $notifications[] = $row;
71  }
72 
73  self::cleanupOnRandom();
74 
75  return $notifications;
76  }
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 11 of file class.ilNotificationOSDHandler.php.

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

11  {
12  global $ilDB;
13 
15 
16  $ilDB->insert(
18  array(
19  'notification_osd_id' => array('integer', $id),
20  'usr_id' => array('integer', $notification->user->getId()),
21  'serialized' => array('text', serialize($notification)),
22  'valid_until' => array('integer', $notification->baseNotification->getValidForSeconds() ? ($notification->baseNotification->getValidForSeconds() + time()) : 0),
23  'visible_for' => array('integer', $notification->baseNotification->getVisibleForSeconds() ? $notification->baseNotification->getVisibleForSeconds() : 0),
24  'type' => array('text', $notification->baseNotification->getType()),
25  'time_added' => array('integer', time()),
26  )
27  );
28  }
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 97 of file class.ilNotificationOSDHandler.php.

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

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

97  {
98  global $ilDB;
99 
100  $query = 'SELECT usr_id FROM ' . ilNotificationSetupHelper::$tbl_notification_osd_handler . ' WHERE notification_osd_id = %s';
101  $types = array('integer');
102  $values = array($notification_osd_id);
103 
104  $rset = $ilDB->queryF($query, $types, $values);
105 
106  if ($row = $ilDB->fetchAssoc($rset)) {
107 
108  $query = 'DELETE FROM ' . ilNotificationSetupHelper::$tbl_notification_osd_handler . ' WHERE notification_osd_id = %s';
109  $types = array('integer');
110  $values = array($notification_osd_id);
111 
112  $ilDB->manipulateF($query, $types, $values);
113 
114  // sends a "delete the given notification" notification using the
115  // osd_maint channel
116  /*$deletedNotification = new ilNotificationConfig('osd_maint');
117  $deletedNotification->setValidForSeconds(120);
118  $deletedNotification->setTitleVar('deleted');
119  $deletedNotification->setShortDescriptionVar($notification_osd_id);
120  $deletedNotification->setLongDescriptionVar('dummy');
121 
122  require_once 'Services/Notifications/classes/class.ilNotificationSystem.php';
123  ilNotificationSystem::sendNotificationToUsers($deletedNotification, array($row['usr_id']));*/
124  }
125  }
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 30 of file class.ilNotificationOSDHandler.php.

References $lng, $txt, and array.

30  {
31  global $lng;
32  $txt = new ilTextInputGUI($lng->txt('polling_intervall'), 'osd_polling_intervall');
33  $txt->setRequired(true);
34  $txt->setInfo($lng->txt('polling_in_seconds'));
35  $txt->setValue('300');
36 
37  $item->addSubItem($txt);
38 
39  return array('osd_polling_intervall');
40  }
This class represents a text property in a property form.
$txt
Definition: error.php:12
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: