Prevent sending empty issues (Closes #1587).
[platal.git] / modules / carnet / feed.inc.php
index 8f5a8e1..0351dc7 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2009 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
  ***************************************************************************/
 
 require_once 'notifs.inc.php';
+@require_once 'Date.php';
 
 class CarnetFeedIterator implements PlIterator
 {
     private $notifs;
     private $it;
 
-    public function __construct(PlUser &$owner)
+    public function __construct(PlUser $owner)
     {
         $notifs = Watch::getEvents($owner);
         $infos  = array();
@@ -34,18 +35,22 @@ class CarnetFeedIterator implements PlIterator
             foreach ($n['users'] as $user) {
                 $op   = $n['operation'];
                 $date = $op->getDate($user);
+                @$datetext = new Date($date);
+                @$datetext = $datetext->format('%e %B %Y');
+                $profile = $user->profile();
                 $infos[] = array('operation'   => $op,
-                                 'title'       => '[' . $op->getTitle(1) . ']  - ' . $user->fullName(),
+                                 'title'       => '[' . $op->getTitle(1) . ']  - ' . $user->fullName() . ' le ' . $datetext,
                                  'author'      => $user->fullName(),
-                                 'publication' => strtotime($op->publicationDate($user)),
+                                 'publication' => $op->publicationDate($user),
                                  'date'        => strtotime($date),
-                                 'id'          => $op->flag . strtotime($date),
+                                 'id'          => $op->flag . '-' . $user->id() . '-' . strtotime($date),
                                  'data'        => $op->getData($user),
                                  'hruid'       => $user->login(),
                                  'dead'        => $user->deathdate,
                                  'profile'     => $user->profile()->hrid(),
+                                 'link'        => Platal::globals()->baseurl . '/profile/' . $profile->hrid(),
                                  'user'        => $user,
-                                 'contact'     => $owner->isContact($user));
+                                 'contact'     => $owner->isContact($profile));
             }
         }
         $this->it = PlIteratorUtils::fromArray($infos);
@@ -85,7 +90,7 @@ class CarnetFeed extends PlFeed
                             'carnet/rss.tpl');
     }
 
-    protected function fetch(PlUser &$user)
+    protected function fetch(PlUser $user)
     {
         return new CarnetFeedIterator($user);
     }