2 /***************************************************************************
3 * Copyright (C) 2003-2009 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 require_once 'notifs.inc.php';
24 class CarnetFeedIterator
implements PlIterator
29 public function __construct(Notifs
& $notifs)
31 $this->notifs
=& $notifs;
32 $this->it
= PlIteratorUtils
::fromArray($notifs->_data
, 3);
35 public function next()
37 $data = $this->it
->next();
41 $cid = $data['keys'][0];
45 @require_once
'Date.php';
46 @$date = new Date($x['date']);
47 @$date = $date->format('%e %B %Y');
48 $author = $x['prenom'] . ' ' . $x['nom'] . ' (X' . $x['promo'] . ')';
49 return array_merge($x,
50 array('author' => $author,
51 'publication' => $x['known'],
52 'id' => 'carnet' . $x['known'] . $cid . $x['bestalias'],
53 'link' => $globals->baseurl
. '/profile/private/'
55 'title' => '[' . $this->notifs
->_cats
[$cid]['short'] . '] '
56 . $author . ' - le ' . $date));
59 public function total()
61 return $this->it
->total();
64 public function first()
66 return $this->it
->first();
69 public function last()
71 return $this->it
->last();
75 class CarnetFeed
extends PlFeed
77 public function __construct()
80 parent
::__construct($globals->core
->sitename
. ' :: Carnet',
81 $globals->baseurl
. '/carnet/panel',
82 'Ton carnet polytechnicien',
83 $globals->baseurl
. '/images/logo.png',
87 protected function fetch(PlUser
&$user)
89 return new CarnetFeedIterator(new Notifs($user->id(), false
));
93 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: