Skip to content

Commit

Permalink
refs #4179 save notifications until delivered
Browse files Browse the repository at this point in the history
  • Loading branch information
tsteur committed Oct 27, 2013
1 parent 442185c commit c877300
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
19 changes: 13 additions & 6 deletions core/Notification/Manager.php
Expand Up @@ -34,17 +34,13 @@ public static function notify($id, Notification $notification)
{
self::checkId($id);

$session = static::getSession();
$session = static::getSession();
$session->$id = $notification;

if (Notification::TYPE_PERSISTENT != $notification->type) {
$session->setExpirationHops(1, $id);
}
}

public static function getAllNotificationsToDisplay()
{
$session = static::getSession();
$session = static::getSession();
$notifications = $session->getIterator();

$notifications->uasort(function ($n1, $n2) {
Expand All @@ -58,6 +54,17 @@ public static function getAllNotificationsToDisplay()
return $notifications;
}

public static function cancelAllNonPersistent()
{
$session = static::getSession();

foreach ($session->getIterator() as $key => $notification) {
if (Notification::TYPE_PERSISTENT != $notification->type) {
unset($session->$key);
}
}
}

/**
* Cancel a previously registered (or persistent) notification.
* @param $id
Expand Down
1 change: 1 addition & 0 deletions core/Plugin/Controller.php
Expand Up @@ -491,6 +491,7 @@ protected function setGeneralVariablesView($view)

$view->topMenu = MenuTop::getInstance()->getMenu();
$view->notifications = NotificationManager::getAllNotificationsToDisplay();
NotificationManager::cancelAllNonPersistent();
} catch (Exception $e) {
Piwik_ExitWithMessage($e->getMessage(), $e->getTraceAsString());
}
Expand Down
1 change: 1 addition & 0 deletions core/Plugin/ControllerAdmin.php
Expand Up @@ -81,6 +81,7 @@ static public function setBasicVariablesAdminView(View $view)

$view->topMenu = MenuTop::getInstance()->getMenu();
$view->notifications = NotificationManager::getAllNotificationsToDisplay();
NotificationManager::cancelAllNonPersistent();
$view->currentAdminMenuName = MenuAdmin::getInstance()->getCurrentAdminMenuName();

$view->enableFrames = PiwikConfig::getInstance()->General['enable_framed_settings'];
Expand Down

0 comments on commit c877300

Please sign in to comment.