make webredirect (aka carva) be a module
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Fri, 3 Dec 2004 11:22:03 +0000 (11:22 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:26:25 +0000 (23:26 +0200)
* WebRedirect :
    - now standalone !

git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-24

15 files changed:
bin/devel/modules_status
htdocs/webredirect.php [moved from htdocs/carva_redirect.php with 90% similarity]
include/conf.d/webredirect.globals.inc.php [new file with mode: 0644]
include/xorg.inc.php
install.d/STATE
install.d/web-redirect/files [deleted file]
install.d/webredirect/README [new file with mode: 0644]
install.d/webredirect/files [new file with mode: 0644]
install.d/webredirect/install.sql [new file with mode: 0644]
install.d/webredirect/uninstall.sql [new file with mode: 0644]
scripts/webredirect.php [moved from bin/carva/redirect.php with 92% similarity]
scripts/webredirect_error.php [moved from bin/carva/error.php with 100% similarity]
templates/preferences.tpl.d/80.webredirect.tpl [moved from templates/preferences.tpl.d/30.redirect.tpl with 95% similarity]
templates/webredirect.tpl [moved from templates/carva_redirect.tpl with 85% similarity]
upgrade/0.9.3/30_auth_user_md5.sql

index 118a173..185e0b8 100755 (executable)
@@ -2,7 +2,7 @@
 
 chdir ${1:-.}
 
-dirs=(bin configs htdocs hooks include plugins templates)
+dirs=(bin configs htdocs hooks include plugins scripts templates)
 opts=(-type f -not -path '*CVS*' -not -name '.cvsignore' -not -path '*.arch*')
 
 diff -u <(cat install.d/**/files|sort) <(find $dirs $opts|sort) \
similarity index 90%
rename from htdocs/carva_redirect.php
rename to htdocs/webredirect.php
index fe52340..3698f41 100644 (file)
  ***************************************************************************/
 
 require_once("xorg.inc.php");
-new_skinned_page('carva_redirect.tpl', AUTH_MDP);
+new_skinned_page('webredirect.tpl', AUTH_MDP);
 
 if (isset($_REQUEST['submit']) and ($_REQUEST['submit'] == "Valider" or $_REQUEST['submit'] == "Modifier") and isset($_REQUEST['url'])) {
     // on change la redirection (attention à http://)
-    $globals->db->query("update auth_user_md5 set redirecturl = '{$_REQUEST['url']}'"
+    $globals->db->query("update auth_user_quick set redirecturl = '{$_REQUEST['url']}'"
               ." where user_id = '{$_SESSION['uid']}'");
     if (mysql_errno($conn) == 0) {
         $_SESSION['log']->log("carva_add","http://".$_REQUEST['url']);
@@ -35,7 +35,7 @@ if (isset($_REQUEST['submit']) and ($_REQUEST['submit'] == "Valider" or $_REQUES
     }
 } elseif (isset($_REQUEST['submit']) and $_REQUEST['submit'] == "Supprimer") {
     // on supprime la redirection
-    $globals->db->query("update auth_user_md5 set redirecturl = '' where user_id = {$_SESSION['uid']}");
+    $globals->db->query("update auth_user_quick set redirecturl = '' where user_id = {$_SESSION['uid']}");
     if (mysql_errno($conn) == 0) {
         $_SESSION['log']->log("carva_del",$_REQUEST['url']);
         $_POST['url'] = '';
@@ -46,7 +46,7 @@ if (isset($_REQUEST['submit']) and ($_REQUEST['submit'] == "Valider" or $_REQUES
 }
 
 
-$result = $globals->db->query("select redirecturl from auth_user_md5 where user_id={$_SESSION['uid']}");
+$result = $globals->db->query("select redirecturl from auth_user_quick where user_id={$_SESSION['uid']}");
 list($carva) = mysql_fetch_row($result);
 mysql_free_result($result);
 $page->assign('carva', $carva);
diff --git a/include/conf.d/webredirect.globals.inc.php b/include/conf.d/webredirect.globals.inc.php
new file mode 100644 (file)
index 0000000..ec4a9b2
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2004 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                *
+ ***************************************************************************/
+
+// {{{ class WebRedirConfig
+
+class WebRedirConfig
+{
+    var $domain       = '';
+}
+
+// }}}
+
+$this->webredirect = new WebRedirConfig;
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
+?>
index c809fb6..eb3e7b2 100644 (file)
@@ -54,7 +54,7 @@ $globals = new XorgGlobals;
 
 function _new_page($type, $tpl_name, $tpl_head, $min_auth, $admin=false)
 {
-    global $page;
+    global $page,$globals;
     require_once("xorg.page.inc.php");
     if (!empty($admin)) {
         $page = new XorgAdmin($tpl_name, $type);
@@ -88,7 +88,7 @@ function new_skinned_page($tpl_name, $min_auth, $tpl_head="")
 
 function new_simple_page($tpl_name, $min_auth, $tpl_head="")
 {
-    global $page;
+    global $page,$globals;
     _new_page(SKINNED, $tpl_name, $tpl_head, $min_auth);
     $page->assign('simple', true);
 }
index 906d247..e87c17e 100644 (file)
@@ -5,6 +5,7 @@ skins.
 
     only one minor bug
 
+webredirect
 
 STILL NEED SOME WORK
 --------------------
@@ -36,5 +37,4 @@ profile
 register
 search
 stats
-web-redirect
 xorg-stuff
diff --git a/install.d/web-redirect/files b/install.d/web-redirect/files
deleted file mode 100644 (file)
index 9df2303..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-htdocs/carva_redirect.php
-bin/carva/error.php
-bin/carva/redirect.php
-templates/carva_redirect.tpl
-templates/preferences.tpl.d/30.redirect.tpl
diff --git a/install.d/webredirect/README b/install.d/webredirect/README
new file mode 100644 (file)
index 0000000..8f0520f
--- /dev/null
@@ -0,0 +1,26 @@
+
+  Notes for the webredirect module for plat/al
+
+
+CONFIG OPTIONS
+--------------
+
+  All settings of the module are shown here with their default and meaning
+
+  [WebRedirect]
+
+  domain = ''             ; the domain used for web redirections.
+
+
+BUGS
+----
+
+  http://trackers.polytechnique.org/index.php?cat=13
+
+
+DEPENDS
+-------
+
+  platal
+
+
diff --git a/install.d/webredirect/files b/install.d/webredirect/files
new file mode 100644 (file)
index 0000000..e33d654
--- /dev/null
@@ -0,0 +1,6 @@
+htdocs/webredirect.php
+include/conf.d/webredirect.globals.inc.php
+scripts/webredirect_error.php
+scripts/webredirect.php
+templates/webredirect.tpl
+templates/preferences.tpl.d/80.webredirect.tpl
diff --git a/install.d/webredirect/install.sql b/install.d/webredirect/install.sql
new file mode 100644 (file)
index 0000000..1830e20
--- /dev/null
@@ -0,0 +1,3 @@
+
+alter table auth_user_quick add column redirecturl varchar(255) not null;
+
diff --git a/install.d/webredirect/uninstall.sql b/install.d/webredirect/uninstall.sql
new file mode 100644 (file)
index 0000000..e96060c
--- /dev/null
@@ -0,0 +1,3 @@
+
+alter table auth_user_quick drop column webredirect;
+
similarity index 92%
rename from bin/carva/redirect.php
rename to scripts/webredirect.php
index ea02e06..72cd26f 100644 (file)
@@ -27,7 +27,7 @@ require("../../include/xorg.inc.php");
 // REQUEST_URI = /prenom.nom(/path/fichier.hmtl)?
 list($username, $path) = preg_split('/\//', $_SERVER["REQUEST_URI"], 2, PREG_SPLIT_NO_EMPTY);
 
-$result = mysql_query("SELECT redirecturl FROM auth_user_md5 AS a INNER JOIN aliases AS al ON (al.id = a.user_id AND (al.type='a_vie' OR al.type='alias' OR al.type='epouse')) where al.alias= '$username'");
+$result = mysql_query("SELECT redirecturl FROM auth_user_quick AS a INNER JOIN aliases AS al ON (al.id = a.user_id AND (al.type='a_vie' OR al.type='alias' OR al.type='epouse')) where al.alias= '$username'");
 if ($result and list($url) = mysql_fetch_row($result) and $url != '') {
        // on envoie un redirect (PHP met automatiquement le code de retour 302
        if (!empty($path)) {
similarity index 95%
rename from templates/preferences.tpl.d/30.redirect.tpl
rename to templates/preferences.tpl.d/80.webredirect.tpl
index 4479135..899c379 100644 (file)
@@ -18,7 +18,7 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************}
 
-<h3><a href="{rel}/carva_redirect.php">Ma redirection de page WEB</a></h3>
+<h3><a href="{rel}/webredirect.php">Ma redirection de page WEB</a></h3>
 <div class='explication'>
   Tu peux configurer tes redirections WEB
   http://www.carva.org/{dyn s=$smarty.session.bestalias}
similarity index 85%
rename from templates/carva_redirect.tpl
rename to templates/webredirect.tpl
index 6c32ab3..3dee9cf 100644 (file)
@@ -31,8 +31,8 @@
   Dans la lignée du service de redirection d'emails de <strong>Polytechnique.org</strong>,
   il est possible de faire pointer
   {dynamic}
-  les adresses <strong>http://www.carva.org/{$smarty.session.bestalias}</strong>
-  et <strong>http://www.carva.org/{$smarty.session.forlife}</strong>
+  les adresses <strong>http://{#globals.webredirect.domain#}/{$smarty.session.bestalias}</strong>
+  et <strong>http://{#globals.webredirect.domain#}/{$smarty.session.forlife}</strong>
   {/dynamic}
   vers la page WEB de ton choix. Pour de plus amples détails, consulte
   <a href="{"docs/doc_carva.php"|url}">cette page</a>
 <p>
 {dynamic}
 {if $carva}
-  Actuellement, les adresses <a href="http://www.carva.org/{$smarty.session.bestalias}">http://www.carva.org/{$smarty.session.bestalias}</a> et <a href="http://www.carva.org/{$smarty.session.forlife}">http://www.carva.org/{$smarty.session.forlife}</a>
-  sont redirigées sur <a href="http://{$carva}">http://{$carva}</a>
+  Actuellement, les adresses
+  <a href="http://{#globals.webredirect.domain#}/{$smarty.session.bestalias}">
+    http://{#globals.webredirect.domain#}/{$smarty.session.bestalias}
+  </a> et <a href="http://{#globals.webredirect.domain#}/{$smarty.session.forlife}">
+    http://{#globals.webredirect.domain#}/{$smarty.session.forlife}
+  </a> sont redirigées sur <a href="http://{$carva}">http://{$carva}</a>
 {else}
   La redirection n'est pas utilisée ...
 {/if}
index 3de96e9..5b67dc7 100644 (file)
@@ -1,8 +1,15 @@
+--
+-- PERMS
+--
 alter table auth_user_md5 change column perms perms enum('user','admin','non-inscrit','pending','disabled');
 update auth_user_md5 set perms='pending' where perms='non-inscrit';
 alter table auth_user_md5 change column perms perms enum('user','admin','pending','disabled');
 alter table auth_user_md5 change column comment comment varchar(64) not null;
 
+--
+-- be naissance live as a date
+--
+
 alter table auth_user_md5 add column foo int;
 update auth_user_md5 set foo=naissance ;
 alter table auth_user_md5 change column naissance naissance date not null;
@@ -14,3 +21,15 @@ update en_cours set foo=naissance ;
 alter table en_cours change column naissance naissance date not null;
 update en_cours set naissance = concat(foo % 10000, '-', (foo / 10000) % 100, '-', foo / 1000000);
 alter table en_cours drop column foo;
+
+--
+-- webredirect
+--
+
+alter table auth_user_quick add column redirecturl varchar(255) not null;
+replace into auth_user_quick (user_id,banana_last,skin,watch_flags,watch_last,redirecturl)
+      select q.user_id,q.banana_last,q.skin,q.watch_flags,q.watch_last,u.redirecturl
+        from auth_user_md5   as u
+  inner join auth_user_quick as q USING(user_id)
+       where u.redirecturl!='';
+alter table auth_user_md5 drop column redirecturl;