ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 78 of file class.ilNotificationOSDHandler.php.

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

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

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

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

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

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
74
75 return $notifications;
76 }
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 '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 }

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

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 }

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

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

References $lng, and $txt.


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