* 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');
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 {
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
}
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);
* 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');
} 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();
?>
--- /dev/null
+<?php
+/***************************************************************************
+ * 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: options.php,v 1.1 2004-09-24 14:35:12 x2000habouzit Exp $
+ ***************************************************************************/
+
+if(empty($_REQUEST['liste'])) header('Location: index.php');
+$liste = strtolower($_REQUEST['liste']);
+
+require("auto.prepend.inc.php");
+new_skinned_page('listes/options.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']}");
+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();
+?>
#* 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
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 ]
#
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):
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 ]
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()
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
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
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()
* 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}
{else}
<div class='rubrique'>
- Administrer la liste {$details.addr}
+ Abonnés de la liste {$details.addr}
</div>
{if !$details.own}
<p class='erreur'>
{/if}
<p>
-[<a href='moderate.php?liste={$smarty.get.liste}'>modérer la liste</a>]
+[<a href='index.php'>listes</a>] >
+[<a href='moderate.php?liste={$smarty.get.liste}'>modération</a>]
+[abonnés]
+[<a href='options.php?liste={$smarty.get.liste}'>options</a>]
</p>
<p>
* 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}
{else}
+<div class='rubrique'>
+ Modérer la liste {$smarty.get.liste}@polytechnique.org
+</div>
+{if !$details.own}
+<p class='erreur'>
+Tu n'es pas administrateur de la liste, mais du site.
+</p>
+{/if}
+
<p>
-[<a href='admin.php?liste={$smarty.request.liste}'>page de la liste</a>]
-[<a href='index.php'>retour</a>]
+[<a href='index.php'>listes</a>] >
+[modération]
+[<a href='admin.php?liste={$smarty.get.liste}'>abonnés</a>]
+[<a href='options.php?liste={$smarty.get.liste}'>options</a>]
</p>
<div class='rubrique'>
</tr>
{foreach from=$mails item=m}
<tr class='{cycle values="pair,impair"}'>
- <td>{$m.sender|tl1}</td>
- <td>{$m.subj|tl1}</td>
+ <td>{$m.sender}</td>
+ <td>{$m.subj}</td>
<td class='right'>{$m.size}o</td>
<td class='right'>{$m.stamp|date_format:"%H:%M:%S<br />%d %b %Y"}</td>
<td class='action'>
--- /dev/null
+{***************************************************************************
+ * 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 )}
+
+<p class='erreur'>La liste n'existe pas ou tu n'as pas le droit de l'administrer</p>
+
+{else}
+
+<div class='rubrique'>
+ Changer les options de la liste {$details.addr}
+</div>
+{if !$details.own}
+<p class='erreur'>
+Tu n'es pas administrateur de la liste, mais du site.
+</p>
+{/if}
+
+<p>
+[<a href='index.php'>listes</a>] >
+[<a href='moderate.php?liste={$smarty.get.liste}'>modération</a>]
+[<a href='admin.php?liste={$smarty.get.liste}'>abonnés</a>]
+[options]
+</p>
+
+<form method='post' action='{$smarty.server.REQUEST_URI}'>
+ <table class='bicol' cellpadding='2' cellspacing='0'>
+ <tr><th colspan='2'>Options de la liste {$details.addr}</th></tr>
+ <tr class='impair'>
+ <td>
+ <strong>description :</strong><br />
+ <span class='smaller'>une courte phrase pour décrire la liste.</span>
+ </td>
+ <td>
+ <input type='text' size='40' name='description' value='{$options.description}' />
+ </td>
+ </tr>
+ <tr class='impair'>
+ <td>
+ <strong>info :</strong><br />
+ <span class='smaller'>une description plus longue de la liste.</span>
+ </td>
+ <td>
+ <textarea cols='40' rows='8' name='info'>{$options.info}</textarea>
+ </td>
+ </tr>
+ <tr class='pair'>
+ <td>
+ <strong>welcome_msg :</strong><br />
+ <span class='smaller'>un texte de bienvenue incorporé au mail envoyé aux nouveaux
+ inscrits.</span>
+ </td>
+ <td>
+ <textarea cols='40' rows='8' name='welcome_msg'>{$options.welcome_msg}</textarea>
+ </td>
+ </tr>
+ <tr class='impair'>
+ <td>
+ <strong>goodbye_msg :</strong><br />
+ <span class='smaller'>un texte d'au revoir incorporé au mail de départ envoyé aux
+ utilisateurs qui se désinscrivent. Ce mail peut être désactivé</span>
+ </td>
+ <td>
+ <input type='checkbox' name='send_goodbye_msg'
+ {if $options.send_goodbye_msg}checked='checked'{/if} /> activer le mail de départ. <br />
+ <textarea cols='40' rows='8' name='goodbye_msg'>{$options.goodbye_msg}</textarea>
+ </td>
+ </tr>
+ <tr><th colspan='2'>Options avancées de la liste {$details.addr}</th></tr>
+ <tr class='impair'>
+ <td>
+ <strong>subject_prefix :</strong><br />
+ <span class='smaller'>Un préfixe ajouté dans le sujet de chaque mail envoyé sur la liste.</span>
+ </td>
+ <td>
+ <input type='text' name='subject_prefix' size='40' value='{$options.subject_prefix}' />
+ </td>
+ </tr>
+ <tr class='impair'>
+ <td>
+ <strong>admin_notify_mchanges :</strong><br />
+ <span class='smaller'>être notifé des inscriptions/désinscriptions sur cette liste.</span>
+ </td>
+ <td>
+ <input type='checkbox' name='admin_notify_mchanges'
+ {if $options.admin_notify_mchanges}checked='checked'{/if} /> Notification activée.
+ </td>
+ </tr>
+ <tr class='impair'>
+ <td>
+ <strong>subscribe_policy :</strong><br />
+ <span class='smaller'>détermine si les inscriptions à la liste sont modérées ou non.</span>
+ </td>
+ <td>
+ <input type='checkbox' name='subscribe_policy'
+ {if $options.subscribe_policy eq 2}checked='checked'{/if} /> Inscription modérée.
+ </td>
+ </tr>
+ </table>
+
+ <div class='center'>
+ <br />
+ <input type='submit' name='submit' value='Valider les modifications' />
+ </div>
+</form>
+
+{if $details.diff eq 1}
+
+<div class='rubrique'>
+ Addresses non modérées de {$details.addr}
+</div>
+<p>
+Les envoi des personnes utilisant les adresses ne sont pas modérés.
+</p>
+
+<p class='erreur'>
+Attention, cette liste est à utiliser pour des non-X ou des non-inscrits à la liste :
+</p>
+<p>
+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.
+</p>
+
+<form method='post' action='{$smarty.server.REQUEST_URI}'>
+ <table class='tinybicol' cellpadding='2' cellspacing='0'>
+ <tr><th>Addresses non modérées</th></tr>
+ <tr>
+ <td>
+ {if $options.accept_these_nonmembers|@count}
+ {foreach from=$options.accept_these_nonmembers item=addr}
+ {$addr}<a href='?liste={$smarty.get.liste}&atn_del={$addr}'>
+ <img src='{"images/retirer.gif"|url}' alt='retirer de la whitelist' />
+ </a><br />
+ {/foreach}
+ {else}
+ <em>vide</em>
+ {/if}
+ </td>
+ </tr>
+ <tr class='center'>
+ <td>
+ <input type='text' size='32' name='atn_add' />
+
+ <input type='submit' value='ajouter' />
+ </td>
+ </tr>
+ </table>
+</form>
+{/if}
+
+{/if}
+
+{/dynamic}
+
+{* vim:set et sw=2 sts=2 sws=2: *}