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)
 
 notify (ilNotificationObject $notification)
 
 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.

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 }
static appendParamToLink($link, $param, $value)
Helper to append an additional parameter to an existing url.

References appendParamToLink().

Referenced by getNotificationsForUser().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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 }

Referenced by appendOsdIdToLinks(), and getNotificationsForUser().

+ Here is the caller graph for this function:

◆ cleanup()

static ilNotificationOSDHandler::cleanup ( )
static

Remove orphaned notifications.

@global ilDB $ilDB

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

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

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

Referenced by cleanupOnRandom().

+ Here is the caller graph for this function:

◆ 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) {
150 }
151 }
static cleanup()
Remove orphaned notifications.

References cleanup().

Referenced by getNotificationsForUser().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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

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
76
77 return $notifications;
78 }
static appendOsdIdToLinks($subject, $osd_id)
static cleanupOnRandom()
Exec self::clean with a probability of 1%.

References $ilDB, $query, $row, ilNotificationSetupHelper\$tbl_notification_osd_handler, appendOsdIdToLinks(), appendParamToLink(), and cleanupOnRandom().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ notify()

ilNotificationOSDHandler::notify ( ilNotificationObject  $notification)

Reimplemented from ilNotificationEchoHandler.

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

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

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

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

@global ilDB $ilDB

Parameters
integer$notification_osd_id

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

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 }

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

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

+ Here is the caller graph for this function:

◆ showSettings()

ilNotificationOSDHandler::showSettings (   $item)

Reimplemented from ilNotificationHandler.

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

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
global $lng
Definition: privfeed.php:17

References $lng, and $txt.


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