From b43e2fa28198e4983a6943d50bc45f407b5c1ed2 Mon Sep 17 00:00:00 2001 From: x2000habouzit Date: Mon, 20 Sep 2004 20:04:37 +0000 Subject: [PATCH] lots of new stuff for mailling lists. still needs to add some great forms --- htdocs/listes/liste.php | 5 ++- htdocs/listes/moderate.php | 52 +++++++++++++++++++++++++++ scripts/mailman/mailman-rpc.py | 45 +++++++++++++++++++++-- templates/listes/liste.tpl | 6 +++- templates/listes/moderate.tpl | 64 +++++++++++++++++++++++++++++++++ templates/listes/moderate_mail.tpl | 73 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 239 insertions(+), 6 deletions(-) create mode 100644 htdocs/listes/moderate.php create mode 100644 templates/listes/moderate.tpl create mode 100644 templates/listes/moderate_mail.tpl diff --git a/htdocs/listes/liste.php b/htdocs/listes/liste.php index 00edf56..f5c8e5e 100644 --- a/htdocs/listes/liste.php +++ b/htdocs/listes/liste.php @@ -18,14 +18,14 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: liste.php,v 1.4 2004-09-11 15:11:13 x2000habouzit Exp $ + $Id: liste.php,v 1.5 2004-09-20 20:04:37 x2000habouzit Exp $ ***************************************************************************/ if(empty($_REQUEST['liste'])) header('Location: index.php'); $liste = $_REQUEST['liste']; require("auto.prepend.inc.php"); -new_skinned_page('listes/liste.tpl', AUTH_COOKIE, true); +new_skinned_page('listes/liste.tpl', AUTH_MDP, true); include('xml-rpc-client.inc.php'); $res = $globals->db->query("SELECT password FROM auth_user_md5 WHERE user_id={$_SESSION['uid']}"); @@ -34,7 +34,6 @@ mysql_free_result($res); $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'])) { diff --git a/htdocs/listes/moderate.php b/htdocs/listes/moderate.php new file mode 100644 index 0000000..a13f011 --- /dev/null +++ b/htdocs/listes/moderate.php @@ -0,0 +1,52 @@ +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(!$client->is_admin($liste)) header('Location: index.php'); + +if(isset($_REQUEST['mid'])) { + $mid = $_REQUEST['mid']; + new_skinned_page('listes/moderate_mail.tpl', AUTH_MDP, true); + $mail = $client->get_pending_mail($liste,$mid); + if(is_array($mail)) { + $page->assign_by_ref('mail', $mail); + } +} else { + new_skinned_page('listes/moderate.tpl', AUTH_MDP, true); + + if(list($subs,$mails) = $client->get_pending_ops($liste)) { + $page->assign_by_ref('subs', $subs); + $page->assign_by_ref('mails', $mails); + } +} +$page->run(); +?> diff --git a/scripts/mailman/mailman-rpc.py b/scripts/mailman/mailman-rpc.py index e20022d..16cb9ba 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.19 2004-09-19 21:09:12 x2000habouzit Exp $ +# $Id: mailman-rpc.py,v 1.20 2004-09-20 20:04:37 x2000habouzit Exp $ #*************************************************************************** import base64, MySQLdb, os @@ -35,6 +35,8 @@ from Mailman import Errors from Mailman import mm_cfg from Mailman import i18n from Mailman.UserDesc import UserDesc +from Mailman.ListAdmin import readMessage +from email.Iterators import typed_subpart_iterator class AuthFailed(Exception): pass @@ -323,6 +325,7 @@ def get_pending_ops((userdesc,perms),listname): 'id' : id, 'sender': sender, 'size' : size, + 'subj' : subject, 'stamp' : ptime }) except: @@ -340,12 +343,48 @@ def handle_request((userdesc,perms),listname,id,value,comment): try: if not is_admin_on(userdesc, perms, mlist): return 0 - mlist.HandleRequest(id,value,comment) + mlist.HandleRequest(int(id),value,comment) return 1 except: return 0 +def get_pending_mail((userdesc,perms),listname,id,raw=0): + try: + mlist = MailList.MailList(listname) + except: + return 0 + try: + if not is_admin_on(userdesc, perms, mlist): + return 0 + ptime, sender, subject, reason, filename, msgdata = mlist.GetRecord(int(id)) + fpath = os.path.join(mm_cfg.DATA_DIR, filename) + size = os.path.getsize(fpath) + msg = readMessage(fpath) + mlist.Unlock() + + if raw: + return str(msg) + results = [] + for part in typed_subpart_iterator(msg,'text','plain'): + results.append (part.get_payload(decode=1)) + return {'id' : id, + 'sender': sender, + 'size' : size, + 'subj' : subject, + 'stamp' : ptime, + 'parts' : results } + except: + mlist.Unlock() + return 0 + +def is_admin((userdesc,perms),listname): + try: + mlist = MailList.MailList(listname, lock=0) + except: + return 0 + return is_admin_on(userdesc, perms, mlist) + ################################################################################ # # INIT @@ -372,6 +411,8 @@ server.register_function(del_owner) server.register_function(set_welcome) server.register_function(get_pending_ops) server.register_function(handle_request) +server.register_function(get_pending_mail) +server.register_function(is_admin) server.serve_forever() diff --git a/templates/listes/liste.tpl b/templates/listes/liste.tpl index 23fb302..3541eb8 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.6 2004-09-11 15:11:14 x2000habouzit Exp $ + $Id: liste.tpl,v 1.7 2004-09-20 20:04:38 x2000habouzit Exp $ ***************************************************************************} {dynamic} @@ -64,6 +64,7 @@ modérateurs de la liste +{if $owners|@count} {foreach from=$owners item=xs key=promo} @@ -80,11 +81,13 @@ {/foreach}
+{/if}
membres de la liste
+{if $members|@count} {foreach from=$members item=xs key=promo} @@ -101,6 +104,7 @@ {/foreach}
+{/if} {if $details.you > 1 || ($details.priv>1 && $smarty.session.perms eq admin)}
diff --git a/templates/listes/moderate.tpl b/templates/listes/moderate.tpl new file mode 100644 index 0000000..5e18b43 --- /dev/null +++ b/templates/listes/moderate.tpl @@ -0,0 +1,64 @@ +{*************************************************************************** + * 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.tpl,v 1.1 2004-09-20 20:04:38 x2000habouzit Exp $ + ***************************************************************************} + +{dynamic} + +{if $no_list} + +

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

+ +{else} + +
+ Inscriptions en attente de modération +
+ +
+ Mails en attente de modération +
+ + + + + + + + + + {foreach from=$mails item=m} + + + + + + + + {/foreach} +
émetteursujettailledate
{$m.sender}{$m.subj}{$m.size}o{$m.stamp|date_format:"%H:%M:%S
%d %b %Y"}
+ voir +
+ +{/if} + +{/dynamic} + +{* vim:set et sw=2 sts=2 sws=2: *} diff --git a/templates/listes/moderate_mail.tpl b/templates/listes/moderate_mail.tpl new file mode 100644 index 0000000..668309f --- /dev/null +++ b/templates/listes/moderate_mail.tpl @@ -0,0 +1,73 @@ +{*************************************************************************** + * 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_mail.tpl,v 1.1 2004-09-20 20:04:38 x2000habouzit Exp $ + ***************************************************************************} + +{dynamic} + +{if $no_list} + +

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

+ +{else} + +
+ Propriétés du mail en attente +
+ + + + + + + + + + + + + + + + + + +
émetteur{$mail.sender}
sujet{$mail.subj}
taille{$mail.size} octets
date{$mail.stamp|date_format:"%H:%M:%S le %d %b %Y"}
+ +
+ Contenu du mail en attente +
+ +{if $mail.parts|@count} + + {foreach from=$mail.parts item=part key=i} + + + + + {/foreach} +
Partie n°{$i}
{$part|regex_replace:"!\\n-- *\\n(.*?)$!sm":"

\\1"}
+{/if} + +{/if} + +{/dynamic} + +{* vim:settd>{$mail et sw=2 sts=2 sws=2: *} -- 2.1.4