listes.php + alias-admin.php
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Thu, 21 Apr 2005 13:38:33 +0000 (13:38 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:28:41 +0000 (23:28 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-578

13 files changed:
htdocs.net/css/xnet.css
htdocs.net/groupe/alias-admin.php [new file with mode: 0644]
htdocs.net/groupe/asso.php
htdocs.net/groupe/listes-admin.php
htdocs.net/groupe/listes-archives.php
htdocs.net/groupe/listes-delete.php
htdocs.net/groupe/listes-members.php
htdocs.net/groupe/listes-moderate.php
htdocs.net/groupe/listes-options.php
htdocs.net/groupe/listes.php [new file with mode: 0644]
htdocs/listes/moderate.php
templates/xnet/groupe/alias-admin.tpl [new file with mode: 0644]
templates/xnet/groupe/listes.tpl [new file with mode: 0644]

index 338635a..59a4fa2 100644 (file)
@@ -42,7 +42,7 @@ img   { vertical-align: middle; }
 td    { vertical-align: top; }
 
 h1    { font-size: 150%; }
-h2    { font-size: 135%; }
+h2    { font-size: 130%; }
 
 /***************************************************************************
  * DEBUG
@@ -132,7 +132,7 @@ td#menu {
 
 .erreur { color: red; }
 .error  { color: red; }
-
+.center { text-align: center; }
 
 .descr {
     text-align: justify;
diff --git a/htdocs.net/groupe/alias-admin.php b/htdocs.net/groupe/alias-admin.php
new file mode 100644 (file)
index 0000000..71f1950
--- /dev/null
@@ -0,0 +1,67 @@
+<?php
+require 'xnet.inc.php';
+
+new_groupadmin_page('xnet/groupe/alias-admin.tpl');
+$page->useMenu();
+$page->setType($globals->asso('cat'));
+
+if (!Get::has('liste')) {
+    header("Location: listes.php");
+}
+
+$lfull = strtolower(Get::get('liste'));
+
+if (Env::has('add_member')) {
+    $add = Env::get('add_member');
+    if(strstr($add, '@')) {
+       list($mbox,$dom) = split('@', strtolower($add));
+    } else {
+       $mbox = $add;
+       $dom = 'm4x.org';
+    }
+    if($dom == 'polytechnique.org' || $dom == 'm4x.org') {
+       $res = $globals->xdb->query(
+                "SELECT  a.alias, b.alias
+                   FROM  x4dat.aliases AS a
+              LEFT JOIN  x4dat.aliases AS b ON (a.id=b.id AND b.type = 'a_vie')
+                  WHERE  a.alias={?} AND a.type!='homonyme'", $mbox);
+       if (list($alias, $blias) = $res->fetchOneRow()) {
+           $alias = empty($blias) ? $alias : $blias;
+            $globals->xdb->query(
+                "INSERT INTO  x4dat.virtual_redirect (vid,redirect)
+                      SELECT  vid, {?}
+                        FROM  x4dat.virtual
+                       WHERE  alias={?}", "$alias@m4x.org", $lfull);
+           $page->trig("$alias@m4x.org ajouté");
+       } else {
+            $page->trig("$mbox@polytechnique.org n'existe pas.");
+       }
+    } else {
+        $globals->xdb->query(
+                "INSERT INTO  x4dat.virtual_redirect (vid,redirect)
+                      SELECT  vid,{?}
+                        FROM  x4dat.virtual
+                       WHERE  alias={?}", "$mbox@$dom", $lfull);
+        $page->trig("$mbox@$dom ajouté");
+    }
+}
+
+if (Env::has('del_member')) {
+    $globals->xdb->query(
+            "DELETE FROM  x4dat.virtual_redirect
+                   USING  x4dat.virtual_redirect
+              INNER JOIN  x4dat.virtual USING(vid)
+                   WHERE  redirect={?} AND alias={?}", Env::get('del_member'), $lfull);
+    header("Location: ?liste=$lfull");
+}
+
+$res = $globals->xdb->iterator(
+        "SELECT  redirect
+           FROM  x4dat.virtual_redirect AS vr
+     INNER JOIN  x4dat.virtual          AS v  USING(vid)
+          WHERE  v.alias={?}
+       ORDER BY  redirect", $lfull);
+$page->assign('mem', $res);
+
+$page->run();
+?>
index b809768..b86c465 100644 (file)
@@ -2,7 +2,7 @@
 
 require 'xnet.inc.php';
 
-new_page('xnet/groupe/asso.tpl', AUTH);
+new_page('xnet/groupe/asso.tpl', AUTH_PUBLIC);
 if (!$globals->asso('id')) {
     header("Location: ../");
 }
index 827f226..30e719f 100644 (file)
@@ -23,7 +23,7 @@ require_once 'xnet.inc.php';
 if (!Env::has('liste')) header('Location: listes.php');
 $liste = strtolower(Env::get('liste'));
 
-new_page('listes/admin.tpl', AUTH_MDP);
+new_group_page('listes/admin.tpl');
 $page->setType($globals->asso('cat'));
 $page->useMenu();
 
index db288f9..15b1c70 100644 (file)
@@ -23,7 +23,7 @@ require_once 'xnet.inc.php';
 if (!Env::has('liste')) header('Location: listes.php');
 $liste = strtolower(Env::get('liste'));
 
-new_page('listes/archives.tpl');
+new_group_page('listes/archives.tpl');
 $page->setType($globals->asso('cat'));
 $page->useMenu();
 
index 309ee07..e6dc9aa 100644 (file)
@@ -23,7 +23,7 @@ require_once 'xnet.inc.php';
 if (!Env::has('liste')) header('Location: listes.php');
 $liste = strtolower(Env::get('liste'));
 
-new_page('listes/delete.tpl', AUTH_MDP);
+new_group_page('listes/delete.tpl');
 $page->setType($globals->asso('cat'));
 $page->useMenu();
 
index c6dc60c..117aa84 100644 (file)
@@ -23,7 +23,7 @@ require_once 'xnet.inc.php';
 if (!Env::has('liste')) header('Location: listes.php');
 $liste = strtolower(Env::get('liste'));
 
-new_page('listes/members.tpl', AUTH_MDP);
+new_group_page('listes/members.tpl');
 $page->setType($globals->asso('cat'));
 $page->useMenu();
 
index 8a1f20f..5a2e906 100644 (file)
@@ -27,7 +27,7 @@ if (preg_match("!(?:[a-z0-9]+\\.)?{".$globals->asso('mail_domain')."}_(.*)!", $l
     header("Location: {$_SERVER['PHP_SELF']}?liste={$matches[1]}");
 }
 
-new_page('listes/moderate.tpl', AUTH_MDP);
+new_group_page('listes/moderate.tpl');
 $page->setType($globals->asso('cat'));
 $page->useMenu();
 
index c5cd1ee..b16c004 100644 (file)
@@ -23,7 +23,7 @@ require_once 'xnet.inc.php';
 if (!Env::has('liste')) header('Location: listes.php');
 $liste = strtolower(Env::get('liste'));
 
-new_page('listes/options.tpl', AUTH_MDP);
+new_group_page('listes/options.tpl');
 $page->setType($globals->asso('cat'));
 $page->useMenu();
 
diff --git a/htdocs.net/groupe/listes.php b/htdocs.net/groupe/listes.php
new file mode 100644 (file)
index 0000000..20715c2
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+
+require_once 'xnet.inc.php';
+
+new_group_page('xnet/groupe/listes.tpl');
+$page->setType($globals->asso('cat'));
+$page->useMenu();
+$page->assign('asso', $globals->asso());
+
+require_once('lists.inc.php');
+$client =& lists_xmlrpc(Session::getInt('uid'), Session::get('password'), $globals->asso('mail_domain'));
+
+
+if(Get::has('del')) {
+    $client->unsubscribe(Get::get('del'));
+    header('Location: listes.php');
+}
+if(Get::has('add')) {
+    $client->subscribe(Get::get('add'));
+    header('Location: listes.php');
+}
+if(Post::has('promo_add')) {
+    $promo = Post::getInt('promo_add');
+    if ($promo>=1900 and $promo<2100) {
+        $client->subscribe("promo$promo");
+    } else {
+        $page->trig("promo incorrecte, il faut une promo sur 4 chiffres.");
+    }
+}
+
+
+if (Post::has('del_alias')) {
+    $globals->xdb->query(
+            'DELETE FROM  x4dat.virtual_redirect, x4dat.virtual
+                   USING  x4dat.virtual AS v
+             INNER JOIN  x4dat.virtual_redirect USING(vid)
+                  WHERE  v.alias={?}', Post::get('del_alias'));
+    $page->trig(Post::get('del_alias')." supprimé !");
+}
+
+$listes = $client->get_lists();
+$page->assign('listes',$listes);
+
+$alias  = $globals->xdb->iterator(
+        'SELECT  alias,type
+           FROM  x4dat.virtual
+          WHERE  alias
+           LIKE  {?} AND type="user"
+       ORDER BY  alias', '%@'.$globals->asso('mail_domain'));
+$page->assign('alias', $alias);
+
+$page->assign('may_update', may_update());
+
+$page->run();
+?>
index 5b50977..a2609b9 100644 (file)
@@ -38,7 +38,7 @@ $page->register_modifier('qpd','quoted_printable_decode');
 
 if(Env::has('sadd')) {
     $client->handle_request($liste,Env::get('sadd'),4,''); /* 4 = SUBSCRIBE */
-    header("Location: moderate.php?liste=$liste");
+    header("Location: {$_SERVER['PHP_SELF']}?liste=$liste");
 }
 
 if(Post::has('sdel')) {
diff --git a/templates/xnet/groupe/alias-admin.tpl b/templates/xnet/groupe/alias-admin.tpl
new file mode 100644 (file)
index 0000000..4af3af8
--- /dev/null
@@ -0,0 +1,54 @@
+{***************************************************************************
+ *  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                *
+ ***************************************************************************}
+<p>[<a href='listes.php'>retour à la page des listes</a>]</p>
+
+<h1>Membres de {$smarty.request.liste}</h1>
+      
+<table style="width:80%; margin: 0px 10%;">
+  <tr>
+    <th>Membres</th>
+    <td>
+      {if $mem->total()}
+      {iterate from=$mem item=m}
+      {$m.redirect}
+      <a href='?liste={$smarty.request.liste}&amp;del_member={$m.redirect}'>
+        <img src='{rel}/images/del.png' alt='retirer membre' title='retirer membre' />
+      </a>
+      <br />
+      {/iterate}
+      {else}
+      <em>aucun membres ...</em>
+      {/if}
+    </td>
+  </tr>
+  <tr>
+    <td><strong>Ajouter</strong></td>
+    <td>
+      <form method="post" action="{$smarty.server.REQUEST_URI}">
+        <input type='text' name='add_member' />
+        &nbsp;
+        <input type='submit' value='ajouter' />
+      </form>
+    </td>
+  </tr>
+</table>
+
+{* vim:set et sw=2 sts=2 sws=2: *}
diff --git a/templates/xnet/groupe/listes.tpl b/templates/xnet/groupe/listes.tpl
new file mode 100644 (file)
index 0000000..3f96996
--- /dev/null
@@ -0,0 +1,112 @@
+{***************************************************************************
+ *  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.get.del_alias}
+
+<p class="error">Est tu sur de supprimer l'alias {$smarty.get.del_alias} ?</p>
+<form action='<?php echo $_SERVER['PHP_SELF']; ?>' method="post">
+  <div class="center">
+    <input type='submit' value="Oui, je suis sur" />
+    <input type='hidden' name='del_alias' value="{$smarty.get.del_alias}" />
+  </div>
+</form>
+<p>[<a href='listes.php'>retour à la page des listes</a>]</p>
+
+{else}
+
+<h1>{$asso.nom} : Listes de diffusion</h1>
+
+<h2>Listes de diffusion du groupe {$asso.nom} :</h2>
+
+<p class="descr">
+Une liste dont <strong>la diffusion</strong> est modérée est une liste dont les mails sont validés
+par les administrateurs avant d'être transmis aux membres de la liste.  Une liste dont
+<strong>l'inscription</strong> est modérée est une liste pour laquelle l'abonnement est soumis à
+l'accord préalable des responsables du groupe.
+</p>
+<p class="descr">
+La dernière colonne du tableau t'indique si tu es inscrit{if $smarty.session.femme}e{/if} ou non à
+la liste. Dans le premier cas, une croix rouge te permet de te désabonner. Dans le second cas, une
+croix verte te permet de t'inscrire, après accord des responsables si l'inscription est modérée.
+</p>
+
+<table cellpadding="0" cellspacing="0" style="width: 100%;">
+  <tr>
+    <th>Liste</th>
+    <th>Description</th>
+    <th>Diffusion</th>
+    <th>Inscription</th>
+    <th>Nb</th>
+    <th>&nbsp;</th>
+  </tr>
+  {foreach from=$listes item=l}
+  <tr>
+    <td>
+      <a href="mailto:{$l.list}@{$asso.mail_domain}"><img src="{rel}/images/mail.png" alt='[mail]' /></a>
+      <a href='listes-members.php?liste={$l.list}'>{$l.list}{if $l.priv}&nbsp;<sup>&Dagger;</sup>{/if}{if $l.own}&nbsp;<sup>*</sup>{/if}</a>
+    </td>
+    <td>{$l.desc}</td>
+    <td class='center'>
+      {if $l.diff eq 2}modérée{elseif $l.diff eq 1}restreinte{else}libre{/if}
+    </td>
+    <td class='center'>{if $l.ins}modérée{else}libre{/if}</td>
+    <td align='right'>{$l.nbsub}</td>
+    <td align='right'>
+      {if $l.sub eq 2}
+      <a href="?del={$l.list}"><img src="{rel}/images/del.png" alt="[désinscrire]" title="me désinscrire" /></a>
+      {elseif $l.sub eq 1}
+      <img src="{rel}/images/flag.png" alt="[en attente]" title="en attente de modération" />
+      {else}
+      <a href="?add={$l.list}"><img src="{rel}/images/ajouter.gif" alt="[m'inscrire]" title="m'inscrire" /></a>
+      {/if}
+    </td>
+  </tr>
+  {foreachelse}
+  <tr><td colspan='6'>Pas de listes pour ce groupe</td></tr>
+  {/foreach}
+  {/if}
+</table>
+
+<p class="descr">
+*: tu es {if $smarty.session.femme}modératrice{else}moderateur{/if} sur cette liste<br />
+<sup>&Dagger;</sup>: cette liste est invisible aux non-membres du groupe. S'en désabonner
+t'empêcherait de t'y réabonner par la suite sans l'aide d'un administrateur.
+</p>
+        
+<h2>Voici les alias existants pour le groupe {$asso.nom} :</h2>
+
+{if $alias->total()}
+<p>
+{iterate from=$alias item=a}
+{if $may_update}
+<a href='mailto:{$a.alias}'><img src='{rel}/images/mail.png' alt='[mail]' /></a>
+<a href="alias-admin.php?liste={$a.alias}">{$a.alias}</a>
+<a href="?del_alias={$a.alias}"><img src='{rel}/images/del.png' alt='[supprimer]' /></a><br />
+{else}
+<a href='mailto:{$a.alias}'><img src='{rel}/images/mail.png' alt='[mail]' /> {$a.alias}</a><br />
+{/if}
+{/iterate}
+</p>
+{else}
+<p>Aucun alias pour ce groupe</p>
+{/if}
+
+{* vim:set et sw=2 sts=2 sws=2: *}