ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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)

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.
static cleanup ()
 Remove orphaned notifications.
static cleanupOnRandom ()
 Exec self::clean with a probability of 1%.

Static Private Member Functions

static appendOsdIdToLinks ($subject, $osd_id)
static appendParamToLink ($link, $param, $value)
 Helper to append an additional parameter to an existing url.

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

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

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

References appendParamToLink().

Referenced by getNotificationsForUser().

{
$matches = array();
preg_match_all('/href="(.*?)"/', $subject, $matches);
if($matches[1]) {
foreach($matches[1] as $match) {
$match_appended = self::appendParamToLink($match, 'osd_id', $osd_id);
$subject = str_replace($match, $match_appended, $subject);
}
}
return $subject;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Referenced by appendOsdIdToLinks(), and getNotificationsForUser().

{
if (strpos($link, '?') !== false) {
$link .= '&' . $param . '=' . $value;
}
else {
$link .= '?' . $param . '=' . $value;
}
return $link;
}

+ Here is the caller graph for this function:

static ilNotificationOSDHandler::cleanup ( )
static

Remove orphaned notifications.

ilDB $ilDB

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

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

Referenced by cleanupOnRandom().

{
global $ilDB;
$query = 'DELETE FROM ' . ilNotificationSetupHelper::$tbl_notification_osd_handler . ' WHERE valid_until < ' . $ilDB->quote( time() ,'integer');
$ilDB->manipulate($query);
}

+ Here is the caller graph for this function:

static ilNotificationOSDHandler::cleanupOnRandom ( )
static

Exec self::clean with a probability of 1%.

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

References cleanup().

Referenced by getNotificationsForUser().

{
$rnd = rand(0, 10000);
if ($rnd == 500) {
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

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

Referenced by ilNotificationGUI\getOSDNotificationsObject().

{
global $ilDB;
$query = 'SELECT notification_osd_id, serialized, valid_until, type FROM ' . ilNotificationSetupHelper::$tbl_notification_osd_handler
. ' WHERE usr_id = %s AND (valid_until = 0 OR valid_until > ' . $ilDB->quote( time() ,'integer') . ') AND time_added > %s';
$types = array('integer', 'integer');
$values = array($user_id, $max_age_seconds ? (time() - $max_age_seconds) : 0);
$rset = $ilDB->queryF($query, $types, $values);
$notifications = array();
while($row = $ilDB->fetchAssoc($rset)) {
$row['data'] = unserialize($row['serialized']);
unset($row['serialized']);
$row['data']->handlerParams = array('general' => $row['data']->handlerParams[''], 'osd' => $row['data']->handlerParams['osd']);
if ($append_osd_id_to_link) {
if ($row['data']->link) {
$row['data']->link = self::appendParamToLink($row['data']->link, 'osd_id', $row['notification_osd_id']);
}
$row['data']->shortDescription = self::appendOsdIdToLinks($row['data']->shortDescription, $row['notification_osd_id']);
$row['data']->longDescription = self::appendOsdIdToLinks($row['data']->longDescription, $row['notification_osd_id']);
}
$notifications[] = $row;
}
return $notifications;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilNotificationOSDHandler::notify ( ilNotificationObject  $notification)

Reimplemented from ilNotificationEchoHandler.

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

References $ilDB, and ilNotificationSetupHelper\$tbl_notification_osd_handler.

{
global $ilDB;
$ilDB->insert(
array(
'notification_osd_id' => array('integer', $id),
'usr_id' => array('integer', $notification->user->getId()),
'serialized' => array('text', serialize($notification)),
'valid_until' => array('integer', $notification->baseNotification->getValidForSeconds() ? ($notification->baseNotification->getValidForSeconds() + time()) : 0),
'type' => array('text', $notification->baseNotification->getType()),
'time_added' => array('integer', time()),
)
);
}
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 96 of file class.ilNotificationOSDHandler.php.

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

Referenced by ilNotificationGUI\removeOSDNotificationsObject().

{
global $ilDB;
$query = 'SELECT usr_id FROM ' . ilNotificationSetupHelper::$tbl_notification_osd_handler . ' WHERE notification_osd_id = %s';
$types = array('integer');
$values = array($notification_osd_id);
$rset = $ilDB->queryF($query, $types, $values);
if ($row = $ilDB->fetchAssoc($rset)) {
$query = 'DELETE FROM ' . ilNotificationSetupHelper::$tbl_notification_osd_handler . ' WHERE notification_osd_id = %s';
$types = array('integer');
$values = array($notification_osd_id);
$ilDB->manipulateF($query, $types, $values);
// sends a "delete the given notification" notification using the
// osd_maint channel
$deletedNotification = new ilNotificationConfig('osd_maint');
$deletedNotification->setValidForSeconds(120);
$deletedNotification->setTitleVar('deleted');
$deletedNotification->setShortDescriptionVar($notification_osd_id);
$deletedNotification->setLongDescriptionVar('dummy');
require_once 'Services/Notifications/classes/class.ilNotificationSystem.php';
ilNotificationSystem::sendNotificationToUsers($deletedNotification, array($row['usr_id']));
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilNotificationOSDHandler::showSettings (   $item)

Reimplemented from ilNotificationHandler.

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

References $lng, and $txt.

{
global $lng;
$txt = new ilTextInputGUI($lng->txt('polling_intervall'), 'osd_polling_intervall');
$txt->setRequired(true);
$txt->setInfo($lng->txt('polling_in_seconds'));
$txt->setValue('300');
$item->addSubItem($txt);
return array('osd_polling_intervall');
}

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