merge webredirect also
authorx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sun, 9 Jul 2006 21:32:22 +0000 (21:32 +0000)
committerx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sun, 9 Jul 2006 21:32:22 +0000 (21:32 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@409 839d8a87-29fc-0310-9880-83ba4fa771e5

hooks/webredirect.inc.php
htdocs/webredirect.php [deleted file]
modules/platal.php
templates/webredirect.tpl

index d074618..47c46b6 100644 (file)
@@ -48,7 +48,7 @@ function webredirect_prefs()
 
     return Array(
             Array(
-                'url'    => 'webredirect.php',
+                'url'    => 'prefs/webredirect',
                 'title'  => 'Ma redirection de page WEB',
                 'text'   => $text,
                 'weight' => 60
diff --git a/htdocs/webredirect.php b/htdocs/webredirect.php
deleted file mode 100644 (file)
index 1643d00..0000000
+++ /dev/null
@@ -1,54 +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('webredirect.tpl', AUTH_MDP);
-$page->assign('xorg_title','Polytechnique.org - Redirection de page WEB');
-
-$log =& Session::getMixed('log');
-$url = Env::get('url');
-
-if ((Env::get('submit') == 'Valider' or Env::get('submit') == 'Modifier') and Env::has('url')) {
-    if ($globals->xdb->execute('UPDATE auth_user_quick SET redirecturl = {?} WHERE user_id = {?}',
-                $url, Session::getInt('uid')))
-    {
-        $log->log('carva_add', 'http://'.Env::get('url'));
-        $page->trig("Redirection activée vers <a href='http://$url'>$url</a>");
-    } else {
-        $page->trig('Erreur de mise à jour');
-    }
-} elseif (Env::get('submit') == "Supprimer") {
-    if ($globals->xdb->execute("UPDATE auth_user_quick SET redirecturl = '' WHERE user_id = {?}", Session::getInt('uid')))
-    {
-        $log->log("carva_del", $url);
-        Post::kill('url');
-        $page->trig('Redirection supprimée');
-    } else {
-        $page->trig('Erreur de suppression');
-    }
-}
-
-
-$res = $globals->xdb->query('SELECT redirecturl FROM auth_user_quick WHERE user_id = {?}', Session::getInt('uid'));
-$page->assign('carva', $res->fetchOneCell());
-
-$page->run();
-?>
index fe02ded..d6057b0 100644 (file)
@@ -27,6 +27,8 @@ class PlatalModule extends PLModule
             // Preferences thingies
             'prefs'     => $this->make_hook('prefs',     AUTH_COOKIE),
             'prefs/rss' => $this->make_hook('prefs_rss', AUTH_COOKIE),
+            'prefs/webredirect'
+                        => $this->make_hook('webredir',  AUTH_MDP),
             'skin'      => $this->make_hook('skin',      AUTH_COOKIE),
 
             // password related thingies
@@ -85,6 +87,42 @@ class PlatalModule extends PLModule
         return PL_OK;
     }
 
+    function handler_webredir(&$page)
+    {
+        global $globals;
+
+        $page->changeTpl('webredirect.tpl');
+
+        $page->assign('xorg_title','Polytechnique.org - Redirection de page WEB');
+
+        $log =& Session::getMixed('log');
+        $url = Env::get('url');
+
+        if (Env::get('submit') == 'Valider' and Env::has('url')) {
+            $globals->xdb->execute('UPDATE auth_user_quick
+                                       SET redirecturl = {?} WHERE user_id = {?}',
+                                   $url, Session::getInt('uid')))
+            $log->log('carva_add', 'http://'.Env::get('url'));
+            $page->trig("Redirection activée vers <a href='http://$url'>$url</a>");
+        } elseif (Env::get('submit') == "Supprimer") {
+            $globals->xdb->execute("UPDATE auth_user_quick
+                                       SET redirecturl = ''
+                                     WHERE user_id = {?}",
+                                   Session::getInt('uid')))
+            $log->log("carva_del", $url);
+            Post::kill('url');
+            $page->trig('Redirection supprimée');
+        }
+
+        $res = $globals->xdb->query('SELECT redirecturl
+                                       FROM auth_user_quick
+                                      WHERE user_id = {?}',
+                                    Session::getInt('uid'));
+        $page->assign('carva', $res->fetchOneCell());
+
+        return PL_OK;
+    }
+
     function handler_prefs_rss(&$page)
     {
         global $globals;
index ec8ff14..9b00a09 100644 (file)
@@ -58,7 +58,7 @@
 </p>
 
 <p>
-  Pour modifier cette redirection remplis le champ suivant et clique sur <strong>Modifier</strong>.
+  Pour modifier cette redirection remplis le champ suivant et clique sur <strong>Valider</strong>.
 {if $carva}
   Si tu veux annuler ta redirection, clique sur <strong>Supprimer</strong>.
 {/if}
       </td>
     </tr>
     <tr>
-{if $carva}
-      <td class="center">
-        <input type="submit" value="Modifier" name="submit" />
-      </td>
-      <td class="center">
-        <input type="submit" value="Supprimer" name="submit" />
-      </td>
-{else}
       <td colspan="2" class="center">
         <input type="submit" value="Valider" name="submit" />
-      </td>
+{if $carva}
+        <input type="submit" value="Supprimer" name="submit" />
 {/if}
+      </td>
     </tr>
   </table>
 </form>