non-X handling
authorx2000habouzit <x2000habouzit>
Tue, 2 Nov 2004 09:03:42 +0000 (09:03 +0000)
committerx2000habouzit <x2000habouzit>
Tue, 2 Nov 2004 09:03:42 +0000 (09:03 +0000)
ChangeLog
htdocs/listes/admin.php
scripts/mailman/mailman-rpc.py
templates/listes/admin.tpl

index f0093ea..b7e7727 100644 (file)
--- 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
index 05f8c38..e73ec92 100644 (file)
@@ -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);
     }
index 7642beb..3ddaee4 100755 (executable)
@@ -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('&','&amp;').replace('>','&gt;').replace('<','&lt;'))
 
+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
index 97449da..d76e73a 100644 (file)
@@ -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}
-        <a href='?liste={$smarty.get.liste}&amp;del_owner={$x.l}'>
+        <a href='?liste={$smarty.get.liste}&amp;del_owner={$x.a}'>
           <img src='{"images/retirer.gif"|url}' alt='retirer modérateur' title='retirer modérateur' />
         </a><br />
         {/foreach}
@@ -107,7 +107,7 @@ c'est-
         {else}
         {$x.l}
         {/if}
-        <a href='?liste={$smarty.get.liste}&amp;del_member={$x.l}'>
+        <a href='?liste={$smarty.get.liste}&amp;del_member={$x.a}'>
           <img src='{"images/retirer.gif"|url}' alt='retirer membre' title='retirer membre' />
         </a><br />
         {/foreach}