Merge commit 'origin/master' into fusionax
authorStéphane Jacob <jacou@melix.net>
Mon, 1 Sep 2008 18:33:45 +0000 (20:33 +0200)
committerStéphane Jacob <jacou@melix.net>
Mon, 1 Sep 2008 18:33:45 +0000 (20:33 +0200)
31 files changed:
Makefile
bin/lists.rpc.py
classes/xnetpage.php
classes/xnetsession.php
configs/platal.ini
core
htdocs/css/default.css
htdocs/javascript/profile.js
include/user.func.inc.php
include/userset.inc.php
include/validations/listes.inc.php
include/validations/medals.inc.php
include/validations/nomusage.inc.php
include/validations/photos.inc.php
include/vcard.inc.php
modules/carnet.php
modules/carnet/feed.inc.php
modules/forums.php
modules/lists.php
modules/profile.php
modules/register.php
modules/search.php
modules/xnetgrp.php
modules/xnetlists.php
plugins/function.select_nat.php
templates/carnet/panel.tpl
templates/include/minifiche.tpl
templates/xnet/index.tpl
templates/xnetgrp/edit.tpl
upgrade/0.9.18/00_edu.sql [new file with mode: 0644]
upgrade/0.9.18/01_nat.sql [new file with mode: 0644]

index f2ca45e..6b18c74 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -26,7 +26,7 @@ endef
 
 all: build
 
-build: core banana wiki medals jquery
+build: core conf banana wiki medals jquery
 
 q:
        @echo -e "Code statistics\n"
@@ -42,7 +42,15 @@ q:
 ## core
 ##
 
-core: spool/templates_c spool/mails_c classes/platalglobals.php configs/platal.cron htdocs/.htaccess spool/conf spool/tmp
+core:
+       [ -d core ] || ( git submodule init && git submodule update )
+       make -C core all
+
+##
+## conf
+##
+
+conf: spool/templates_c spool/mails_c classes/platalglobals.php configs/platal.cron htdocs/.htaccess spool/conf spool/tmp 
 
 spool/templates_c spool/mails_c spool/uploads spool/conf spool/tmp:
        mkdir -p $@
@@ -148,5 +156,5 @@ $(JQUERY_PLUGINS_PATHES):
 
 ################################################################################
 
-.PHONY: build dist clean wiki build-wiki banana htdocs/images/banana htdocs/css/banana.css include/banana/banana.inc.php http*
+.PHONY: build dist clean core wiki build-wiki banana htdocs/images/banana htdocs/css/banana.css include/banana/banana.inc.php http*
 
index ccf3654..8484af0 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 #***************************************************************************
-#*  Copyright (C) 2004 polytechnique.org                                   *
+#*  Copyright (C) 2004-2008 polytechnique.org                              *
 #*  http://opensource.polytechnique.org/                                   *
 #*                                                                         *
 #*  This program is free software; you can redistribute it and/or modify   *
@@ -74,6 +74,9 @@ PLATAL_DOMAIN2 = get_config('Mail', 'domain2', '')
 VHOST_SEP      = get_config('Lists', 'vhost_sep', '_')
 ON_CREATE_CMD  = get_config('Lists', 'on_create', '')
 
+SRV_HOST       = get_config('Lists', 'rpchost', 'localhost')
+SRV_PORT       = int(get_config('Lists', 'rpcport', '4949'))
+
 ################################################################################
 #
 # CLASSES
@@ -93,13 +96,17 @@ class BasicAuthXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
     argument a UserDesc taken from the database, containing name, email and perms
     """
 
+    def _get_function(self, method):
+        try:
+            # check to see if a matching function has been registered
+            return self.server.funcs[method]
+        except:
+            raise Exception('method "%s" is not supported' % method)
+
+
     def _dispatch(self, method, params):
-        # TODO: subclass in SimpleXMLRPCDispatcher and not here.
         new_params = list(params)
-        new_params.insert(0, self.data[2])
-        new_params.insert(0, self.data[1])
-        new_params.insert(0, self.data[0])
-        return self.server._dispatch(method, new_params)
+        return list_call_dispatcher(self._get_function(method), self.data[0], self.data[1], self.data[2], *params)
 
     def do_POST(self):
         try:
@@ -202,10 +209,70 @@ def remove_it(listname, filename):
     elif os.path.isdir(filename):
         shutil.rmtree(filename)
 
+##
+# Call dispatcher
+##
+
+def has_annotation(method, name):
+    """ Check if the method contains the given annoation.
+    """
+    return method.__doc__ and method.__doc__.find("@%s" % name) > -1
+
+def list_call_dispatcher(method, userdesc, perms, vhost, *arg):
+    """Dispatch the call to the right handler.
+    This function checks the options of the called method the set the environment of the call.
+    The dispatcher uses method annotation (special tokens in the documentation of the method) to
+    guess the requested environment:
+        @mlist: the handler requires a mlist object instead of the vhost/listname couple
+        @lock:  the handler requires the mlist to be locked (@mlist MUST be specified)
+        @edit:  the handler edit the mlist (@mlist MUST be specified)
+        @admin: the handler requires admin rights on the list (@mlist MUST be specified)
+        @root:  the handler requires site admin rights
+    """
+    try:
+        if has_annotation(method, "root") and perms != "admin":
+            return 0
+        if has_annotation(method, "mlist"):
+            listname = arg[0]
+            arg = arg[1:]
+            mlist = MailList.MailList(vhost + VHOST_SEP + listname.lower(), lock=0)
+            if has_annotation(method, "admin") and not is_admin_on(userdesc, perms, mlist):
+                return 0
+            if has_annotation(method, "edit") or has_annotation(method, "lock"):
+                return list_call_locked(method, userdesc, perms, mlist, has_annotation(method, "edit"), *arg)
+            else:
+                return method(userdesc, perms, mlist, *arg)
+        else:
+            return method(userdesc, perms, vhost, *arg)
+    except Exception, e:
+        raise e
+        return 0
+
+def list_call_locked(method, userdesc, perms, mlist, edit, *arg):
+    """Call the given method after locking the mlist.
+    """
+    try:
+        mlist.Lock()
+        ret = method(userdesc, perms, mlist, *arg)
+        if edit:
+            mlist.Save()
+        mlist.Unlock()
+        return ret
+    except:
+        mlist.Unlock()
+        return 0
+    # TODO: use finally when switching to python 2.5
+
 #-------------------------------------------------------------------------------
 # helpers on lists
 #
 
+def is_subscription_pending(userdesc, perms, mlist, edit):
+    for id in mlist.GetSubscriptionIds():
+        if userdesc.address == mlist.GetRecord(id)[1]:
+            return True
+    return False
+
 def get_list_info(userdesc, perms, mlist, front_page=0):
     members    = mlist.getRegularMemberKeys()
     is_member  = userdesc.address in members
@@ -213,15 +280,8 @@ def get_list_info(userdesc, perms, mlist, front_page=0):
     if mlist.advertised or is_member or is_owner or (not front_page and perms == 'admin'):
         is_pending = False
         if not is_member and (mlist.subscribe_policy > 1):
-            try:
-                mlist.Lock()
-                for id in mlist.GetSubscriptionIds():
-                    if userdesc.address == mlist.GetRecord(id)[1]:
-                        is_pending = 1
-                        break
-                mlist.Unlock()
-            except:
-                mlist.Unlock()
+            is_pending = list_call_locked(userdesc, perms, mlist, is_subscription_pending, False)
+            if is_pending is 0:
                 return 0
 
         host = mlist.internal_name().split(VHOST_SEP)[0].lower()
@@ -241,57 +301,46 @@ def get_list_info(userdesc, perms, mlist, front_page=0):
         return (details, members)
     return 0
 
-def get_options(userdesc, perms, vhost, listname, opts):
-    try:
-        mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
-    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:
-                if type(v) is str:
-                    options[k] = quote(v)
-                else: options[k] = v
-        details = get_list_info(userdesc, perms, mlist)[0]
-        return (details, options)
-    except:
-        return 0
-
-def set_options(userdesc, perms, vhost, listname, opts, vals):
-    try:
-        mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
-    except:
-        return 0
-    try:
-        if not is_admin_on(userdesc, perms, mlist):
-            return 0
-        mlist.Lock()
-        for (k, v) in vals.iteritems():
-            if k not in opts:
-                continue
-            if k == 'default_member_moderation':
-                for member in mlist.getMembers():
-                    mlist.setMemberOption(member, mm_cfg.Moderate, int(v))
-            t = type(mlist.__dict__[k])
-            if   t is bool: mlist.__dict__[k] = bool(v)
-            elif t is int:  mlist.__dict__[k] = int(v)
-            elif t is str:  mlist.__dict__[k] = Utils.uncanonstr(v, 'fr')
-            else:           mlist.__dict__[k] = v
-        mlist.Save()
-        mlist.Unlock()
-        return 1
-    except:
-        mlist.Unlock()
-        return 0
+def get_options(userdesc, perms, mlist, opts):
+    """ Get the options of a list.
+            @mlist
+            @admin
+    """
+    options = { }
+    for (k, v) in mlist.__dict__.iteritems():
+        if k in opts:
+            if type(v) is str:
+                options[k] = quote(v)
+            else: options[k] = v
+    details = get_list_info(userdesc, perms, mlist)[0]
+    return (details, options)
+
+def set_options(userdesc, perms, mlist, vals):
+    """ Set the options of a list.
+            @mlist
+            @edit
+            @admin
+    """
+    for (k, v) in vals.iteritems():
+        if k not in opts:
+            continue
+        if k == 'default_member_moderation':
+            for member in mlist.getMembers():
+                mlist.setMemberOption(member, mm_cfg.Moderate, int(v))
+        t = type(mlist.__dict__[k])
+        if   t is bool: mlist.__dict__[k] = bool(v)
+        elif t is int:  mlist.__dict__[k] = int(v)
+        elif t is str:  mlist.__dict__[k] = Utils.uncanonstr(v, 'fr')
+        else:           mlist.__dict__[k] = v
+    return 1
 
 #-------------------------------------------------------------------------------
 # users procedures for [ index.php ]
 #
 
 def get_lists(userdesc, perms, vhost, email=None):
+    """ List available lists for the given vhost
+    """
     if email is None:
         udesc = userdesc
     else:
@@ -314,42 +363,29 @@ def get_lists(userdesc, perms, vhost, email=None):
             continue
     return result
 
-def subscribe(userdesc, perms, vhost, listname):
-    try:
-        mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
-    except:
-        return 0
-    try:
-        mlist.Lock()
-        if ( mlist.subscribe_policy in (0, 1) ) or userdesc.address in mlist.owner:
-            mlist.ApprovedAddMember(userdesc)
-            result = 2
-        else:
-            result = 1
-            try:
-                mlist.AddMember(userdesc)
-            except Errors.MMNeedApproval:
-                pass
-        mlist.Save()
-    except:
-        result = 0
-    mlist.Unlock()
+def subscribe(userdesc, perms, mlist):
+    """ Subscribe to a list.
+            @mlist
+            @edit
+    """
+    if ( mlist.subscribe_policy in (0, 1) ) or userdesc.address in mlist.owner:
+        mlist.ApprovedAddMember(userdesc)
+        result = 2
+    else:
+        result = 1
+        try:
+            mlist.AddMember(userdesc)
+        except Errors.MMNeedApproval:
+            pass
     return result
 
-def unsubscribe(userdesc, perms, vhost, listname):
-    try:
-        mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
-    except:
-        return 0
-    try:
-        mlist.Lock()
-        mlist.ApprovedDeleteMember(userdesc.address)
-        mlist.Save()
-        mlist.Unlock()
-        return 1
-    except:
-        mlist.Unlock()
-        return 0
+def unsubscribe(userdesc, perms, mlist):
+    """ Unsubscribe from a list
+            @mlist
+            @edit
+    """
+    mlist.ApprovedDeleteMember(userdesc.address)
+    return 1
 
 #-------------------------------------------------------------------------------
 # users procedures for [ index.php ]
@@ -361,278 +397,208 @@ def get_name(member):
     except:
         return ''
 
-def get_members(userdesc, perms, vhost, listname):
-    try:
-        mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
-    except:
-        return 0
-    try:
-        details, members = get_list_info(userdesc, perms, mlist)
-        members.sort()
-        members = map(lambda member: (get_name(member), member), members)
-        return (details, members, mlist.owner)
-    except:
-        return 0
+def get_members(userdesc, perms, mlist):
+    """ List the members of a list.
+            @mlist
+    """
+    details, members = get_list_info(userdesc, perms, mlist)
+    members.sort()
+    members = map(lambda member: (get_name(member), member), members)
+    return (details, members, mlist.owner)
+
 
 #-------------------------------------------------------------------------------
 # users procedures for [ trombi.php ]
 #
 
-def get_members_limit(userdesc, perms, vhost, listname, page, nb_per_page):
-    try:
-        members = get_members(userdesc, perms, vhost, listname.lower())[1]
-    except:
-        return 0
+def get_members_limit(userdesc, perms, mlist, page, nb_per_page):
+    """ Get a range of members of the list.
+            @mlist
+    """
+    members = get_members(userdesc, perms, mlist)[1]
     i = int(page) * int(nb_per_page)
     return (len(members), members[i:i+int(nb_per_page)])
 
-def get_owners(userdesc, perms, vhost, listname):
-    try:
-        details, members, owners = get_members(userdesc, perms, vhost, listname.lower())
-    except:
-        return 0
+def get_owners(userdesc, perms, mlist):
+    """ Get the owners of the list.
+            @mlist
+    """
+    details, members, owners = get_members(userdesc, perms, mlist)
     return (details, owners)
 
+
 #-------------------------------------------------------------------------------
 # owners procedures [ admin.php ]
 #
 
-def replace_email(userdesc, perms, vhost, listname, from_email, to_email):
-    try:
-        mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
-    except:
-        return 0
-    try:
-        if not is_admin_on(userdesc, perms, mlist):
-            return 0
-
-        mlist.Lock()
-        mlist.ApprovedChangeMemberAddress(from_email.lower(), to_email.lower(), 0)
-        mlist.Save()
-        mlist.Unlock()
-        return 1
-    except:
-        return 0
-
-def mass_subscribe(userdesc, perms, vhost, listname, users):
-    try:
-        mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
-    except:
-        return 0
-    try:
-        if not is_admin_on(userdesc, perms, mlist):
-            return 0
+def replace_email(userdesc, perms, mlist, from_email, to_email):
+    """ Replace the address of a member by another one.
+            @mlist
+            @edit
+            @admin
+    """
+    mlist.ApprovedChangeMemberAddress(from_email.lower(), to_email.lower(), 0)
+    return 1
 
-        members = mlist.getRegularMemberKeys()
-        added = []
-        mlist.Lock()
-        for user in users:
-            email, name = to_forlife(user)
-            if ( email is None ) or ( email in members ):
-                continue
-            userd = UserDesc(email, name, None, 0)
-            mlist.ApprovedAddMember(userd)
-            added.append( (quote(userd.fullname), userd.address) )
-        mlist.Save()
-    except:
-        pass
-    mlist.Unlock()
+def mass_subscribe(userdesc, perms, mlist, users):
+    """ Add a list of users to the list.
+            @mlist
+            @edit
+            @admin
+    """
+    members = mlist.getRegularMemberKeys()
+    added = []
+    mlist.Lock()
+    for user in users:
+        email, name = to_forlife(user)
+        if ( email is None ) or ( email in members ):
+            continue
+        userd = UserDesc(email, name, None, 0)
+        mlist.ApprovedAddMember(userd)
+        added.append( (quote(userd.fullname), userd.address) )
     return added
 
-def mass_unsubscribe(userdesc, perms, vhost, listname, users):
-    try:
-        mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
-    except:
-        return 0
-    try:
-        if not is_admin_on(userdesc, perms, mlist):
-            return 0
-
-        mlist.Lock()
-        map(lambda user: mlist.ApprovedDeleteMember(user), users)
-        mlist.Save()
-    except:
-        pass
-    mlist.Unlock()
+def mass_unsubscribe(userdesc, perms, mlist, users):
+    """ Remove a list of users from the list.
+            @mlist
+            @edit
+            @admin
+    """
+    map(lambda user: mlist.ApprovedDeleteMember(user), users)
     return users
 
-def add_owner(userdesc, perms, vhost, listname, user):
-    try:
-        mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
-    except:
+def add_owner(userdesc, perms, mlist, user):
+    """ Add a owner to the list.
+            @mlist
+            @edit
+            @admin
+    """
+    email = to_forlife(user)[0]
+    if email is None:
         return 0
-    try:
-        if not is_admin_on(userdesc, perms, mlist):
-            return 0
-        email = to_forlife(user)[0]
-        if email is None:
-            return 0
-        if email not in mlist.owner:
-            mlist.Lock()
-            mlist.owner.append(email)
-            mlist.Save()
-    except:
-        pass
-    mlist.Unlock()
+    if email not in mlist.owner:
+        mlist.owner.append(email)
     return True
 
-def del_owner(userdesc, perms, vhost, listname, user):
-    try:
-        mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
-    except:
+def del_owner(userdesc, perms, mlist, user):
+    """ Remove a owner of the list.
+            @mlist
+            @edit
+            @admin
+    """
+    if len(mlist.owner) < 2:
         return 0
-    try:
-        if not is_admin_on(userdesc, perms, mlist):
-            return 0
-        if len(mlist.owner) < 2:
-            return 0
-        mlist.Lock()
-        mlist.owner.remove(user)
-        mlist.Save()
-    except:
-        pass
-    mlist.Unlock()
+    mlist.owner.remove(user)
     return True
 
 #-------------------------------------------------------------------------------
 # owners procedures [ admin.php ]
 #
 
-def get_pending_ops(userdesc, perms, vhost, listname):
-    try:
-        mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
-    except:
-        return 0
-    try:
-        if not is_admin_on(userdesc, perms, mlist):
-            return 0
-
-        mlist.Lock()
-
-        subs = []
-        seen = []
-        dosave = False
-        for id in mlist.GetSubscriptionIds():
-            time, addr, fullname, passwd, digest, lang = mlist.GetRecord(id)
-            if addr in seen:
-                mlist.HandleRequest(id, mm_cfg.DISCARD)
-                dosave = True
-                continue
-            seen.append(addr)
-            try:
-                login = re.match("^[^.]*\.[^.]*\.\d\d\d\d$", addr.split('@')[0]).group()
-                subs.append({'id': id, 'name': quote(fullname), 'addr': addr, 'login': login })
-            except:
-                subs.append({'id': id, 'name': quote(fullname), 'addr': addr })
-
-        helds = []
-        for id in mlist.GetHeldMessageIds():
-            ptime, sender, subject, reason, filename, msgdata = mlist.GetRecord(id)
-            fpath = os.path.join(mm_cfg.DATA_DIR, filename)
-            try:
-                size = os.path.getsize(fpath)
-            except OSError, e:
-                if e.errno <> errno.ENOENT: raise
-                continue
-            try:
-                msg = readMessage(fpath)
-                fromX = msg.has_key("X-Org-Mail")
-            except:
-                pass
-            helds.append({
-                    'id'    : id,
-                    'sender': quote(sender, True),
-                    'size'  : size,
-                    'subj'  : quote(subject, True),
-                    'stamp' : ptime,
-                    'fromx' : fromX
-                    })
-        if dosave: mlist.Save()
-        mlist.Unlock()
-    except:
-        mlist.Unlock()
-        return 0
-    return (subs, helds)
-
-def handle_request(userdesc, perms, vhost, listname, id, value, comment):
-    try:
-        mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
-    except:
-        return 0
-    try:
-        if not is_admin_on(userdesc, perms, mlist):
-            return 0
-        mlist.Lock()
-        mlist.HandleRequest(int(id), int(value), comment)
-        mlist.Save()
-        mlist.Unlock()
-        return 1
-    except:
-        mlist.Unlock()
-        return 0
-
-def get_pending_sub(userdesc, perms, vhost, listname, id):
-    try:
-        mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
-    except:
-        return 0
-    try:
-        if not is_admin_on(userdesc, perms, mlist):
-            return 0
-
-        mlist.Lock()
-        sub = 0
-        id = int(id)
-        if id in mlist.GetSubscriptionIds():
-            time, addr, fullname, passwd, digest, lang = mlist.GetRecord(id)
-            try:
-                login = re.match("^[^.]*\.[^.]*\.\d\d\d\d$", addr.split('@')[0]).group()
-                sub = {'id': id, 'name': quote(fullname), 'addr': addr, 'login': login }
-            except:
-                sub = {'id': id, 'name': quote(fullname), 'addr': addr }
-        mlist.Unlock()
-    except:
-        mlist.Unlock()
-        return 0
-    return sub
+def get_pending_ops(userdesc, perms, mlist):
+    """ Get the list of operation waiting for an action from the owners.
+            @mlist
+            @lock
+            @admin
+    """
+    subs = []
+    seen = []
+    dosave = False
+    for id in mlist.GetSubscriptionIds():
+        time, addr, fullname, passwd, digest, lang = mlist.GetRecord(id)
+        if addr in seen:
+            mlist.HandleRequest(id, mm_cfg.DISCARD)
+            dosave = True
+            continue
+        seen.append(addr)
+        try:
+            login = re.match("^[^.]*\.[^.]*\.\d\d\d\d$", addr.split('@')[0]).group()
+            subs.append({'id': id, 'name': quote(fullname), 'addr': addr, 'login': login })
+        except:
+            subs.append({'id': id, 'name': quote(fullname), 'addr': addr })
 
-def get_pending_mail(userdesc, perms, vhost, listname, id, raw=0):
-    try:
-        mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
-    except:
-        return 0
-    try:
-        if not is_admin_on(userdesc, perms, mlist):
-            return 0
-        mlist.Lock()
-        ptime, sender, subject, reason, filename, msgdata = mlist.GetRecord(int(id))
+    helds = []
+    for id in mlist.GetHeldMessageIds():
+        ptime, sender, subject, reason, filename, msgdata = mlist.GetRecord(id)
         fpath = os.path.join(mm_cfg.DATA_DIR, filename)
-        size = os.path.getsize(fpath)
-        msg = readMessage(fpath)
-        mlist.Unlock()
-
-        if raw:
-            return quote(str(msg))
-        results_plain = []
-        results_html  = []
-        for part in typed_subpart_iterator(msg, 'text', 'plain'):
-            c = part.get_payload()
-            if c is not None: results_plain.append (c)
-        results_plain = map(lambda x: quote(x), results_plain)
-        for part in typed_subpart_iterator(msg, 'text', 'html'):
-            c = part.get_payload()
-            if c is not None: results_html.append (c)
-        results_html = map(lambda x: quote(x), results_html)
-        return {'id'    : id,
+        try:
+            size = os.path.getsize(fpath)
+        except OSError, e:
+            if e.errno <> errno.ENOENT: raise
+            continue
+        try:
+            msg = readMessage(fpath)
+            fromX = msg.has_key("X-Org-Mail")
+        except:
+            pass
+        helds.append({
+                'id'    : id,
                 'sender': quote(sender, True),
                 'size'  : size,
                 'subj'  : quote(subject, True),
                 'stamp' : ptime,
-                'parts_plain' : results_plain,
-                'parts_html': results_html }
-    except:
-        mlist.Unlock()
-        return 0
+                'fromx' : fromX
+                })
+    if dosave:
+        mlist.Save()
+    return (subs, helds)
+
+def handle_request(userdesc, perms, mlist, id, value, comment):
+    """ Handle a moderation request.
+            @mlist
+            @edit
+            @admin
+    """
+    mlist.HandleRequest(int(id), int(value), comment)
+    return 1
+
+def get_pending_sub(userdesc, perms, mlist, id):
+    """ Get informations about a given subscription moderation.
+            @mlist
+            @lock
+            @admin
+    """
+    sub = 0
+    id = int(id)
+    if id in mlist.GetSubscriptionIds():
+        time, addr, fullname, passwd, digest, lang = mlist.GetRecord(id)
+        try:
+            login = re.match("^[^.]*\.[^.]*\.\d\d\d\d$", addr.split('@')[0]).group()
+            sub = {'id': id, 'name': quote(fullname), 'addr': addr, 'login': login }
+        except:
+            sub = {'id': id, 'name': quote(fullname), 'addr': addr }
+    return sub
+
+def get_pending_mail(userdesc, perms, mlist, id, raw=0):
+    """ Get informations about a given mail moderation.
+            @mlist
+            @lock
+            @admin
+    """
+    ptime, sender, subject, reason, filename, msgdata = mlist.GetRecord(int(id))
+    fpath = os.path.join(mm_cfg.DATA_DIR, filename)
+    size = os.path.getsize(fpath)
+    msg = readMessage(fpath)
+
+    if raw:
+        return quote(str(msg))
+    results_plain = []
+    results_html  = []
+    for part in typed_subpart_iterator(msg, 'text', 'plain'):
+        c = part.get_payload()
+        if c is not None: results_plain.append (c)
+    results_plain = map(lambda x: quote(x), results_plain)
+    for part in typed_subpart_iterator(msg, 'text', 'html'):
+        c = part.get_payload()
+        if c is not None: results_html.append (c)
+    results_html = map(lambda x: quote(x), results_html)
+    return {'id'    : id,
+            'sender': quote(sender, True),
+            'size'  : size,
+            'subj'  : quote(subject, True),
+            'stamp' : ptime,
+            'parts_plain' : results_plain,
+            'parts_html': results_html }
 
 #-------------------------------------------------------------------------------
 # owner options [ options.php ]
@@ -643,126 +609,104 @@ owner_opts = ['accept_these_nonmembers', 'admin_notify_mchanges', 'description',
         'subject_prefix', 'goodbye_msg', 'send_goodbye_msg', 'subscribe_policy', \
         'welcome_msg']
 
-def get_owner_options(userdesc, perms, vhost, listname):
-    return get_options(userdesc, perms, vhost, listname.lower(), owner_opts)
+def get_owner_options(userdesc, perms, mlist):
+    """ Get the owner options of a list.
+            @mlist
+            @admin
+    """
+    return get_options(userdesc, perms, mlist, owner_opts)
 
-def set_owner_options(userdesc, perms, vhost, listname, values):
-    return set_options(userdesc, perms, vhost, listname.lower(), owner_opts, values)
+def set_owner_options(userdesc, perms, mlist, values):
+    """ Set the owner options of a list.
+            @mlist
+            @edit
+            @admin
+    """
+    return set_options(userdesc, perms, mlist, owner_opts, values)
 
-def add_to_wl(userdesc, perms, vhost, listname, addr):
-    try:
-        mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
-    except:
-        return 0
-    try:
-        if not is_admin_on(userdesc, perms, mlist):
-            return 0
-        mlist.Lock()
-        mlist.accept_these_nonmembers.append(addr)
-        mlist.Save()
-        mlist.Unlock()
-        return 1
-    except:
-        mlist.Unlock()
-        return 0
+def add_to_wl(userdesc, perms, mlist, addr):
+    """ Add addr to the whitelist
+            @mlist
+            @edit
+            @admin
+    """
+    mlist.accept_these_nonmembers.append(addr)
+    return 1
 
-def del_from_wl(userdesc, perms, vhost, listname, addr):
-    try:
-        mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
-    except:
-        return 0
-    try:
-        if not is_admin_on(userdesc, perms, mlist):
-            return 0
-        mlist.Lock()
-        mlist.accept_these_nonmembers.remove(addr)
-        mlist.Save()
-        mlist.Unlock()
-        return 1
-    except:
-        mlist.Unlock()
-        return 0
+def del_from_wl(userdesc, perms, mlist, addr):
+    """ Remove an address from the whitelist
+            @mlist
+            @edit
+            @admin
+    """
+    mlist.accept_these_nonmembers.remove(addr)
+    return 1
 
-def get_bogo_level(userdesc, perms, vhost, listname):
-    """ Compute bogo level from the filtering rules set up on the list. """
-    try:
-        mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
-    except:
+def get_bogo_level(userdesc, perms, mlist):
+    """ Compute bogo level from the filtering rules set up on the list.
+            @mlist
+            @admin
+    """
+    if len(mlist.header_filter_rules) == 0:
         return 0
-    try:
-        if not is_admin_on(userdesc, perms, mlist):
-            return 0
-        if len(mlist.header_filter_rules) == 0:
-            return 0
 
-        unsurelevel = 0
-        filterlevel = 0
-        filterbase = 0
+    unsurelevel = 0
+    filterlevel = 0
+    filterbase = 0
 
-        # The first rule filters Unsure mails
-        if mlist.header_filter_rules[0][0] == 'X-Spam-Flag: Unsure, tests=bogofilter':
-            unsurelevel = 1
-            filterbase = 1
+    # The first rule filters Unsure mails
+    if mlist.header_filter_rules[0][0] == 'X-Spam-Flag: Unsure, tests=bogofilter':
+        unsurelevel = 1
+        filterbase = 1
 
-        # Check the other rules:
-        #  - we have 2 rules: this is level 2 (drop > 0.999999, moderate Yes)
-        #  - we have only one rule with HOLD directive : this is level 1 (moderate spams)
-        #  - we have only one rule with DISCARD directive : this is level 3 (drop spams)
-        try:
-            action = mlist.header_filter_rules[filterbase + 1][1]
-            filterlevel = 2
-        except:
-            action = mlist.header_filter_rules[filterbase][1]
-            if action == mm_cfg.HOLD:
-                filterlevel = 1
-            elif action == mm_cfg.DISCARD:
-                filterlevel = 3
-        return (filterlevel << 1) + unsurelevel
+    # Check the other rules:
+    #  - we have 2 rules: this is level 2 (drop > 0.999999, moderate Yes)
+    #  - we have only one rule with HOLD directive : this is level 1 (moderate spams)
+    #  - we have only one rule with DISCARD directive : this is level 3 (drop spams)
+    try:
+        action = mlist.header_filter_rules[filterbase + 1][1]
+        filterlevel = 2
     except:
-        return 0
+        action = mlist.header_filter_rules[filterbase][1]
+        if action == mm_cfg.HOLD:
+            filterlevel = 1
+        elif action == mm_cfg.DISCARD:
+            filterlevel = 3
+    return (filterlevel << 1) + unsurelevel
 
 def set_bogo_level(userdesc, perms, vhost, listname, level):
-    """ set filter to the specified level. """
-    try:
-        mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
-    except:
-        return 0
-    try:
-        if not is_admin_on(userdesc, perms, mlist):
-            return 0
-        hfr = []
-
-        # The level is a combination of a spam filtering level and unsure filtering level
-        #   - the unsure filtering level is only 1 bit (1 = HOLD unsures, 0 = Accept unsures)
-        #   - the spam filtering level is a number growing with filtering strength
-        #     (0 = no filtering, 1 = moderate spam, 2 = drop 0.999999 and moderate others, 3 = drop spams)
-        bogolevel = int(level)
-        filterlevel = bogolevel >> 1
-        unsurelevel = bogolevel & 1
-
-        # Set up unusre filtering
-        if unsurelevel == 1:
-            hfr.append(('X-Spam-Flag: Unsure, tests=bogofilter', mm_cfg.HOLD, False))
-
-        # Set up spam filtering
-        if filterlevel is 1:
-            hfr.append(('X-Spam-Flag: Yes, tests=bogofilter', mm_cfg.HOLD, False))
-        elif filterlevel is 2:
-            hfr.append(('X-Spam-Flag: Yes, tests=bogofilter, spamicity=(0\.999999|1\.000000)', mm_cfg.DISCARD, False))
-            hfr.append(('X-Spam-Flag: Yes, tests=bogofilter', mm_cfg.HOLD, False))
-        elif filterlevel is 3:
-            hfr.append(('X-Spam-Flag: Yes, tests=bogofilter', mm_cfg.DISCARD, False))
-
-        # save configuration
-        if mlist.header_filter_rules != hfr:
-            mlist.Lock()
-            mlist.header_filter_rules = hfr
-            mlist.Save()
-            mlist.Unlock()
-        return 1
-    except:
-        mlist.Unlock()
-        return 0
+    """ Set filter to the specified level.
+            @mlist
+            @edit
+            @admin
+    """
+    hfr = []
+
+    # The level is a combination of a spam filtering level and unsure filtering level
+    #   - the unsure filtering level is only 1 bit (1 = HOLD unsures, 0 = Accept unsures)
+    #   - the spam filtering level is a number growing with filtering strength
+    #     (0 = no filtering, 1 = moderate spam, 2 = drop 0.999999 and moderate others, 3 = drop spams)
+    bogolevel = int(level)
+    filterlevel = bogolevel >> 1
+    unsurelevel = bogolevel & 1
+
+    # Set up unusre filtering
+    if unsurelevel == 1:
+        hfr.append(('X-Spam-Flag: Unsure, tests=bogofilter', mm_cfg.HOLD, False))
+
+    # Set up spam filtering
+    if filterlevel is 1:
+        hfr.append(('X-Spam-Flag: Yes, tests=bogofilter', mm_cfg.HOLD, False))
+    elif filterlevel is 2:
+        hfr.append(('X-Spam-Flag: Yes, tests=bogofilter, spamicity=(0\.999999|1\.000000)', mm_cfg.DISCARD, False))
+        hfr.append(('X-Spam-Flag: Yes, tests=bogofilter', mm_cfg.HOLD, False))
+    elif filterlevel is 3:
+        hfr.append(('X-Spam-Flag: Yes, tests=bogofilter', mm_cfg.DISCARD, False))
+
+    # save configuration
+    if mlist.header_filter_rules != hfr:
+        mlist.header_filter_rules = hfr
+    return 1
 
 #-------------------------------------------------------------------------------
 # admin procedures [ soptions.php ]
@@ -771,15 +715,20 @@ def set_bogo_level(userdesc, perms, vhost, listname, level):
 admin_opts = [ 'advertised', 'archive', \
         'max_message_size', 'msg_footer', 'msg_header']
 
-def get_admin_options(userdesc, perms, vhost, listname):
-    if perms != 'admin':
-        return 0
-    return get_options(userdesc, perms, vhost, listname.lower(), admin_opts)
+def get_admin_options(userdesc, perms, mlist):
+    """ Get administrator options.
+            @mlist
+            @root
+    """
+    return get_options(userdesc, perms, mlist, admin_opts)
 
-def set_admin_options(userdesc, perms, vhost, listname, values):
-    if perms != 'admin':
-        return 0
-    return set_options(userdesc, perms, vhost, listname.lower(), admin_opts, values)
+def set_admin_options(userdesc, perms, mlist, values):
+    """ Set administrator options.
+            @mlist
+            @edit
+            @root
+    """
+    return set_options(userdesc, perms, mlist, admin_opts, values)
 
 #-------------------------------------------------------------------------------
 # admin procedures [ check.php ]
@@ -826,38 +775,37 @@ check_opts = {
     'unsubscribe_policy'            : 0,
 }
 
+def check_options_runner(userdesc, perms, mlist, listname, correct):
+    options = { }
+    for (k, v) in check_opts.iteritems():
+        if mlist.__dict__[k] != v:
+            options[k] = v, mlist.__dict__[k]
+            if correct: mlist.__dict__[k] = v
+    if mlist.real_name.lower() != listname:
+        options['real_name'] = listname, mlist.real_name
+        if correct: mlist.real_name = listname
+    details = get_list_info(userdesc, perms, mlist)[0]
+    return (details, options)
+
+
 def check_options(userdesc, perms, vhost, listname, correct=False):
+    """ Check the list.
+            @root
+    """
     listname = listname.lower()
-    try:
-        mlist = MailList.MailList(vhost+VHOST_SEP+listname, lock=0)
-    except:
-        return 0
-    try:
-        if perms != 'admin': return 0
-        if correct:
-            mlist.Lock()
-        options = { }
-        for (k, v) in check_opts.iteritems():
-            if mlist.__dict__[k] != v:
-                options[k] = v, mlist.__dict__[k]
-                if correct: mlist.__dict__[k] = v
-        if mlist.real_name.lower() != listname:
-            options['real_name'] = listname, mlist.real_name
-            if correct: mlist.real_name = listname
-        if correct:
-            mlist.Save()
-            mlist.Unlock()
-        details = get_list_info(userdesc, perms, mlist)[0]
-        return (details, options)
-    except:
-        if correct: mlist.Unlock()
-        return 0
+    mlist = MailList.MailList(vhost + VHOST_SEP + listname, lock=0)
+    if correct:
+        return list_call_locked(check_options_runner, userdesc, perms, mlist, True, listname, True)
+    else:
+        return check_options_runner(userdesc, perms, mlist, listname, False)
 
 #-------------------------------------------------------------------------------
 # super-admin procedures
 #
 
 def get_all_lists(userdesc, perms, vhost):
+    """ Get all the list for the given vhost
+    """
     prefix = vhost.lower()+VHOST_SEP
     names = Utils.list_names()
     names.sort()
@@ -869,9 +817,10 @@ def get_all_lists(userdesc, perms, vhost):
     return result
 
 def create_list(userdesc, perms, vhost, listname, desc, advertise, modlevel, inslevel, owners, members):
-    if perms != 'admin':
-        return 0
-    name = vhost.lower()+VHOST_SEP+listname.lower();
+    """ Create a new list.
+            @root
+    """
+    name = vhost.lower() + VHOST_SEP + listname.lower();
     if Utils.list_exists(name):
         return 0
 
@@ -916,66 +865,59 @@ def create_list(userdesc, perms, vhost, listname, desc, advertise, modlevel, ins
         mlist.header_filter_rules = []
         mlist.header_filter_rules.append(('X-Spam-Flag: Unsure, tests=bogofilter', mm_cfg.HOLD, False))
         mlist.header_filter_rules.append(('X-Spam-Flag: Yes, tests=bogofilter', mm_cfg.HOLD, False))
-
         mlist.Save()
-
         mlist.Unlock()
 
         if ON_CREATE_CMD != '':
             try:    os.system(ON_CREATE_CMD + ' ' + name)
             except: pass
 
-        check_options(userdesc, perms, vhost, listname.lower(), True)
-        mass_subscribe(userdesc, perms, vhost, listname.lower(), members)
+        check_options(userdesc, perms, mlist, True)
+        mass_subscribe(userdesc, perms, mlist, members)
 
         # avoid the "-1 mail to moderate" bug
         mlist = MailList.MailList(name)
         mlist._UpdateRecords()
         mlist.Save()
-        mlist.Unlock()
-    except:
-        try:
-            mlist.Unlock()
-        except:
-            pass
-        return 0
-    return 1
 
-def delete_list(userdesc, perms, vhost, listname, del_archives=0):
-    lname = vhost+VHOST_SEP+listname.lower()
-    try:
-        mlist = MailList.MailList(lname, lock=0)
-    except:
-        return 0
-    try:
-        if not is_admin_on(userdesc, perms, mlist):
-            return 0
-        # remove the list
-        REMOVABLES = [ os.path.join('lists', lname), ]
-        # remove stalled locks
-        for filename in os.listdir(mm_cfg.LOCK_DIR):
-            fn_lname = filename.split('.')[0]
-            if fn_lname == lname:
-                REMOVABLES.append(os.path.join(mm_cfg.LOCK_DIR, filename))
-        # remove archives ?
-        if del_archives:
-            REMOVABLES.extend([
-                    os.path.join('archives', 'private', lname),
-                    os.path.join('archives', 'private', lname+'.mbox'),
-                    os.path.join('archives', 'public',  lname),
-                    os.path.join('archives', 'public',  lname+'.mbox')
-                ])
-        map(lambda dir: remove_it(lname, os.path.join(mm_cfg.VAR_PREFIX, dir)), REMOVABLES)
         return 1
-    except:
-        return 0
+    finally:
+        mlist.Unlock()
+    return 0
+
+def delete_list(userdesc, perms, mlist, del_archives=0):
+    """ Delete the list.
+            @mlist
+            @admin
+    """
+    lname = mlist.internal_name()
+    # remove the list
+    REMOVABLES = [ os.path.join('lists', lname), ]
+    # remove stalled locks
+    for filename in os.listdir(mm_cfg.LOCK_DIR):
+        fn_lname = filename.split('.')[0]
+        if fn_lname == lname:
+            REMOVABLES.append(os.path.join(mm_cfg.LOCK_DIR, filename))
+    # remove archives ?
+    if del_archives:
+        REMOVABLES.extend([
+                os.path.join('archives', 'private', lname),
+                os.path.join('archives', 'private', lname+'.mbox'),
+                os.path.join('archives', 'public',  lname),
+                os.path.join('archives', 'public',  lname+'.mbox')
+            ])
+    map(lambda dir: remove_it(lname, os.path.join(mm_cfg.VAR_PREFIX, dir)), REMOVABLES)
+    return 1
 
 def kill(userdesc, perms, vhost, alias, del_from_promo):
+    """ Remove a user from all the lists.
+    """
     exclude = []
     if not del_from_promo:
-        exclude.append(PLATAL_DOMAIN+VHOST_SEP+'promo'+alias[-4:])
+        exclude.append(PLATAL_DOMAIN + VHOST_SEP + 'promo' + alias[-4:])
     for list in Utils.list_names():
-        if list in exclude: continue
+        if list in exclude:
+            continue
         try:
             mlist = MailList.MailList(list, lock=0)
         except:
@@ -1029,7 +971,7 @@ lock = Lock()
 #-------------------------------------------------------------------------------
 # server
 #
-server = FastXMLRPCServer(("localhost", 4949), BasicAuthXMLRPCRequestHandler)
+server = FastXMLRPCServer((SRV_HOST, SRV_PORT), BasicAuthXMLRPCRequestHandler)
 
 # index.php
 server.register_function(get_lists)
index bebe4aa..f020535 100644 (file)
@@ -73,7 +73,7 @@ class XnetPage extends PlPage
         $menu = array();
 
         $sub = array();
-        $sub['liste des groupes'] = 'plan';
+        $sub['tous les groupes'] = 'plan';
         $sub['documentation']     = 'Xnet';
         $sub['signaler un bug']   = array('href' => 'send_bug/'.$_SERVER['REQUEST_URI'], 'class' => 'popup_840x600');
         $menu["no_title"]   = $sub;
index 4a96f12..a1a6cf8 100644 (file)
@@ -19,7 +19,7 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-class XnetSession extends PlSession
+class XnetSession extends XorgSession
 {
     public function __construct()
     {
@@ -124,32 +124,6 @@ class XnetSession extends PlSession
         return true;
     }
 
-    public function tokenAuth($login, $token)
-    {
-        // FIXME: we broke the session here because some RSS feeds (mainly wiki feeds) require
-        // a valid nome and checks the permissions. When the PlUser object will be ready, we'll
-        // be able to return a simple 'PlUser' object here without trying to alterate the
-        // session.
-        $res = XDB::query('SELECT  u.user_id AS uid, u.perms, u.nom, u.nom_usage, u.prenom, u.promo, FIND_IN_SET(\'femme\', u.flags) AS sexe
-                             FROM  aliases         AS a
-                       INNER JOIN  auth_user_md5   AS u ON (a.id = u.user_id AND u.perms IN ("admin", "user"))
-                       INNER JOIN  auth_user_quick AS q ON (a.id = q.user_id AND q.core_rss_hash = {?})
-                            WHERE  a.alias = {?} AND a.type != "homonyme"', $token, $login);
-        if ($res->numRows() == 1) {
-            $sess = $res->fetchOneAssoc();
-            if (!S::has('uid')) {
-                $_SESSION = $sess;
-                $this->makePerms($sess['perms']);
-                return S::i('uid');
-            } else if (S::i('uid') == $sess['uid']) {
-                return S::i('uid');
-            } else {
-                Platal::page()->kill('Invalid state. To be fixed when hruid is ready');
-            }
-        }
-        return null;
-    }
-
     public function doSelfSuid()
     {
         if (!$this->startSUID(S::i('uid'))) {
@@ -171,30 +145,6 @@ class XnetSession extends PlSession
         S::set('perms', $suid['perms']);
         return true;
     }
-
-    public function makePerms($perm)
-    {
-        $flags = new PlFlagSet();
-        if ($perm == 'disabled' || $perm == 'ext') {
-            S::set('perms', $flags);
-            return;
-        }
-        $flags->addFlag(PERMS_USER);
-        if ($perm == 'admin') {
-            $flags->addFlag(PERMS_ADMIN);
-        }
-        S::set('perms', $flags);
-    }
-
-    public function loggedLevel()
-    {
-        return AUTH_COOKIE;
-    }
-
-    public function sureLevel()
-    {
-        return AUTH_MDP;
-    }
 }
 
 // {{{ function may_update
index 3923847..7580684 100644 (file)
@@ -28,7 +28,7 @@ webservice_url = ""
 
 [Lists]
 rpchost   = "localhost"
-rpcport   = 4949
+rpcport   = "4949"
 
 spool     = "/var/lib/mailman/archives/private"
 vhost_sep = "_"
diff --git a/core b/core
index 2417392..5177a1b 160000 (submodule)
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit 24173926fa9e13ef5c3509645fca69e5304b0068
+Subproject commit 5177a1b50e47e7d62a66aba9565580af3abf15dd
index f76e148..70e0fed 100644 (file)
@@ -290,7 +290,7 @@ div.contact-list div.grayed {
 
 div.contact div.identity {
     float: left;
-    width: 89%;
+    width: 85%;
 }
 
 div.contact div.nom {
@@ -300,7 +300,7 @@ div.contact div.nom {
 div.contact div.bits {
     text-align: right;
     float: right;
-    width: 10%;
+    width: 14%;
 }
 
 div.contact div.long {
index 7f49044..315fc38 100644 (file)
@@ -51,7 +51,7 @@ function wizPage_onLoad(id)
             updateJobSecteur(i, 'job_' + i, 'jobs[' + i + ']',
                              document.forms.prof_annu["jobs[" + i + "][ss_secteur]"].value);
         }
-        registerEnterpriseAutocomplete(-1);
+        setTimeout('registerEnterpriseAutocomplete(-1)', 100);
         break;
     }
 }
index 6074fda..39580d2 100644 (file)
@@ -359,6 +359,7 @@ function get_user_details_adr($uid, $view = 'private') {
                      gp.pays AS countrytxt,a.region, a.regiontxt,
                      FIND_IN_SET('active', a.statut) AS active, a.adrid,
                      FIND_IN_SET('res-secondaire', a.statut) AS secondaire,
+                     FIND_IN_SET('courrier', a.statut) AS courier,
                      a.pub, gp.display, a.comment
                FROM  adresses AS a
           LEFT JOIN  geoloc_pays AS gp ON (gp.a2=a.country)
index f0c1ab0..ce536a4 100644 (file)
@@ -63,8 +63,7 @@ class SearchSet extends UserSet
 
     public function __construct($quick = false, $no_search = false, $join = '', $where = '')
     {
-        require_once dirname(__FILE__).'/../modules/search/search.inc.php';
-
+        Platal::load('search', 'search.inc.php');
         if ($no_search) {
             return;
         }
@@ -79,7 +78,7 @@ class SearchSet extends UserSet
 
     private function getQuick($join, $where)
     {
-        require_once dirname(__FILE__).'/../modules/search/search.inc.php';
+        Platal::load('search', 'search.inc.php');
         global $globals;
         if (!S::logged()) {
             Env::kill('with_soundex');
@@ -179,7 +178,7 @@ class MinificheView extends MultipageView
                 u.perms != 'pending' AS wasinscrit,
                 u.deces != 0 AS dcd, u.deces, u.matricule_ax,
                 FIND_IN_SET('femme', u.flags) AS sexe,
-                e.entreprise, es.label AS secteur, ef.fonction_fr AS fonction,
+                e.entreprise, e.web AS job_web, es.label AS secteur, ef.fonction_fr AS fonction,
                 IF(n1.nat='',n1.pays,n1.nat) AS nat1, n1.a2 AS iso3166_1,
                 IF(n2.nat='',n2.pays,n2.nat) AS nat2, n2.a2 AS iso3166_2,
                 IF(n3.nat='',n3.pays,n3.nat) AS nat3, n3.a2 AS iso3166_3,
index 35b79de..31a3515 100644 (file)
@@ -101,7 +101,7 @@ class ListeReq extends Validate
 
     protected function _mail_subj()
     {
-        return "[Polytechnique.org/LISTES] Demande de la liste {$this->liste}";
+        return "[Polytechnique.org/LISTES] Demande de la liste {$this->liste}@{$this->domain}";
     }
 
     // }}}
@@ -110,9 +110,9 @@ class ListeReq extends Validate
     protected function _mail_body($isok)
     {
         if ($isok) {
-            return "  La liste de diffusion {$this->liste} que tu avais demandée vient d'être créée.";
+            return "  La liste de diffusion {$this->liste}@{$this->domain} que tu avais demandée vient d'être créée.";
         } else {
-            return "  La demande que tu avais faite pour la liste de diffusion {$this->liste} a été refusée.";
+            return "  La demande que tu avais faite pour la liste de diffusion {$this->liste}@{$this->domain} a été refusée.";
         }
     }
 
index 98d14d2..599ba21 100644 (file)
@@ -101,7 +101,7 @@ class MedalReq extends Validate
     public function commit ()
     {
         require_once 'notifs.inc.php';
-        register_watch_op($this->uid, WATCH_FICHE, 'medals');
+        register_watch_op($this->uid, WATCH_FICHE, '', 'medals');
         return XDB::execute('REPLACE INTO  profile_medals_sub
                                    VALUES  ({?}, {?}, {?})',
                             $this->uid, $this->mid, $this->gid);
index 788d7c6..15f3e8e 100644 (file)
@@ -110,7 +110,7 @@ class UsageReq extends Validate
     public function commit()
     {
         require_once 'notifs.inc.php';
-        register_watch_op($this->uid, WATCH_FICHE, 'nom');
+        register_watch_op($this->uid, WATCH_FICHE, '', 'nom');
         require_once('user.func.inc.php');
         $this->bestalias = set_new_usage($this->uid, $this->nom_usage, $this->alias);
         return true;
index b2fc0a1..0f2d109 100644 (file)
@@ -141,7 +141,7 @@ class PhotoReq extends Validate
         XDB::execute('REPLACE INTO  photo (uid, attachmime, attach, x, y)
                             VALUES  ({?},{?},{?},{?},{?})',
                      $this->uid, $this->mimetype, $this->data, $this->x, $this->y);
-        register_watch_op($this->uid, WATCH_FICHE, 'photo');
+        register_watch_op($this->uid, WATCH_FICHE, '', 'photo');
         return true;
     }
 
index 6083b25..2be89de 100644 (file)
 
 require_once('user.func.inc.php');
 
-class VCardIterator implements PlIterator
+class VCard extends PlVCard
 {
     private $user_list = array();
     private $count     = 0;
     private $freetext  = null;
     private $photos    = true;
 
-    public function __construct($photos, $freetext)
+    public function __construct($photos = true, $freetext = null)
     {
+        PlVCard::$folding = false;
         $this->freetext = $freetext;
         $this->photos   = $photos;
     }
 
-    public function add_user($user)
+    public function addUser($user)
     {
         $forlife = get_user_forlife($user, '_silent_user_callback');
         if ($forlife) {
@@ -43,42 +44,94 @@ class VCardIterator implements PlIterator
         }
     }
 
-    public function first()
-    {
-        return count($this->user_list) == $this->count - 1;
-    }
-
-    public function last()
-    {
-        return count($this->user_list) == 0;
+    public function addUsers(array $users) {
+        foreach ($users as $user) {
+            $this->addUser($user);
+        }
     }
 
-    public function total()
+    protected function fetch()
     {
-        return $this->count;
+        return PlIteratorUtils::fromArray($this->user_list);
     }
 
-    public function next()
+    protected function buildEntry($entry)
     {
-        if (!$this->user_list) {
-            return null;
-        }
         global $globals;
-        $login = array_shift($this->user_list);
+        $login = $entry['value'];
         $user  = get_user_details($login);
 
-        if (strlen(trim($user['freetext']))) {
-            $user['freetext'] = pl_entity_decode($user['freetext']);
+        if (empty($user['nom_usage'])) {
+            $entry = new PlVCardEntry($user['prenom'], $user['nom'], null, null, @$user['nickname']);
+        } else {
+            $entry = new PlVCardEntry($user['prenom'], array($user['nom'], $user['nom_usage']), null, null, @$user['nickname']);
         }
+
+        // Free text
+        $freetext = '(' . $user['promo'] . ')';
         if ($this->freetext) {
-            if (strlen(trim($user['freetext']))) {
-                $user['freetext'] = $this->freetext . "\n" . $user['freetext'];
-            } else {
-                $user['freetext'] = $this->freetext;
+            $freetext .= "\n" . $this->freetext;
+        }
+        if (strlen(trim($user['freetext']))) {
+            $freetext .= "\n" . MiniWiki::WikiToText($user['freetext']);
+        }
+        $entry->set('NOTE', $freetext);
+
+        // Mobile
+        if (!empty($user['mobile'])) {
+            $entry->addTel(null, $user['mobile'], false, true, true, false, true, true);
+        }
+
+        // Emails
+        $entry->addMail(null, $user['bestalias'] . '@' . $globals->mail->domain, true);
+        $entry->addMail(null, $user['bestalias'] . '@' . $globals->mail->domain2);
+        if ($user['bestalias'] != $user['forlife']) {
+            $entry->addMail(null, $user['forlife'] . '@' . $globals->mail->domain);
+            $entry->addMail(null, $user['forlife'] . '@' . $globals->mail->domain2);
+        }
+
+        // Homes
+        foreach ($user['adr'] as $adr) {
+            $street = array($adr['adr1']);
+            if (!empty($adr['adr2'])) {
+                $street[] = $adr['adr2'];
+            }
+            if (!empty($adr['adr3'])) {
+                $street[] = $adr['adr3'];
+            }
+            $group = $entry->addHome($street, null, null, $adr['postcode'], $adr['city'], $adr['region'], @$adr['country'],
+                                     $adr['active'], $adr['courier'], $adr['courier']);
+            if (!empty($adr['tels'])) {
+                foreach ($adr['tels'] as $tel) {
+                    $fax = $tel['tel_type'] == 'Fax';
+                    $entry->addTel($group, $tel['tel'], $fax, !$fax, !$fax, false, false, !$fax && $adr['active'] && empty($user['mobile']));
+                }
+            }
+        }
+
+        // Pro
+        foreach ($user['adr_pro'] as $pro) {
+            $street = array($adr['adr1']);
+            if (!empty($pro['adr2'])) {
+                $street[] = $pro['adr2'];
+            }
+            if (!empty($pro['adr3'])) {
+                $street[] = $pro['adr3'];
+            }
+            $group = $entry->addWork($pro['entreprise'], null, $pro['poste'], $pro['fonction'],
+                                     $street, null, null, $pro['postcode'], $pro['city'], $pro['region'], @$pro['country']);
+            if (!empty($pro['tel'])) {
+                $entry->addTel($group, $pro['tel']);
+            }
+            if (!empty($pro['fax'])) {
+                $entry->addTel($group, $pro['fax'], true);
+            }
+            if (!empty($pro['email'])) {
+                $entry->addMail($group, $pro['email']);
             }
         }
 
-        // alias virtual
+        // Melix
         $res = XDB::query(
                 "SELECT alias
                    FROM virtual
@@ -89,11 +142,22 @@ class VCardIterator implements PlIterator
                 $user['user_id'],
                 $user['forlife'].'@'.$globals->mail->domain,
                 $user['forlife'].'@'.$globals->mail->domain2);
+        if ($res->numRows()) {
+            $entry->addMail(null, $res->fetchOneCell());
+        }
+
+        // Custom fields
+        if (count($user['gpxs_name'])) {
+            $entry->set('X-GROUPS', join(', ', $user['gpxs_name']));
+        }
+        if (count($user['binets'])) {
+            $entry->set('X-BINETS', join(', ', $user['binets']));
+        }
+        if (!empty($user['section'])) {
+            $entry->set('X-SECTION', $user['section']);
+        }
 
-        $user['virtualalias'] = $res->fetchOneCell();
-        $user['gpxs_vcardjoin'] = join(', ', array_map(array('VCard', 'text_encode'), $user['gpxs_name']));
-        $user['binets_vcardjoin'] = join(', ', array_map(array('VCard', 'text_encode'), $user['binets']));
-        // get photo
+        // Photo
         if ($this->photos) {
             $res = XDB::query(
                     "SELECT attach, attachmime
@@ -101,80 +165,12 @@ class VCardIterator implements PlIterator
                  INNER JOIN aliases AS a ON (a.id = p.uid AND a.type = 'a_vie')
                       WHERE a.alias = {?}", $login);
             if ($res->numRows()) {
-                $user['photo'] = $res->fetchOneAssoc();
-            }
-        }
-        return $user;
-    }
-}
-
-class VCard
-{
-    static private $windows = false;
-    private $iterator = null;
-
-    public function __construct($users, $photos = true, $freetext = null)
-    {
-        $this->iterator = new VCardIterator($photos, $freetext);
-        VCard::$windows  = (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false);
-        if (is_array($users)) {
-            foreach ($users as $user) {
-                $this->iterator->add_user($user);
+                list($data, $type) = $res->fetchOneRow();
+                $entry->setPhoto($data, strtoupper($type));
             }
-        } else {
-            $this->iterator->add_user($users);
-        }
-    }
-
-    public static function escape($text)
-    {
-        if (VCard::$windows) {
-            return str_replace(';', '\\\\;', $text);
-        } else {
-            return str_replace(array(';', ','), array('\\\\;', '\\\\,'), $text);
-        }
-    }
-
-    public static function format_adr($params, &$smarty)
-    {
-        // $adr1, $adr2, $adr3, $postcode, $city, $region, $country
-        extract($params['adr']);
-        $adr = trim($adr1);
-        $adr = trim("$adr\n$adr2");
-        $adr = trim("$adr\n$adr3");
-        return VCard::text_encode(';;'
-                . (VCard::$windows ? VCard::escape($adr) : $adr) . ';'
-                . (VCard::$windows ? VCard::escape($city) : $city) . ';'
-                . (VCard::$windows ? VCard::escape($region) : $region) . ';'
-                . (VCard::$windows ? VCard::escape($postcode) : $postcode) . ';'
-                . (VCard::$windows ? VCard::escape($country) : $country), false);
-    }
-
-    public static function text_encode($text, $escape = true)
-    {
-        if (is_array($text)) {
-            return implode(',', array_map(array('VCard', 'text_encode'), $text));
-        }
-        if ($escape) {
-            $text = VCard::escape($text);
         }
-        if (VCard::$windows) {
-            $text = utf8_decode($text);
-        }
-        return str_replace(array("\r\n", "\n", "\r"), '\n', $text);
+        return $entry;
     }
-
-    public function do_page(&$page)
-    {
-        $page->changeTpl('core/vcard.tpl', NO_SKIN);
-        $page->register_modifier('vcard_enc',  array($this, 'text_encode'));
-        $page->register_function('format_adr', array($this, 'format_adr'));
-        $page->assign_by_ref('users', $this->iterator);
-
-        header("Pragma: ");
-        header("Cache-Control: ");
-        header("Content-type: text/x-vcard; charset=UTF-8");
-  }
 }
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
index d577057..ce4b16c 100644 (file)
@@ -37,13 +37,6 @@ class CarnetModule extends PLModule
         );
     }
 
-    function on_subscribe($forlife, $uid, $promo, $password)
-    {
-        require_once 'notifs.inc.php';
-        register_watch_op($uid, WATCH_INSCR);
-        inscription_notifs_base($uid);
-    }
-
     function _add_rss_link(&$page)
     {
         if (!S::has('core_rss_hash')) {
@@ -260,7 +253,7 @@ class CarnetModule extends PLModule
             require_once 'userset.inc.php';
             $base = 'carnet/contacts/search';
 
-            require_once(dirname(__FILE__) . '/search/classes.inc.php');
+            Platal::load('search', 'classes.inc.php');
             ThrowError::$throwHook = array($this, 'searchErrorHandler');
             $view = new SearchSet(true, false, "INNER JOIN contacts AS c2 ON (u.user_id = c2.contact)", "c2.uid = $uid");
         } else {
@@ -371,8 +364,9 @@ class CarnetModule extends PLModule
         $res = XDB::query('SELECT contact
                              FROM contacts
                             WHERE uid = {?}', S::v('uid'));
-        $vcard = new VCard($res->fetchColumn(), $photos == 'photos');
-        $vcard->do_page(&$page);
+        $vcard = new VCard($photos == 'photos');
+        $vcard->addUsers($res->fetchColumn());
+        $vcard->show();
     }
 }
 
index 68f7fcf..fad227c 100644 (file)
@@ -29,7 +29,7 @@ class CarnetFeedIterator implements PlIterator
     public function __construct(Notifs& $notifs)
     {
         $this->notifs =& $notifs;
-        $this->it = new PlArrayIterator($notifs->_data, 3);
+        $this->it = PlIteratorUtils::fromArray($notifs->_data, 3);
     }
 
     public function next()
index 80ea2fd..e67966d 100644 (file)
@@ -24,38 +24,12 @@ class ForumsModule extends PLModule
     function handlers()
     {
         return array(
-            'banana'              => $this->make_hook('banana', AUTH_COOKIE),
-            'banana/rss'          => $this->make_hook('rss', AUTH_PUBLIC, 'user', NO_HTTPS),
+            'banana'         => $this->make_hook('banana', AUTH_COOKIE),
+            'banana/rss'     => $this->make_hook('rss', AUTH_PUBLIC, 'user', NO_HTTPS),
             'admin/forums'   => $this->make_hook('forums_bans', AUTH_MDP, 'admin'),
         );
     }
 
-    function on_subscribe($forlife, $uid, $promo, $password)
-    {
-        $cible = array('xorg.general', 'xorg.pa.divers', 'xorg.pa.logements');
-        $p_for = "xorg.promo.x$promo";
-
-        // récupération de l'id du forum promo
-        $res = XDB::query("SELECT fid FROM forums.list WHERE nom={?}", $p_for);
-        if ($res->numRows()) {
-            $cible[] = $p_for;
-        } else { // pas de forum promo, il faut le créer
-            $res = XDB::query("SELECT  SUM(perms IN ('admin','user') AND deces=0),COUNT(*)
-                                 FROM  auth_user_md5 WHERE promo={?}", $promo);
-            list($effau, $effid) = $res->fetchOneRow();
-            if (5*$effau>$effid) { // + de 20% d'inscrits
-                $mymail = new PlMailer('admin/forums-promo.mail.tpl');
-                $mymail->assign('promo', $promo);
-                $mymail->send();
-            }
-        }
-
-        while (list ($key, $val) = each ($cible)) {
-            XDB::execute("INSERT INTO  forums.abos (fid,uid)
-                               SELECT  fid,{?} FROM forums.list WHERE nom={?}", $uid, $val);
-        }
-    }
-
     function handler_banana(&$page, $group = null, $action = null, $artid = null)
     {
         $page->changeTpl('banana/index.tpl');
index a4ea356..36b247b 100644 (file)
@@ -46,12 +46,6 @@ class ListsModule extends PLModule
         );
     }
 
-    function on_subscribe($forlife, $uid, $promo, $password)
-    {
-        $this->prepare_client(null);
-        $this->client->subscribe("promo$promo");
-    }
-
     function prepare_client(&$page)
     {
         global $globals;
index e8ba7bf..322a13f 100644 (file)
@@ -759,8 +759,9 @@ class ProfileModule extends PLModule
             $x = substr($x, 0, strlen($x) - 4);
         }
 
-        $vcard = new VCard($x);
-        $vcard->do_page($page);
+        $vcard = new VCard();
+        $vcard->addUser($x);
+        $vcard->show();
     }
 
     function handler_admin_trombino(&$page, $uid = null, $action = null) {
index 9a32e60..8d30088 100644 (file)
@@ -301,22 +301,43 @@ class RegisterModule extends PLModule
         $redirect->add_email($email);
 
         // on cree un objet logger et on log l'inscription
-        $logger = new PlLogger($uid);
-        S::logger()->log('inscription', $email);
-
+        S::logger($uid)->log('inscription', $email);
         XDB::execute('UPDATE register_pending SET hash="INSCRIT" WHERE uid={?}', $uid);
 
-        global $platal;
-        $platal->on_subscribe($forlife, $uid, $promo, $password);
 
         $mymail = new PlMailer('register/inscription.reussie.tpl');
         $mymail->assign('forlife', $forlife);
         $mymail->assign('prenom', $prenom);
         $mymail->send();
 
+        // Enable search on the user
         require_once('user.func.inc.php');
         user_reindex($uid);
 
+        // Add notification for people looking for this registration
+        require_once 'notifs.inc.php';
+        register_watch_op($uid, WATCH_INSCR);
+        inscription_notifs_base($uid);
+
+        // Default registration on forums
+        $p_for = 'xorg.promo.x' . $promo;
+        $cible = array('xorg.general', 'xorg.pa.divers', 'xorg.pa.logements', $p_for);
+        foreach ($cible as $val) {
+            XDB::execute("INSERT INTO  forums.abos (fid,uid)
+                               SELECT  fid, {?} FROM forums.list WHERE nom={?}", $uid, $val);
+            if (XDB::affectedRows() == 0 && $val == $p_for) {
+                $res = XDB::query("SELECT  SUM(perms IN ('admin','user') AND deces = 0), COUNT(*)
+                                     FROM  auth_user_md5
+                                    WHERE  promo = {?}", $promo);
+                list($effau, $effid) = $res->fetchOneRow();
+                if (5 * $effau > $effid) { // + 
+                    $mymail = new PlMailer('admin/forums-promo.mail.tpl');
+                    $mymail->assign('promo', $promo);
+                    $mymail->send();
+                }
+            }
+        }
+
         // update number of subscribers (perms has changed)
         $globals->updateNbIns();
 
@@ -464,7 +485,7 @@ class RegisterModule extends PLModule
             NewsLetter::subscribe();
         }
         if (Post::v('add_to_ax')) {
-            require_once dirname(__FILE__) . '/axletter/axletter.inc.php';
+            Platal::load('axletter', 'axletter.inc.php');
             AXLetter::subscribe();
         }
         if (Post::v('add_to_promo')) {
index f8e316e..2e913df 100644 (file)
@@ -38,13 +38,6 @@ class SearchModule extends PLModule
         exit;
     }
 
-    function on_subscribe($forlife, $uid, $promo, $pass)
-    {
-        require_once 'user.func.inc.php';
-        user_reindex($uid);
-    }
-
-
     function form_prepare()
     {
         Platal::page()->assign('formulaire',1);
index b7a9eef..afe992d 100644 (file)
@@ -237,6 +237,15 @@ class XnetGrpModule extends PLModule
             if (Post::has('notif_unsub') && Post::i('notif_unsub') == 1) {
                 $flags->addFlag('notif_unsub');
             }
+            $site = trim(Post::v('site'));
+            if ($site && ($site != "http://")) {
+                $scheme = parse_url($site, PHP_URL_SCHEME);
+                if (!$scheme) {
+                    $site = "http://" . $site;
+                }
+            } else {
+                $site = "";
+            }
             if (S::has_perms()) {
                 if (Post::v('mail_domain') && (strstr(Post::v('mail_domain'), '.') === false)) {
                     $page->trigError("le domaine doit être un FQDN (aucune modif effectuée) !!!");
@@ -252,7 +261,7 @@ class XnetGrpModule extends PLModule
                       WHERE  id={?}",
                       Post::v('nom'), Post::v('diminutif'),
                       Post::v('cat'), Post::i('dom'),
-                      Post::v('descr'), Post::v('site'),
+                      Post::v('descr'), $site,
                       Post::v('mail'), Post::v('resp'),
                       Post::v('forum'), Post::v('mail_domain'),
                       Post::has('ax'), Post::v('pub'),
@@ -269,7 +278,7 @@ class XnetGrpModule extends PLModule
                              forum={?}, ax={?}, pub= {?}, sub_url={?},
                              unsub_url={?},flags={?}
                       WHERE  id={?}",
-                      Post::v('descr'), Post::v('site'),
+                      Post::v('descr'), $site,
                       Post::v('mail'), Post::v('resp'),
                       Post::v('forum'), Post::has('ax'),
                       Post::v('pub'),
@@ -479,8 +488,9 @@ class XnetGrpModule extends PLModule
         $res = XDB::query('SELECT  uid
                              FROM  groupex.membres
                             WHERE  asso_id = {?}', $globals->asso('id'));
-        $vcard = new VCard($res->fetchColumn(), $photos == 'photos', 'Membre du groupe ' . $globals->asso('nom'));
-        $vcard->do_page($page);
+        $vcard = new VCard($photos == 'photos', 'Membre du groupe ' . $globals->asso('nom'));
+        $vcard->addUsers($res->fetchColumn());
+        $vcard->show();
     }
 
     function handler_csv(&$page, $filename = null)
index 3c71652..de5392d 100644 (file)
@@ -19,7 +19,7 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-require_once dirname(__FILE__).'/lists.php';
+Platal::load('lists');
 
 class XnetListsModule extends ListsModule
 {
@@ -56,8 +56,7 @@ class XnetListsModule extends ListsModule
     function prepare_client(&$page)
     {
         global $globals;
-
-        require_once dirname(__FILE__).'/lists/lists.inc.php';
+        Platal::load('lists', 'lists.inc.php');
 
         $this->client = new MMList(S::v('uid'), S::v('password'),
                                    $globals->asso('mail_domain'));
index 60a9a8e..9e7edd5 100644 (file)
@@ -21,7 +21,7 @@
 
 
 function select_nat($valeur, $pad=false) {
-    $sql = "SELECT a2 AS id,IF(nat='',pays,nat) AS text FROM geoloc_pays ORDER BY text";
+    $sql = "SELECT a2 AS id, IF(nat='', pays, nat) AS text FROM geoloc_pays WHERE nat IS NOT NULL ORDER BY text";
     $res = XDB::iterRow($sql);
     $sel = ' selected="selected"';
 
index 446d644..ef97c4c 100644 (file)
@@ -80,11 +80,11 @@ Il faut pour cela se rendre sur la page de <a href='carnet/notifs'>configuration
       {$promo[row].prenom} {$promo[row].nom}
       {/if}
     </td>
-    <td style="width:25%" {if $promo[row].data}rowspan="2"{/if}>
+    <td style="width:25%">
       {$promo[row].date|date_format}
     </td>
     {if $promo[row].data}
-    </tr><tr><td>{$promo[row].data|smarty:nodefaults}</td>
+    </tr><tr><td colspan="2">{$promo[row].data|smarty:nodefaults}</td>
     {/if}
   </tr>
   {/section}
index 00808ed..bc3a644 100644 (file)
@@ -76,6 +76,8 @@
         {if !$c.dcd}
     <a href="vcard/{$c.forlife}.vcf">{*
     *}{icon name=vcard title="Afficher la carte de visite"}</a>
+    <a href="mailto:{$c.forlife}@{#globals.mail.domain#}">{*
+    *}{icon name=email title="Envoyer un email"}</a>
           {if $show_action eq ajouter}
     <a href="carnet/contacts?action={$show_action}&amp;user={$c.forlife}&amp;token={xsrf_token}">{*
     *}{icon name=add title="Ajouter à mes contacts"}</a>
       <tr>
         <td class="lt">Profession&nbsp;:</td>
         <td class="rt">
-          {$c.entreprise} {if $c.secteur}({$c.secteur}){/if}
-          {if $c.fonction}<br />{$c.fonction}{/if}
+          {if $c.job_web}<a href="{$c.job_web}">{$c.entreprise}</a>{else}{$c.entreprise}{/if}
+          {if $c.secteur}({$c.secteur}){/if} {if $c.fonction}<br />{$c.fonction}{/if}
         </td>
       </tr>
       {/if}
index c825ef8..a51f744 100644 (file)
@@ -23,7 +23,7 @@
 <table id="content" cellpadding="2" cellspacing="0">
   <tr>
     <td style="vertical-align: middle;">
-      <img src="images/parfait.jpg" width="459" height="200" alt="Logo des groupes" />
+      <a href="plan"><img src="images/parfait.jpg" width="459" height="200" alt="Logo des groupes" /></a>
     </td>
 
     <td>
index 470f688..ae9d761 100644 (file)
@@ -94,7 +94,7 @@
         Site web&nbsp;:
       </td>
       <td>
-        <input type="text" size="40" value="{$asso.site}" name="site" />
+        <input type="text" size="40" value="{$asso.site|default:"http://"}" name="site" />
       </td>
     </tr>
 
diff --git a/upgrade/0.9.18/00_edu.sql b/upgrade/0.9.18/00_edu.sql
new file mode 100644 (file)
index 0000000..812f473
--- /dev/null
@@ -0,0 +1,6 @@
+ALTER TABLE applis_ins MODIFY type enum('Corps','Ingénieur','MBA','ME','MS','PhD','Diplôme','DEA','MiF','MPA', 'MIA');
+
+ALTER TABLE applis_def MODIFY type set('Corps','Ingénieur','MBA','ME','MS','PhD','Diplôme','DEA','MiF','MPA', 'MIA')
+
+# vim:set syntax=mysql:
+
diff --git a/upgrade/0.9.18/01_nat.sql b/upgrade/0.9.18/01_nat.sql
new file mode 100644 (file)
index 0000000..7bed2d9
--- /dev/null
@@ -0,0 +1,8 @@
+alter table geoloc_pays change column nat nat varchar(100);
+update geoloc_pays
+   set nat = NULL
+ where a2 = 'MQ' or a2 = 'RE' or a2 = 'GP' or a2 = 'YT' or a2 = 'TF' or a2 = 'PF' or a2 = 'NC' or a2 = 'GF'
+       or a2 = 'UM';
+update auth_user_md5 set nationalite = 'FR' where nationalite = 'MQ' or nationalite = 'RE' or nationalite = 'GP' or nationalite = 'YT' or nationalite = 'TF' or nationalite = 'PF' or nationalite = 'NC' or nationalite = 'GF';
+
+# vim:set syntax=mysql: