trombino.php => photo/change
authorx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Tue, 11 Jul 2006 20:12:18 +0000 (20:12 +0000)
committerx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Tue, 11 Jul 2006 20:12:18 +0000 (20:12 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@442 839d8a87-29fc-0310-9880-83ba4fa771e5

htdocs/trombino.php [deleted file]
modules/profile.php
templates/login.tpl
templates/profil/general.tpl
templates/trombino.tpl

diff --git a/htdocs/trombino.php b/htdocs/trombino.php
deleted file mode 100644 (file)
index 32f10a2..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2006 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-require_once('xorg.inc.php');
-new_skinned_page('trombino.tpl', AUTH_MDP);
-
-require_once('validations.inc.php');
-
-$trombi_x = '/home/web/trombino/photos'.Session::get('promo').'/'.Session::get('forlife').'.jpg';
-
-if (Env::has('upload')) {
-    $file = isset($_FILES['userfile']['tmp_name']) ? $_FILES['userfile']['tmp_name'] : Env::get('photo');
-    if ($data = file_get_contents($file)) {
-        if ($myphoto = new PhotoReq(Session::getInt('uid'), $data)) {
-            $myphoto->submit();
-        }
-    } else {
-        $page->trig('Fichier inexistant ou vide');
-    }
-} elseif (Env::has('trombi')) {
-    $myphoto = new PhotoReq(Session::getInt('uid'), file_get_contents($trombi_x));
-    if ($myphoto) {
-        $myphoto->commit();
-        $myphoto->clean();
-    }
-} elseif (Env::get('suppr')) {
-    $globals->xdb->execute('DELETE FROM photo WHERE uid = {?}', Session::getInt('uid'));
-    $globals->xdb->execute('DELETE FROM requests WHERE user_id = {?} AND type="photo"', Session::getInt('uid'));
-} elseif (Env::get('cancel')) {
-    $sql = $globals->xdb->query('DELETE FROM requests WHERE user_id={?} AND type="photo"', Session::getInt('uid'));
-}
-
-$sql = $globals->xdb->query('SELECT COUNT(*) FROM requests WHERE user_id={?} AND type="photo"', Session::getInt('uid'));
-$page->assign('submited', $sql->fetchOneCell());
-$page->assign('has_trombi_x', file_exists($trombi_x));
-
-$page->run();
-
-// Affichage de la page principale
-?>
index 2d12210..7713e7b 100644 (file)
@@ -24,8 +24,9 @@ class ProfileModule extends PLModule
     function handlers()
     {
         return array(
-            'photo'  => $this->make_hook('photo',  AUTH_PUBLIC),
-            'trombi' => $this->make_hook('trombi', AUTH_COOKIE),
+            'photo'           => $this->make_hook('photo',        AUTH_PUBLIC),
+            'photo/change'    => $this->make_hook('photo_change', AUTH_MDP),
+            'trombi'          => $this->make_hook('trombi',       AUTH_COOKIE),
         );
     }
 
@@ -82,12 +83,62 @@ class ProfileModule extends PLModule
                 echo $data;
             } else {
                 Header('Content-type: image/png');
-                echo file_get_contents(dirname(__FILE__).'../htdocs/images/none.png');
+                echo file_get_contents(dirname(__FILE__).'/../htdocs/images/none.png');
             }
         }
         exit;
     }
 
+    function handler_photo_change(&$page)
+    {
+        global $globals;
+
+        $page->changeTpl('trombino.tpl');
+
+        require_once('validations.inc.php');
+
+        $trombi_x = '/home/web/trombino/photos'.Session::get('promo')
+                    .'/'.Session::get('forlife').'.jpg';
+
+        if (Env::has('upload')) {
+            $file = isset($_FILES['userfile']['tmp_name'])
+                    ? $_FILES['userfile']['tmp_name']
+                    : Env::get('photo');
+            if ($data = file_get_contents($file)) {
+                if ($myphoto = new PhotoReq(Session::getInt('uid'), $data)) {
+                    $myphoto->submit();
+                }
+            } else {
+                $page->trig('Fichier inexistant ou vide');
+            }
+        } elseif (Env::has('trombi')) {
+            $myphoto = new PhotoReq(Session::getInt('uid'),
+                                    file_get_contents($trombi_x));
+            if ($myphoto) {
+                $myphoto->commit();
+                $myphoto->clean();
+            }
+        } elseif (Env::get('suppr')) {
+            $globals->xdb->execute('DELETE FROM photo WHERE uid = {?}',
+                                   Session::getInt('uid'));
+            $globals->xdb->execute('DELETE FROM requests
+                                     WHERE user_id = {?} AND type="photo"',
+                                   Session::getInt('uid'));
+        } elseif (Env::get('cancel')) {
+            $sql = $globals->xdb->query('DELETE FROM requests 
+                                        WHERE user_id={?} AND type="photo"',
+                                        Session::getInt('uid'));
+        }
+
+        $sql = $globals->xdb->query('SELECT COUNT(*) FROM requests
+                                      WHERE user_id={?} AND type="photo"',
+                                    Session::getInt('uid'));
+        $page->assign('submited', $sql->fetchOneCell());
+        $page->assign('has_trombi_x', file_exists($trombi_x));
+
+        return PL_OK;
+    }
+
     function handler_trombi(&$page, $promo = null)
     {
         require_once 'trombi.inc.php';
index 3b3800d..f21628f 100644 (file)
@@ -53,7 +53,7 @@ Bienvenue {$smarty.session.prenom}
 {if $photo_incitation}
   <p>
     Tu n'as pas mis de photo de toi sur ta fiche, c'est dommage.
-    Clique <a href="{rel}/trombino.php">ici</a> si tu souhaites en ajouter une.
+    Clique <a href="{rel}/photo/change">ici</a> si tu souhaites en ajouter une.
   </p>
 {/if}
 
index dd3decb..d9c5e68 100644 (file)
         d'identité (dans un fichier au format JPEG, PNG ou GIF).<br />
         <div class="center">
           <span class="lien">
-            <a href="trombino.php">Éditer ta photo</a>
+            <a href="{rel}/photo/change">Éditer ta photo</a>
           </span>
         </div>
       </td>
index 7bbb9c7..1719ffc 100644 (file)
@@ -23,7 +23,7 @@
 
 <h1>Trombinoscope</h1>
 
-<form enctype="multipart/form-data" action="{$smarty.server.REQUEST_URI}" method="post">
+<form enctype="multipart/form-data" action="{rel}/photo/change" method="post">
   <table class="flags" cellspacing="0" summary="Flags">
     <tr>
       <td class="rouge"><input type="radio" checked="checked" /></td>