X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fcarnet%2Ffeed.inc.php;h=2f1a9264a00e1610fad579781a38107adff04d42;hb=89cb2025f5f2aed0be3994c89ac473aa11535853;hp=3172b4a10680671594576038539776c064d555ab;hpb=e85e121558a37e06cbf2099843588a6e5e5c267a;p=platal.git diff --git a/modules/carnet/feed.inc.php b/modules/carnet/feed.inc.php index 3172b4a..2f1a926 100644 --- a/modules/carnet/feed.inc.php +++ b/modules/carnet/feed.inc.php @@ -20,40 +20,44 @@ ***************************************************************************/ require_once 'notifs.inc.php'; +@require_once 'Date.php'; class CarnetFeedIterator implements PlIterator { private $notifs; private $it; - public function __construct(Notifs& $notifs) + public function __construct(PlUser &$owner) { - $this->notifs =& $notifs; - $this->it = PlIteratorUtils::fromArray($notifs->_data, 3); + $notifs = Watch::getEvents($owner); + $infos = array(); + foreach ($notifs as $n) { + foreach ($n['users'] as $user) { + $op = $n['operation']; + $date = $op->getDate($user); + @$datetext = new Date($date); + @$datetext = $datetext->format('%e %B %Y'); + $infos[] = array('operation' => $op, + 'title' => '[' . $op->getTitle(1) . '] - ' . $user->fullName() . ' le ' . $datetext, + 'author' => $user->fullName(), + 'publication' => $op->publicationDate($user), + 'date' => strtotime($date), + 'id' => $op->flag . '-' . $user->id() . '-' . strtotime($date), + 'data' => $op->getData($user), + 'hruid' => $user->login(), + 'dead' => $user->deathdate, + 'profile' => $user->profile()->hrid(), + 'user' => $user, + 'contact' => $owner->isContact($user)); + } + } + $this->it = PlIteratorUtils::fromArray($infos); } public function next() { $data = $this->it->next(); - if (is_null($data)) { - return null; - } - $cid = $data['keys'][0]; - $x = $data['value']; - - global $globals; - @require_once 'Date.php'; - @$date = new Date($x['date']); - @$date = $date->format('%e %B %Y'); - $author = $x['prenom'] . ' ' . $x['nom'] . ' (X' . $x['promo'] . ')'; - return array_merge($x, - array('author' => $author, - 'publication' => $x['known'], - 'id' => 'carnet' . $x['known'] . $cid . $x['bestalias'], - 'link' => $globals->baseurl . '/profile/private/' - . $x['bestalias'], - 'title' => '[' . $this->notifs->_cats[$cid]['short'] . '] ' - . $author . ' - le ' . $date)); + return $data['value']; } public function total() @@ -86,7 +90,7 @@ class CarnetFeed extends PlFeed protected function fetch(PlUser &$user) { - return new CarnetFeedIterator(new Notifs($user->id(), false)); + return new CarnetFeedIterator($user); } }