From 6f5d05aef05cc1e107a50b8a62e4432dea70bc60 Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Sat, 14 May 2011 15:05:43 +0200 Subject: [PATCH 1/1] Extend the example with a more fine-grained storage of the list of read messages. Signed-off-by: Florent Bruneau --- examples/index.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/examples/index.php b/examples/index.php index 5ce833e..4419ee3 100644 --- a/examples/index.php +++ b/examples/index.php @@ -30,6 +30,31 @@ class MyBanana extends Banana } } +// Implements storage of a list of read messages +// (this is only an example of what is possible) +function hook_listReadMessages($group) +{ + if (!isset($_COOKIE['banana_read'])) { + return null; + } + $msgs = unserialize(gzinflate(base64_decode($_COOKIE['banana_read']))); + return array_keys($msgs); +} + +function hook_markAsRead($group, $artid, $msg) +{ + $msgs = array(); + if (isset($_COOKIE['banana_read'])) { + $msgs = unserialize(gzinflate(base64_decode($_COOKIE['banana_read']))); + } + $id = $msg->getHeader('message-id'); + $msgs[$id] = true; + $msgs = base64_encode(gzdeflate(serialize($msgs))); + setcookie('banana_read', $msgs, 0); + $_COOKIE['banana_read'] = $msgs; +} + + // Minimalist login if ((@$_GET['action'] == 'rss2') || (!isset($_SESSION['banana_email']) || isset($_POST['change_login']) || isset($_POST['valid_change']))) { -- 2.1.4