Uses UFC_NameTokens instead of UFC_Name to perform search on names in xnet.
[platal.git] / bin / lists.rpc.py
index e006547..843f7c0 100755 (executable)
@@ -22,6 +22,8 @@
 import base64, MySQLdb, os, getopt, sys, sha, signal, re, shutil, ConfigParser
 import MySQLdb.converters
 import SocketServer
+import errno
+import traceback
 
 sys.path.append('/usr/lib/mailman/bin')
 
@@ -127,12 +129,12 @@ class BasicAuthXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
             self.end_headers()
 
     def getUser(self, uid, md5, vhost):
-        res = mysql_fetchone ("""SELECT  a.full_name, IF(aa.alias IS NULL, a.email, CONCAT(aa.alias, '@%s')),
+        res = mysql_fetchone ("""SELECT  a.full_name, IF(s.email IS NULL, a.email, CONCAT(s.email, '@%s')),
                                          IF (a.is_admin, 'admin',
                                                          IF(FIND_IN_SET('lists', at.perms) OR FIND_IN_SET('lists', a.user_perms), 'lists', NULL))
                                    FROM  accounts AS a
                              INNER JOIN  account_types AS at ON (at.type = a.type)
-                              LEFT JOIN  aliases  AS aa ON (a.uid = aa.uid AND aa.type = 'a_vie')
+                              LEFT JOIN  email_source_account AS s ON (s.uid = a.uid AND s.type = 'forlife')
                                   WHERE  a.uid = '%s' AND a.password = '%s' AND a.state = 'active'
                                   LIMIT  1""" \
                               % (PLATAL_DOMAIN, uid, md5))
@@ -200,11 +202,10 @@ def to_forlife(email):
         mbox = email
         fqdn = PLATAL_DOMAIN
     if ( fqdn == PLATAL_DOMAIN ) or ( fqdn == PLATAL_DOMAIN2 ):
-        res = mysql_fetchone("""SELECT  CONCAT(f.alias, '@%s'), a.full_name
+        res = mysql_fetchone("""SELECT  CONCAT(s1.email, '@%s'), a.full_name
                                   FROM  accounts AS a
-                            INNER JOIN  aliases  AS f  ON (f.uid = a.uid AND f.type = 'a_vie')
-                            INNER JOIN  aliases  AS aa ON (aa.uid = a.uid AND aa.alias = '%s'
-                                                           AND a.type != 'homonyme')
+                            INNER JOIN  email_source_account AS s1 ON (a.uid = s1.uid AND s1.type = 'forlife')
+                            INNER JOIN  email_source_account AS s2 ON (a.uid = s2.uid AND s2.email = '%s')
                                  WHERE  a.state = 'active'
                                  LIMIT  1""" \
                               % (PLATAL_DOMAIN, mbox))
@@ -275,6 +276,7 @@ def list_call_locked(method, userdesc, perms, mlist, edit, *arg):
         mlist.Unlock()
         return ret
     except Exception, e:
+        traceback.print_exc(file=sys.stderr)
         sys.stderr.write('Exception in locked call %s: %s\n' % (method.__name__, str(e)))
         mlist.Unlock()
         return 0
@@ -568,6 +570,11 @@ def handle_request(userdesc, perms, mlist, id, value, comment):
             @edit
             @admin
     """
+    # Force encoding to mailman's default for french, since this is what
+    # Mailman will use internally
+    # LC_DESCRIPTIONS is a dict of lang => (name, charset, direction) tuples.
+    encoding = mm_cfg.LC_DESCRIPTIONS['fr'][1]
+    comment = comment.encode(encoding, 'replace')
     mlist.HandleRequest(int(id), int(value), comment)
     return 1