From 1122d86042181dde30c7b19b72800088ee66ddc8 Mon Sep 17 00:00:00 2001 From: x2000habouzit Date: Tue, 21 Sep 2004 15:40:35 +0000 Subject: [PATCH] tons of bugfixes + subscribe moderation now works !!! --- htdocs/listes/index.php | 6 ++-- htdocs/listes/liste.php | 16 +++------- htdocs/listes/moderate.php | 33 +++++++++++++++++--- htdocs/listes/trombi.php | 4 +-- scripts/mailman/mailman-rpc.py | 17 ++++++----- templates/listes/liste.tpl | 15 +++++---- templates/listes/listes.inc.tpl | 62 ++++++++++++++++++-------------------- templates/listes/moderate.tpl | 21 +++++++++++-- templates/listes/moderate_mail.tpl | 4 +-- templates/listes/moderate_sub.tpl | 61 +++++++++++++++++++++++++++++++++++++ 10 files changed, 170 insertions(+), 69 deletions(-) create mode 100644 templates/listes/moderate_sub.tpl diff --git a/htdocs/listes/index.php b/htdocs/listes/index.php index b8bb818..8c00c89 100644 --- a/htdocs/listes/index.php +++ b/htdocs/listes/index.php @@ -18,17 +18,19 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: index.php,v 1.1 2004-09-10 11:52:36 x2000habouzit Exp $ + $Id: index.php,v 1.2 2004-09-21 15:40:35 x2000habouzit Exp $ ***************************************************************************/ require("auto.prepend.inc.php"); -new_skinned_page('listes/index.tpl', AUTH_COOKIE); +new_skinned_page('listes/index.tpl', AUTH_MDP); include('xml-rpc-client.inc.php'); $res = $globals->db->query("SELECT password FROM auth_user_md5 WHERE user_id={$_SESSION['uid']}"); list($pass) = mysql_fetch_row($res); mysql_free_result($res); $client = new xmlrpc_client("http://{$_SESSION['uid']}:$pass@localhost:4949"); +if(isset($_GET['del'])) { $client->unsubscribe($_GET['del']); header('Location: index.php'); } +if(isset($_GET['add'])) { $client->subscribe($_GET['add']); header('Location: index.php'); } $listes = $client->get_lists(); $page->assign_by_ref('listes',$listes); diff --git a/htdocs/listes/liste.php b/htdocs/listes/liste.php index f5c8e5e..e334494 100644 --- a/htdocs/listes/liste.php +++ b/htdocs/listes/liste.php @@ -18,11 +18,11 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: liste.php,v 1.5 2004-09-20 20:04:37 x2000habouzit Exp $ + $Id: liste.php,v 1.6 2004-09-21 15:40:35 x2000habouzit Exp $ ***************************************************************************/ if(empty($_REQUEST['liste'])) header('Location: index.php'); -$liste = $_REQUEST['liste']; +$liste = strtolower($_REQUEST['liste']); require("auto.prepend.inc.php"); new_skinned_page('listes/liste.tpl', AUTH_MDP, true); @@ -37,15 +37,7 @@ $client = new xmlrpc_client("http://{$_SESSION['uid']}:$pass@localhost:4949"); if(isset($_REQUEST['welc'])) $client->set_welcome($liste, $_REQUEST['welc']); if(isset($_REQUEST['add_member']) && isset($_REQUEST['member'])) { - if(list($added) = $client->mass_subscribe($liste, Array($_REQUEST['member']))) { - $members = $client->get_members($liste); - include_once("diogenes.mailer.inc.php"); - $mailer = new DiogenesMailer("\"Mailing list $liste\" <$liste-owner@polytechnique.org>", - "\"{$added[0]}\" <{$added[1]}>", - "Bienvenue sur la liste de diffusion $liste@polytechnique.org"); - $mailer->setBody($members[0]['welc']); - $mailer->send(); - } + $client->mass_subscribe($liste, Array($_REQUEST['member'])); } if(isset($_REQUEST['del_member']) && isset($_REQUEST['member'])) { @@ -74,7 +66,7 @@ if(isset($_REQUEST['del_owner']) && isset($_REQUEST['owner'])) { mysql_free_result($res); } -if(empty($members)) $members = $client->get_members($liste); +$members = $client->get_members($liste); if(is_array($members)) { $membres = Array(); foreach($members[1] as $member) { diff --git a/htdocs/listes/moderate.php b/htdocs/listes/moderate.php index a13f011..d29cc16 100644 --- a/htdocs/listes/moderate.php +++ b/htdocs/listes/moderate.php @@ -18,11 +18,11 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: moderate.php,v 1.1 2004-09-20 20:04:37 x2000habouzit Exp $ + $Id: moderate.php,v 1.2 2004-09-21 15:40:35 x2000habouzit Exp $ ***************************************************************************/ if(empty($_REQUEST['liste'])) header('Location: index.php'); -$liste = $_REQUEST['liste']; +$liste = strtolower($_REQUEST['liste']); require("auto.prepend.inc.php"); include('xml-rpc-client.inc.php'); @@ -32,8 +32,33 @@ mysql_free_result($res); $client = new xmlrpc_client("http://{$_SESSION['uid']}:$pass@localhost:4949"); if(!$client->is_admin($liste)) header('Location: index.php'); - -if(isset($_REQUEST['mid'])) { + +if(isset($_REQUEST['sadd'])) { + $client->handle_request($liste,$_REQUEST['sadd'],4,''); /** 4 is the magic for SUBSCRIBE see Defaults.py **/ + header("Location: moderate.php?liste=$liste"); +} + +if(isset($_POST['sdel'])) { + $client->handle_request($liste,$_POST['sdel'],2,stripslashes($_POST['reason'])); /** 2 is the magic for REJECT see Defaults.py **/ +} + +if(isset($_REQUEST['sid'])) { + $sid = $_REQUEST['sid']; + if(list($subs,$mails) = $client->get_pending_ops($liste)) { + foreach($subs as $user) { + if($user['id'] == $sid) $u = $user; + } + } + + if($u) { + new_skinned_page('listes/moderate_sub.tpl', AUTH_MDP, true); + $page->assign('del_user',$user); + } else { + new_skinned_page('listes/moderate.tpl', AUTH_MDP, true); + $page->assign_by_ref('subs', $subs); + $page->assign_by_ref('mails', $mails); + } +} elseif(isset($_REQUEST['mid'])) { $mid = $_REQUEST['mid']; new_skinned_page('listes/moderate_mail.tpl', AUTH_MDP, true); $mail = $client->get_pending_mail($liste,$mid); diff --git a/htdocs/listes/trombi.php b/htdocs/listes/trombi.php index fc886b7..38ee27d 100644 --- a/htdocs/listes/trombi.php +++ b/htdocs/listes/trombi.php @@ -18,11 +18,11 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: trombi.php,v 1.1 2004-09-10 23:13:04 x2000habouzit Exp $ + $Id: trombi.php,v 1.2 2004-09-21 15:40:35 x2000habouzit Exp $ ***************************************************************************/ if(empty($_REQUEST['liste'])) header('Location: index.php'); -$liste = $_REQUEST['liste']; +$liste = strtolower($_REQUEST['liste']); require("auto.prepend.inc.php"); new_skinned_page('listes/trombi.tpl', AUTH_COOKIE, true); diff --git a/scripts/mailman/mailman-rpc.py b/scripts/mailman/mailman-rpc.py index 16cb9ba..abc0b8e 100755 --- a/scripts/mailman/mailman-rpc.py +++ b/scripts/mailman/mailman-rpc.py @@ -18,7 +18,7 @@ #* Foundation, Inc., * #* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * #*************************************************************************** -# $Id: mailman-rpc.py,v 1.20 2004-09-20 20:04:37 x2000habouzit Exp $ +# $Id: mailman-rpc.py,v 1.21 2004-09-21 15:40:35 x2000habouzit Exp $ #*************************************************************************** import base64, MySQLdb, os @@ -167,9 +167,9 @@ def subscribe((userdesc,perms),listname): except: return 0 try: - if ( mlist.subscribe_policy in (0,1) ) or is_admin_on(userdesc, perms, mlist): + if ( mlist.subscribe_policy in (0,1) ) or ( userdesc.address in mlist.owner ) or ( mm_cfg.ADMIN_ML_OWNER in mlist.owner ): result = 2 - mlist.ApprovedAddMember(userdesc,0,0) + mlist.ApprovedAddMember(userdesc) else: result = 1 try: @@ -188,7 +188,7 @@ def unsubscribe((userdesc,perms),listname): except: return 0 try: - mlist.ApprovedDeleteMember(userdesc.address, None, 0, 0) + mlist.ApprovedDeleteMember(userdesc.address) mlist.Save() mlist.Unlock() return 1 @@ -222,7 +222,7 @@ def mass_subscribe((userdesc,perms),listname,users): if forlife+'@polytechnique.org' in members: continue userd = UserDesc(forlife+'@polytechnique.org', name, None, 0) - mlist.ApprovedAddMember(userd,0,0) + mlist.ApprovedAddMember(userd) added.append( (userd.fullname, userd.address) ) mlist.Save() finally: @@ -238,7 +238,7 @@ def mass_unsubscribe((userdesc,perms),listname,users): if not is_admin_on(userdesc, perms, mlist): return 0 - map(lambda user: mlist.ApprovedDeleteMember(user+'@polytechnique.org', None, 0, 0), users) + map(lambda user: mlist.ApprovedDeleteMember(user+'@polytechnique.org'), users) mlist.Save() finally: mlist.Unlock() @@ -343,9 +343,12 @@ def handle_request((userdesc,perms),listname,id,value,comment): try: if not is_admin_on(userdesc, perms, mlist): return 0 - mlist.HandleRequest(int(id),value,comment) + mlist.HandleRequest(int(id),int(value),comment) + mlist.Save() + mlist.Unlock() return 1 except: + mlist.Unlock() return 0 diff --git a/templates/listes/liste.tpl b/templates/listes/liste.tpl index 3541eb8..e4bc567 100644 --- a/templates/listes/liste.tpl +++ b/templates/listes/liste.tpl @@ -17,7 +17,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: liste.tpl,v 1.7 2004-09-20 20:04:38 x2000habouzit Exp $ + $Id: liste.tpl,v 1.8 2004-09-21 15:40:36 x2000habouzit Exp $ ***************************************************************************} {dynamic} @@ -106,10 +106,17 @@ {/if} -{if $details.you > 1 || ($details.priv>1 && $smarty.session.perms eq admin)} +{if $details.you > 1 || $smarty.session.perms eq admin}
Administrer la liste
+{if $details.priv < 2} +

+Tu n'es pas administrateur de la liste, mais du site. +

+{/if} + +

modération : modérer la liste

Pour entrer un utilisateur, il faut remplir les champs prévus à cet effet par son login, @@ -149,10 +156,6 @@ c'est- Un message est adressé automatiquement à toute personne ajoutée à la liste de diffusion. Voici le message actuellement envoyé : il est modifiable à volonté !

-

-L'objet du mail est "Bienvenue sur la liste de diffusion {$details.name} !"
-Et si la personne fait "répondre à", le message arrive aux modérateurs de la liste. -

diff --git a/templates/listes/listes.inc.tpl b/templates/listes/listes.inc.tpl index a0fd164..d25b951 100644 --- a/templates/listes/listes.inc.tpl +++ b/templates/listes/listes.inc.tpl @@ -17,39 +17,37 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: listes.inc.tpl,v 1.1 2004-09-20 21:31:29 x2000habouzit Exp $ + $Id: listes.inc.tpl,v 1.2 2004-09-21 15:40:36 x2000habouzit Exp $ ***************************************************************************} - - - - - - - - - {foreach from=$listes item=liste} - {if $liste.priv >= $min && $liste.priv <= $max|default:$min} - - - - - - - {/if} - {/foreach} -
ListeDescriptionDiffusionInscription
- {$liste.list} - {if $liste.you>1}[mod]{/if} - {$liste.desc}{if $liste.diff}modérée{else}libre{/if} - {if $liste.you is odd} - {if $liste.ins}inscrit{/if} - {elseif $liste.ins} - - {else} - - {/if} -
- + + + + + + + + + {foreach from=$listes item=liste} + {if $liste.priv >= $min && $liste.priv <= $max|default:$min} + + + + + + + + {/if} + {/foreach} +
ListeDescriptionDiffusionInscription
+ {$liste.list} + {if $liste.you>1}[mod]{/if} + {$liste.desc}{if $liste.diff}modérée{else}libre{/if}{if $liste.ins}modérée{else}libre{/if} + {if $liste.you is odd} + me désinscrire + {elseif $liste.ins} + m'inscrire + {/if} +
{* vim:set et sw=2 sts=2 sws=2: *} diff --git a/templates/listes/moderate.tpl b/templates/listes/moderate.tpl index 771fa66..b1f2be5 100644 --- a/templates/listes/moderate.tpl +++ b/templates/listes/moderate.tpl @@ -17,7 +17,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: moderate.tpl,v 1.2 2004-09-20 21:31:29 x2000habouzit Exp $ + $Id: moderate.tpl,v 1.3 2004-09-21 15:40:36 x2000habouzit Exp $ ***************************************************************************} {dynamic} @@ -33,6 +33,23 @@
{if $subs|@count} + + + + + + + {foreach from=$subs item=s} + + + + + + {/foreach} +
NomAdresse
{$s.name}{$s.addr} + ajouter + refuser +
{else}

pas d'inscriptions en attente de modération

{/if} @@ -57,7 +74,7 @@ {$m.size}o {$m.stamp|date_format:"%H:%M:%S
%d %b %Y"} - voir + voir {/foreach} diff --git a/templates/listes/moderate_mail.tpl b/templates/listes/moderate_mail.tpl index 668309f..803976a 100644 --- a/templates/listes/moderate_mail.tpl +++ b/templates/listes/moderate_mail.tpl @@ -17,7 +17,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: moderate_mail.tpl,v 1.1 2004-09-20 20:04:38 x2000habouzit Exp $ + $Id: moderate_mail.tpl,v 1.2 2004-09-21 15:40:36 x2000habouzit Exp $ ***************************************************************************} {dynamic} @@ -70,4 +70,4 @@ {/dynamic} -{* vim:settd>{$mail et sw=2 sts=2 sws=2: *} +{* vim:set et sw=2 sts=2 sws=2: *} diff --git a/templates/listes/moderate_sub.tpl b/templates/listes/moderate_sub.tpl new file mode 100644 index 0000000..b158d2f --- /dev/null +++ b/templates/listes/moderate_sub.tpl @@ -0,0 +1,61 @@ +{*************************************************************************** + * 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 * + *************************************************************************** + $Id: moderate_sub.tpl,v 1.1 2004-09-21 15:40:36 x2000habouzit Exp $ + ***************************************************************************} + +{dynamic} + +{if $no_list} + +

La liste n'existe pas ou tu n'as pas le droit de la modérer

+ +{else} + +
+ Refuser l'inscription d'un utilisateur +
+ +
+ + + + + + + + + + + + + +
refuser l'inscription de :
{$del_user.name}
raison: + +
+ + +
+
+ +{/if} + +{/dynamic} + +{* vim:set et sw=2 sts=2 sws=2: *} -- 2.1.4