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(PlUser
&$owner)
31 $notifs = Watch
::getEvents($owner);
33 foreach ($notifs as $n) {
34 foreach ($n['users'] as $user) {
35 $op = $n['operation'];
36 $date = $op->getDate($user);
37 $infos[] = array('operation' => $op,
38 'title' => '[' . $op->getTitle(1) . '] - ' . $user->fullName(),
39 'author' => $user->fullName(),
40 'publication' => strtotime($op->publicationDate($user)),
41 'date' => strtotime($date),
42 'id' => $op->flag
. strtotime($date),
43 'data' => $op->getData($user),
44 'hruid' => $user->login(),
45 'dead' => $user->deathdate
,
46 'profile' => $user->profile()->hrid(),
48 'contact' => $owner->isContact($user));
51 $this->it
= PlIteratorUtils
::fromArray($infos);
54 public function next()
56 $data = $this->it
->next();
57 return $data['value'];
60 public function total()
62 return $this->it
->total();
65 public function first()
67 return $this->it
->first();
70 public function last()
72 return $this->it
->last();
76 class CarnetFeed
extends PlFeed
78 public function __construct()
81 parent
::__construct($globals->core
->sitename
. ' :: Carnet',
82 $globals->baseurl
. '/carnet/panel',
83 'Ton carnet polytechnicien',
84 $globals->baseurl
. '/images/logo.png',
88 protected function fetch(PlUser
&$user)
90 return new CarnetFeedIterator($user);
94 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: