Arrange templates by module
[platal.git] / modules / xnet.php
index 5f2564f..812e9ed 100644 (file)
@@ -32,9 +32,31 @@ 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),
+            'photo'     => $this->make_hook('photo',     AUTH_MDP),
         );
     }
 
+    function handler_photo(&$page, $x = null)
+    {
+        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)
     {
         $page->nomenu = true;
@@ -43,11 +65,15 @@ class XnetModule extends PLModule
 
     function handler_login(&$page)
     {
-        pl_redirect('');
+        $allkeys = func_get_args();
+        unset($allkeys[0]);
+        $url = join('/',$allkeys);
+        pl_redirect($url);
     }
 
     function handler_exit(&$page)
     {
+        XnetSession::killSuid();
         XnetSession::destroy();
         $page->changeTpl('xnet/deconnexion.tpl');
     }