ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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 77 of file class.ilNotificationOSDHandler.php.

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

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

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 131 of file class.ilNotificationOSDHandler.php.

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

140 {
141 $rnd = rand(0, 10000);
142 if ($rnd == 500) {
144 }
145 }
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 41 of file class.ilNotificationOSDHandler.php.

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

+ 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 11 of file class.ilNotificationOSDHandler.php.

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 'type' => array('text', $notification->baseNotification->getType()),
24 'time_added' => array('integer', time()),
25 )
26 );
27 }

References $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 96 of file class.ilNotificationOSDHandler.php.

96 {
97 global $ilDB;
98
99 $query = 'SELECT usr_id FROM ' . ilNotificationSetupHelper::$tbl_notification_osd_handler . ' WHERE notification_osd_id = %s';
100 $types = array('integer');
101 $values = array($notification_osd_id);
102
103 $rset = $ilDB->queryF($query, $types, $values);
104
105 if ($row = $ilDB->fetchAssoc($rset)) {
106
107 $query = 'DELETE FROM ' . ilNotificationSetupHelper::$tbl_notification_osd_handler . ' WHERE notification_osd_id = %s';
108 $types = array('integer');
109 $values = array($notification_osd_id);
110
111 $ilDB->manipulateF($query, $types, $values);
112
113 // sends a "delete the given notification" notification using the
114 // osd_maint channel
115 $deletedNotification = new ilNotificationConfig('osd_maint');
116 $deletedNotification->setValidForSeconds(120);
117 $deletedNotification->setTitleVar('deleted');
118 $deletedNotification->setShortDescriptionVar($notification_osd_id);
119 $deletedNotification->setLongDescriptionVar('dummy');
120
121 require_once 'Services/Notifications/classes/class.ilNotificationSystem.php';
122 ilNotificationSystem::sendNotificationToUsers($deletedNotification, array($row['usr_id']));
123 }
124 }
Describes a notification and provides methods for publishing this notification.
static sendNotificationToUsers(ilNotificationConfig $notification, $users, $processAsync=false)

References $ilDB, $query, $row, ilNotificationSetupHelper\$tbl_notification_osd_handler, and ilNotificationSystem\sendNotificationToUsers().

Referenced by ilNotificationGUI\removeOSDNotificationsObject().

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

◆ showSettings()

ilNotificationOSDHandler::showSettings (   $item)

Reimplemented from ilNotificationHandler.

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

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

References $lng, and $txt.


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