From bb1e3f2862e96317ac7e81c07e095ae7a9a54a5d Mon Sep 17 00:00:00 2001 From: x2000habouzit Date: Tue, 2 Nov 2004 09:03:42 +0000 Subject: [PATCH] non-X handling --- ChangeLog | 2 ++ htdocs/listes/admin.php | 10 +++---- scripts/mailman/mailman-rpc.py | 61 +++++++++++++++++++++++------------------- templates/listes/admin.tpl | 6 ++--- 4 files changed, 43 insertions(+), 36 deletions(-) diff --git a/ChangeLog b/ChangeLog index f0093ea..b7e7727 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,12 +7,14 @@ Changes : - Creation of the Plugin class. -MC - First instance of the plugin class : class Trombi. (FS#135) -MC - Now only use iso3166 countries, no more `nationalites`. -MC + - A photo change now updates the last time the `fiche` was edited. -MC * Contacts : - Trombino of the contacts is available ! (FS#138) -MC * Lists : - Refusal message is shown on mail moderation page. (FS#138) -MC + - Now supports non-X natively. -MC * Search : - Hide SoundEX search when neither name nor second name selected. -MC diff --git a/htdocs/listes/admin.php b/htdocs/listes/admin.php index 05f8c38..e73ec92 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.9 2004-10-31 14:42:36 x2000habouzit Exp $ + $Id: admin.php,v 1.10 2004-11-02 09:03:42 x2000habouzit Exp $ ***************************************************************************/ if(empty($_REQUEST['liste'])) header('Location: index.php'); @@ -59,9 +59,9 @@ if(list($det,$mem,$own) = $client->get_members('polytechnique.org', $liste)) { foreach($mem as $member) { if(preg_match('/^([^.]*\.([^.]*)\.\d\d\d\d)@polytechnique.org$/', $member[1], $matches)) { $key = strtoupper($matches[2]{0}); - $membres[$key][$matches[2]] = Array('n' => $member[0], 'l' => $matches[1]); + $membres[$key][$matches[2]] = Array('n' => $member[0], 'l' => $matches[1], 'a' => $member[1]); } else { - $membres[0][] = Array('l' => $member[1]); + $membres[0][] = Array('l' => $member[1], 'a' => $member[1]); } } foreach($membres as $key=>$val) ksort($membres[$key]); @@ -75,9 +75,9 @@ if(list($det,$mem,$own) = $client->get_members('polytechnique.org', $liste)) { INNER JOIN aliases AS a ON u.user_id = a.id WHERE a.alias = '$m'"); if(list($nom, $promo) = mysql_fetch_row($res)) { - $moderos[$promo][] = Array('n' => $nom, 'l' => $m); + $moderos[$promo][] = Array('n' => $nom, 'l' => $m, 'a'=>$owner); } else { - $moderos[0][] = Array('l' => $owner); + $moderos[0][] = Array('l' => $owner, 'a' => $owner); } mysql_free_result($res); } diff --git a/scripts/mailman/mailman-rpc.py b/scripts/mailman/mailman-rpc.py index 7642beb..3ddaee4 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.68 2004-10-31 14:42:37 x2000habouzit Exp $ +# $Id: mailman-rpc.py,v 1.69 2004-11-02 09:03:42 x2000habouzit Exp $ #*************************************************************************** import base64, MySQLdb, os, getopt, sys, MySQLdb.converters, sha, signal @@ -126,6 +126,22 @@ def quote(s,is_header=False): h = s return Utils.uquote(h.replace('&','&').replace('>','>').replace('<','<')) +def to_forlife(email): + try: + mbox,fqdn = email.split('@') + except: + mbox = email + fqdn = 'polytechnique.org' + if ( fqdn == 'm4x.org' ) or (fqdn == 'polytechnique.org' ): + mysql.execute ("""SELECT CONCAT(f.alias,'@polytechnique.org'), CONCAT(u.prenom,' ',u.nom) + FROM auth_user_md5 AS u + INNER JOIN aliases AS f ON (f.id=u.user_id AND f.type='a_vie') + INNER JOIN aliases AS a ON (a.id=u.user_id AND a.alias='%s' AND a.type!='homonyme') + LIMIT 1""" %( mbox ) ) + if int(mysql.rowcount) is 1: + return mysql.fetchone() + return (email,mbox) + #------------------------------------------------------------------------------- # helpers on lists # @@ -325,18 +341,12 @@ def mass_subscribe((userdesc,perms),vhost,listname,users): added = [] mlist.Lock() for user in users: - mysql.execute ("""SELECT CONCAT(u.prenom,' ',u.nom), f.alias - FROM auth_user_md5 AS u - INNER JOIN aliases AS f ON (f.id=u.user_id AND f.type='a_vie') - INNER JOIN aliases AS a ON (a.id=u.user_id AND a.alias='%s' AND a.type!='homonyme') - LIMIT 1""" %( user ) ) - if int(mysql.rowcount) is 1: - name, forlife = mysql.fetchone() - if forlife+'@polytechnique.org' in members: - continue - userd = UserDesc(forlife+'@polytechnique.org', name, None, 0) - mlist.ApprovedAddMember(userd) - added.append( (quote(userd.fullname), userd.address) ) + email, name = to_forlife(user) + if email in members: + continue + userd = UserDesc(email, name, None, 0) + mlist.ApprovedAddMember(userd) + added.append( (quote(userd.fullname), userd.address) ) mlist.Save() except: pass @@ -353,7 +363,7 @@ def mass_unsubscribe((userdesc,perms),vhost,listname,users): return 0 mlist.Lock() - map(lambda user: mlist.ApprovedDeleteMember(user+'@polytechnique.org'), users) + map(lambda user: mlist.ApprovedDeleteMember(user), users) mlist.Save() except: pass @@ -368,17 +378,11 @@ def add_owner((userdesc,perms),vhost,listname,user): try: if not is_admin_on(userdesc, perms, mlist): return 0 - mysql.execute ("""SELECT f.alias - FROM aliases AS f - INNER JOIN aliases AS a ON (a.id=f.id AND a.alias='%s' AND a.type!='homonyme') - WHERE f.type='a_vie' - LIMIT 1""" %( user ) ) - if int(mysql.rowcount) is 1: - forlife = mysql.fetchone()[0] - if forlife+'@polytechnique.org' not in mlist.owner: - mlist.Lock() - mlist.owner.append(forlife+'@polytechnique.org') - mlist.Save() + email = to_forlife(user)[0] + if email not in mlist.owner: + mlist.Lock() + mlist.owner.append(email) + mlist.Save() except: pass mlist.Unlock() @@ -395,7 +399,7 @@ def del_owner((userdesc,perms),vhost,listname,user): if len(mlist.owner) < 2: return 0 mlist.Lock() - mlist.owner.remove(user+'@polytechnique.org') + mlist.owner.remove(user) mlist.Save() except: pass @@ -709,7 +713,8 @@ def create_list((userdesc,perms),vhost,listname,desc,advertise,modlevel,inslevel oldmask = os.umask(002) pw = sha.new('foobar').hexdigest() try: - mlist.Create(name, owners[0]+'@polytechnique.org', pw) + email = to_forlife(owners[0])[0] + mlist.Create(name, email, pw) finally: os.umask(oldmask) @@ -723,7 +728,7 @@ def create_list((userdesc,perms),vhost,listname,desc,advertise,modlevel,inslevel mlist.subscribe_policy = 2 * (int(inslevel) is 1) mlist.admin_notify_mchanges = (mlist.subscribe_policy or mlist.generic_nonmember_action or mlist.default_member_moderation or not mlist.advertised) - mlist.owner = map(lambda a: a+'@polytechnique.org', owners) + mlist.owner = map(lambda a: to_forlife(a)[0], owners) mlist.subject_prefix = '['+listname+'] ' mlist.max_message_size = 0 diff --git a/templates/listes/admin.tpl b/templates/listes/admin.tpl index 97449da..d76e73a 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.15 2004-10-27 13:44:27 x2002marichez Exp $ + $Id: admin.tpl,v 1.16 2004-11-02 09:03:43 x2000habouzit Exp $ ***************************************************************************} {dynamic} @@ -72,7 +72,7 @@ c'est- {else} {$x.l} {/if} - + retirer modérateur
{/foreach} @@ -107,7 +107,7 @@ c'est- {else} {$x.l} {/if} - + retirer membre
{/foreach} -- 2.1.4