From: x2000habouzit Date: Fri, 24 Sep 2004 14:35:12 +0000 (+0000) Subject: loooooooots of work around owner options, moderation and admin... still needs to... X-Git-Tag: xorg/old~1500 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=958dec258aa860f3e28c5f98bc7e7b5e1e87ea68;p=platal.git loooooooots of work around owner options, moderation and admin... still needs to do : admin options page, hidden options check, maillist creation, and a page of all lists for administration purposes --- diff --git a/htdocs/listes/admin.php b/htdocs/listes/admin.php index 4dfe2c5..bbe1ac4 100644 --- a/htdocs/listes/admin.php +++ b/htdocs/listes/admin.php @@ -18,7 +18,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: admin.php,v 1.2 2004-09-23 17:20:35 x2000habouzit Exp $ + $Id: admin.php,v 1.3 2004-09-24 14:35:12 x2000habouzit Exp $ ***************************************************************************/ if(empty($_REQUEST['liste'])) header('Location: index.php'); @@ -52,10 +52,9 @@ if(isset($_REQUEST['del_owner'])) { header("Location: ?liste=$liste"); } -$members = $client->get_members('polytechnique.org', $liste); -if(is_array($members)) { +if(list($det,$mem,$own) = $client->get_members('polytechnique.org', $liste)) { $membres = Array(); - foreach($members[1] as $member) { + foreach($mem as $member) { if(preg_match('/^([^.]*.[^.]*.(\d\d\d\d))@polytechnique.org$/', $member[1], $matches)) { $membres[$matches[2]][] = Array('n' => $member[0], 'l' => $matches[1]); } else { @@ -65,7 +64,7 @@ if(is_array($members)) { ksort($membres); $moderos = Array(); - foreach($members[2] as $owner) { + foreach($own as $owner) { list($m) = split('@',$owner); $res = $globals->db->query("SELECT CONCAT(prenom, ' ', nom), promo FROM auth_user_md5 AS u @@ -80,7 +79,7 @@ if(is_array($members)) { } ksort($moderos); - $page->assign_by_ref('details', $members[0]); + $page->assign_by_ref('details', $det); $page->assign_by_ref('members', $membres); $page->assign_by_ref('owners', $moderos); diff --git a/htdocs/listes/moderate.php b/htdocs/listes/moderate.php index 7396ad3..c1a6d5d 100644 --- a/htdocs/listes/moderate.php +++ b/htdocs/listes/moderate.php @@ -18,7 +18,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: moderate.php,v 1.4 2004-09-23 18:46:58 x2000habouzit Exp $ + $Id: moderate.php,v 1.5 2004-09-24 14:35:12 x2000habouzit Exp $ ***************************************************************************/ if(empty($_REQUEST['liste'])) header('Location: index.php'); @@ -93,8 +93,6 @@ if(isset($_REQUEST['sid'])) { } else $page->assign('no_list', true); -function tolatin1($s) { return iconv('utf-8', 'iso-8859-1', $s); } -$page->register_modifier('tl1','tolatin1'); $page->register_modifier('qpd','quoted_printable_decode'); $page->run(); ?> diff --git a/htdocs/listes/options.php b/htdocs/listes/options.php new file mode 100644 index 0000000..3377895 --- /dev/null +++ b/htdocs/listes/options.php @@ -0,0 +1,61 @@ +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($_POST['submit'])) { + $values = $_POST; + unset($values['submit']); + $values['send_goodbye_msg'] = empty($values['send_goodbye_msg']) ? false : true; + $values['admin_notify_mchanges'] = empty($values['admin_notify_mchanges']) ? false : true; + $values['subscribe_policy'] = empty($values['subscribe_policy']) ? 0 : 2; + if(isset($values['subject_prefix'])) { + $values['subject_prefix'] = trim($values['subject_prefix']).' '; + } + $client->set_owner_options('polytechnique.org', $liste, $values); +} elseif(isset($_POST['atn_add']) && isvalid_email($_POST['atn_add'])) { + $client->add_to_wl('polytechnique.org', $liste, $_POST['atn_add']); +} elseif(isset($_GET['atn_del'])) { + $client->del_from_wl('polytechnique.org', $liste, $_GET['atn_del']); + header("Location: ?liste=$liste"); +} + +if(list($details,$options) = $client->get_owner_options('polytechnique.org', $liste)) { + $page->assign_by_ref('details', $details); + $page->assign_by_ref('options', $options); +} else + $page->assign('no_list', true); + +$page->run(); +?> diff --git a/scripts/mailman/mailman-rpc.py b/scripts/mailman/mailman-rpc.py index 3a7dafa..faa8d07 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.32 2004-09-23 18:46:59 x2000habouzit Exp $ +# $Id: mailman-rpc.py,v 1.33 2004-09-24 14:35:13 x2000habouzit Exp $ #*************************************************************************** import base64, MySQLdb, os, getopt, sys, MySQLdb.converters @@ -115,6 +115,69 @@ def is_owner(userdesc,perms,mlist): def is_admin_on(userdesc,perms,mlist): return ( perms == 'admin' ) or ( userdesc.address in mlist.owner ) +def get_list_info((userdesc,perms),mlist): + members = mlist.getRegularMemberKeys() + is_member = userdesc.address in members + is_admin = mm_cfg.ADMIN_ML_OWNER in mlist.owner + is_owner = ( perms == 'admin' and is_admin ) or ( userdesc.address in mlist.owner ) + if mlist.advertised or is_member or is_owner: + is_pending = False + for id in mlist.GetSubscriptionIds(): + if userdesc.address == mlist.GetRecord(id)[1]: + is_pending = True + break + chunks = mlist.internal_name().split('-') + details = { + 'list' : mlist.real_name, + 'addr' : str('-').join(chunks[1:]) + '@' + chunks[0], + 'host' : chunks[0], + 'desc' : mlist.description, + 'diff' : (mlist.default_member_moderation>0) + (mlist.generic_nonmember_action>0), + 'ins' : mlist.subscribe_policy > 1, + 'priv' : (1-mlist.advertised)+2*is_admin, + 'sub' : is_pending + 2*is_member, + 'own' : is_owner + } + return (details,members) + return 0 + +def get_options((userdesc,perms),vhost,listname,opts): + try: + mlist = MailList.MailList(vhost+'-'+listname) + except: + return 0 + try: + if not is_admin_on(userdesc, perms, mlist): + return 0 + options = { } + for (k,v) in mlist.__dict__.iteritems(): + if k in opts: + options[k] = v + details = get_list_info((userdesc,perms),mlist)[0] + mlist.Unlock() + return (details,options) + except: + mlist.Unlock() + return 0 + +def set_options((userdesc,perms),vhost,listname,opts,vals): + try: + mlist = MailList.MailList(vhost+'-'+listname) + except: + return 0 + try: + if not is_admin_on(userdesc, perms, mlist): + return 0 + for (k,v) in vals.iteritems(): + if k in opts: + mlist.__dict__[k] = v + mlist.Save() + mlist.Unlock() + return 1 + except: + mlist.Unlock() + return 0 + #------------------------------------------------------------------------------- # users procedures for [ index.php ] # @@ -131,25 +194,11 @@ def get_lists((userdesc,perms),vhost): mlist = MailList.MailList(name) except: continue - is_member = userdesc.address in mlist.getRegularMemberKeys() - is_admin = mm_cfg.ADMIN_ML_OWNER in mlist.owner - is_owner = ( perms == 'admin' and is_admin ) or ( userdesc.address in mlist.owner ) - is_pending = False - for id in mlist.GetSubscriptionIds(): - if userdesc.address == mlist.GetRecord(id)[1]: - is_pending = True - break - if mlist.advertised or is_member or is_owner: - result.append( { - 'list' : str('-').join(name.split('-')[1:]), - 'desc' : mlist.description, - 'diff' : mlist.generic_nonmember_action, - 'ins' : mlist.subscribe_policy > 1, - 'priv' : (1-mlist.advertised)+2*is_admin, - 'sub' : is_pending + 2*is_member, - 'own' : is_owner - } ) - mlist.Unlock() + try: + details = get_list_info((userdesc,perms),mlist)[0] + result.append(details) + finally: + mlist.Unlock() return result def subscribe((userdesc,perms),vhost,listname): @@ -196,30 +245,15 @@ def get_members((userdesc,perms),vhost,listname): mlist = MailList.MailList(vhost+'-'+listname) except: return 0 - members = mlist.getRegularMemberKeys() - is_member = userdesc.address in members - is_admin = mm_cfg.ADMIN_ML_OWNER in mlist.owner - is_owner = ( perms == 'admin' and is_admin ) or ( userdesc.address in mlist.owner ) - is_pending = False - for id in mlist.GetSubscriptionIds(): - if userdesc.address == mlist.GetRecord(id)[1]: - is_pending = True - break - if mlist.advertised or is_member or is_owner or ( perms == 'admin' ): + try: + details,members = get_list_info((userdesc,perms),mlist) members.sort() - details = { 'addr' : listname+'@polytechnique.org', - 'desc' : mlist.description, - 'diff' : mlist.generic_nonmember_action, - 'ins' : mlist.subscribe_policy > 1, - 'priv' : (1-mlist.advertised)+2*is_admin, - 'sub' : is_pending + 2*is_member, - 'own' : is_owner - } - members = map(lambda member: (mlist.getMemberName(member) or '', member), members) + members = map(lambda member: (Utils.uquote(mlist.getMemberName(member)) or '', member), members) mlist.Unlock() return (details,members,mlist.owner) - mlist.Unlock() - return 0 + except: + mlist.Unlock() + return 0 #------------------------------------------------------------------------------- # users procedures for [ trombi.php ] @@ -357,9 +391,9 @@ def get_pending_ops((userdesc,perms),vhost,listname): continue helds.append({ 'id' : id, - 'sender': Utils.oneline(sender,'utf8'), + 'sender': Utils.uquote(sender), 'size' : size, - 'subj' : Utils.oneline(subject,'utf8'), + 'subj' : Utils.uquote(subject), 'stamp' : ptime }) if dosave: mlist.save() @@ -410,15 +444,82 @@ def get_pending_mail((userdesc,perms),vhost,listname,id,raw=0): for part in typed_subpart_iterator(msg,'text','plain'): results.append (part.get_payload()) return {'id' : id, - 'sender': Utils.oneline(sender,'utf8'), + 'sender': Utils.uquote(sender), 'size' : size, - 'subj' : Utils.oneline(subject,'utf8'), + 'subj' : Utils.uquote(subject), 'stamp' : ptime, 'parts' : results } except: mlist.Unlock() return 0 +#------------------------------------------------------------------------------- +# owner options [ options.php ] +# + +def get_owner_options((userdesc,perms),vhost,listname): + opts = 'accept_these_nonmembers', 'admin_notify_mchanges', 'description', \ + 'info', 'subject_prefix', 'goodbye_msg', 'send_goodbye_msg', \ + 'subscribe_policy', 'welcome_msg' + return get_options((userdesc,perms),vhost,listname,opts) + +def set_owner_options((userdesc,perms),vhost,listname,values): + opts = 'accept_these_nonmembers', 'admin_notify_mchanges', 'description', \ + 'info', 'subject_prefix', 'goodbye_msg', 'send_goodbye_msg', \ + 'subscribe_policy', 'welcome_msg' + return set_options((userdesc,perms),vhost,listname,opts,values) + +def add_to_wl((userdesc,perms),vhost,listname,addr): + try: + mlist = MailList.MailList(vhost+'-'+listname) + except: + return 0 + try: + if not is_admin_on(userdesc, perms, mlist): + return 0 + mlist.accept_these_nonmembers.append(addr) + mlist.Save() + mlist.Unlock() + return 1 + except: + mlist.Unlock() + return 0 + +def del_from_wl((userdesc,perms),vhost,listname,addr): + try: + mlist = MailList.MailList(vhost+'-'+listname) + except: + return 0 + try: + if not is_admin_on(userdesc, perms, mlist): + return 0 + mlist.accept_these_nonmembers.remove(addr) + mlist.Save() + mlist.Unlock() + return 1 + except: + mlist.Unlock() + return 0 + +#------------------------------------------------------------------------------- +# admin procedures [ ?????.php ] +# + +def get_admin_options((userdesc,perms),vhost,listname): + if perms != 'admin': + return 0 + opts = 'advertised', 'archive', 'ban_list', 'default_member_moderation', \ + 'generic_nonmember_action', 'hold_these_nonmembers', 'max_message_size', \ + 'max_num_recipients', 'member_moderation_action', 'msg_footer', 'msg_header', \ + 'new_member_options', 'reject_these_nonmembers' + return get_options((userdesc,perms),vhost,listname,opts) + +#------------------------------------------------------------------------------- +# server +# +class FastXMLRPCServer(SimpleXMLRPCServer): + allow_reuse_address = True + ################################################################################ # # INIT @@ -443,13 +544,11 @@ for o, a in opts: if o == '-f' and os.fork(): sys.exit(0) +mysql = connectDB() + #------------------------------------------------------------------------------- # server # -class FastXMLRPCServer(SimpleXMLRPCServer): - allow_reuse_address = True - -mysql = connectDB() server = FastXMLRPCServer(("localhost", 4949), BasicAuthXMLRPCRequestHandler) # index.php @@ -469,6 +568,13 @@ server.register_function(del_owner) server.register_function(get_pending_ops) server.register_function(handle_request) server.register_function(get_pending_mail) +# options.php +server.register_function(get_owner_options) +server.register_function(set_owner_options) +server.register_function(add_to_wl) +server.register_function(del_from_wl) +# +server.register_function(get_admin_options) server.serve_forever() diff --git a/templates/listes/admin.tpl b/templates/listes/admin.tpl index 8d36bad..09193cd 100644 --- a/templates/listes/admin.tpl +++ b/templates/listes/admin.tpl @@ -17,7 +17,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: admin.tpl,v 1.4 2004-09-23 18:47:00 x2000habouzit Exp $ + $Id: admin.tpl,v 1.5 2004-09-24 14:35:13 x2000habouzit Exp $ ***************************************************************************} {dynamic} @@ -29,7 +29,7 @@ {else}
- Administrer la liste {$details.addr} + Abonnés de la liste {$details.addr}
{if !$details.own}

@@ -38,7 +38,10 @@ Tu n'es pas administrateur de la liste, mais du site. {/if}

-[modérer la liste] +[listes] > +[modération] +[abonnés] +[options]

diff --git a/templates/listes/moderate.tpl b/templates/listes/moderate.tpl index bbdd823..3bdf159 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.5 2004-09-22 11:39:51 x2000habouzit Exp $ + $Id: moderate.tpl,v 1.6 2004-09-24 14:35:13 x2000habouzit Exp $ ***************************************************************************} {dynamic} @@ -28,9 +28,20 @@ {else} +

+ Modérer la liste {$smarty.get.liste}@polytechnique.org +
+{if !$details.own} +

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

+{/if} +

-[page de la liste] -[retour] +[listes] > +[modération] +[abonnés] +[options]

@@ -74,8 +85,8 @@ {foreach from=$mails item=m} - {$m.sender|tl1} - {$m.subj|tl1} + {$m.sender} + {$m.subj} {$m.size}o {$m.stamp|date_format:"%H:%M:%S
%d %b %Y"} diff --git a/templates/listes/options.tpl b/templates/listes/options.tpl new file mode 100644 index 0000000..c4c0897 --- /dev/null +++ b/templates/listes/options.tpl @@ -0,0 +1,176 @@ +{*************************************************************************** + * 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 : admin.tpl,v 1.4 2004/09/23 18:47:00 x2000habouzit Exp $ + ***************************************************************************} + +{dynamic} + +{if $no_list || ( !$details.own && $smarty.session.perms neq admin )} + +

La liste n'existe pas ou tu n'as pas le droit de l'administrer

+ +{else} + +
+ Changer les options de la liste {$details.addr} +
+{if !$details.own} +

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

+{/if} + +

+[listes] > +[modération] +[abonnés] +[options] +

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Options de la liste {$details.addr}
+ description :
+ une courte phrase pour décrire la liste. +
+ +
+ info :
+ une description plus longue de la liste. +
+ +
+ welcome_msg :
+ un texte de bienvenue incorporé au mail envoyé aux nouveaux + inscrits. +
+ +
+ goodbye_msg :
+ un texte d'au revoir incorporé au mail de départ envoyé aux + utilisateurs qui se désinscrivent. Ce mail peut être désactivé +
+ activer le mail de départ.
+ +
Options avancées de la liste {$details.addr}
+ subject_prefix :
+ Un préfixe ajouté dans le sujet de chaque mail envoyé sur la liste. +
+ +
+ admin_notify_mchanges :
+ être notifé des inscriptions/désinscriptions sur cette liste. +
+ Notification activée. +
+ subscribe_policy :
+ détermine si les inscriptions à la liste sont modérées ou non. +
+ Inscription modérée. +
+ +
+
+ +
+
+ +{if $details.diff eq 1} + +
+ Addresses non modérées de {$details.addr} +
+

+Les envoi des personnes utilisant les adresses ne sont pas modérés. +

+ +

+Attention, cette liste est à utiliser pour des non-X ou des non-inscrits à la liste : +

+

+les X inscrits à la liste doivent ajouter leurs adresses usuelles parmis leurs adresses de +redirection en mode 'inactif'. le logiciel de mailing list saura se débrouiller tout seul. +

+ +
+ + + + + + + + +
Addresses non modérées
+ {if $options.accept_these_nonmembers|@count} + {foreach from=$options.accept_these_nonmembers item=addr} + {$addr} + retirer de la whitelist +
+ {/foreach} + {else} + vide + {/if} +
+ +   + +
+
+{/if} + +{/if} + +{/dynamic} + +{* vim:set et sw=2 sts=2 sws=2: *}