ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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

 __construct (\ilDBInterface $database=null, \ilLanguage $language=null, \ILIAS\DI\Container $dic=null)
 ilNotificationOSDHandler constructor. More...
 
 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...
 

Private Attributes

 $database
 
 $language
 

Detailed Description

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

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

Constructor & Destructor Documentation

◆ __construct()

ilNotificationOSDHandler::__construct ( \ilDBInterface  $database = null,
\ilLanguage  $language = null,
\ILIAS\DI\Container  $dic = null 
)

ilNotificationOSDHandler constructor.

Parameters
ilDBInterface | null$database
ilLanguage | null$language
\ILIAS\DI\Container | null$dic

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

29 {
30 if ($dic === null) {
31 global $DIC;
32 $dic = $DIC;
33 }
34
35 if ($database === null) {
36 $database = $dic->database();
37 }
38 $this->database = $database;
39
40 if ($language === null) {
41 $language = $dic->language();
42 }
43 $this->language = $language;
44 }
global $DIC
Definition: saml.php:7

References $database, $DIC, and $language.

Member Function Documentation

◆ appendOsdIdToLinks()

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

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

114 {
115 $matches = array();
116 preg_match_all('/href="(.*?)"/', $subject, $matches);
117 if ($matches[1]) {
118 foreach ($matches[1] as $match) {
119 $match_appended = self::appendParamToLink($match, 'osd_id', $osd_id);
120 $subject = str_replace($match, $match_appended, $subject);
121 }
122 }
123 return $subject;
124 }
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 188 of file class.ilNotificationOSDHandler.php.

189 {
190 if (strpos($link, '?') !== false) {
191 $link .= '&' . $param . '=' . $value;
192 } else {
193 $link .= '?' . $param . '=' . $value;
194 }
195 return $link;
196 }

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

160 {
161 global $DIC;
162
163 $ilDB = $DIC->database();
164
165 $query = 'DELETE FROM ' . ilNotificationSetupHelper::$tbl_notification_osd_handler . ' WHERE valid_until < ' . $ilDB->quote(time(), 'integer');
166 $ilDB->manipulate($query);
167 }
$query
global $ilDB

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

173 {
174 $rnd = rand(0, 10000);
175 if ($rnd == 500) {
177 }
178 }
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 76 of file class.ilNotificationOSDHandler.php.

77 {
78 global $DIC;
79
80 $ilDB = $DIC->database();
81
82 $query = 'SELECT notification_osd_id, serialized, valid_until, visible_for, type FROM ' . ilNotificationSetupHelper::$tbl_notification_osd_handler
83 . ' WHERE usr_id = %s AND (valid_until = 0 OR valid_until > ' . $ilDB->quote(time(), 'integer') . ') AND time_added > %s';
84
85 $types = array('integer', 'integer');
86 $values = array($user_id, $max_age_seconds ? (time() - $max_age_seconds) : 0);
87
88 $rset = $ilDB->queryF($query, $types, $values);
89 $notifications = array();
90
91 while ($row = $ilDB->fetchAssoc($rset)) {
92 $row['data'] = unserialize($row['serialized']);
93 unset($row['serialized']);
94
95 $row['data']->handlerParams = array('general' => $row['data']->handlerParams[''], 'osd' => $row['data']->handlerParams['osd']);
96
97 if ($append_osd_id_to_link) {
98 if ($row['data']->link) {
99 $row['data']->link = self::appendParamToLink($row['data']->link, 'osd_id', $row['notification_osd_id']);
100 }
101
102 $row['data']->shortDescription = self::appendOsdIdToLinks($row['data']->shortDescription, $row['notification_osd_id']);
103 $row['data']->longDescription = self::appendOsdIdToLinks($row['data']->longDescription, $row['notification_osd_id']);
104 }
105 $notifications[] = $row;
106 }
107
109
110 return $notifications;
111 }
static appendOsdIdToLinks($subject, $osd_id)
static cleanupOnRandom()
Exec self::clean with a probability of 1%.
$row
$values

References $DIC, $ilDB, $query, $row, ilNotificationSetupHelper\$tbl_notification_osd_handler, $values, 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 46 of file class.ilNotificationOSDHandler.php.

47 {
49
50 $this->database->insert(
52 array(
53 'notification_osd_id' => array('integer', $id),
54 'usr_id' => array('integer', $notification->user->getId()),
55 'serialized' => array('text', serialize($notification)),
56 'valid_until' => array('integer', $notification->baseNotification->getValidForSeconds() ? ($notification->baseNotification->getValidForSeconds() + time()) : 0),
57 'visible_for' => array('integer', $notification->baseNotification->getVisibleForSeconds() ? $notification->baseNotification->getVisibleForSeconds() : 0),
58 'type' => array('text', $notification->baseNotification->getType()),
59 'time_added' => array('integer', time()),
60 )
61 );
62 }
if(!array_key_exists('StateId', $_REQUEST)) $id

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

134 {
135 global $DIC;
136
137 $ilDB = $DIC->database();
138
139 $query = 'SELECT usr_id FROM ' . ilNotificationSetupHelper::$tbl_notification_osd_handler . ' WHERE notification_osd_id = %s';
140 $types = array('integer');
141 $values = array($notification_osd_id);
142
143 $rset = $ilDB->queryF($query, $types, $values);
144
145 if ($row = $ilDB->fetchAssoc($rset)) {
146 $query = 'DELETE FROM ' . ilNotificationSetupHelper::$tbl_notification_osd_handler . ' WHERE notification_osd_id = %s';
147 $types = array('integer');
148 $values = array($notification_osd_id);
149
150 $ilDB->manipulateF($query, $types, $values);
151 }
152 }

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

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

65 {
66 $txt = new ilTextInputGUI($this->language->txt('polling_intervall'), 'osd_polling_intervall');
67 $txt->setRequired(true);
68 $txt->setInfo($this->language->txt('polling_in_seconds'));
69 $txt->setValue('300');
70
71 $item->addSubItem($txt);
72
73 return array('osd_polling_intervall');
74 }
This class represents a text property in a property form.
$txt
Definition: error.php:11

References $txt.

Field Documentation

◆ $database

ilNotificationOSDHandler::$database
private

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

Referenced by __construct().

◆ $language

ilNotificationOSDHandler::$language
private

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

Referenced by __construct().


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