From d1ebc57a6035c4b43153dd85a34cfce19bc33026 Mon Sep 17 00:00:00 2001 From: x2000habouzit Date: Sat, 22 Jul 2006 22:12:55 +0000 Subject: [PATCH] create new function to generate a simily PHP_SELF var. use it where it's better than the current soup also make pseudo token be %grp which cannot happen in an url for Xnet git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@574 839d8a87-29fc-0310-9880-83ba4fa771e5 --- classes/Platal.php | 14 ++++++++++++++ classes/Xnet.php | 7 ++++--- include/platal.inc.php | 5 +++++ include/xorg.plugin.inc.php | 3 +-- modules/xnetevents.php | 13 ++++++------- modules/xnetgrp.php | 26 +++++++++++++------------- modules/xnetlists.php | 26 +++++++++++++------------- templates/listes/admin.tpl | 4 ++-- templates/listes/archives.tpl | 4 ++-- templates/listes/check.tpl | 2 +- templates/listes/delete.tpl | 2 +- templates/listes/members.tpl | 8 ++++---- templates/listes/moderate.tpl | 8 ++++---- templates/listes/moderate_mail.tpl | 2 +- templates/listes/moderate_sub.tpl | 2 +- templates/listes/options.tpl | 6 +++--- templates/listes/soptions.tpl | 2 +- templates/listes/trombi.tpl | 4 ++-- 18 files changed, 78 insertions(+), 60 deletions(-) diff --git a/classes/Platal.php b/classes/Platal.php index a052193..43cf776 100644 --- a/classes/Platal.php +++ b/classes/Platal.php @@ -46,6 +46,20 @@ class Platal } } + function pl_self($n = null) + { + if (is_null($n)) + return $this->path; + + if ($n >= 0) + return join('/', array_slice($this->argv, 0, $n + 1)); + + if ($n <= -count($this->argv)) + return $this->argv[0]; + + return join('/', array_slice($this->argv, 0, $n)); + } + function find_hook() { $p = $this->path; diff --git a/classes/Xnet.php b/classes/Xnet.php index 9435a9d..3d5dbb1 100644 --- a/classes/Xnet.php +++ b/classes/Xnet.php @@ -32,10 +32,10 @@ class Xnet extends Platal if ($globals->asso()) { if ($p = strpos($this->path, '/')) { $this->ns = substr($this->path, 0, $p).'/'; - $this->path = 'grp'.substr($this->path, $p); + $this->path = '%grp'.substr($this->path, $p); } else { $this->ns = $this->path.'/'; - $this->path = 'grp'; + $this->path = '%grp'; } } } @@ -44,7 +44,8 @@ class Xnet extends Platal { $ans = parent::find_hook(); if ($ans && $this->ns) { - $this->path = $this->ns . substr($this->path, 4); + $this->path = $this->ns . substr($this->path, 5); + $this->argv[0] = $this->ns . substr($this->argv[0], 5); } return $ans; } diff --git a/include/platal.inc.php b/include/platal.inc.php index b4d0491..f3fbe94 100644 --- a/include/platal.inc.php +++ b/include/platal.inc.php @@ -48,6 +48,11 @@ function pl_url($path, $query = null, $fragment = null) return $fragment ? $base.'#'.$fragment : $base; } +function pl_self($n = null) { + global $platal; + return $platal->pl_self($n); +} + function http_redirect($fullurl) { if (count($_SESSION)) { diff --git a/include/xorg.plugin.inc.php b/include/xorg.plugin.inc.php index 3723ee4..445e340 100644 --- a/include/xorg.plugin.inc.php +++ b/include/xorg.plugin.inc.php @@ -101,8 +101,7 @@ class XOrgPlugin } } - global $platal; - return $platal->path . '?' . join('&', $get); + return pl_self() . '?' . join('&', $get); } // }}} diff --git a/modules/xnetevents.php b/modules/xnetevents.php index 6dfb3f5..24f1182 100644 --- a/modules/xnetevents.php +++ b/modules/xnetevents.php @@ -26,11 +26,11 @@ class XnetEventsModule extends PLModule function handlers() { return array( - 'grp/events' => $this->make_hook('events', AUTH_MDP), - 'grp/events/sub' => $this->make_hook('sub', AUTH_MDP), - 'grp/events/csv' => $this->make_hook('csv', AUTH_MDP), - 'grp/events/edit' => $this->make_hook('edit', AUTH_MDP), - 'grp/events/admin' => $this->make_hook('admin', AUTH_MDP), + '%grp/events' => $this->make_hook('events', AUTH_MDP), + '%grp/events/sub' => $this->make_hook('sub', AUTH_MDP), + '%grp/events/csv' => $this->make_hook('csv', AUTH_MDP), + '%grp/events/edit' => $this->make_hook('edit', AUTH_MDP), + '%grp/events/admin' => $this->make_hook('admin', AUTH_MDP), ); } @@ -346,8 +346,7 @@ class XnetEventsModule extends PLModule } if (is_null($evt['eid'])) { - global $platal; - pl_redirect($platal->path.'/'.$eid); + pl_redirect(url_self().'/'.$eid); } } diff --git a/modules/xnetgrp.php b/modules/xnetgrp.php index d4a713f..bb52952 100644 --- a/modules/xnetgrp.php +++ b/modules/xnetgrp.php @@ -65,23 +65,23 @@ class XnetGrpModule extends PLModule function handlers() { return array( - 'grp' => $this->make_hook('index', AUTH_PUBLIC), - 'grp/asso.php' => $this->make_hook('index', AUTH_PUBLIC), - 'grp/logo' => $this->make_hook('logo', AUTH_PUBLIC), - 'grp/edit' => $this->make_hook('edit', AUTH_MDP), - 'grp/mail' => $this->make_hook('mail', AUTH_MDP), - 'grp/annuaire' => $this->make_hook('annuaire', AUTH_MDP), - 'grp/subscribe' => $this->make_hook('subscribe', AUTH_MDP), - 'grp/paiement' => $this->make_hook('paiement', AUTH_MDP), - - 'grp/admin/annuaire' + '%grp' => $this->make_hook('index', AUTH_PUBLIC), + '%grp/asso.php' => $this->make_hook('index', AUTH_PUBLIC), + '%grp/logo' => $this->make_hook('logo', AUTH_PUBLIC), + '%grp/edit' => $this->make_hook('edit', AUTH_MDP), + '%grp/mail' => $this->make_hook('mail', AUTH_MDP), + '%grp/annuaire' => $this->make_hook('annuaire', AUTH_MDP), + '%grp/subscribe' => $this->make_hook('subscribe', AUTH_MDP), + '%grp/paiement' => $this->make_hook('paiement', AUTH_MDP), + + '%grp/admin/annuaire' => $this->make_hook('admin_annuaire', AUTH_MDP), - 'grp/member' + '%grp/member' => $this->make_hook('admin_member', AUTH_MDP), - 'grp/member/new' + '%grp/member/new' => $this->make_hook('admin_member_new', AUTH_MDP), - 'grp/member/del' + '%grp/member/del' => $this->make_hook('admin_member_del', AUTH_MDP), ); } diff --git a/modules/xnetlists.php b/modules/xnetlists.php index 6d2f110..c32b934 100644 --- a/modules/xnetlists.php +++ b/modules/xnetlists.php @@ -28,23 +28,23 @@ class XnetListsModule extends ListsModule function handlers() { return array( - 'grp/lists' => $this->make_hook('lists', AUTH_MDP), - 'grp/lists/create' => $this->make_hook('create', AUTH_MDP), + '%grp/lists' => $this->make_hook('lists', AUTH_MDP), + '%grp/lists/create' => $this->make_hook('create', AUTH_MDP), - 'grp/lists/members' => $this->make_hook('members', AUTH_COOKIE), - 'grp/lists/archives' => $this->make_hook('archives', AUTH_COOKIE), + '%grp/lists/members' => $this->make_hook('members', AUTH_COOKIE), + '%grp/lists/archives' => $this->make_hook('archives', AUTH_COOKIE), - 'grp/lists/moderate' => $this->make_hook('moderate', AUTH_MDP), - 'grp/lists/admin' => $this->make_hook('admin', AUTH_MDP), - 'grp/lists/options' => $this->make_hook('options', AUTH_MDP), - 'grp/lists/delete' => $this->make_hook('delete', AUTH_MDP), + '%grp/lists/moderate' => $this->make_hook('moderate', AUTH_MDP), + '%grp/lists/admin' => $this->make_hook('admin', AUTH_MDP), + '%grp/lists/options' => $this->make_hook('options', AUTH_MDP), + '%grp/lists/delete' => $this->make_hook('delete', AUTH_MDP), - 'grp/lists/soptions' => $this->make_hook('soptions', AUTH_MDP), - 'grp/lists/check' => $this->make_hook('check', AUTH_MDP), - 'grp/lists/sync' => $this->make_hook('sync', AUTH_MDP), + '%grp/lists/soptions' => $this->make_hook('soptions', AUTH_MDP), + '%grp/lists/check' => $this->make_hook('check', AUTH_MDP), + '%grp/lists/sync' => $this->make_hook('sync', AUTH_MDP), - 'grp/alias/admin' => $this->make_hook('aadmin', AUTH_MDP), - 'grp/alias/create' => $this->make_hook('acreate', AUTH_MDP), + '%grp/alias/admin' => $this->make_hook('aadmin', AUTH_MDP), + '%grp/alias/create' => $this->make_hook('acreate', AUTH_MDP), /* hack: lists uses that */ 'profile' => $this->make_hook('profile', AUTH_PUBLIC), diff --git a/templates/listes/admin.tpl b/templates/listes/admin.tpl index 1455cda..ec10594 100644 --- a/templates/listes/admin.tpl +++ b/templates/listes/admin.tpl @@ -52,7 +52,7 @@ qui y {else} {$x.l} {/if} - retirer modérateur + retirer modérateur
{/foreach} @@ -86,7 +86,7 @@ qui y {else} {$x.l} {/if} - retirer membre + retirer membre
{/foreach} diff --git a/templates/listes/archives.tpl b/templates/listes/archives.tpl index bfac627..daaa12a 100644 --- a/templates/listes/archives.tpl +++ b/templates/listes/archives.tpl @@ -42,7 +42,7 @@ {foreach from=$range item=i} {if $m[$i]} - {"0000-$i-01"|date_format:"%B"} + {"0000-$i-01"|date_format:"%B"} {else}   {/if} @@ -68,7 +68,7 @@ {foreach from=$range item=i} {if $m[$i]} - {"0000-$i-01"|date_format:"%B"} + {"0000-$i-01"|date_format:"%B"} {else}   {/if} diff --git a/templates/listes/check.tpl b/templates/listes/check.tpl index 9a1a0bb..8e01569 100644 --- a/templates/listes/check.tpl +++ b/templates/listes/check.tpl @@ -35,7 +35,7 @@ {/foreach} -
+

diff --git a/templates/listes/delete.tpl b/templates/listes/delete.tpl index 1e4ffc0..17fc13c 100644 --- a/templates/listes/delete.tpl +++ b/templates/listes/delete.tpl @@ -40,7 +40,7 @@ Tu n'es pas administrateur de la liste, mais du site. Détruire la liste {$details.addr} ? - + @@ -105,9 +105,9 @@

membres de la liste {if $smarty.get.alpha} - (trier par promo) + (trier par promo) {else} - (trier par nom) + (trier par nom) {/if}

diff --git a/templates/listes/moderate.tpl b/templates/listes/moderate.tpl index 2e3626d..bef65e1 100644 --- a/templates/listes/moderate.tpl +++ b/templates/listes/moderate.tpl @@ -42,8 +42,8 @@ {/foreach} @@ -89,8 +89,8 @@ + voir
+ accepter détruire {/foreach}
diff --git a/templates/listes/members.tpl b/templates/listes/members.tpl index 5975f66..c88b2ae 100644 --- a/templates/listes/members.tpl +++ b/templates/listes/members.tpl @@ -58,13 +58,13 @@ {if $details.sub>1} Tu es inscrit sur la liste.
Te désinscrire : - [me désinsiscrire] + [me désinsiscrire] {elseif $details.sub eq 1} Ta demande d'inscription est en cours de validation. {else} Tu n'es pas inscrit.
Demander ton inscription : - [demander mon inscription] + [demander mon inscription] {/if}
{$s.addr} - ajouter - refuser + ajouter + refuser
{$m.size}o {$m.stamp|date_format:"%X
%x"}
- voir
- accepter détruire
diff --git a/templates/listes/moderate_mail.tpl b/templates/listes/moderate_mail.tpl index ba34562..c72e312 100644 --- a/templates/listes/moderate_mail.tpl +++ b/templates/listes/moderate_mail.tpl @@ -60,7 +60,7 @@
{/if} - + diff --git a/templates/listes/moderate_sub.tpl b/templates/listes/moderate_sub.tpl index 36c4a39..1c0fa8e 100644 --- a/templates/listes/moderate_sub.tpl +++ b/templates/listes/moderate_sub.tpl @@ -22,7 +22,7 @@

Refuser l'inscription d'un utilisateur

- +
Modérer le mail
diff --git a/templates/listes/options.tpl b/templates/listes/options.tpl index 8d281e5..7c4a4a5 100644 --- a/templates/listes/options.tpl +++ b/templates/listes/options.tpl @@ -33,7 +33,7 @@ Tu n'es pas administrateur de la liste, mais du site. Changer les options de la liste {$details.addr} - +
refuser l'inscription de :
@@ -159,14 +159,14 @@ les X inscrits redirection en mode 'inactif'. le logiciel de mailing list saura se débrouiller tout seul.

- +
Options de la liste {$details.addr}
Addresses non modérées
{if $options.accept_these_nonmembers|@count} {foreach from=$options.accept_these_nonmembers item=addr} - {$addr} + {$addr} retirer de la whitelist
{/foreach} diff --git a/templates/listes/soptions.tpl b/templates/listes/soptions.tpl index 00fcdf8..d358d69 100644 --- a/templates/listes/soptions.tpl +++ b/templates/listes/soptions.tpl @@ -27,7 +27,7 @@ Changer les options de la liste {$details.addr} - + diff --git a/templates/listes/trombi.tpl b/templates/listes/trombi.tpl index dba1460..08adcab 100644 --- a/templates/listes/trombi.tpl +++ b/templates/listes/trombi.tpl @@ -54,13 +54,13 @@ {if $details.sub>1} Tu es inscrit sur la liste.
Te désinscrire : - [me désinsiscrire] + [me désinsiscrire] {elseif $details.sub eq 1} Ta demande d'inscription est en cours de validation. {else} Tu n'es pas inscrit.
Demander ton inscription : - [demander mon inscription] + [demander mon inscription] {/if} -- 2.1.4
Options de la liste {$details.addr}