Close #510
authorx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Mon, 26 Feb 2007 15:11:58 +0000 (15:11 +0000)
committerx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Mon, 26 Feb 2007 15:11:58 +0000 (15:11 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1521 839d8a87-29fc-0310-9880-83ba4fa771e5

ChangeLog
include/rss.inc.php
modules/carnet.php
templates/carnet/mescontacts.tpl

index 6f0687e..604250f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -15,6 +15,9 @@ Bug/Wish:
     * Banana:
         - #407: RSS feed                                                   -FRU
 
+    * Carnet:
+        - #510: Use RSS hash to get iCal                                   -FRU
+
     * Profile:
         - Better checks on image type for photos                           -FRU
 
index a52bfbe..41ede2c 100644 (file)
@@ -59,7 +59,9 @@ function init_rss($template, $alias, $hash, $require_uid = true)
         }
     }
 
-    header('Content-Type: application/rss+xml; charset=utf8');
+    if ($template) {
+        header('Content-Type: application/rss+xml; charset=utf8');
+    }    
     return $uid;
 }
 
index f833946..c593816 100644 (file)
@@ -30,7 +30,7 @@ class CarnetModule extends PLModule
 
             'carnet/contacts'       => $this->make_hook('contacts', AUTH_COOKIE),
             'carnet/contacts/pdf'   => $this->make_hook('pdf',      AUTH_COOKIE),
-            'carnet/contacts/ical'  => $this->make_hook('ical',     AUTH_COOKIE),
+            'carnet/contacts/ical'  => $this->make_hook('ical',     AUTH_PUBLIC),
             'carnet/contacts/vcard' => $this->make_hook('vcard',    AUTH_COOKIE),
 
             'carnet/rss'            => $this->make_hook('rss',      AUTH_PUBLIC),
@@ -333,8 +333,20 @@ class CarnetModule extends PLModule
         $page->assign('notifs', $notifs);
     }
 
-    function handler_ical(&$page)
+    function handler_ical(&$page, $alias = null, $hash = null)
     {
+        require_once 'rss.inc.php';
+        $uid = init_rss(null, $alias, $hash, false);
+        if (S::logged()) {
+            if (!$uid) {
+                $uid = S::i('uid');
+            } else if ($uid != S::i('uid')) {
+                require_once 'xorg.misc.inc.php';
+                send_warning_email("Récupération d\'un autre utilisateur ($uid)");
+            }
+        } else if (!$uid) {
+            exit;
+        }
         require_once 'ical.inc.php';
         $page->changeTpl('carnet/calendar.tpl', NO_SKIN);
         $page->register_function('display_ical', 'display_ical');
@@ -350,7 +362,7 @@ class CarnetModule extends PLModule
                    FROM contacts      AS c
              INNER JOIN auth_user_md5 AS u ON (u.user_id = c.contact)
              INNER JOIN aliases       AS a ON (u.user_id = a.id AND a.type = \'a_vie\')
-                  WHERE c.uid = {?}', S::v('uid'));
+                  WHERE c.uid = {?}', $uid);
 
         $annivs = Array();
         while (list($prenom, $nom, $promo, $naissance, $end, $ts, $forlife) = $res->next()) {
index 6757859..b6ae910 100644 (file)
@@ -61,7 +61,7 @@ Pour récupérer ta liste de contacts dans un PDF imprimable :<br />
 <ul>
   <li>
     {icon name=calendar_view_day title='Anniversaires'} 
-    <a href="carnet/contacts/ical/anniv-x.ics">
+    <a href="carnet/contacts/ical/{$smarty.session.forlife}/{$smarty.session.core_rss_hash}/anniv-x.ics">
       Le calendrier des anniversaires
     </a>
   </li>