a real bad part of plat/al vanish. (closes FS#236)
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Sat, 15 Jan 2005 13:55:57 +0000 (13:55 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:27:38 +0000 (23:27 +0200)
no more creation of preferences.tpl by rendez-vous in preferences.tpl.d

it solves the skin pb.

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

14 files changed:
hooks/README
hooks/emails.inc.php
hooks/skin.inc.php
hooks/tmp.inc.php
hooks/webredirect.inc.php
htdocs/preferences.php
include/xorg/hook.inc.php
plugins/modifier.glob.php [deleted file]
templates/preferences.tpl
templates/preferences.tpl.d/10.mails.tpl [deleted file]
templates/preferences.tpl.d/20.alias.tpl [deleted file]
templates/preferences.tpl.d/30.mailformat.tpl [deleted file]
templates/preferences.tpl.d/80.webredirect.tpl [deleted file]
templates/preferences.tpl.d/90.skin.tpl [deleted file]

index 764717b..86ad06b 100644 (file)
@@ -8,3 +8,6 @@ menu()
 subscribe($forlife, $uid, $promo, $pass)
     triggered when a user subscription is sucessfull
 
+prefs()
+    function used to add boxes in htdocs/preferences.php
+    must return a dictionnary : url, title, text, weight.
index 464c96f..687cf25 100644 (file)
@@ -67,5 +67,31 @@ function emails_menu()
 }
 
 // }}}
+// {{{ prefs HOOK
 
+function emails_prefs()
+{
+    global $globals;
+    
+    $res[] = Array(
+            'url'    => 'emails.php',
+            'title'  => 'Mes adresses de redirection',
+            'text'   => 'Tu peux configurer tes différentes redirections de mails ici.',
+            'weight' => 10
+    );
+
+    if ($globals->mail->alias_dom) {
+        $res [] = Array(
+                'url'    => 'alias.php',
+                'title'  => 'Mon alias mail @'.$globals->mail->alias_dom,
+                'text'   => "Pour choisir un alias @{$globals->mail->alias_dom}/{$globals->mail->alias_dom2} (en choisir un nouveau annule l'ancien).",
+                'weight' => 20
+        );
+    }
+
+
+    return $res;
+}
+
+// }}}
 ?>
index c3d92ad..d6c7870 100644 (file)
@@ -39,6 +39,25 @@ function skin_config()
 }
 
 // }}}
+// {{{ prefs hook
+
+function skin_prefs()
+{
+    global $globals;
+    if (empty($globals->skin->enable)) {
+        return null;
+    }
+    return Array(
+            Array(
+                'url'    => 'skins.php',
+                'title'  => 'Apparence du site (skins)',
+                'text'   => 'Tu peux changer les couleurs et les images du site.',
+                'weight' => 90
+            )
+        );
+}
+
+// }}}
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
 ?>
index 2dfc311..9ab5d2a 100644 (file)
@@ -47,5 +47,21 @@ function tmp_subscribe($forlife, $uid, $promo, $password)
 }
 
 // }}}
+// {{{ prfs hook
 
+function tmp_prefs()
+{
+    $fmt  = Session::get('mail_fmt', 'html') == 'html' ? 'texte' : 'html';
+    $fmt2 = Session::get('mail_fmt', 'html') == 'html' ? 'texte' : 'HTML';
+    return Array(
+            Array(
+                'url'    => 'preferences.php?mail_fmt='.$fmt,
+                'title'  => 'Recevoir les mails en format '.$fmt2,
+                'text'   => 'Les mails envoyés par le site (lettre mensuelle, carnet, ...) le sont de préférence en format '.Session::get('mail_fmt', 'html'),
+                'weight' => 30
+            )
+        );
+}
+
+// }}}
 ?>
index c49fe49..74b5d02 100644 (file)
@@ -37,6 +37,26 @@ function webredirect_config()
 }
 
 // }}}
+// {{{ prefs hook
+
+function webredirect_prefs()
+{
+    $text = "Tu peux configurer tes redirections WEB http://www.carva.org/" . Session::get('bestalias');
+    if (Session::get('forlife') != Session::get('bestalias')) {
+        $text .= ' et http://www.carva.org/'.Session::get('forlife');
+    }
+
+    return Array(
+            Array(
+                'url'    => 'webredirect.php',
+                'title'  => 'Ma redirection de page WEB',
+                'text'   => $text,
+                'weight' => 80
+            )
+        );
+}
+
+// }}}
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
 ?>
index 1a3eed1..f74f1b6 100644 (file)
@@ -48,7 +48,8 @@ if (Env::has('mail_fmt')) {
     $_SESSION['mail_fmt'] = $fmt;
 }
 
-$page->run($has_cookie);
+$page->assign('prefs', $globals->hook->prefs());
+$page->run();
 
 // vim:set et sw=4 sts=4 sws=4:
 ?>
index 5e0510c..d64dd81 100644 (file)
@@ -84,6 +84,9 @@ class XOrgHook
         }
     }
 
+    // }}}
+    // {{{ function menu
+
     function menu()
     {
         foreach ($this->_mods as $mod) {
@@ -92,6 +95,9 @@ class XOrgHook
         }
     }
 
+    // }}}
+    // {{{ function subscribe
+
     function subscribe($forlife, $uid, $promo, $pass)
     {
         foreach ($this->_mods as $mod) {
@@ -101,6 +107,20 @@ class XOrgHook
     }
 
     // }}}
+    // {{{ function prefs
+
+    function prefs()
+    {
+        $res = Array();
+        foreach ($this->_mods as $mod) {
+            if (!function_exists($mod.'_prefs')) continue;
+            $res = array_merge($res, call_user_func($mod.'_prefs'));
+        }
+        usort($res, create_function('$a, $b', 'return strcmp($a["weight"], $b["weight"]);'));
+        return $res;
+    }
+
+    // }}}
 }
 
 // }}}
diff --git a/plugins/modifier.glob.php b/plugins/modifier.glob.php
deleted file mode 100644 (file)
index c06b985..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-<?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                *
- ***************************************************************************/
-
-// {{{ function smarty_modifier_glob()
-
-/**
- * smarty modifier that perform a glob in the templates directory
- */
-function smarty_modifier_glob($string)
-{
-    global $globals;
-
-    return glob($globals->root.'/templates/'.$string);
-}
-
-// }}}
-
-?>
index 38c8570..f555359 100644 (file)
     Configuration des différents services du site
     </th>
   </tr>
-  {foreach from="preferences.tpl.d/*.tpl"|glob item=inc key=id name=glob}
+  {foreach from=$prefs item=pref key=id name=glob}
   {if $id is even}
   <tr class="{cycle values="impair,pair"}">
-  {/if}
+    {/if}
     <td class="half">
-      {include file=$inc}
+      <h3><a href="{rel}/{$pref.url}">{$pref.title}</a></h3>
+      <div class='explication'>{$pref.text|smarty:nodefaults}</div>
     </td>
     {if $id is even && $smarty.foreach.glob.last}
     <td class="half"></td>
diff --git a/templates/preferences.tpl.d/10.mails.tpl b/templates/preferences.tpl.d/10.mails.tpl
deleted file mode 100644 (file)
index d94448a..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-{***************************************************************************
- *  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                *
- ***************************************************************************}
-
-<h3><a href="{rel}/emails.php">Mes adresses de redirection</a></h3>
-<div class='explication'>
-  Tu peux configurer tes différentes redirections de mails ici.
-</div>
-
-{* vim:set et sw=2 sts=2 sws=2: *}
diff --git a/templates/preferences.tpl.d/20.alias.tpl b/templates/preferences.tpl.d/20.alias.tpl
deleted file mode 100644 (file)
index 3e891a4..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-{***************************************************************************
- *  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                *
- ***************************************************************************}
-
-{if #globals.mail.alias_dom#}
-<h3><a href="{rel}/alias.php">Mon alias mail {#globals.mail.alias_dom#}</a></h3>
-<div class='explication'>
-  Pour choisir un alias {#globals.mail.alias_dom#} et {#globals.mail.alias_dom2#} (en choisir un nouveau annule l'ancien).
-</div>
-{/if}
-
-{* vim:set et sw=2 sts=2 sws=2: *}
diff --git a/templates/preferences.tpl.d/30.mailformat.tpl b/templates/preferences.tpl.d/30.mailformat.tpl
deleted file mode 100644 (file)
index bab457c..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-{***************************************************************************
- *  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                *
- ***************************************************************************}
-
-{if $smarty.session.mail_fmt eq 'texte'}
-<h3><a href="?mail_fmt=html">Recevoir les mails en format HTML</a></h3>
-{else}
-<h3><a href="?mail_fmt=texte">Recevoir les mails en format texte</a></h3>
-{/if}
-<div class='explication'>
-  Les mails envoyés par le site (lettre mensuelle, carnet, ...) le sont de préférence en format {$smarty.session.mail_fmt}.
-</div>
-
-{* vim:set et sw=2 sts=2 sws=2: *}
diff --git a/templates/preferences.tpl.d/80.webredirect.tpl b/templates/preferences.tpl.d/80.webredirect.tpl
deleted file mode 100644 (file)
index 31b499b..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-{***************************************************************************
- *  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                *
- ***************************************************************************}
-
-<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/{$smarty.session.bestalias}
-  et http://www.carva.org/{$smarty.session.forlife}
-  </div>
-
-{* vim:set et sw=2 sts=2 sws=2: *}
diff --git a/templates/preferences.tpl.d/90.skin.tpl b/templates/preferences.tpl.d/90.skin.tpl
deleted file mode 100644 (file)
index ac09516..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-{***************************************************************************
- *  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                *
- ***************************************************************************}
-
-{if #globals.skin.enable#}
-<h3><a href="{rel}/skins.php">Apparence du site (skins)</a></h3>
-<div class="explication">
-  Tu peux changer les couleurs et les images du site.
-</div>
-{/if}
-
-{* vim:set et sw=2 sts=2 sws=2: *}