2006 => 2007 Happy New Year\!
[platal.git] / modules / xnet.php
index ce9ed09..3690e88 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2006 Polytechnique.org                              *
+ *  Copyright (C) 2003-2007 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -32,24 +32,29 @@ class XnetModule extends PLModule
             'groups'    => $this->make_hook('groups',    AUTH_PUBLIC),
             'groupes.php' => $this->make_hook('groups2', AUTH_PUBLIC),
             'plan'      => $this->make_hook('plan',      AUTH_PUBLIC),
-            'send_bug'  => $this->make_hook('bug',       AUTH_MDP),
+            'photo'     => $this->make_hook('photo',     AUTH_MDP),
         );
     }
 
-    function handler_bug(&$page)
+    function handler_photo(&$page, $x = null)
     {
-        $page->changeTpl('bug.tpl',SIMPLE);
-        $page->addJsLink('close_on_esc.js');
-        if (Env::has('send')) {
-            $page->assign('bug_sent',1);
-            require_once "diogenes/diogenes.hermes.inc.php";
-            $mymail = new HermesMailer();
-            $mymail->setFrom('"'.S::v('prenom').' '.S::v('nom').'" <'.S::v('bestalias').'@polytechnique.org>');
-            $mymail->addTo('support+platal@polytechnique.org');
-            $mymail->setSubject('Plat/al '.Env::v('task_type').' : '.Env::v('item_summary'));
-            $mymail->setTxtBody(Env::v('detailed_desc'));
-            $mymail->send();
+        if (is_null($x)) {
+            return PL_NOT_FOUND;
         }
+
+        $res = XDB::query("SELECT attachmime, attach
+                             FROM aliases
+                       INNER JOIN photo ON(id = uid)
+                            WHERE alias = {?}", $x);
+
+        if ((list($type, $data) = $res->fetchOneRow())) {
+            Header("Content-type: image/$type");
+            echo $data;
+        } else {
+            Header('Content-type: image/png');
+            echo file_get_contents(dirname(__FILE__).'/../htdocs/images/none.png');
+        }
+        exit;
     }
     
     function handler_index(&$page)
@@ -68,6 +73,7 @@ class XnetModule extends PLModule
 
     function handler_exit(&$page)
     {
+        XnetSession::killSuid();
         XnetSession::destroy();
         $page->changeTpl('xnet/deconnexion.tpl');
     }