update Piwik to version 2.16 (fixes #91)
This commit is contained in:
parent
296343bf3b
commit
d885a4baa9
5833 changed files with 418860 additions and 226988 deletions
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
|
|
@ -9,11 +9,12 @@
|
|||
namespace Piwik\Notification;
|
||||
|
||||
use Piwik\Notification;
|
||||
use Piwik\Session;
|
||||
use Piwik\Session\SessionNamespace;
|
||||
|
||||
/**
|
||||
* Posts and removes UI notifications (see {@link Piwik\Notification} to learn more).
|
||||
*
|
||||
*
|
||||
*/
|
||||
class Manager
|
||||
{
|
||||
|
|
@ -36,13 +37,14 @@ class Manager
|
|||
{
|
||||
self::checkId($id);
|
||||
|
||||
self::removeOldestNotificationsIfThereAreTooMany();
|
||||
self::addNotification($id, $notification);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a posted notification by ID.
|
||||
*
|
||||
* @param $id The notification ID, see {@link notify()}.
|
||||
*
|
||||
* @param string $id The notification ID, see {@link notify()}.
|
||||
*/
|
||||
public static function cancel($id)
|
||||
{
|
||||
|
|
@ -53,7 +55,7 @@ class Manager
|
|||
|
||||
/**
|
||||
* Removes all temporary notifications.
|
||||
*
|
||||
*
|
||||
* Call this method after the notifications have been
|
||||
* displayed to make sure temporary notifications won't be displayed twice.
|
||||
*/
|
||||
|
|
@ -103,12 +105,31 @@ class Manager
|
|||
|
||||
private static function addNotification($id, Notification $notification)
|
||||
{
|
||||
if (!self::isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$session = static::getSession();
|
||||
$session->notifications[$id] = $notification;
|
||||
}
|
||||
|
||||
private static function removeOldestNotificationsIfThereAreTooMany()
|
||||
{
|
||||
$maxNotificationsInSession = 30;
|
||||
|
||||
$session = static::getSession();
|
||||
|
||||
while (count($session->notifications) >= $maxNotificationsInSession) {
|
||||
array_shift($session->notifications);
|
||||
}
|
||||
}
|
||||
|
||||
private static function getAllNotifications()
|
||||
{
|
||||
if (!self::isEnabled()) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$session = static::getSession();
|
||||
|
||||
return $session->notifications;
|
||||
|
|
@ -116,12 +137,21 @@ class Manager
|
|||
|
||||
private static function removeNotification($id)
|
||||
{
|
||||
if (!self::isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$session = static::getSession();
|
||||
if (array_key_exists($id, $session->notifications)) {
|
||||
unset($session->notifications[$id]);
|
||||
}
|
||||
}
|
||||
|
||||
private static function isEnabled()
|
||||
{
|
||||
return Session::isWritable() && Session::isReadable();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SessionNamespace
|
||||
*/
|
||||
|
|
@ -131,7 +161,7 @@ class Manager
|
|||
static::$session = new SessionNamespace('notification');
|
||||
}
|
||||
|
||||
if (empty(static::$session->notifications)) {
|
||||
if (empty(static::$session->notifications) && self::isEnabled()) {
|
||||
static::$session->notifications = array();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue