2 /***************************************************************************
3 * Copyright (C) 2003-2011 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';
23 @require_once
'Date.php';
25 class CarnetFeedIterator
implements PlIterator
30 public function __construct(PlUser
&$owner)
32 $notifs = Watch
::getEvents($owner);
34 foreach ($notifs as $n) {
35 foreach ($n['users'] as $user) {
36 $op = $n['operation'];
37 $date = $op->getDate($user);
38 @$datetext = new Date($date);
39 @$datetext = $datetext->format('%e %B %Y');
40 $profile = $user->profile();
41 $infos[] = array('operation' => $op,
42 'title' => '[' . $op->getTitle(1) . '] - ' . $user->fullName() . ' le ' . $datetext,
43 'author' => $user->fullName(),
44 'publication' => $op->publicationDate($user),
45 'date' => strtotime($date),
46 'id' => $op->flag
. '-' . $user->id() . '-' . strtotime($date),
47 'data' => $op->getData($user),
48 'hruid' => $user->login(),
49 'dead' => $user->deathdate
,
50 'profile' => $user->profile()->hrid(),
51 'link' => Platal
::globals()->baseurl
. '/profile/' . $profile->hrid(),
53 'contact' => $owner->isContact($profile));
56 $this->it
= PlIteratorUtils
::fromArray($infos);
59 public function next()
61 $data = $this->it
->next();
62 return $data['value'];
65 public function total()
67 return $this->it
->total();
70 public function first()
72 return $this->it
->first();
75 public function last()
77 return $this->it
->last();
81 class CarnetFeed
extends PlFeed
83 public function __construct()
86 parent
::__construct($globals->core
->sitename
. ' :: Carnet',
87 $globals->baseurl
. '/carnet/panel',
88 'Ton carnet polytechnicien',
89 $globals->baseurl
. '/images/logo.png',
93 protected function fetch(PlUser
&$user)
95 return new CarnetFeedIterator($user);
99 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: