From: Florent Bruneau Date: Sat, 14 May 2011 13:05:43 +0000 (+0200) Subject: Extend the example with a more fine-grained storage of the list of read X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=6f5d05aef05cc1e107a50b8a62e4432dea70bc60;hp=05114a3e055d9c5997e7f1c03568ac24a78ae4d8;p=banana.git Extend the example with a more fine-grained storage of the list of read messages. Signed-off-by: Florent Bruneau --- 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']))) {