Commit | Line | Data |
---|---|---|
4e9a7a6d FB |
1 | <?php |
2 | /*************************************************************************** | |
9f5bd98e | 3 | * Copyright (C) 2003-2010 Polytechnique.org * |
4e9a7a6d FB |
4 | * http://opensource.polytechnique.org/ * |
5 | * * | |
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. * | |
10 | * * | |
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. * | |
15 | * * | |
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 * | |
18 | * Foundation, Inc., * | |
19 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * | |
20 | ***************************************************************************/ | |
21 | ||
22 | require_once 'notifs.inc.php'; | |
2f85f758 | 23 | @require_once 'Date.php'; |
4e9a7a6d FB |
24 | |
25 | class CarnetFeedIterator implements PlIterator | |
26 | { | |
27 | private $notifs; | |
4018f0b3 | 28 | private $it; |
4e9a7a6d | 29 | |
c350577b | 30 | public function __construct(PlUser &$owner) |
4e9a7a6d | 31 | { |
c350577b FB |
32 | $notifs = Watch::getEvents($owner); |
33 | $infos = array(); | |
34 | foreach ($notifs as $n) { | |
35 | foreach ($n['users'] as $user) { | |
36 | $op = $n['operation']; | |
37 | $date = $op->getDate($user); | |
2f85f758 FB |
38 | @$datetext = new Date($date); |
39 | @$datetext = $datetext->format('%e %B %Y'); | |
69c9557d | 40 | $profile = $user->profile(); |
c350577b | 41 | $infos[] = array('operation' => $op, |
2f85f758 | 42 | 'title' => '[' . $op->getTitle(1) . '] - ' . $user->fullName() . ' le ' . $datetext, |
c350577b | 43 | 'author' => $user->fullName(), |
2f85f758 | 44 | 'publication' => $op->publicationDate($user), |
c350577b | 45 | 'date' => strtotime($date), |
2f85f758 | 46 | 'id' => $op->flag . '-' . $user->id() . '-' . strtotime($date), |
c350577b FB |
47 | 'data' => $op->getData($user), |
48 | 'hruid' => $user->login(), | |
49 | 'dead' => $user->deathdate, | |
50 | 'profile' => $user->profile()->hrid(), | |
51 | 'user' => $user, | |
69c9557d | 52 | 'contact' => $owner->isContact($profile)); |
c350577b FB |
53 | } |
54 | } | |
55 | $this->it = PlIteratorUtils::fromArray($infos); | |
4e9a7a6d FB |
56 | } |
57 | ||
58 | public function next() | |
59 | { | |
4018f0b3 | 60 | $data = $this->it->next(); |
c350577b | 61 | return $data['value']; |
4e9a7a6d FB |
62 | } |
63 | ||
64 | public function total() | |
65 | { | |
4018f0b3 | 66 | return $this->it->total(); |
4e9a7a6d FB |
67 | } |
68 | ||
69 | public function first() | |
70 | { | |
4018f0b3 | 71 | return $this->it->first(); |
4e9a7a6d FB |
72 | } |
73 | ||
74 | public function last() | |
75 | { | |
4018f0b3 | 76 | return $this->it->last(); |
4e9a7a6d FB |
77 | } |
78 | } | |
79 | ||
80 | class CarnetFeed extends PlFeed | |
81 | { | |
82 | public function __construct() | |
83 | { | |
84 | global $globals; | |
85 | parent::__construct($globals->core->sitename . ' :: Carnet', | |
86 | $globals->baseurl . '/carnet/panel', | |
87 | 'Ton carnet polytechnicien', | |
88 | $globals->baseurl . '/images/logo.png', | |
89 | 'carnet/rss.tpl'); | |
90 | } | |
91 | ||
3f63a693 | 92 | protected function fetch(PlUser &$user) |
4e9a7a6d | 93 | { |
c350577b | 94 | return new CarnetFeedIterator($user); |
4e9a7a6d FB |
95 | } |
96 | } | |
97 | ||
98 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: | |
99 | ?> |