Merge branch 'platal-0.9.17'
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Mon, 1 Sep 2008 19:32:50 +0000 (21:32 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Mon, 1 Sep 2008 19:32:50 +0000 (21:32 +0200)
194 files changed:
.gitmodules [new file with mode: 0644]
ChangeLog
Makefile
bin/connect.db.inc.php
bin/csv2sql.php
bin/emails.broken.helper.php
bin/emails.broken.php
bin/lists.create_promo.php
bin/lists.rpc.py
bin/search.rebuild_db.php
classes/.gitignore [new file with mode: 0644]
classes/corelogger.php [deleted file]
classes/csvimporter.php [deleted file]
classes/env.php [deleted file]
classes/flagset.php [deleted file]
classes/miniwiki.php [deleted file]
classes/platal.php [deleted file]
classes/platalglobals.php.in [new file with mode: 0644]
classes/platalpage.php [deleted file]
classes/plbacktrace.php [deleted file]
classes/pliterator.php [deleted file]
classes/plmailer.php [deleted file]
classes/plmodule.php [deleted file]
classes/plset.php [deleted file]
classes/pltableeditor.php [deleted file]
classes/plupload.php [deleted file]
classes/plwizard.php [deleted file]
classes/s.php [deleted file]
classes/session.php [deleted file]
classes/varstream.php [deleted file]
classes/xdb.php [deleted file]
classes/xmlrpcclient.php [deleted file]
classes/xnet.php
classes/xnetpage.php [moved from include/xnet/page.inc.php with 93% similarity]
classes/xnetsession.php [moved from include/xnet/session.inc.php with 65% similarity]
classes/xorg.php [moved from classes/mmlist.php with 75% similarity]
classes/xorgpage.php [moved from plugins/function.xsrf_token_field.php with 74% similarity]
classes/xorgsession.php [new file with mode: 0644]
configs/platal.ini
core [new submodule]
htdocs/css/default.css
htdocs/javascript/ajax.js
htdocs/listes_redirect.php
htdocs/webredirect.php
htdocs/xnet.php
htdocs/xorg.php
include/.gitignore [deleted file]
include/applis.func.inc.php
include/banana/forum.inc.php
include/banana/hooks.inc.php
include/banana/moderate.inc.php
include/common.inc.php [moved from plugins/modifier.miniwiki.php with 79% similarity]
include/emails.inc.php
include/globals.inc.php.in [deleted file]
include/marketing.inc.php
include/massmailer.inc.php
include/notifs.inc.php
include/platal.inc.php [deleted file]
include/rss.inc.php
include/security.inc.php [new file with mode: 0644]
include/synchro_ax.inc.php
include/user.func.inc.php
include/userset.inc.php
include/validations.inc.php
include/validations/listes.inc.php
include/validations/nomusage.inc.php
include/vcard.inc.php
include/wiki.inc.php [deleted file]
include/wiki/engine.php [deleted file]
include/xnet.inc.php
include/xorg.inc.php
include/xorg.misc.inc.php [deleted file]
include/xorg/session.inc.php [deleted file]
modules/admin.php
modules/auth.php
modules/axletter.php
modules/carnet.php
modules/carnet/feed.inc.php [new file with mode: 0644]
modules/core.php [deleted file]
modules/email.php
modules/events.php
modules/events/feed.inc.php [moved from classes/plprofiler.php with 53% similarity]
modules/forums.php
modules/gadgets/gadgets.inc.php
modules/geoloc.php
modules/googleapps.php
modules/lists.php
modules/marketing.php
modules/newsletter.php
modules/payment.php
modules/payment/money.inc.php
modules/payment/money/cyberpaiement.inc.php
modules/payment/money/paypal.inc.php
modules/platal.php
modules/platal/review.inc.php
modules/profile.php
modules/profile/addresses.inc.php
modules/profile/decos.inc.php
modules/profile/general.inc.php
modules/profile/groups.inc.php
modules/profile/jobs.inc.php
modules/profile/mentor.inc.php
modules/profile/page.inc.php
modules/profile/skills.inc.php
modules/register.php
modules/register/register.inc.php
modules/search.php
modules/search/classes.inc.php
modules/search/search.inc.php
modules/survey.php
modules/xnet.php
modules/xnetevents.php
modules/xnetevents/xnetevents.inc.php
modules/xnetgrp.php
modules/xnetgrp/feed.inc.php [new file with mode: 0644]
modules/xnetlists.php
plugins/block.tidy.php [deleted file]
plugins/compiler.checkpasswd.php [deleted file]
plugins/compiler.icon.php
plugins/compiler.iterate.php [deleted file]
plugins/compiler.javascript.php [deleted file]
plugins/function.make_forlife.php
plugins/function.select_db_table.php [deleted file]
plugins/function.select_nat.php
plugins/function.valid_date.php [deleted file]
plugins/function.xsrf_token.php [deleted file]
plugins/modifier.date_format.php [deleted file]
plugins/modifier.htmlentities.php [deleted file]
plugins/modifier.number_format.php [deleted file]
plugins/modifier.uint_to_ip.php [deleted file]
templates/admin/promo.tpl
templates/axletter/admin.tpl
templates/banana/index.tpl
templates/carnet/mescontacts.tpl
templates/carnet/notif.mail.tpl
templates/carnet/notifs.tpl
templates/carnet/panel.tpl
templates/carnet/rss.tpl
templates/core/403.tpl [deleted file]
templates/core/404.tpl [deleted file]
templates/core/bug.tpl [deleted file]
templates/core/password_prompt.tpl
templates/core/password_prompt_logged.tpl
templates/core/plset.tpl [deleted file]
templates/core/plwizard.tpl [deleted file]
templates/core/table-editor.tpl [deleted file]
templates/core/vcard.tpl [deleted file]
templates/core/wiki.help.tpl [deleted file]
templates/core/wiki.tpl [deleted file]
templates/emails/redirect.tpl
templates/events/admin_tips.tpl
templates/events/rss.tpl
templates/forums/admin.tpl
templates/gadgets/ig-minifiche.tpl
templates/googleapps/index.tpl
templates/include/csv-importer.tpl [deleted file]
templates/include/emploi.tpl
templates/include/flags.radio.tpl
templates/include/minifiche.tpl
templates/include/plview.multipage.tpl [deleted file]
templates/lists/annu.tpl
templates/lists/check.tpl
templates/lists/moderate_sub.tpl
templates/marketing/private.tpl
templates/marketing/promo.tpl
templates/payment/index.tpl
templates/platal/filrss.tpl
templates/platal/motdepasse.tpl
templates/profile/admin_decos.tpl
templates/profile/deco.tpl
templates/profile/general.tpl
templates/profile/groups.tpl
templates/profile/mentor.tpl
templates/profile/referent.tpl
templates/register/step2.tpl
templates/search/adv.form.tpl
templates/search/index.tpl
templates/skin/common.backtrace.tpl [deleted file]
templates/skin/common.content.tpl
templates/skin/common.devel.tpl
templates/skin/common.header.tpl
templates/skin/common.triggers.tpl [deleted file]
templates/survey/error.tpl
templates/xnet/index.tpl
templates/xnet/skin.tpl
templates/xnetevents/edit.tpl
templates/xnetgrp/announce-rss.tpl
templates/xnetgrp/annuaire.tpl
templates/xnetgrp/asso.tpl
templates/xnetgrp/edit.tpl
templates/xnetgrp/membres-add.tpl
templates/xnetgrp/membres-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]

diff --git a/.gitmodules b/.gitmodules
new file mode 100644 (file)
index 0000000..7c16f52
--- /dev/null
@@ -0,0 +1,3 @@
+[submodule "core"]
+       path = core
+       url = ./
index 740a280..ae3c74f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,14 @@
 ================================================================================
+VERSION 0.9.18                                                        XX XX XXXX
+
+Bug/Wish:
+
+    * Search:
+        - #691: Adds search on postcode and thus on "arrondissements"      -JAC
+        - #791: Adds the possibility to do an exact search                 -JAC
+        - #822: Adds the possibility to search on diplomas                 -JAC
+
+================================================================================
 VERSION 0.9.17                                                        19 07 2008
 
 New:
index 0b6b37b..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 include/globals.inc.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 $@
@@ -134,7 +142,7 @@ JQUERY_PLUGINS_PATHES=$(addprefix htdocs/javascript/jquery.,$(addsuffix .js,$(JQ
 
 jquery: htdocs/javascript/jquery.js htdocs/javascript/jquery.autocomplete.js $(JQUERY_PLUGINS_PATHES)
 
-htdocs/javascript/jquery.js: DOWNLOAD_SRC = http://jquery.com/src/jquery-latest.pack.js
+htdocs/javascript/jquery.js: DOWNLOAD_SRC = http://jquery.com/src/jquery-latest.min.js
 htdocs/javascript/jquery.js:
        @$(download)
 
@@ -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 f13dfa1..0d8015e 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-ini_set('include_path',dirname(__FILE__).'/../include:' . dirname(__FILE__).'/../classes:/usr/share/php');
-
+ini_set('include_path', dirname(__FILE__) . '/../core/include:'
+                      . dirname(__FILE__) . '/../include:'
+                      . dirname(__FILE__) . '/../core/classes:'
+                      . dirname(__FILE__) . '/../classes:'
+                      . '/usr/share/php');
 require_once('xorg.inc.php');
-require_once('xorg.misc.inc.php');
 
-require_once 'xdb.php';
+new Xorg('core');
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
 ?>
index e768aab..9820fbf 100755 (executable)
@@ -20,7 +20,7 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-require_once(dirname(__FILE__) . '/../classes/csvimporter.php');
+require_once(dirname(__FILE__) . '/../core/classes/csvimporter.php');
 
 // {{{ function showHelp()
 
@@ -86,7 +86,7 @@ $action          = CSV_INSERT;
 $keys            = 'id';
 
 processArgs();
-require_once(dirname(__FILE__) . '/../classes/xdb.php');
+require_once(dirname(__FILE__) . '/../core/classes/xdb.php');
 
 $source          = file_get_contents($sourceName);
 $insert_relation = null;
index c88db0b..9534e0e 100755 (executable)
@@ -23,7 +23,6 @@
 ini_set('include_path', '.:../include:/usr/share/php');
 
 require_once('connect.db.inc.php');
-require_once('xorg.inc.php');
 require_once('emails.inc.php');
 
 $opts = getopt('o:');
index 358fe0a..d371854 100755 (executable)
@@ -23,7 +23,6 @@
 ini_set('include_path', '.:../include:/usr/share/php');
 
 require_once('connect.db.inc.php');
-require_once('xorg.inc.php');
 require_once('emails.inc.php');
 require_once('../classes/plmailer.php');
 
index 7296798..34eb213 100755 (executable)
@@ -1,6 +1,7 @@
 #!/usr/bin/php5 -q
 <?php
-require_once("xorg.inc.php");
+
+require_once(dirname(__FILE__) . '/connect.db.inc.php');
 require_once('validations.inc.php');
 
 global $globals;
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 3835a9d..c201f21 100755 (executable)
@@ -29,7 +29,7 @@ $globals->debug = 0; // Do not store backtraces
 XDB::execute('DELETE FROM search_name');
 $res = XDB::iterRow('SELECT  auth_user_md5.user_id, nom, prenom, nom_usage, profile_nick
                        FROM  auth_user_md5
-                  LEFT JOIN auth_user_quick USING(user_id)');
+                  LEFT JOIN  auth_user_quick USING(user_id)');
 $i = 0;
 $muls = array(1, 1, 1, 0.2);
 $pub  = array(true, true, true, false);
diff --git a/classes/.gitignore b/classes/.gitignore
new file mode 100644 (file)
index 0000000..b478258
--- /dev/null
@@ -0,0 +1 @@
+/platalglobals.php
diff --git a/classes/corelogger.php b/classes/corelogger.php
deleted file mode 100644 (file)
index 8d06056..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-<?php
-/*
- * Copyright (C) 2003-2004 Polytechnique.org
- * http://opensource.polytechnique.org/
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-class CoreLogger
-{
-    /** user id */
-    public $uid;
-    /** id of the session */
-    private $session;
-    /** list of available actions */
-    private $actions;
-
-    public $ip;
-    public $host;
-    public $proxy_ip;
-    public $proxy_host;
-
-    /** The constructor, creates a new entry in the sessions table
-     *
-     * @param $uid the id of the logged user
-     * @param $suid the id of the administrator who has just su'd to the user
-     * @return VOID
-     */
-    public function __construct($uid, $suid = 0)
-    {
-        // write the session entry
-        $this->uid     = $uid;
-        $this->session = $this->writeSession($uid, $suid);
-
-        // retrieve available actions
-        $res = XDB::iterRow("SELECT id, text FROM logger.actions");
-
-        while (list($action_id, $action_text) = $res->next()) {
-            $this->actions[$action_text] = $action_id;
-        }
-    }
-
-    /** Creates a new session entry in database and return its ID.
-     *
-     * @param $uid the id of the logged user
-     * @param $suid the id of the administrator who has just su'd to the user
-     * @return session the session id
-     */
-    private function writeSession($uid, $suid = 0)
-    {
-        $ip      = $_SERVER['REMOTE_ADDR'];
-        $host    = strtolower(gethostbyaddr($_SERVER['REMOTE_ADDR']));
-        $browser = (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '');
-
-        @list($forward_ip,) = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
-        $forward_host = $forward_ip;
-        if ($forward_host) {
-            $forward_host = strtolower(gethostbyaddr($forward_host));
-        }
-        $proxy = '';
-        if ($forward_ip || @$_SERVER['HTTP_VIA']) {
-            $proxy = 'proxy';
-        }
-
-        XDB::execute("INSERT INTO logger.sessions
-                         SET uid={?}, host={?}, ip={?}, forward_ip={?}, forward_host={?}, browser={?}, suid={?}, flags={?}",
-                     $uid, $host, ip_to_uint($ip), ip_to_uint($forward_ip), $forward_host, $browser, $suid, $proxy);
-        if ($forward_ip) {
-            $this->proxy_ip = $ip;
-            $this->proxy_host = $host;
-            $this->ip = $forward_ip;
-            $this->host = $forward_host;
-        } else {
-            $this->ip = $ip;
-            $this->host = $host;
-        }
-
-        return XDB::insertId();
-    }
-
-
-    /** Logs an action and its related data.
-     *
-     * @param $action le type d'action
-     * @param $data les données (id de liste, etc.)
-     * @return VOID
-     */
-    public function log($action, $data = null)
-    {
-        if (isset($this->actions[$action])) {
-            XDB::execute("INSERT INTO logger.events
-                             SET session={?}, action={?}, data={?}",
-                         $this->session, $this->actions[$action], $data);
-        } else {
-            trigger_error("CoreLogger: unknown action, $action", E_USER_WARNING);
-        }
-    }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/csvimporter.php b/classes/csvimporter.php
deleted file mode 100644 (file)
index 571d227..0000000
+++ /dev/null
@@ -1,355 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-define('CSV_INSERT',     'insert'); // INSERT IGNORE
-define('CSV_REPLACE',    'replace'); // REPLACE
-define('CSV_UPDATE',     'update'); // INSERT and UPDATE on error
-define('CSV_UPDATEONLY', 'updateonly'); // UPDATE
-
-class CSVImporter
-{
-    private $table;
-    private $key;
-    private $do_sql;
-
-    private $index;
-    private $data = array();
-
-    private $user_functions = array();
-    private $field_desc = array();
-    private $field_value = array();
-
-    public function __construct($table, $key = 'id', $do_sql = true)
-    {
-        $this->table     = $table;
-        $this->key       = explode(',', $key);
-        $this->do_sql    = $do_sql;
-    }
-
-    private function processLine(array $array)
-    {
-        if (is_null($this->index)) {
-            $this->index = array_map('strtolower', $array);
-            return true;
-        }
-
-        if (count($array) != count($this->index)) {
-            return false;
-        }
-        $assoc = array();
-        $i     = 0;
-        foreach ($this->index as $key) {
-            $assoc[$key] = $array[$i];
-            $i++;
-        }
-        $this->data[] = $assoc;
-        return true;
-    }
-
-    private function getValue($line, $key, $action)
-    {
-        if (@array_key_exists($action, $line)) {
-            $value = $line[$action];
-        } elseif (is_callable($action, false)) {
-            $value = call_user_func($action, $line, $key);
-        } else {
-            $value = $action;
-        }
-        if (is_null($value) || $value == 'NULL') {
-            $value = 'NULL';
-        }
-        return $value;
-    }
-
-    private function makeAssoc($line, $relation)
-    {
-        $ops = array();
-        foreach ($relation as $key=>$ref) {
-            $ops[$key] = $this->getValue($line, $key, $ref);
-        }
-        return $ops;
-    }
-
-    private function makeRequestArgs($line, $relation)
-    {
-        $ops = array();
-        foreach ($relation as $key=>$ref) {
-            $value = $this->getValue($line, $key, $ref);
-            if (!is_null($value) && $value != 'NULL') {
-                $value = "'" . addslashes($value) . "'";
-            }
-            $ops[$key] = "$key = $value";
-        }
-        return $ops;
-    }
-
-    private function makeRelation()
-    {
-        $relation = array();
-        foreach ($this->index as $title) {
-            $relation[$title] = $title;
-        }
-        return $relation;
-    }
-
-    private function execute($query)
-    {
-        if (!$this->do_sql) {
-            echo "$query;\n";
-            return false;
-        }
-        return XDB::execute($query);
-    }
-
-    private function getFieldList()
-    {
-        $res = XDB::query("SHOW COLUMNS FROM {$this->table}");
-        if ($res->numRows()) {
-            return $res->fetchColumn();
-        }
-        return null;
-    }
-
-    public function setCSV($csv, $index = null, $separator = ';')
-    {
-        require_once dirname(__FILE__) . '/varstream.php';
-        VarStream::init();
-        global $csv_source;
-        $this->index     = null;
-
-        $csv_source = $csv;
-        $res        = fopen('var://csv_source', 'r');
-
-        while (!feof($res)) {
-            $this->processLine(fgetcsv($res, 0, $separator));
-        }
-    }
-
-    public function run($action = CSV_UPDATE, $insert_relation = null, $update_relation = null)
-    {
-        if (is_null($insert_relation)) {
-            $insert_relation = $this->makeRelation();
-        }
-        if (is_null($update_relation)) {
-            $update_relation = $insert_relation;
-        }
-        foreach ($this->data as $line) {
-            $set = join(', ', $this->makeRequestArgs($line, $insert_relation));
-            switch ($action) {
-              case CSV_INSERT:
-                $this->execute("INSERT IGNORE INTO {$this->table} SET $set");
-                break;
-              case CSV_REPLACE:
-                $this->execute("REPLACE INTO {$this->table} SET $set");
-                break;
-              case CSV_UPDATE: case CSV_UPDATEONLY:
-                if ($action == CSV_UPDATEONLY || !$this->execute("INSERT INTO {$this->table} SET $set")) {
-                    $ops = $this->makeRequestArgs($line, $update_relation);
-                    $set = join(', ', $ops);
-                    $where = array();
-                    foreach ($this->key as $key) {
-                        $where[] = $ops[$key];
-                    }
-                    $where = join(' AND ', $where);
-                    $this->execute("UPDATE {$this->table} SET $set WHERE $where");
-                }
-                break;
-            }
-        }
-    }
-
-    static public function dynamicCond($line, $key)
-    {
-        static $fields, $conds, $values, $thens, $elses;
-
-        if (!isset($fields)) {
-            $fields = $_SESSION['csv_cond_field'];
-            $conds  = $_SESSION['csv_cond'];
-            $values = $_SESSION['csv_cond_value'];
-            $thens  = $_SESSION['csv_cond_then'];
-            $elses  = $_SESSION['csv_cond_else'];
-        }
-        $field = $line[$fields[$key]];
-        $cond  = $conds[$key];
-        $value = $values[$key];
-        if (is_numeric($field) && is_numeric($value)) {
-            $field = floatval($field);
-            $value = floatval($value);
-        }
-        switch ($cond) {
-            case 'defined':          $ok = (!empty($field)); break;
-            case 'equals':           $ok = ($field == $value); break;
-            case 'contains':         $ok = (strpos($field, $value) !== false); break;
-            case 'contained':        $ok = (strpos($value, $field) !== false); break;
-            case 'greater':          $ok = ($field > $value); break;
-            case 'greater_or_equal': $ok ($field >= $value); break;
-            case 'lower':            $ok = ($field < $value); break;
-            case 'lower_or_equal':   $ok = ($field <= $value); break;
-            default:                 $ok = false;
-        }
-        if ($ok) {
-            return $thens[$key];
-        } else {
-            return $elses[$key];
-        }
-    }
-
-    public function registerFunction($name, $desc, $callback)
-    {
-        if (is_callable($callback, false, $ref)) {
-            $this->user_functions['func_' . $name] = array('desc' => $desc, 'callback' => $callback);
-            return true;
-        }
-        return false;
-    }
-
-    public function describe($name, $desc)
-    {
-        $this->field_desc[$name] = $desc;
-    }
-
-    public function forceValue($name, $value)
-    {
-        $this->field_value[$name] = $value;
-    }
-
-    private function cleanSession($fields)
-    {
-        foreach ($fields as $field) {
-            unset($_SESSION[$field]);
-        }
-    }
-
-    /** Handle insertion form
-     * @param $page  PlatalPage to process
-     * @param $url   URI of the page
-     * @param $field Editable fields
-     */
-    public function apply(&$page, $url, $fields = null)
-    {
-        $sesfields = array('csv_value', 'csv_user_value', 'csv_cond_field',
-                           'csv_update', 'csv_action', 'csv_cond_field',
-                           'csv_cond', 'csv_cond_value', 'csv_cond_then',
-                           'csv_cond_else', 'csv', 'csv_separator', 'csv_url');
-        if ($url != @$_SESSION['csv_url']) {
-            $this->cleanSession($sesfields);
-            $_SESSION['csv_url'] = $url;
-        }
-
-        if (is_null($fields) || empty($fields)) {
-            $fields = $this->getFieldList();
-        }
-        if (is_null($fields)) {
-            return false;
-        }
-        foreach ($this->field_value as $key=>$value) {
-            $search = array_search($key, $fields);
-            unset($fields[$search]);
-        }
-
-        $current = Env::v('csv_page');
-        if (empty($current)) {
-            $current = 'source';
-        }
-        $next = Env::v('csv_next_page');
-        if (empty($next)) {
-            $next = $current;
-        }
-        $csv  = @$_SESSION['csv'];
-        if ($current == 'source' && Env::has('csv_valid')) {
-            $csv = Env::v('csv_source');
-            $_SESSION['csv'] = $csv;
-            $next = 'values';
-        }
-        if ($csv) {
-            if (Env::has('csv_separator')) {
-                $sep = Env::v('csv_separator');
-                if (empty($sep)) {
-                    $sep = ';';
-                }
-                $_SESSION['csv_separator'] = $sep;
-            }
-            $this->setCSV($csv, null, $_SESSION['csv_separator']);
-        }
-        if ($current == 'values' && Env::has('csv_valid')) {
-            $next = 'valid';
-        }
-        if (empty($csv)) {
-            $next = 'source';
-        }
-        if (Env::has('csv_action')) {
-            $_SESSION['csv_action'] = Env::v('csv_action');
-        }
-        if ($next == 'valid') {
-            if ($current != 'valid') {
-                $cpyfields = array('csv_value', 'csv_user_value', 'csv_cond_field',
-                                   'csv_update', 'csv_action', 'csv_cond_field',
-                                   'csv_cond', 'csv_cond_value', 'csv_cond_then',
-                                   'csv_cond_else');
-                foreach ($cpyfields as $field) {
-                    $_SESSION[$field] = Env::v($field);
-                }
-            }
-            $insert   = $_SESSION['csv_value'];
-            $values   = $_SESSION['csv_user_value'];
-            $update   = $_SESSION['csv_update'];
-            foreach ($insert as $key=>$value) {
-                if (empty($value)) {
-                    $insert[$key] = null;
-                } elseif ($value == 'user_value') {
-                    $insert[$key] = $values[$key];
-                } elseif ($value == 'cond_value') {
-                    $insert[$key] = array($this, 'dynamicCond');
-                } elseif (array_key_exists($value, $this->user_functions)) {
-                    $insert[$key] = $this->user_functions[$value]['callback'];
-                }
-                if (isset($update[$key])) {
-                    $update[$key] = $insert[$key];
-                }
-            }
-            foreach ($this->field_value as $key=>$value) {
-                $insert[$key] = $value;
-                $fields[]     = $key;
-            }
-            if ($current == 'valid' && Env::has('csv_valid')) {
-                S::assert_xsrf_token();
-                $this->run($_SESSION['csv_action'], $insert, $update);
-                $page->assign('csv_done', true);
-                $this->cleanSession($sesfields);
-            } else {
-                $preview = array();
-                foreach ($this->data as $line) {
-                    $preview[] = $this->makeAssoc($line, $insert);
-                }
-                $page->assign('csv_preview', $preview);
-            }
-        }
-        $page->assign('csv_index', $this->index);
-        $page->assign('csv_functions', $this->user_functions);
-        $page->assign('csv_field_desc', $this->field_desc);
-        $page->assign('csv_page', $next);
-        $page->assign('csv_path', $url);
-        $page->assign('csv_fields', $fields);
-    }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/env.php b/classes/env.php
deleted file mode 100644 (file)
index e3bbd88..0000000
+++ /dev/null
@@ -1,214 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-class Env
-{
-    public static function _get($key, $default)
-    {
-        return isset($_REQUEST[$key]) ? $_REQUEST[$key] : $default;
-    }
-
-    public static function has($key)
-    {
-        return isset($_REQUEST[$key]);
-    }
-
-    public static function kill($key)
-    {
-        unset($_REQUEST[$key]);
-    }
-
-    public static function v($key, $default = null)
-    {
-        return Env::_get($key, $default);
-    }
-
-    public static function s($key, $default = '')
-    {
-        return (string)Env::_get($key, $default);
-    }
-
-    public static function b($key, $default = false)
-    {
-        return (bool)Env::_get($key, $default);
-    }
-
-    public static function i($key, $default = 0)
-    {
-        $i = Env::_get($key, $default);
-        return is_numeric($i) ? intval($i) : $default;
-    }
-
-    public static function l(array $keys)
-    {
-        return array_map(array('Env', 'v'), $keys);
-    }
-}
-
-class Post
-{
-    public static function _get($key, $default)
-    {
-        return isset($_POST[$key]) ? $_POST[$key] : $default;
-    }
-
-    public static function has($key)
-    {
-        return isset($_POST[$key]);
-    }
-
-    public static function kill($key)
-    {
-        unset($_POST[$key]);
-    }
-
-    public static function v($key, $default = null)
-    {
-        return Post::_get($key, $default);
-    }
-
-    public static function b($key, $default = false)
-    {
-        return (bool)Post::_get($key, $default);
-    }
-
-    public static function s($key, $default = '')
-    {
-        return (string)Post::_get($key, $default);
-    }
-
-    public static function i($key, $default = 0)
-    {
-        $i = Post::_get($key, $default);
-        return is_numeric($i) ? intval($i) : $default;
-    }
-
-     public static function l(array $keys)
-    {
-        return array_map(array('Post', 'v'), $keys);
-    }
-}
-
-class Get
-{
-    public static function _get($key, $default)
-    {
-        return isset($_GET[$key]) ? $_GET[$key] : $default;
-    }
-
-    public static function has($key)
-    {
-        return isset($_GET[$key]);
-    }
-
-    public static function kill($key)
-    {
-        unset($_GET[$key]);
-    }
-
-    public static function v($key, $default = null)
-    {
-        return Get::_get($key, $default);
-    }
-
-    public static function b($key, $default = false)
-    {
-        return (bool)Get::_get($key, $default);
-    }
-
-    public static function s($key, $default = '')
-    {
-        return (string)Get::_get($key, $default);
-    }
-
-    public static function i($key, $default = 0)
-    {
-        $i = Get::_get($key, $default);
-        return is_numeric($i) ? intval($i) : $default;
-    }
-
-    public static function l(array $keys)
-    {
-        return array_map(array('Get', 'v'), $keys);
-    }
-}
-
-class Cookie
-{
-    public static function _get($key, $default)
-    {
-        return isset($_COOKIE[$key]) ? $_COOKIE[$key] : $default;
-    }
-
-    public static function has($key)
-    {
-        return isset($_COOKIE[$key]);
-    }
-
-    public static function kill($key)
-    {
-        unset($_COOKIE[$key]);
-    }
-
-    public static function v($key, $default = null)
-    {
-        return Cookie::_get($key, $default);
-    }
-
-    public static function s($key, $default = '')
-    {
-        return (string)Cookie::_get($key, $default);
-    }
-
-    public static function b($key, $default = false)
-    {
-        return (bool)Cookie::_get($key, $default);
-    }
-
-    public static function i($key, $default = 0)
-    {
-        $i = Cookie::_get($key, $default);
-        return is_numeric($i) ? intval($i) : $default;
-    }
-
-    public static function l(array $keys)
-    {
-        return array_map(array('Cookie', 'v'), $keys);
-    }
-}
-
-function fix_gpc_magic(&$item, $key) {
-    if (is_array($item)) {
-        array_walk($item, 'fix_gpc_magic');
-    } else {
-        $item = stripslashes($item);
-    }
-}
-
-if (ini_get('magic_quotes_gpc') && empty($DONT_FIX_GPC)) {
-    array_walk($_GET, 'fix_gpc_magic');
-    array_walk($_POST, 'fix_gpc_magic');
-    array_walk($_COOKIE, 'fix_gpc_magic');
-    array_walk($_REQUEST, 'fix_gpc_magic');
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/flagset.php b/classes/flagset.php
deleted file mode 100644 (file)
index ce3d558..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-<?php
-/*
- * Copyright (C) 2003-2004 Polytechnique.org
- * http://opensource.polytechnique.org/
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-/** class for describing flags
- */
-class Flagset
-{
-    /** string that holds the flagset */
-    private $value;
-
-    /** the boundary between flags */
-    private $sep = ",";
-
-
-    /** set flag
-     * @param $flags services FROM coupures
-     * @return VOID
-     */
-    public function __construct($flags = "")
-    {
-        $this->value = $flags;
-    }
-
-
-    /** add flag
-     * @param $flag XXX
-     * @return VOID
-     */
-    public function addFlag($flag)
-    {
-        if (!$flag) return;
-        if (!$this->hasflag($flag)) {
-            if ($this->value)
-                $this->value .= $this->sep;
-            $this->value .= $flag;
-        }
-    }
-
-
-    /** test si flag ou pas
-     * @param $flag XXX
-     * @return 1 || 0
-     */
-    public function hasFlag($flag)
-    {
-        $tok = strtok($this->value,$this->sep);
-        while ($tok) {
-            if ($tok==$flag) return 1;
-            $tok = strtok($this->sep);
-        }
-        return 0;
-    }
-
-    /** test flag combination
-     */
-    public function hasFlagCombination($flag)
-    {
-        $perms = explode(',', $flag);
-        foreach ($perms as $perm)
-        {
-            $ok = true;
-            $rights = explode(':', $perm);
-            foreach ($rights as $right) {
-                if (($right{0} == '!' && $this->hasFlag(substr($right, 1))) || !$this->hasFlag($right)) {
-                    $ok = false;
-                }
-            }
-            if ($ok) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /** remove flag
-     * @param $flag XXX
-     * @return VOID
-     */
-    public function rmFlag($flag)
-    {
-        if (!$flag) return;
-        $newvalue = "";
-        $tok = strtok($this->value,$this->sep);
-        while ($tok) {
-            if ($tok!=$flag) {
-                if ($newvalue)
-                    $newvalue .= $this->sep;
-                $newvalue .= $tok;
-            }
-            $tok = strtok($this->sep);
-        }
-        $this->value=$newvalue;
-    }
-
-    /** return the flagset
-     */
-    public function flags()
-    {
-        return $this->value;
-    }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/miniwiki.php b/classes/miniwiki.php
deleted file mode 100644 (file)
index ab547e0..0000000
+++ /dev/null
@@ -1,198 +0,0 @@
-<?php
-
-class MiniWiki
-{
-
-    private static $patternsWiki = array();
-    private static $replacementHTML = array();
-    private static $replacementText = array();
-
-    private static $title_index = -1;
-    private static $info     = array();
-
-    public static function Markup($pattern, $replacement, $replacementTxt, $info = null)
-    {
-        $id = count(MiniWiki::$patternsWiki);
-        MiniWiki::$patternsWiki[$id] = $pattern;
-        MiniWiki::$replacementHTML[$id] = $replacement;
-        MiniWiki::$replacementText[$id] = $replacementTxt;
-        if ($info) {
-            MiniWiki::$info[$id] = $info;
-        }
-        return $id;
-    }
-
-    public static function init()
-    {
-        if (isset(MiniWiki::$patternsWiki[0])) {
-            return;
-        }
-        MiniWiki::Markup("/(\r\n|\r([^\n]))/", "\n$2", "\n$2");
-
-        // retours à la ligne avec \\
-        MiniWiki::Markup("/\\\\(?".">(\\\\*))\n/e", "str_repeat('<br />\n',mb_strlen('$1'))", "str_repeat('\n',mb_strlen('$1'))", "ligne1\\\\\nligne2");
-
-        // * unordered list
-        MiniWiki::Markup("/(^|\n)\*(([^\n]*(\n|$))(\*[^\n]*(\n|$))*)/se",
-                         "'</p><ul><li>'.str_replace(\"\\n*\",'</li><li>','$2').'</li></ul><p>'",
-                         "'$1 -' . str_replace(\"\\n*\", \"\\n -\", '$2')",
-                         "* element1\n* element2\n* element3");
-        // # unordered list
-        MiniWiki::Markup("/(^|\n)#(([^\n]*(\n|$))(#[^\n]*(\n|$))*)/se", "'<ol><li>'.str_replace(\"\\n#\",'</li><li>','$2').'</li></ol>'", "'$0'", "# element1\n# element2\n# element3");
-
-        // bold, italic and others
-        // ''' bold '''
-        MiniWiki::Markup("/'''(.*?)'''/",'<strong>$1</strong>','*$1*', "'''gras'''");
-        // '' italic ''
-        MiniWiki::Markup("/''(.*?)''/",'<em>$1</em>','/$1/', "''italique''");
-        // '+ big +'
-        MiniWiki::Markup("/'\\+(.*?)\\+'/",'<big>$1</big>','*$1*', "'+grand+'");
-        // '- small -'
-        MiniWiki::Markup("/'\\-(.*?)\\-'/",'<small>$1</small>','$1', "'-petit-'");
-        // '^superscript^'
-        MiniWiki::Markup("/'\\^(.*?)\\^'/",'<sup>$1</sup>','$1', "'^exposant^'");
-        // '_subscript_'
-        MiniWiki::Markup("/'_(.*?)_'/",'<sub>$1</sub>','$1', "'_indice_'");
-        // {+ underline +}
-        MiniWiki::Markup("/\\{\\+(.*?)\\+\\}/",'<ins>$1</ins>','_$1_', "{+insertion+}");
-        // {- strikeout -}
-        MiniWiki::Markup("/\\{-(.*?)-\\}/",'<del>$1</del>','-$1-', "{-suppression-}");
-        // {color| colored text |}
-        MiniWiki::Markup("/%([a-z]+|\#[0-9a-f]{3,6})%(.*?)%%/i", "<span style='color: $1;'>$2</span>", "$2",
-                         "%red% texte en rouge %%\\\\\n%#ff0% texte en jaune %%\\\\\n%#0000ff% texte en bleu %%");
-        // [+ big +] [++ bigger ++] [+++ even bigger +++] ...
-        MiniWiki::Markup("/\\[(([-+])+)(.*?)\\1\\]/e","'<span style=\'font-size:'.(round(pow(6/5,$2mb_strlen('$1'))*100,0)).'%\'>$3</span>'", "'$3'", "[+ grand +]\n\n[++ plus grand ++]\n\n[+++ encore plus grand +++]");
-
-        // ----- <hr/>
-        MiniWiki::Markup("/(\n|^)--(--+| \n)/s", '$1<hr/>', '$1-- '."\n", "----\n");
-        // titles
-        MiniWiki::$title_index = MiniWiki::Markup('/(\n|^)(!+)([^\n]*)/se',
-                                                  "'$1<h'.mb_strlen('$2').'>$3</h'.mb_strlen('$2').'>'",
-                                                  "'$1$3'", "!titre1\n\n!!titre2\n\n!!!titre3");
-
-        // links
-        MiniWiki::Markup('/((?:https?|ftp):\/\/(?:[\.\,\;\!\:]*[\w@~%$£µ&i#\-+=_\/\?])*)/ui',
-                         '<a href="\\0">\\0</a>', '<\\0>');
-        MiniWiki::Markup('/(\s|^|\[\[)www\.((?:[\.\,\;\!\:]*[\w@~%$£µ&i#\-+=_\/\?])*)/iu',
-                         '\\1<a href="http://www.\\2">www.\\2</a>', '\\1<http://www.\\2>');
-        MiniWiki::Markup('/(?:mailto:)?([a-z0-9.\-+_]+@([\-.+_]?[a-z0-9])+)/i', '<a href="mailto:\\0">\\0</a>', '<\\0>');
-        MiniWiki::Markup('/\[\[\s*<(?:a href=")?([^">]*?)(?:">.*?<\/a)?>\s*\|([^\]]+)\]\]/i',
-                         '<a href="\\1">\\2</a>', '\\2 <\\1>',
-                         "[[http://www.example.com|Mon site web]]\n\nhttp://www.example.com\n\ntest@example.com");
-
-        // paragraphs and empty lines
-        MiniWiki::Markup("/\n\n/", '</p><p>', "\n\n", "paragraphe1\n\nparagraphe2");
-        MiniWiki::Markup("/\n/", ' ', "\n");
-        MiniWiki::Markup("/^.*<\/p>.*<p>.*$/s", "<p>$0</p>", "$0");
-
-        // french typo rules, unbreakable spaces
-        MiniWiki::Markup("/ +([!?:;])/", "&nbsp;$1", "$0");
-    }
-
-    public static function WikiToHTML($wiki, $title = false)
-    {
-        if (!$title) {
-            $oldrule12 = MiniWiki::$replacementHTML[MiniWiki::$title_index];
-            MiniWiki::$replacementHTML[MiniWiki::$title_index] = "'$0'";
-        }
-        $html = preg_replace(MiniWiki::$patternsWiki,
-                             MiniWiki::$replacementHTML,
-                             htmlentities(trim($wiki), ENT_COMPAT, 'UTF-8'));
-        if (!$title) {
-            MiniWiki::$replacementHTML[MiniWiki::$title_index] = $oldrule12;
-        }
-        return $html;
-    }
-
-    private static function justify($text, $n)
-    {
-        $arr = explode("\n", wordwrap($text, $n));
-        $arr = array_map('trim', $arr);
-        $res = '';
-        foreach ($arr as $key => $line) {
-            $nxl       = isset($arr[$key+1]) ? trim($arr[$key+1]) : '';
-            $nxl_split = preg_split('! +!u', $nxl);
-            $nxw_len   = count($nxl_split) ? mb_strlen($nxl_split[0]) : 0;
-            $line      = trim($line);
-
-            if (mb_strlen($line)+1+$nxw_len < $n) {
-                $res .= "$line\n";
-                continue;
-            }
-
-            if (preg_match('![.:;]$!u',$line)) {
-                $res .= "$line\n";
-                continue;
-            }
-
-            $tmp   = preg_split('! +!u', trim($line));
-            $words = count($tmp);
-            if ($words <= 1) {
-                $res .= "$line\n";
-                continue;
-            }
-
-            $len   = array_sum(array_map('mb_strlen', $tmp));
-            $empty = $n - $len;
-            $sw    = floatval($empty) / floatval($words-1);
-
-            $cur = 0;
-            $l   = '';
-            foreach ($tmp as $word) {
-                $l   .= $word;
-                $cur += $sw + strlen($word); // Use strlen here instead of mb_strlen because it is used by str_pad
-                                             // which is not multibyte compatible
-                $l   = str_pad($l, intval($cur + 0.5));
-            }
-            $res .= trim($l)."\n";
-        }
-        return trim($res);
-    }
-
-
-    public static function WikiToText($wiki, $just=false, $indent=0, $width=68, $title=false)
-    {
-        if (!$title) {
-            $oldrule12 = MiniWiki::$replacementHTML[MiniWiki::$title_index];
-            MiniWiki::$replacementHTML[MiniWiki::$title_index] = "'$0'";
-        }
-        //$text = trim($wiki);
-        //foreach (MiniWiki::$patternsWiki as $key=>$pattern) {
-        //    echo $key . " -  " . $pattern . "\n";
-        //    $text = preg_replace($pattern, MiniWiki::$replacementText[$key], $text);
-        //}
-        $text = preg_replace(MiniWiki::$patternsWiki, MiniWiki::$replacementText, trim($wiki));
-        if (!$title) {
-            MiniWiki::$replacementHTML[MiniWiki::$title_index] = $oldrule12;
-        }
-        $text = $just ? MiniWiki::justify($text, $width - $indent) :  wordwrap($text, $width - $indent);
-        if($indent) {
-            $ind = str_pad('',$indent);
-            $text = $ind.str_replace("\n","\n$ind",$text);
-        }
-        return $text;
-    }
-
-    static public function help($with_title = false)
-    {
-        if (!$with_title) {
-            $info12 = MiniWiki::$info[MiniWiki::$title_index];
-            unset(MiniWiki::$info[MiniWiki::$title_index]);
-        }
-
-        $res = array();
-        foreach (MiniWiki::$info as $value) {
-            $res[$value] = MiniWiki::wikiToHtml($value, true);
-        }
-
-        if (!$with_title) {
-            MiniWiki::$info[MiniWiki::$title_index] = $info12;
-        }
-        return $res;
-    }
-}
-
-MiniWiki::init();
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/platal.php b/classes/platal.php
deleted file mode 100644 (file)
index 4c1f60a..0000000
+++ /dev/null
@@ -1,323 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-define('PL_DO_AUTH',   300);
-define('PL_FORBIDDEN', 403);
-define('PL_NOT_FOUND', 404);
-
-class Platal
-{
-    private $__mods;
-    private $__hooks;
-
-    protected $https;
-
-    public $ns;
-    public $path;
-    public $argv;
-
-    public function __construct()
-    {
-        $modules    = func_get_args();
-        if (is_array($modules[0])) {
-            $modules = $modules[0];
-        }
-        $this->path = trim(Get::_get('n', null), '/');
-
-        $this->__mods  = array();
-        $this->__hooks = array();
-
-        array_unshift($modules, 'core');
-        foreach ($modules as $module) {
-            $module = strtolower($module);
-            $this->__mods[$module] = $m = PLModule::factory($module);
-            $this->__hooks += $m->handlers();
-        }
-
-        global $globals;
-        if ($globals->mode == '') {
-            pl_redirect('index.html');
-        }
-    }
-
-    public function pl_self($n = null)
-    {
-        if (is_null($n))
-            return $this->path;
-
-        if ($n >= 0)
-            return join('/', array_slice($this->argv, 0, $n + 1));
-
-        if ($n <= -count($this->argv))
-            return $this->argv[0];
-
-        return join('/', array_slice($this->argv, 0, $n));
-    }
-
-    protected function find_hook()
-    {
-        $p = $this->path;
-
-        while ($p) {
-            if (array_key_exists($p, $this->__hooks))
-                break;
-
-            $p = substr($p, 0, strrpos($p, '/'));
-        }
-
-        if (empty($this->__hooks[$p])) {
-            return null;
-        }
-
-        $hook = $this->__hooks[$p];
-
-        if (!is_callable($hook['hook'])) {
-            return null;
-        }
-
-        $this->https = ($hook['type'] & NO_HTTPS) ? false : true;
-        $this->argv    = explode('/', substr($this->path, strlen($p)));
-        $this->argv[0] = $p;
-
-        return $hook;
-    }
-
-    protected function find_nearest_key($key, array &$array)
-    {
-        $keys    = array_keys($array);
-        if (in_array($key, $keys)) {
-            return $key;
-        }
-
-        if (($pos = strpos($key, '.php')) !== false) {
-            $key = substr($key, 0, $pos);
-        }
-
-        $has_end = in_array("#final#", $keys);
-        if (strlen($key) > 24 && $has_end) {
-            return "#final#";
-        }
-
-        foreach ($keys as $k) {
-            if ($k == "#final#") {
-                continue;
-            }
-            $lev = levenshtein($key, $k);
-
-            if ((!isset($val) || $lev < $val)
-                && ($lev <= strlen($k)/2 || strpos($k, $key) !== false || strpos($key, $k) !== false)) {
-                $val  = $lev;
-                $best = $k;
-            }
-        }
-        if (!isset($best) && $has_end) {
-            return "#final#";
-        } else if (isset($best)) {
-            return $best;
-        }
-        return null;
-    }
-
-    public function near_hook()
-    {
-        $hooks = array();
-        $leafs = array();
-        foreach ($this->__hooks as $hook=>$handler) {
-            if (!$this->check_perms($handler['perms'])) {
-                continue;
-            }
-            $parts = split('/', $hook);
-            $place =& $hooks;
-            foreach ($parts as $part) {
-                if (!isset($place[$part])) {
-                    $place[$part] = array();
-                }
-                $place =& $place[$part];
-            }
-            $leaf = $parts[count($parts)-1];
-            if (!isset($leafs[$leaf])) {
-                $leafs[$leaf] = $hook;
-            } else if (is_array($leafs[$leaf])) {
-                $leafs[$leaf][] = $hook;
-            } else {
-                $leafs[$leaf] = array($hook, $leafs[$leaf]);
-            }
-            $place["#final#"] = array();
-        }
-
-        // search for the nearest full path
-        $p = split('/', $this->path);
-        $place =& $hooks;
-        $link  = '';
-        foreach ($p as $k) {
-            if (!isset($ended)) {
-                $key = $this->find_nearest_key($k, $place);
-            } else {
-                $key = $k;
-            }
-            if ($key == "#final#") {
-                if (!array_key_exists($link, $this->__hooks)) {
-                    $link = '';
-                    break;
-                }
-                $key = $k;
-                $ended = true;
-            }
-            if (!is_null($key)) {
-                if (!empty($link)) {
-                    $link .= '/';
-                }
-                $link .= $key;
-                $place =& $place[$key];
-            } else {
-                $link = '';
-                break;
-            }
-        }
-        if ($link == $this->path) {
-            $link = '';
-        }
-        if ($link && levenshtein($link, $this->path) < strlen($link)/3) {
-            return $link;
-        }
-
-        // search for missing namespace (the given name is a leaf)
-        $leaf = array_shift($p);
-        $args = count($p) ? '/' . implode('/', $p) : '';
-        if (isset($leafs[$leaf]) && !is_array($leafs[$leaf]) && $leafs[$leaf] != $this->path) {
-            return $leafs[$leaf] . $args;
-        }
-        unset($val);
-        $best = null;
-        foreach ($leafs as $k=>&$path) {
-            if (is_array($path)) {
-                continue;
-            }
-            $lev = levenshtein($leaf, $k);
-
-            if ((!isset($val) || $lev < $val)
-                && ($lev <= strlen($k)/2 || strpos($k, $leaf) !== false || strpos($leaf, $k) !== false)) {
-                $val  = $lev;
-                $best = $path;
-            }
-        }
-        return $best == null ? ( $link ? $link : null ) : $best . $args;
-    }
-
-    protected function check_perms($perms)
-    {
-        if (!$perms) { // No perms, no check
-            return true;
-        }
-        $s_perms = S::v('perms');
-        return $s_perms->hasFlagCombination($perms);
-    }
-
-    private function call_hook(PlatalPage &$page)
-    {
-        $hook = $this->find_hook();
-        if (empty($hook)) {
-            return PL_NOT_FOUND;
-        }
-        global $globals;
-        if ($this->https && !$_SERVER['HTTPS'] && $globals->core->secure_domain) {
-            http_redirect('https://' . $globals->core->secure_domain . $_SERVER['REQUEST_URI']);
-        }
-
-        $args    =  $this->argv;
-        $args[0] =& $page;
-
-        if ($hook['auth'] > S::v('auth', AUTH_PUBLIC)) {
-            if ($hook['type'] & DO_AUTH) {
-                if (!call_user_func(array($globals->session, 'doAuth'))) {
-                    $this->force_login($page);
-                }
-            } else {
-                return PL_FORBIDDEN;
-            }
-        }
-        if ($hook['auth'] != AUTH_PUBLIC && !$this->check_perms($hook['perms'])) {
-            return PL_FORBIDDEN;
-        }
-
-        $val = call_user_func_array($hook['hook'], $args);
-        if ($val == PL_DO_AUTH) {
-            // The handler need a better auth with the current args
-            if (!call_user_func(array($globals->session, 'doAuth'))) {
-                $this->force_login($page);
-            }
-            $val = call_user_func_array($hook['hook'], $args);
-        }
-        return $val;
-    }
-
-    public function force_login(PlatalPage &$page)
-    {
-        header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
-        if (S::logged()) {
-            $page->changeTpl('core/password_prompt_logged.tpl');
-            $page->addJsLink('do_challenge_response_logged.js');
-        } else {
-            $page->changeTpl('core/password_prompt.tpl');
-            $page->addJsLink('do_challenge_response.js');
-        }
-        $page->assign('platal', $this);
-        $page->run();
-    }
-
-    public function run()
-    {
-        global $page;
-
-        new_skinned_page('platal/index.tpl');
-
-        if (empty($this->path)) {
-            $this->path = 'index';
-        }
-
-        $page->assign('platal', $this);
-        switch ($this->call_hook($page)) {
-          case PL_FORBIDDEN:
-            $this->__mods['core']->handler_403($page);
-            break;
-
-          case PL_NOT_FOUND:
-            $this->__mods['core']->handler_404($page);
-            break;
-        }
-
-        $page->assign('platal', $this);
-        $page->run();
-    }
-
-    public function on_subscribe($forlife, $uid, $promo, $pass)
-    {
-        $args = func_get_args();
-        foreach ($this->__mods as $mod) {
-            if (!is_callable($mod, 'on_subscribe'))
-                continue;
-            call_user_func_array(array($mod, 'on_subscribe'), $args);
-        }
-    }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/platalglobals.php.in b/classes/platalglobals.php.in
new file mode 100644 (file)
index 0000000..43140c6
--- /dev/null
@@ -0,0 +1,106 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2008 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************/
+
+class PlatalGlobals extends PlGlobals
+{
+    /** The x.org version */
+    public $version = '@VERSION@';
+
+    /** db params */
+    public $dbdb               = 'x4dat';
+    public $dbhost             = 'localhost';
+    public $dbuser             = 'x4dat';
+    public $dbpwd              = 'x4dat';
+    public $dbcharset          = 'utf8';
+
+    /** default skin */
+    public $skin;
+    public $register_skin;
+
+    public function __construct()
+    {
+        parent::__construct(array('platal.ini', 'platal.conf'));
+    }
+
+    public function init()
+    {
+        $this->bootstrap(array('NbIns'), array($this, 'updateNbIns'));
+        $this->bootstrap(array('NbValid'), array($this, 'updateNbValid'));
+    }
+
+    public function asso($key=null)
+    {
+        static $aid = null;
+
+        if (is_null($aid)) {
+            $gp = Get::v('n');
+            if ($p = strpos($gp, '/')) {
+                $gp = substr($gp, 0, $p);
+            }
+
+            if ($gp) {
+                $res = XDB::query('SELECT  a.*, d.nom AS domnom,
+                                           FIND_IN_SET(\'wiki_desc\', a.flags) AS wiki_desc,
+                                           FIND_IN_SET(\'notif_unsub\', a.flags) AS notif_unsub
+                                     FROM  groupex.asso AS a
+                                LEFT JOIN  groupex.dom  AS d ON d.id = a.dom
+                                    WHERE  diminutif = {?}', $gp);
+                if (!($aid = $res->fetchOneAssoc())) {
+                    $aid = array();
+                }
+            } else {
+                $aid = array();
+            }
+        }
+        if (empty($key)) {
+            return $aid;
+        } elseif ( isset($aid[$key]) ) {
+            return $aid[$key];
+        } else {
+            return null;
+        }
+    }
+
+
+    public function updateNbIns()
+    {
+        $res = XDB::query("SELECT  COUNT(*)
+                             FROM  auth_user_md5
+                            WHERE  perms IN ('admin','user') AND deces=0");
+        $cnt = $res->fetchOneCell();
+        $this->changeDynamicConfig(array('NbIns' => $cnt));
+    }
+
+    public function updateNbValid()
+    {
+        $res = XDB::query("SELECT  COUNT(*)
+                             FROM  requests");
+        $this->changeDynamicConfig(array('NbValid' => $res->fetchOneCell()));
+    }
+}
+
+
+/******************************************************************************
+ * Dynamic configuration update/edition stuff
+ *****************************************************************************/
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
diff --git a/classes/platalpage.php b/classes/platalpage.php
deleted file mode 100644 (file)
index f3bb2fa..0000000
+++ /dev/null
@@ -1,445 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-require_once 'smarty/libs/Smarty.class.php';
-
-abstract class PlatalPage extends Smarty
-{
-    private $_page_type;
-    private $_tpl;
-    private $_errors;
-    private $_failure;
-    private $_jsonVars;
-
-    // {{{ function PlatalPage()
-
-    public function __construct($tpl, $type = SKINNED)
-    {
-        parent::Smarty();
-
-        global $globals;
-
-        $this->caching       = false;
-        $this->config_overwrite = false;
-        $this->use_sub_dirs  = false;
-        $this->template_dir  = $globals->spoolroot."/templates/";
-        $this->compile_dir   = $globals->spoolroot."/spool/templates_c/";
-        array_unshift($this->plugins_dir, $globals->spoolroot."/plugins/");
-        $this->config_dir    = $globals->spoolroot."/configs/";
-
-        $this->compile_check = !empty($globals->debug);
-
-        $this->changeTpl($tpl, $type);
-        $this->_errors    = array('errors' => array());
-        $this->_jsonVars  = array();
-        $this->_failure   = false;
-
-        if ($globals->mode != 'rw') {
-            $this->trigError("En raison d'une maintenance, une partie des fonctionnalités du site sont"
-                      . " actuellement désactivée, en particuliers aucune donnée ne sera sauvegardée");
-        }
-        $this->register_prefilter('at_to_globals');
-        $this->addJsLink('xorg.js');
-        $this->addJsLink('jquery.js');
-    }
-
-    // }}}
-    // {{{ function changeTpl()
-
-    public function changeTpl($tpl, $type = SKINNED)
-    {
-      $this->_tpl       = $tpl;
-      $this->_page_type = $type;
-      $this->assign('xorg_tpl', $tpl);
-    }
-
-    // }}}
-    // {{{ function raw()
-
-    public function raw()
-    {
-        global $globals;
-        $this->assign('globals', $globals);
-        return $this->fetch($this->_tpl);
-    }
-
-    // }}}
-    // {{{ function _run()
-
-    protected function _run($skin)
-    {
-        global $globals, $TIME_BEGIN;
-
-        session_write_close();
-
-        $this->register_prefilter('trimwhitespace');
-        $this->register_prefilter('form_force_encodings');
-        $this->register_prefilter('wiki_include');
-        $this->register_prefilter('if_has_perms');
-        $this->assign('xorg_triggers', $this->_errors);
-        $this->assign('xorg_errors', $this->nb_errs());
-        $this->assign('xorg_failure', $this->_failure);
-        $this->assign('globals', $globals);
-
-        if (Env::has('json') && count($this->_jsonVars)) {
-            return $this->jsonDisplay();
-        }
-
-        if (Env::v('display') == 'light') {
-            $this->_page_type = SIMPLE;
-        } elseif (Env::v('display') == 'raw') {
-            $this->_page_type = NO_SKIN;
-        } elseif (Env::v('display') == 'full') {
-            $this->_page_typ = SKINNED;
-        }
-
-        switch ($this->_page_type) {
-          case NO_SKIN:
-            if (!($globals->debug & DEBUG_SMARTY)) {
-                error_reporting(0);
-            }
-            $this->display($this->_tpl);
-            exit;
-
-          case SIMPLE:
-            $this->assign('simple', true);
-
-          case SKINNED:
-            $this->register_modifier('escape_html', 'escape_html');
-            $this->default_modifiers = Array('@escape_html');
-        }
-        if (S::i('auth') <= AUTH_PUBLIC) {
-            $this->register_outputfilter('hide_emails');
-        }
-        $this->addJsLink('wiki.js');
-        header("Accept-Charset: utf-8");
-        if (Env::v('forceXml')) {
-            header("Content-Type: text/xml; charset=utf-8");
-        }
-
-        if (!$globals->debug) {
-            error_reporting(0);
-            $this->display($skin);
-            exit;
-        }
-
-        $this->assign('validate', true);
-        if (!($globals->debug & DEBUG_SMARTY)) {
-            error_reporting(0);
-        }
-        $START_SMARTY = microtime(true);
-        $result = $this->fetch($skin);
-        $ttime  = sprintf('Temps total: %.02fs (Smarty %.02fs) - Mémoire totale : %dKo<br />',
-                          microtime(true) - $TIME_BEGIN, microtime(true) - $START_SMARTY,
-                          memory_get_peak_usage(true) / 1024);
-        if ($globals->debug & DEBUG_BT) {
-            PlBacktrace::clean();
-            $this->assign_by_ref('backtraces', PlBacktrace::$bt);
-            $result = str_replace('@@BACKTRACE@@', $this->fetch('skin/common.backtrace.tpl'), $result);
-        } else {
-            $result = str_replace('@@BACKTRACE@@', '', $result);
-        }
-
-        $replc  = "<span class='erreur'>VALIDATION HTML INACTIVE</span><br />";
-        if ($globals->debug & DEBUG_VALID) {
-            $fd = fopen($this->compile_dir."/valid.html","w");
-            fwrite($fd, $result);
-            fclose($fd);
-
-            exec($globals->spoolroot."/bin/devel/xhtml.validate.pl ".$this->compile_dir."/valid.html", $val);
-            foreach ($val as $h) {
-                if (preg_match("/^X-W3C-Validator-Errors: (\d+)$/", $h, $m)) {
-                    $replc = '<span style="color: #080;">HTML OK</span><br />';
-                    if ($m[1]) {
-                        $replc = "<span class='erreur'><a href='http://validator.w3.org/check?uri={$globals->baseurl}"
-                            ."/valid.html&amp;ss=1#result'>{$m[1]} ERREUR(S) !!!</a></span><br />";
-                    }
-                    break;
-                }
-            }
-        }
-
-        echo str_replace("@HOOK@", $ttime.$replc, $result);
-        exit;
-    }
-
-    abstract public function run();
-
-    // }}}
-    // {{{ function nb_errs()
-
-    public function nb_errs()
-    {
-        return count($this->_errors['errors']);
-    }
-
-    // }}}
-    // {{{ function trig()
-
-    private function trig($msg, $type = 'errors')
-    {
-        if (!isset($this->_errors[$type])) {
-            $this->_errors[$type] = array();
-        }
-        $this->_errors[$type][] = $msg;
-    }
-
-    public function trigError($msg)
-    {
-        $this->trig($msg, 'errors');
-    }
-
-    public function trigWarning($msg)
-    {
-        $this->trig($msg, 'warnings');
-    }
-
-    public function trigSuccess($msg)
-    {
-        $this->trig($msg, 'success');
-    }
-
-    // }}}
-    // {{{ function kill()
-
-    public function kill($msg)
-    {
-        global $platal;
-
-        $this->assign('platal', $platal);
-        $this->trigError($msg);
-        $this->_failure = true;
-        $this->run();
-    }
-
-    // }}}
-    // {{{ function addJsLink
-
-    public function addJsLink($path)
-    {
-        $this->append('xorg_js', $path);
-    }
-
-    // }}}
-    // {{{ function addCssLink
-
-    public function addCssLink($path)
-    {
-        $this->append('xorg_css', $path);
-    }
-
-    // }}}
-    // {{{ function addCssInline
-
-    public function addCssInline($css)
-    {
-        if (!empty($css)) {
-            $this->append('xorg_inline_css', $css);
-        }
-    }
-
-    // }}}
-    // {{{ function setRssLink
-
-    public function setRssLink($title, $path)
-    {
-        $this->assign('xorg_rss', array('title' => $title, 'href' => $path));
-    }
-
-    // }}}
-    // {{{ function jsonDisplay
-    protected function jsonDisplay()
-    {
-        header("Content-type: text/javascript; charset=utf-8");
-        array_walk_recursive($this->_jsonVars, "escape_xorgDB");
-        $jsonbegin = Env::v('jsonBegin');
-        $jsonend = Env::v('jsonEnd');
-        if (Env::has('jsonVar')) {
-            $jsonbegin = Env::v('jsonVar').' = ';
-            $jsonend = ';';
-        } elseif (Env::has('jsonFunc')) {
-            $jsonbegin = Env::v('jsonFunc').'(';
-            $jsonend = ');';
-        }
-        echo $jsonbegin, json_encode($this->_jsonVars), $jsonend;
-        exit;
-    }
-    // }}}
-    // {{{ function jsonAssign
-    public function jsonAssign($var, $value)
-    {
-        $this->_jsonVars[$var] = $value;
-    }
-
-    // }}}
-}
-
-function escape_xorgDB(&$item, $key)
-{
-    if (is_a($item, 'XOrgDBIterator')) {
-        $expanded = array();
-        while ($a = $item->next()) {
-            $expanded[] = $a;
-        }
-        $item = $expanded;
-    }
-}
-
-// {{{ function escape_html ()
-
-/**
- * default smarty plugin, used to auto-escape dangerous html.
- *
- * < --> &lt;
- * > --> &gt;
- * " --> &quot;
- * & not followed by some entity --> &amp;
- */
-function escape_html($string)
-{
-    if (is_string($string)) {
-        return htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
-    } else {
-        return $string;
-    }
-}
-
-// }}}
-// {{{ function at_to_globals()
-
-/**
- * helper
- */
-
-function _to_globals($s) {
-    global $globals;
-    $t = explode('.',$s);
-    if (count($t) == 1) {
-        return var_export($globals->$t[0],true);
-    } else {
-        return var_export($globals->$t[0]->$t[1],true);
-    }
-}
-
-/**
- * compilation plugin used to import $globals confing through #globals.foo.bar# directives
- */
-
-function at_to_globals($tpl_source, &$smarty)
-{
-    return preg_replace('/#globals\.([a-zA-Z0-9_.]+?)#/e', '_to_globals(\'\\1\')', $tpl_source);
-}
-
-// }}}
-// {{{  function trimwhitespace
-
-function trimwhitespace($source, &$smarty)
-{
-    $tags = '(script|pre|textarea)';
-    preg_match_all("!<$tags.*?>.*?</(\\1)>!ius", $source, $tagsmatches);
-    $source = preg_replace("!<$tags.*?>.*?</(\\1)>!ius", "&&&tags&&&", $source);
-
-    // remove all leading spaces, tabs and carriage returns NOT
-    // preceeded by a php close tag.
-    $source = preg_replace('/((?<!\?>)\n)[\s]+/m', '\1', $source);
-    $source = preg_replace("!&&&tags&&&!e",  'array_shift($tagsmatches[0])', $source);
-
-    return $source;
-}
-
-// }}}
-// {{{ function wiki_include
-
-function wiki_include($source, &$smarty)
-{
-    return preg_replace('/\{include( [^}]*)? wiki=([^} ]+)(.*?)\}/ui',
-                        '{include\1 file="../spool/wiki.d/cache_\2.tpl"\3 included=1}',
-                        $source);
-}
-
-// }}}
-//{{{ function hasPerm
-
-function if_has_perms($source, &$smarty)
-{
-    $source = preg_replace('/\{if([^}]*) (\!?)hasPerms\(([^)]+)\)([^}]*)\}/',
-                           '{if\1 \2$smarty.session.perms->hasFlagCombination(\3)\4}',
-                           $source);
-    return preg_replace('/\{if([^}]*) (\!?)hasPerm\(([^)]+)\)([^}]*)\}/',
-                        '{if\1 \2($smarty.session.perms && $smarty.session.perms->hasFlag(\3))\4}',
-                        $source);
-}
-
-// }}}
-// {{{
-
-function form_force_encodings($source, &$smarty)
-{
-    return preg_replace('/<form[^\w]/',
-                        '\0 accept-charset="utf-8" ',
-                        $source);
-}
-
-// }}}
-// {{{ function hide_emails
-
-function _hide_email($source)
-{
-    $source = str_replace("\n", '', $source);
-    return '<script type="text/javascript">//<![CDATA[' . "\n" .
-           'Nix.decode("' . addslashes(str_rot13($source)) . '");' . "\n" .
-           '//]]></script>';
-}
-
-function hide_emails($source, &$smarty)
-{
-    if (!strpos($source, '@')) {
-        return $source;
-    }
-
-    //prevent email replacement in <script> and <textarea>
-    $tags = '(script|textarea|select)';
-    preg_match_all("!<$tags.*?>.*?</(\\1)>!ius", $source, $tagsmatches);
-    $source = preg_replace("!<$tags.*?>.*?</(\\1)>!ius", "&&&tags&&&", $source);
-
-    //catch all emails in <a href="mailto:...">
-    preg_match_all("!<a[^>]+href=[\"'][^\"']*[-a-z0-9+_.]+@[-a-z0-9_.]+[^\"']*[\"'].*?>.*?</a>!ius", $source, $ahref);
-    $source = preg_replace("!<a[^>]+href=[\"'][^\"']*[-a-z0-9+_.]+@[-a-z0-9_.]+[^\"']*[\"'].*?>.*?</a>!ius", '&&&ahref&&&', $source);
-
-    //prevant replacement in tag attributes
-    preg_match_all("!<[^>]+[-a-z0-9_+.]+@[-a-z0-9_.]+.+?>!ius", $source, $misc);
-    $source = preg_replace("!<[^>]+[-a-z0-9_+.]+@[-a-z0-9_.]+.+?>!ius", '&&&misc&&&', $source);
-
-    //catch !
-    $source = preg_replace('!([-a-z0-9_+.]+@[-a-z0-9_.]+)!iue', '_hide_email("\1")', $source);
-    $source = preg_replace('!&&&ahref&&&!e', '_hide_email(array_shift($ahref[0]))', $source);
-
-    // restore data
-    $source = preg_replace('!&&&misc&&&!e', 'array_shift($misc[0])', $source);
-    $source = preg_replace("!&&&tags&&&!e",  'array_shift($tagsmatches[0])', $source);
-
-    return $source;
-}
-
-// }}}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/plbacktrace.php b/classes/plbacktrace.php
deleted file mode 100644 (file)
index 9fb80ec..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-/** Ligth debugging tool to generate execution backtrace
- */
-class PlBacktrace
-{
-    static public $bt = array();
-
-    public $traces    = array();
-    public $totaltime = 0.0;
-    public $error     = false;
-
-    function __construct($name, array $init = array(), $sizef = 'rows', $timef = 'exectime', $errorf = 'error')
-    {
-        PlBacktrace::$bt[$name] = $this;
-        foreach ($init as &$entry) {
-            $this->add($entry, $sizef, $timef, $errorf);
-        }
-    }
-
-    private function fixCharset($action)
-    {
-        if (!is_string($action)) {
-            return $action;
-        } else {
-            return is_utf8($action) ? $action : utf8_encode($action);
-        }
-    }
-
-    private function add(array &$entry, $sizef = 'rows', $timef = 'exectime', $errorf = 'error')
-    {
-        $trace = array();
-        $trace['action'] = $this->fixCharset($entry['action']);
-        unset($entry['action']);
-        $trace['exectime'] = @$entry[$timef];
-        $this->totaltime += $trace['exectime'];
-        unset($entry[$timef]);
-        $trace['rows'] = @$entry[$sizef];
-        unset($entry[$sizef]);
-        $trace['error'] = $this->fixCharset(@$entry[$errorf]);
-        unset($entry[$errorf]);
-        if ($trace['error']) {
-            $this->error = true;
-        }
-        $trace['data'] = array($this->fixCharset($entry));
-        $this->traces[] =& $trace;
-    }
-
-    public function newEvent($action, $rows = 0, $error = null, array $userdata = array())
-    {
-        $trace = array('action' => $this->fixCharset($action), 'time' => 0);
-        $this->traces[] =& $trace;
-        $this->update($rows, $error, $userdata);
-    }
-
-    public function start($action)
-    {
-        $this->traces[] =  array('action' => $this->fixCharset($action), 'starttime' => microtime(true));;
-    }
-
-    public function stop($rows = 0, $error = null, array $userdata = array())
-    {
-        $time = microtime(true);
-        if (!$this->traces) {
-            return;
-        }
-        $trace =& $this->traces[count($this->traces) - 1];
-        $trace['exectime'] = $time - $trace['starttime'];
-        unset($trace['starttime']);
-        $this->totaltime += $trace['exectime'];
-        $this->update($rows, $error, $userdata);
-    }
-
-    public function update($rows = 0, $error = null, array $userdata = array())
-    {
-        $trace =& $this->traces[count($this->traces) - 1];
-        $trace['rows']  = $rows;
-        $trace['error'] = $this->fixCharset($error);
-        array_walk_recursive($userdata, array($this, 'fixCharset'));
-        $trace['data']  = $userdata;
-        if ($trace['error']) {
-            $this->error = true;
-        }
-    }
-
-    public static function clean()
-    {
-        foreach (PlBacktrace::$bt as $name=>&$entry) {
-            if (!$entry->traces) {
-                unset(PlBacktrace::$bt[$name]);
-            }
-        }
-    }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/pliterator.php b/classes/pliterator.php
deleted file mode 100644 (file)
index 0b5f254..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-interface PlIterator
-{
-    public function next();
-    public function total();
-    public function first();
-    public function last();
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/plmailer.php b/classes/plmailer.php
deleted file mode 100644 (file)
index 2106d50..0000000
+++ /dev/null
@@ -1,336 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-require_once('smarty/libs/Smarty.class.php');
-
-/** Classe de mail avec corps en templates.
- */
-class PlMail extends Smarty
-{
-    private $tpl;
-    private $mailer = null;
-
-    function __construct($tpl)
-    {
-        global $globals;
-        $this->tpl           = $tpl;
-        $this->caching       = false;
-        $this->compile_check = true;
-
-        $this->template_dir  = $globals->spoolroot . "/templates/";
-        $this->compile_dir   = $globals->spoolroot . "/spool/mails_c/";
-        $this->config_dir    = $globals->spoolroot . "/configs/";
-        array_unshift($this->plugins_dir, $globals->spoolroot."/plugins/");
-
-        $this->register_outputfilter(Array($this, 'mail_format'));
-        $this->register_function('from',    Array($this, 'setFrom'));
-        $this->register_function('to',      Array($this, 'addTo'));
-        $this->register_function('cc',      Array($this, 'addCc'));
-        $this->register_function('bcc',     Array($this, 'addBcc'));
-        $this->register_function('subject', Array($this, 'setSubject'));
-        $this->register_function('add_header', Array($this, 'addHeader'));
-        $this->assign_by_ref('globals', $globals);
-    }
-
-    public static function &get(&$mailer, $tpl)
-    {
-        static $plmail;
-        if (!isset($plmail) || $plmail->tpl != $tpl) {
-            $plmail = new PlMail($tpl);
-        }
-        $plmail->mailer =& $mailer;
-        return $plmail;
-    }
-
-    public function run($version)
-    {
-        $this->assign('mail_part', $version);
-        $text = $this->fetch($this->tpl);
-        if ($version == 'text') {
-            return wordwrap($text, 78);
-        }
-        return $text;
-    }
-
-    /** used to remove the empty lines due to {from ...}, {to ...} ... functions */
-    static public function mail_format($output, &$smarty)
-    {
-        return "\n".trim($output)."\n";
-    }
-
-    static protected function format_addr(&$params)
-    {
-        if (isset($params['full'])) {
-            return $params['full'];
-        } elseif (empty($params['text'])) {
-            return $params['addr'];
-        } else {
-            return $params['text'].' <'.$params['addr'].'>';
-        }
-    }
-
-    /** template function : from.
-     * {from full=...} for an already formatted address
-     * {from addr=... [text=...]} else
-     */
-    public function setFrom($params, &$smarty)
-    {
-        $smarty->mailer->setFrom(PlMail::format_addr($params));
-    }
-
-    /** template function : to.
-     * {to full=...} for an already formatted address
-     * {to addr=... [text=...]} else
-     */
-    public function addTo($params, &$smarty)
-    {
-        $smarty->mailer->addTo(PlMail::format_addr($params));
-    }
-
-    /** template function : cc.
-     * {cc full=...} for an already formatted address
-     * {cc addr=... [text=...]} else
-     */
-    public function addCc($params, &$smarty)
-    {
-        $smarty->mailer->addCc(PlMail::format_addr($params));
-    }
-
-    /** template function : bcc.
-     * {bcc full=...} for an already formatted address
-     * {bcc addr=... [text=...]} else
-     */
-    public function addBcc($params, &$smarty)
-    {
-        $smarty->mailer->addBcc(PlMail::format_addr($params));
-    }
-
-    /** template function : subject.
-     * {subject text=...}
-     */
-    public function setSubject($params, &$smarty)
-    {
-        $smarty->mailer->setSubject($params['text']);
-    }
-
-    /** template function : add_header.
-     * {add_header name=... value=...}
-     */
-    public function addHeader($params, &$smarty)
-    {
-        $smarty->mailer->addHeader($params['name'], $params['value']);
-    }
-}
-
-require_once('Mail.php');
-require_once('Mail/mime.php');
-
-/** Class for sending inline or multipart-emails.
- * Based on Diogenes' HermesMailer
- */
-class PlMailer extends Mail_Mime {
-
-    private $mail;
-    private $page    = null;
-    private $charset;
-    private $wiki    = null;
-
-    function __construct($tpl = null, $charset = "UTF-8")
-    {
-        $this->charset = $charset;
-        $this->Mail_Mime("\n");
-        $this->mail = Mail::factory('sendmail', Array('sendmail_args' => '-oi'));
-        if (!is_null($tpl)) {
-            $this->page =& PlMail::get($this, $tpl);
-        }
-    }
-
-    /**
-     * converts all : Foo Bar Baz <quux@foobar.org> into "Foo Bar Baz" <quux@foobar.org> which is RFC compliant
-     */
-    private function correct_emails($email)
-    {
-        return preg_replace('!(^|, *)([^<"]+?) *(<[^>]*>)!u', '\1"\2" \3', $email);
-    }
-
-    public function addTo($email)
-    {
-        $email = $this->correct_emails($email);
-        if (isset($this->_headers['To'])) {
-            $this->_headers['To'] .= ", $email";
-        } else {
-            $this->_headers['To'] = $email;
-        }
-    }
-
-    public function addCc($email)
-    {
-        return parent::addCc($this->correct_emails($email));
-    }
-
-    public function addBcc($email)
-    {
-        return parent::addBcc($this->correct_emails($email));
-    }
-
-    public function setFrom($email)
-    {
-        return parent::setFrom($this->correct_emails($email));
-    }
-
-    public function addHeader($hdr,$val)
-    {
-        switch($hdr) {
-            case 'From':
-                $this->setFrom($val);
-                break;
-
-            case 'To':
-                unset($this->_headers[$hdr]);
-                $this->addTo($val);
-                break;
-
-            case 'Cc':
-                unset($this->_headers[$hdr]);
-                $this->addCc($val);
-                break;
-
-            case 'Bcc':
-                unset($this->_headers[$hdr]);
-                $this->addBcc($val);
-                break;
-
-            default:
-                $this->headers(Array($hdr=>$val));
-        }
-    }
-
-    public function addUploadAttachment(PlUpload &$upload, $name)
-    {
-        $encoding = $upload->isType('text') ? 'quoted-printable' : 'base64';
-        $this->addAttachment($upload->getContents(), $upload->contentType(), $name, false, $encoding);
-    }
-
-    public function assign($var, $value)
-    {
-        if (!is_null($this->page)) {
-            $this->page->assign($var, $value);
-        }
-    }
-
-    public function assign_by_ref($var, &$value)
-    {
-        if (!is_null($this->page)) {
-            $this->page->assign_by_ref($var, $value);
-        }
-    }
-
-    public function register_modifier($var, $callback)
-    {
-        if (!is_null($this->page)) {
-            $this->page->register_modifier($var, $callback);
-        }
-    }
-
-    public function register_function($var, $callback)
-    {
-        if (!is_null($this->page)) {
-            $this->page->register_function($var, $callback);
-        }
-    }
-
-    public function setWikiBody($wiki)
-    {
-        $this->wiki = $wiki;
-    }
-
-    private function processPage($with_html = true)
-    {
-        if (!is_null($this->page)) {
-            global $globals;
-            if (!($globals->debug & DEBUG_SMARTY)) {
-                $level = error_reporting(0);
-            }
-            $this->page->run('head'); // process page headers
-            $this->wiki = trim($this->page->run('wiki')); // get wiki
-            if (!$this->wiki) {
-                $this->setTxtBody($this->page->run('text'));
-                if ($with_html) {
-                    $html = trim($this->page->run('html'));
-                    if (!empty($html)) {
-                        $this->setHtmlBody($html);
-                    }
-                }
-            }
-            if (!($globals->debug & DEBUG_SMARTY)) {
-                error_reporting($level);
-            }
-        }
-        if ($this->wiki) {
-            $this->setTxtBody(MiniWiki::WikiToText($this->wiki, false, 0, 78));
-            if ($with_html) {
-                $this->setHtmlBody('<html><body>' . MiniWiki::WikiToHtml($this->wiki, true) . '</body></html>');
-            }
-        }
-    }
-
-    public function send($with_html = true)
-    {
-        $this->processPage($with_html);
-        if (S::v('forlife')) {
-            global $globals;
-            $this->addHeader('X-Org-Mail', S::v('forlife') . '@' . $globals->mail->domain);
-        }
-        $addrs = Array();
-        foreach(Array('To', 'Cc', 'Bcc') as $hdr) {
-            if(isset($this->_headers[$hdr])) {
-                require_once 'Mail/RFC822.php';
-                $parsed = @Mail_RFC822::parseAddressList($this->_headers[$hdr]);
-                if (is_array($parsed)) {
-                    $addrs = array_merge($addrs, $parsed);
-                }
-            }
-        }
-        if(empty($addrs)) {
-            return false;
-        }
-
-        $dests = Array();
-        foreach($addrs as $a) {
-            $dests[] = "{$a->mailbox}@{$a->host}";
-        }
-
-        // very important to do it in THIS order very precisely.
-        $body = $this->get(array('text_charset' => $this->charset,
-                                 'text_encoding' => '8bit',
-                                 'html_charset' => $this->charset,
-                                 'head_charset' => $this->charset));
-        $hdrs = $this->headers();
-        if (empty($hdrs['From'])) {
-            trigger_error('Empty "From", mail not sent', E_USER_WARNING);
-            return false;
-        }
-        return $this->mail->send($dests, $hdrs, $body);
-    }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/plmodule.php b/classes/plmodule.php
deleted file mode 100644 (file)
index 06e5da8..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-abstract class PLModule
-{
-    abstract function handlers();
-
-    /** Register a hook
-     * @param fun name of the handler (the exact name will be handler_$fun)
-     * @param auth authentification level of needed to run this handler
-     * @param perms permission required to run this handler
-     * @param type additionnal flags
-     *
-     * Perms syntax is the following:
-     * perms = rights(,rights)*
-     * rights = right(:right)*
-     * right is an atomic right permission (like 'admin', 'user', 'groupadmin', 'groupmember'...)
-     *
-     * If type is set to NO_AUTH, the system will return 403 instead of asking auth data
-     * this is useful for Ajax handler
-     * If type is not set to NO_SKIN, the system will consider redirecting the user to https
-     */
-    public function make_hook($fun, $auth, $perms = 'user', $type = DO_AUTH)
-    {
-        return array('hook'  => array($this, 'handler_'.$fun),
-                     'auth'  => $auth,
-                     'perms' => $perms,
-                     'type'  => $type);
-    }
-
-    /* static functions */
-
-    public static function factory($modname)
-    {
-        $mod_path = dirname(__FILE__) . '/../modules/' . $modname . '.php';
-        $class    = ucfirst($modname) . 'Module';
-
-        require_once $mod_path;
-        return new $class();
-    }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/plset.php b/classes/plset.php
deleted file mode 100644 (file)
index 71bd5ee..0000000
+++ /dev/null
@@ -1,307 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-/** UserSet is a light-weight Model/View tool for displaying a set of items
- */
-class PlSet
-{
-    private $from    = null;
-    private $groupby = null;
-    private $joins   = null;
-    private $where   = null;
-
-    private $count   = null;
-
-    private $mods      = array();
-    private $modParams = array();
-    private $mod       = null;
-    private $default   = null;
-
-    public function __construct($from, $joins = '', $where = '', $groupby = '')
-    {
-        $this->from    = $from;
-        $this->joins   = $joins;
-        $this->where   = $where;
-        $this->groupby = $groupby;
-    }
-
-    public function addMod($name, $description, $default = false, array $params = array())
-    {
-        $name = strtolower($name);
-        $this->mods[$name]      = $description;
-        $this->modParams[$name] = $params;
-        if ($default) {
-            $this->default = $name;
-        }
-    }
-
-    public function rmMod($name)
-    {
-        $name = strtolower($name);
-        unset($this->mods[$name]);
-    }
-
-    private function &query($fields, $from, $joins, $where, $groupby, $order, $limit)
-    {
-        if (trim($order)) {
-            $order = "ORDER BY $order";
-        }
-        if (trim($where)) {
-            $where = "WHERE $where";
-        }
-        if (trim($groupby)) {
-            $groupby = "GROUP BY $groupby";
-        }
-        $query = "SELECT  SQL_CALC_FOUND_ROWS
-                          $fields
-                    FROM  $from
-                          $joins
-                          $where
-                          $groupby
-                          $order
-                          $limit";
-//        echo $query;
-//        print_r($this);
-        $it    = XDB::query($query);
-        $it    = $it->fetchAllAssoc();
-        $count = XDB::query('SELECT FOUND_ROWS()');
-        $this->count = intval($count->fetchOneCell());
-        return $it;
-    }
-
-    public function args()
-    {
-        $get = $_GET;
-        unset($get['n']);
-        return $get;
-    }
-
-    protected function encodeArgs(array $args, $encode = false)
-    {
-        $qs = '?';
-        $sep = '&';
-        foreach ($args as $k=>$v) {
-            if (!$encode) {
-                $k = urlencode($k);
-                $v = urlencode($v);
-            }
-            $qs .= "$k=$v$sep";
-        }
-        return $encode ? urlencode($qs) : $qs;
-    }
-
-    public function &get($fields, $joins, $where, $groupby, $order, $limitcount = null, $limitfrom = null)
-    {
-        if (!is_null($limitcount)) {
-            if (!is_null($limitfrom)) {
-                $limitcount = "$limitfrom,$limitcount";
-            }
-            $limitcount = "LIMIT $limitcount";
-        }
-        $joins  = $this->joins . ' ' . $joins;
-        if (trim($this->where)) {
-            if (trim($where)) {
-                $where .= ' AND ';
-            }
-            $where .= $this->where;
-        }
-        if (!$groupby) {
-            $groupby = $this->groupby;
-        }
-        return $this->query($fields, $this->from, $joins, $where, $groupby, $order, $limitcount);
-    }
-
-    public function count()
-    {
-        return $this->count;
-    }
-
-    private function &buildView($view, $data)
-    {
-        $view = strtolower($view);
-        if (!$view || !class_exists($view . 'View') || !isset($this->mods[$view])) {
-            reset($this->mods);
-            $view = $this->default ? $this->default : key($this->mods);
-        }
-        $this->mod = $view;
-        $class = $view . 'View';
-        if (!class_exists($class)) {
-            $view = null;
-        } else {
-            $view = new $class($this, $data, $this->modParams[$this->mod]);
-            if (!$view instanceof PlView) {
-                $view = null;
-            }
-        }
-        return $view;
-    }
-
-    public function apply($baseurl, PlatalPage &$page, $view = null, $data = null)
-    {
-        $view =& $this->buildView($view, $data);
-        if (is_null($view)) {
-            return false;
-        }
-        $args = $view->args();
-        if (!isset($args['rechercher'])) {
-            $args['rechercher'] = 'Chercher';
-        }
-        $page->changeTpl('core/plset.tpl');
-        $page->assign('plset_base', $baseurl);
-        $page->assign('plset_mods', $this->mods);
-        $page->assign('plset_mod', $this->mod);
-        $page->assign('plset_search', $this->encodeArgs($args));
-        $page->assign('plset_search_enc', $this->encodeArgs($args, true));
-        foreach ($this->modParams[$this->mod] as $param=>$value) {
-            $page->assign($this->mod . '_' . $param, $value);
-        }
-        $page->assign('plset_content', $view->apply($page));
-        $page->assign('plset_count', $this->count);
-        return true;
-    }
-}
-
-interface PlView
-{
-    public function __construct(PlSet &$set, $data, array $params);
-    public function apply(PlatalPage &$page);
-    public function args();
-}
-
-abstract class MultipageView implements PlView
-{
-    protected $set;
-
-    public $pages  = 1;
-    public $page   = 1;
-    public $offset = 0;
-
-    protected $entriesPerPage = 20;
-    protected $params = array();
-
-    protected $sortkeys = array();
-    protected $defaultkey = null;
-
-    protected $bound_field = null;
-
-    public function __construct(PlSet &$set, $data, array $params)
-    {
-        $this->set   =& $set;
-        $this->page   = Env::i('page', 1);
-        $this->offset = $this->entriesPerPage * ($this->page - 1);
-        $this->params = $params;
-    }
-
-    public function joins()
-    {
-        return null;
-    }
-
-    public function where()
-    {
-        return null;
-    }
-
-    public function groupBy()
-    {
-        return null;
-    }
-
-    public function bounds()
-    {
-        return null;
-    }
-
-    protected function addSortKey($name, array $keys, $desc, $default = false)
-    {
-        $this->sortkeys[$name] = array('keys' => $keys, 'desc' => $desc);
-        if (!$this->defaultkey || $default) {
-            $this->defaultkey = $name;
-        }
-    }
-
-    public function order()
-    {
-        $order = Env::v('order', $this->defaultkey);
-        $invert = ($order{0} == '-');
-        if ($invert) {
-            $order = substr($order, 1);
-        }
-        $list = array();
-        foreach ($this->sortkeys[$order]['keys'] as $item) {
-            $desc = ($item{0} == '-');
-            if ($desc) {
-                $item = substr($item, 1);
-            }
-            if ($desc xor $invert) {
-                $item .= ' DESC';
-            }
-            $list[] = $item;
-        }
-        return implode(', ', $list);
-    }
-
-    abstract public function templateName();
-
-    public function apply(PlatalPage &$page)
-    {
-        $res = $this->set->get($this->fields(),
-                               $this->joins(),
-                               $this->where(),
-                               $this->groupBy(),
-                               $this->order(),
-                               $this->entriesPerPage,
-                               $this->offset);
-        $show_bounds = $this->bounds();
-        $end         = end($res);
-        if ($show_bounds) {
-            if ($show_bounds == 1) {
-                $first = $res[0][$this->bound_field];
-                $last  = $end[$this->bound_field];
-            } elseif ($show_bounds == -1) {
-                $first = $end[$this->bound_field];
-                $last  = $res[0][$this->bound_field];
-            }
-            $page->assign('first', $first);
-            $page->assign('last', $last);
-        }
-
-        $page->assign('show_bounds', $show_bounds);
-        $page->assign('order', Env::v('order', $this->defaultkey));
-        $page->assign('orders', $this->sortkeys);
-        $page->assign_by_ref('plview', $this);
-        $page->assign_by_ref('set', $res);
-        $count = $this->set->count();
-        $this->pages = intval(ceil($count / $this->entriesPerPage));
-        return 'include/plview.multipage.tpl';
-    }
-
-    public function args()
-    {
-        $list = $this->set->args();
-        unset($list['page']);
-        unset($list['order']);
-        return $list;
-    }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/pltableeditor.php b/classes/pltableeditor.php
deleted file mode 100644 (file)
index d42d6b8..0000000
+++ /dev/null
@@ -1,324 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-class PLTableEditor
-{
-    // the plat/al name of the page
-    public $pl;
-    // the table name
-    public $table;
-    // joint tables to delete when deleting an entry
-    public $jtables = array();
-    // sorting field
-    public $sort = array();
-    // the id field
-    public $idfield;
-    // possibility to edit the field
-    public $idfield_editable;
-    // vars
-    public $vars;
-    // number of displayed fields
-    public $nbfields;
-    // a where clause to restrict table
-    public $whereclause;
-    // the field for sorting entries
-    public $sortfield;
-    public $sortdesc = false;
-    // action to do to delete row:
-    // null => delete effectively, false => no deletion, SQL
-    public $delete_action;
-    public $delete_message;
-    // Should "Save" button return to the list view
-    public $auto_return = true;
-
-    /* table editor for platal
-     * $plname : the PLname of the page, ex: admin/payments
-     * $table : the table to edit, ex: profile_medals
-     * $idfield : the field of the table which is the id, ex: id
-     * $editid : is the id editable or not (if not, it is considered as an int)
-     */
-    public function __construct($plname, $table, $idfield, $editid=false)
-    {
-        $this->pl = $plname;
-        $this->table = $table;
-        $this->idfield = $idfield;
-        $this->sortfield = $idfield;
-        $this->idfield_editable = $editid;
-        $this->whereclause = '1';
-        $r = XDB::iterator("SHOW FULL COLUMNS FROM $table");
-        $this->vars = array();
-        while ($a = $r->next()) {
-            // desc will be the title of the column
-            $a['desc'] = $a['Field'];
-            $a['display'] = true;
-
-            if (substr($a['Type'],0,8) == 'varchar(') {
-                // limit editing box size
-                $a['Size'] = $a['Maxlength'] = substr($a['Type'], 8, strlen($a['Type']) - 9);
-                if ($a['Size'] > 40) $a['Size'] = 40;
-                // if too big, put a textarea
-                $a['Type'] = ($a['Maxlength']<200)?'varchar':'varchar200';
-            }
-            elseif ($a['Type'] == 'text' || $a['Type'] == 'mediumtext')
-                $a['Type'] = 'textarea';
-            elseif (substr($a['Type'],0,4) == 'set(') {
-                // get the list of options
-                $a['List'] = explode('§',str_replace("','","§",substr($a['Type'], 5, strlen($a['Type']) - 7)));
-                if (count($a['List']) == 1) {
-                    $a['Type'] = 'checkbox';
-                    $a['Value'] = $a['List'][0];
-                } else {
-                    $a['Type'] = 'set';
-                }
-            }
-            elseif (substr($a['Type'],0,5) == 'enum(') {
-                // get the list of options
-                $a['List'] = explode('§',str_replace("','","§",substr($a['Type'], 6, strlen($a['Type']) - 8)));
-                $a['Type'] = 'enum';
-            }
-            elseif (substr($a['Type'],0,10) == 'timestamp(' || $a['Type'] == 'datetime') {
-                $a['Type'] = 'timestamp';
-            }
-            elseif ($a['Comment'] == 'ip_address') {
-                $a['Type']='ip_address';
-            }
-
-            $this->vars[$a['Field']] = $a;
-        }
-        $this->vars[$idfield]['desc'] = 'id';
-    }
-
-    // called before creating a new entry
-    private function prepare_new()
-    {
-        $entry = array();
-        foreach ($this->vars as $field => $descr) {
-            $entry[$field] = $descr['Default'];
-        }
-        return $this->prepare_edit($entry);
-    }
-
-    // called before editing $entry
-    private function prepare_edit(&$entry)
-    {
-        foreach ($this->vars as $field => $descr) {
-            if ($descr['Type'] == 'set') {
-                // get the list of options selected
-                $selected = explode(',', $entry[$field]);
-                $entry[$field] = array();
-                foreach ($selected as $option)
-                    $entry[$field][$option] = 1;
-            }
-            if ($descr['Type'] == 'timestamp') {
-                // set readable timestamp
-                $date =& $entry[$field];
-                $date = preg_replace('/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', '\3/\2/\1 \4:\5:\6', $date);
-            }
-            if ($descr['Type'] == 'date') {
-                $date =& $entry[$field];
-                $date = preg_replace('/([0-9]{4})-?([0-9]{2})-?([0-9]{2})/', '\3/\2/\1', $date);
-            }
-            if ($descr['Type'] == 'ip_address') {
-                $ip = & $entry[$field];
-                $ip = long2ip($ip);
-            }
-        }
-        return $entry;
-    }
-
-    // set whether the save button show redirect to list view or edit view
-    public function list_on_edit($var)
-    {
-        $this->auto_return = $var;
-    }
-
-    // change display of a field
-    public function describe($name, $desc, $display)
-    {
-        $this->vars[$name]['desc'] = $desc;
-        $this->vars[$name]['display'] = $display;
-    }
-
-    // add a join table, when deleting a row corresponding entries will be deleted in these tables
-    public function add_join_table($name,$joinid,$joindel,$joinextra="")
-    {
-        if ($joindel)
-            $this->jtables[$name] = array("joinid" => $joinid,"joinextra" => $joinextra?(" AND ".$joinextra):"");
-    }
-
-    // add a sort key
-    public function add_sort_field($key, $desc = false, $default = false)
-    {
-        if ($default) {
-            $this->sortfield = $key . ($desc ? ' DESC' : '');
-        } else {
-            $this->sort[] = $key . ($desc ? ' DESC' : '');
-        }
-    }
-
-    // add a where clause to limit table listing
-    public function set_where_clause($whereclause="1")
-    {
-        $this->whereclause = $whereclause;
-    }
-    
-    // set an action when trying to delete row
-    public function on_delete($action = NULL, $message = NULL)
-    {
-        $this->delete_action = $action;
-        $this->delete_message = $message;
-    }
-
-    // call when done
-    public function apply(PlatalPage &$page, $action, $id = false)
-    {
-        $page->changeTpl('core/table-editor.tpl');
-        $list = true;
-        if ($action == 'delete') {
-            S::assert_xsrf_token();
-
-            if (!isset($this->delete_action)) {
-                foreach ($this->jtables as $table => $j)
-                    XDB::execute("DELETE FROM {$table} WHERE {$j['joinid']} = {?}{$j['joinextra']}", $id);
-                XDB::execute("DELETE FROM {$this->table} WHERE {$this->idfield} = {?}",$id);
-                $page->trigSuccess("L'entrée ".$id." a été supprimée.");
-            } else if ($this->delete_action) {
-                XDB::execute($this->delete_action, $id);
-                if (isset($this->delete_message)) {
-                    $page->trigSuccess($this->delete_message);
-                } else {
-                    $page->trigSuccess("L'entrée ".$id." a été supprimée.");
-                }
-            } else {
-                $page->trigError("Impossible de supprimer l'entrée.");
-            }
-        }
-        if ($action == 'edit') {
-            $r = XDB::query("SELECT * FROM {$this->table} WHERE {$this->idfield} = {?} AND {$this->whereclause}",$id);
-            $entry = $r->fetchOneAssoc();
-            $page->assign('entry', $this->prepare_edit($entry));
-            $page->assign('id', $id);
-            $list = false;
-        }
-        if ($action == 'massadd') {
-            $importer = new CSVImporter($this->table, $this->idfield_editable ? $this->idfield : null);
-            $fields   = array();
-            foreach ($this->vars as $field=>$descr) {
-                if ($this->idfield_editable || $field != $this->idfield) {
-                    $fields[] = $field;
-                    $importer->describe($field, @$descr['desc']);
-                }
-            }
-            $page->assign('massadd', true);
-            $importer->apply($page, $this->pl . '/massadd', $fields);
-            $list = false;
-        }
-        if ($action == 'new') {
-            if (!$this->idfield_editable) {
-                $r = XDB::query("SELECT MAX({$this->idfield})+1 FROM {$this->table}");
-                $page->assign('id', $r->fetchOneCell());
-                $page->assign('entry', $this->prepare_new());
-            }
-            $list = false;
-        }
-        if ($action == 'update') {
-            S::assert_xsrf_token();
-
-            $values = "";
-            $cancel = false;
-            foreach ($this->vars as $field => $descr) {
-                if ($values) $values .= ',';
-                if (($field == $this->idfield) && !$this->idfield_editable)
-                    $val = "'".addslashes($id)."'";
-                elseif ($descr['Type'] == 'set') {
-                    $val = "";
-                    if (Post::has($field)) foreach (Post::v($field) as $option) {
-                        if ($val) $val .= ',';
-                        $val .= $option;
-                    }
-                    $val = "'".addslashes($val)."'";
-                } elseif ($descr['Type'] == 'checkbox') {
-                    $val = Post::has($field)?"'".addslashes($descr['Value'])."'":"''";
-                } elseif (Post::has($field)) {
-                    $val = Post::v($field);
-                    if ($descr['Type'] == 'timestamp') {
-                        $val = preg_replace('/([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})/', '\3\2\1\4\5\6', $val);
-                    }
-                    elseif ($descr['Type'] == 'date') {
-                        $val = preg_replace('/([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})/', '\3-\2-\1', $val);
-                    }
-                    elseif ($descr['Type'] == 'ip_address') {
-                        $val = ip2long($val);
-                    }
-                    $val = "'".addslashes($val)."'";
-                } else {
-                    $cancel = true;
-                    $page->trigError("Il manque le champ ".$field);
-                }
-                $values .= $val;
-            }
-            if (!$cancel) {
-                if ($this->idfield_editable && ($id != Post::v($this->idfield)) && $action != 'new')
-                    XDB::execute("UPDATE {$this->table} SET {$this->idfield} = {?} WHERE {$this->idfield} = {?} AND {$this->whereclause}", Post::v($this->idfield), $id);
-                XDB::execute("REPLACE INTO {$this->table} VALUES ($values)");
-                if ($id !== false)
-                    $page->trigSuccess("L'entrée ".$id." a été mise à jour.");
-                else {
-                    $page->trigSuccess("Une nouvelle entrée a été créée.");
-                    $id = XDB::insertId();
-                }
-            } else
-                $page->trigError("Impossible de mettre à jour.");
-            if (!$this->auto_return) {
-                return $this->apply($page, 'edit', $id);
-            }
-        }
-        if ($action == 'sort') {
-            $this->sortfield = $id;
-        }
-        if ($action == 'sortdesc') {
-            $this->sortfield = $id.' DESC';
-        }
-        if ($list) {
-            // user can sort by field by clicking the title of the column
-            if (isset($this->sortfield)) {
-                // add this sort order after the others (chosen by dev)
-                $this->add_sort_field($this->sortfield);
-                if (substr($this->sortfield,-5) == ' DESC') {
-                    $this->sortfield = substr($this->sortfield,0,-5);
-                    $this->sortdesc = true;
-                }
-            }
-            if (count($this->sort) > 0) {
-                $sort = 'ORDER BY ' . join($this->sort, ',');
-            }
-            $it = XDB::iterator("SELECT * FROM {$this->table} WHERE {$this->whereclause} $sort");
-            $this->nbfields = 0;
-            foreach ($this->vars as $field => $descr)
-                if ($descr['display']) $this->nbfields++;
-            $page->assign('list', $it);
-        }
-        $page->assign('t', $this);
-    }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/plupload.php b/classes/plupload.php
deleted file mode 100644 (file)
index ea192f0..0000000
+++ /dev/null
@@ -1,316 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-/** Class to store per user and per category files
- */
-class PlUpload
-{
-    private $forlife;
-    private $category;
-    private $file_id;
-
-    private $filename;
-    private $type;
-
-    static public $lastError;
-
-    /** For images
-     */
-    private $x;
-    private $y;
-
-    public function __construct($forlife, $category, $filename = null)
-    {
-        $this->file_id  = $filename;
-        $this->category = $category;
-        $this->forlife  = $forlife;
-        $this->filename = $this->makeFilename($this->file_id);
-        $this->checkContentType();
-    }
-
-    private function makeFilename($file_id)
-    {
-        global $globals;
-        $filename = $globals->spoolroot . '/spool/tmp/';
-        if (!file_exists($filename)) {
-            if (!mkdir($filename)) {
-                trigger_error('can\'t create upload directory: ' . $filename, E_USER_ERROR);
-            }
-        }
-        $filename .= $this->forlife . '--' . $this->category;
-        if ($file_id) {
-            $filename .= '--' . $file_id;
-        }
-        return $filename;
-    }
-
-    private function checkContentType()
-    {
-        if ($this->exists()) {
-            $this->type = trim(mime_content_type($this->filename));
-            if ($this->type == 'text/plain') { // Workaround a bug of php 5.2.0+etch10 (mime_content_type fallback is 'text/plain')
-                $this->type = preg_replace('/;.*/', '', trim(shell_exec('file -bi ' . escapeshellarg($this->filename))));
-            }
-        }
-    }
-
-    public function upload(array &$file)
-    {
-        if (@$file['error']) {
-            PlUpload::$lastError = 'Erreur de téléchargement de ' . $file['name'] . ' : ';
-            switch ($file['error']) {
-              case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE:
-                PlUpload::$lastError .= 'le fichier est trop gros (limite : ' . ini_get('upload_max_filesize') . ')';
-                break;
-              case UPLOAD_ERR_PARTIAL: case UPLOAD_ERR_NO_FILE:
-                PlUpload::$lastError .= 'le fichier n\'a pas été transmis intégralement';
-                break;
-              default:
-                PlUpload::$lastError .= 'erreur interne';
-                break;
-            }
-            return false;
-        }
-        if (!is_uploaded_file($file['tmp_name'])) {
-            return false;
-        } else if (!move_uploaded_file($file['tmp_name'], $this->filename)) {
-            return false;
-        }
-        $this->checkContentType();
-        return true;
-    }
-
-    public function copyFrom($filename)
-    {
-        if (!copy($filename, $this->filename)) {
-            return false;
-        }
-        $this->checkContentType();
-        return true;
-    }
-
-    public function download($url)
-    {
-        if (!$url || @parse_url($url) === false) {
-            trigger_error('malformed URL given', E_USER_NOTICE);
-            return false;
-        }
-        $data = file_get_contents($url);
-        if (!$data) {
-            return false;
-        }
-        if (!file_put_contents($this->filename, $data)) {
-            return false;
-        }
-        $this->checkContentType();
-        return true;
-    }
-
-    static public function &get(array &$file, $forlife, $category, $uniq = false)
-    {
-        $upload = new PlUpload($forlife, $category, $uniq ? null : $file['name']);
-        if (!$upload->upload($file)) {
-            $upload = null;
-        }
-        return $upload;
-    }
-
-    public function rm()
-    {
-        @unlink($this->filename);
-        @clearstatcache();
-    }
-
-    public function rename($fn)
-    {
-        if (!$this->file_id) {
-            return false;
-        }
-        $filename = $this->makeFilename($fn);
-        if (rename($this->filename)) {
-            $this->filename = $filename;
-            $this->file_id  = $fn;
-            clearstatcache();
-            return true;
-        }
-        return false;
-    }
-
-    public function exists()
-    {
-        return file_exists($this->filename);
-    }
-
-    static public function listRawFiles($forlife = '*', $category = '*', $uniq = false, $basename = false)
-    {
-        global $globals;
-        $filename = $globals->spoolroot . '/spool/tmp/';
-        $filename .= $forlife . '--' . $category;
-        if (!$uniq) {
-            $filename .= '--*';
-        }
-        $files = glob($filename);
-        if ($basename) {
-            $files = array_map('basename', $files);
-        }
-        return $files;
-    }
-
-    static public function listFilenames($forlife = '*', $category = '*')
-    {
-        $files = PlUpload::listRawFiles($forlife, $category, false, true);
-        foreach ($files as &$name) {
-            list($forlife, $cat, $fn) = explode('--', $name, 3);
-            $name = $fn;
-        }
-        return $files;
-    }
-
-    static public function &listFiles($forlife = '*', $category = '*', $uniq = false)
-    {
-        $res   = array();
-        $files = PlUpload::listRawFiles($forlife, $category, $uniq, true);
-        foreach ($files as $name) {
-            list($forlife, $cat, $fn) = explode('--', $name, 3);
-            $res[$fn] = new PlUpload($forlife, $cat, $fn);
-        }
-        return $res;
-    }
-
-    static public function clear($user = '*', $category = '*', $uniq = false)
-    {
-        $files = PlUpload::listRawFiles($user, $category, $uniq, false);
-        array_map('unlink', $files);
-    }
-
-    public function contentType()
-    {
-        return $this->type;
-    }
-
-    public function isType($type, $subtype = null)
-    {
-        list($mytype, $mysubtype) = explode('/', $this->type);
-        if ($mytype != $type || ($subtype && $mysubtype != $subtype)) {
-            return false;
-        }
-        return true;
-    }
-
-    public function imageInfo()
-    {
-        static $map;
-        if (!isset($map)) {
-            $tmpmap = array (IMG_GIF => 'gif', IMG_JPG => 'jpeg', IMG_PNG => 'png', IMG_WBMP => 'bmp', IMG_XPM => 'xpm');
-            $map = array();
-            $supported = imagetypes();
-            foreach ($tmpmap as $type=>$mime) {
-                if ($supported & $type) {
-                    $map[$type] = $mime;
-                }
-            }
-        }
-        $array = getimagesize($this->filename);
-        $array[2] = @$map[$array[2]];
-        if (!$array[2]) {
-            list($image, $type) = explode('/', $array['mime']);
-            $array[2] = $type;
-        }
-        if (!$array[2]) {
-            trigger_error('unknown image type', E_USER_NOTICE);
-            return null;
-        }
-        return $array;
-    }
-
-    public function resizeImage($max_x = -1, $max_y = -1, $min_x = 0, $min_y = 0, $maxsize = -1)
-    {
-        if (!$this->exists() || strpos($this->type, 'image/') !== 0) {
-            trigger_error('not an image', E_USER_NOTICE);
-            return false;
-        }
-        $image_infos = $this->imageInfo();
-        if (!$image_infos) {
-            trigger_error('invalid image', E_USER_NOTICE);
-            return false;
-        }
-        list($this->x, $this->y, $mimetype) = $image_infos;
-        if ($max_x == -1) {
-            $max_x = $this->x;
-        }
-        if ($max_y == -1) {
-            $max_y = $this->y;
-        }
-        if ($maxsize == -1) {
-            $maxsize = filesize($this->filename);
-        }
-        if (filesize($this->filename) > $maxsize || $this->x > $max_x || $this->y > $max_y
-                                                 || $this->x < $min_x || $this->y < $min_y) {
-            $img = imagecreatefromstring(file_get_contents($this->filename));
-            if (!$img) {
-                trigger_error('too large image, can\'t be resized', E_USER_NOTICE);
-                return false;
-            }
-
-            $nx = $this->x;
-            $ny = $this->y;
-            if ($nx > $max_x) {
-                $ny = intval($ny*$max_x/$nx);
-                $nx = $max_x;
-            }
-            if ($ny > $max_y) {
-                $nx = intval($nx*$max_y/$ny);
-                $ny = $max_y;
-            }
-            if ($nx < $min_x) {
-                $ny = intval($ny*$min_x/$nx);
-                $nx = $min_x;
-            }
-            if ($ny < $min_y) {
-                $nx = intval($nx * $min_y/$ny);
-                $ny = $min_y;
-            }
-
-            $comp = 90;
-            do {
-                $img2 = imagecreatetruecolor($nx, $ny);
-                imagecopyresampled($img2, $img, 0, 0, 0, 0, $nx, $ny, $this->x, $this->y);
-                imagejpeg($img2, $this->filename, $comp);
-                $comp --;
-                clearstatcache();
-            } while (filesize($this->filename) > $maxsize && $comp > 0);
-            $this->type = 'image/jpeg';
-            $this->x    = $nx;
-            $this->y    = $ny;
-        }
-        return true;
-    }
-
-    public function getContents()
-    {
-        if ($this->exists()) {
-            return file_get_contents($this->filename);
-        }
-        return null;
-    }
-}
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/plwizard.php b/classes/plwizard.php
deleted file mode 100644 (file)
index fecf881..0000000
+++ /dev/null
@@ -1,221 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- **************************************************************************/
-
-/** A Wizard Page is a page of a wizard. It is a self-contained step which
- * handles both the creation and initialisation of the step (by using the
- * Wizard global state, if needed) and the processing of the action the
- * user made on it.
- */
-interface PlWizardPage
-{
-    /** Build a new instance of the class
-     * associated with the given wizard master.
-     */
-    public function __construct(PlWizard &$wiz);
-
-    /** Return the name of the templace describing the page.
-     */
-    public function template();
-
-    /** Prepare the page by assigning to it any useful value.
-     */
-    public function prepare(PlatalPage &$page, $id);
-
-    /** Process information resulting of the application of the page.
-     * This function must return a clue indicating the next page to show.
-     * This clue can be either a page id, a page number or a navigation
-     * id (PlWizard::FIRST_PAGE, PlWizard::NEXT_PAGE, PlWizard::CURRENT_PAGE
-     *  PlWizard::PREVIOUS_PAGE, PlWizard::LAST_PAGE).
-     */
-    public function process();
-}
-
-/** A PlWizard is a set of pages through which the user can navigate,
- * his action on a page determining which the next one will be.
- *
- * A Wizard can either a stateless wizard (which is only a set of
- * independent pages through which the user can easily navigate) or
- * stateful (a suite of steps where each step gives clue for the next
- * one).
- */
-class PlWizard
-{
-    const FIRST_PAGE    = 'bt_first';
-    const NEXT_PAGE     = 'bt_next';
-    const CURRENT_PAGE  = 'bt_current';
-    const PREVIOUS_PAGE = 'bt_previous';
-    const LAST_PAGE     = 'bt_last';
-
-    protected $name;
-    protected $layout;
-    protected $stateless;
-    protected $ajax;
-
-    protected $pages;
-    protected $titles;
-    protected $lookup;
-    protected $inv_lookup;
-
-    public function __construct($name, $layout, $stateless = false, $ajax = true)
-    {
-        $this->name      = 'wiz_' . $name;
-        $this->layout    = $layout;
-        $this->stateless = $stateless;
-        $this->pages  = array();
-        $this->lookup = array();
-        $this->titles = array();
-        $this->ajax   = $ajax;
-        if (!isset($_SESSION[$this->name])) {
-            $_SESSION[$this->name] = array();
-            $_SESSION[$this->name . '_page']  = null;
-            $_SESSION[$this->name . '_stack'] = array();
-        }
-    }
-
-    public function addPage($class, $title, $id = null)
-    {
-        if ($id == null) {
-            $id = count($this->pages);
-        }
-        $this->lookup[$id]  = count($this->pages);
-        $this->inv_lookup[] = $id;
-        $this->pages[]      = $class;
-        $this->titles[]     = $title;
-    }
-
-    public function set($varname, $value)
-    {
-        $_SESSION[$this->name][$varname] = $value;
-    }
-
-    public function get($varname, $default = null)
-    {
-        return isset($_SESSION[$this->name][$varname]) ?
-                    $_SESSION[$this->name][$varname] : $default;
-    }
-
-    public function v($varname, $default = "")
-    {
-        return $this->get($varname, $default);
-    }
-
-    public function i($varname, $default = 0)
-    {
-        return (int)$this->get($varname, $default);
-    }
-
-    public function clear($varname = null)
-    {
-        if (is_null($varname)) {
-            $_SESSION[$this->name] = array();
-        } else {
-            unset($_SESSION[$this->name][$varname]);
-        }
-        $_SESSION[$this->name . '_page'] = null;
-    }
-
-    private function getPage($id)
-    {
-        $page = $this->pages[$id];
-        return new $page($this);
-    }
-
-    public function apply(PlatalPage &$smarty, $baseurl, $pgid = null, $mode = 'normal')
-    {
-        if ($this->stateless && (isset($this->lookup[$pgid]) || isset($this->pages[$pgid]))) { 
-            $curpage = is_numeric($pgid) ? $pgid : $this->lookup[$pgid]; 
-        } else if ($this->stateless && is_null($pgid)) {
-            $curpage = 0;
-        } else {
-            $curpage = $_SESSION[$this->name . '_page'];
-        }
-        $oldpage = $curpage;
-
-        // Process the previous page
-        if (Post::has('valid_page')) {
-            S::assert_xsrf_token();
-
-            $page = $this->getPage(Post::i('valid_page'));
-            $curpage = Post::i('valid_page');
-            $next = $page->process();
-            $last = $curpage;
-            switch ($next) {
-              case PlWizard::FIRST_PAGE:
-                $curpage = 0;
-                break;
-              case PlWizard::PREVIOUS_PAGE:
-                if (!$this->stateless && count($_SESSION[$this->name . '_stack'])) {
-                    $curpage = array_pop($_SESSION[$this->name . '_stack']);
-                } elseif ($curpage && $this->stateless) {
-                    $curpage--;
-                } else {
-                    $curpage = 0;
-                }
-                break;
-              case PlWizard::NEXT_PAGE:
-                if ($curpage < count($this->pages) - 1) {
-                    $curpage++;
-                }
-                break;
-              case PlWizard::LAST_PAGE:
-                $curpage = count($this->pages) - 1;
-                break;
-              case PlWizard::CURRENT_PAGE: break; // don't change the page
-              default:
-                $curpage = is_numeric($next) ? $next : $this->lookup[$next];
-                break;
-            }
-            if (!$this->stateless) {
-                array_push($_SESSION[$this->name . '_stack'], $last);
-            }
-        }
-        if (is_null($curpage)) {
-            $curpage = 0;
-        }
-
-        // Prepare the page
-        $_SESSION[$this->name . '_page'] = $curpage;
-        if ($curpage != $oldpage) {
-            pl_redirect($baseurl . '/' . $this->inv_lookup[$curpage]);
-        } else if (!isset($page)) {
-            $page = $this->getPage($curpage);
-        }
-        if ($mode == 'ajax') {
-            header('Content-Type: text/html; charset=utf-8');
-            $smarty->changeTpl($page->template(), NO_SKIN);
-        } else {
-            $smarty->changeTpl($this->layout);
-        }
-        $smarty->assign('pages', $this->titles);
-        $smarty->assign('current', $curpage);
-        $smarty->assign('lookup', $this->inv_lookup);
-        $smarty->assign('stateless', $this->stateless);
-        $smarty->assign('wiz_baseurl', $baseurl);
-        $smarty->assign('wiz_ajax', $this->ajax);
-        $smarty->assign('tab_width', (int)(99 / count($this->pages)));
-        $smarty->assign('wiz_page', $page->template());
-        $smarty->assign('xorg_no_errors', true);
-        $page->prepare($smarty, isset($this->inv_lookup[$curpage]) ? $this->inv_lookup[$curpage] : $curpage);
-    }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/s.php b/classes/s.php
deleted file mode 100644 (file)
index 338a437..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-class S extends Session {
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/session.php b/classes/session.php
deleted file mode 100644 (file)
index 6eb5b30..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-class Session
-{
-    public static function init()
-    {
-        @session_start();
-        if (empty($_SESSION['challenge'])) {
-            $_SESSION['challenge'] = sha1(uniqid(rand(), true));
-        }
-        if (empty($_SESSION['xsrf_token'])) {
-            require_once 'xorg.misc.inc.php';
-            $_SESSION['xsrf_token'] = rand_url_id();
-        }
-        if (!isset($_SESSION['perms']) || !($_SESSION['perms'] instanceof FlagSet)) {
-            $_SESSION['perms'] = new FlagSet();
-        }
-    }
-
-    public static function destroy()
-    {
-        @session_destroy();
-        unset($_SESSION);
-    }
-
-    public static function has($key)
-    {
-        return isset($_SESSION[$key]);
-    }
-
-    public static function kill($key)
-    {
-        unset($_SESSION[$key]);
-    }
-
-    public static function v($key, $default = null)
-    {
-        return isset($_SESSION[$key]) ? $_SESSION[$key] : $default;
-    }
-
-    public static function s($key, $default = '')
-    {
-        return (string)Session::v($key, $default);
-    }
-
-    public static function i($key, $default = 0)
-    {
-        $i = Session::v($key, $default);
-        return is_numeric($i) ? intval($i) : $default;
-    }
-
-    public static function l(array $keys)
-    {
-        return array_map(array('Session', 'v'), $keys);
-    }
-
-    public static function has_perms()
-    {
-        return Session::logged() && Session::v('perms')->hasFlag(PERMS_ADMIN);
-    }
-
-    public static function logged()
-    {
-        return Session::v('auth', AUTH_PUBLIC) >= AUTH_COOKIE;
-    }
-
-    public static function identified()
-    {
-        return Session::v('auth', AUTH_PUBLIC) >= AUTH_MDP;
-    }
-
-    // Anti-XSRF protections.
-    public static function has_xsrf_token()
-    {
-        return Session::has('xsrf_token') && Session::v('xsrf_token') == Env::v('token');
-    }
-
-    public static function assert_xsrf_token()
-    {
-        if (!Session::has_xsrf_token()) {
-            global $page;
-            if ($page instanceof PlatalPage) {
-                $page->kill("L'opération n'a pas pu aboutir, merci de réessayer.");
-            }
-        }
-    }
-
-    public static function rssActivated()
-    {
-        return Session::has('core_rss_hash') && Session::v('core_rss_hash');
-    }
-}
-
-// {{{ function check_perms()
-
-/** verifie si un utilisateur a les droits pour voir une page
- ** si ce n'est pas le cas, on affiche une erreur
- * @return void
- */
-function check_perms()
-{
-    global $page;
-    if (!S::has_perms()) {
-        if ($_SESSION['log']) {
-            $_SESSION['log']->log("noperms",$_SERVER['PHP_SELF']);
-        }
-        $page->kill("Tu n'as pas les permissions nécessaires pour accéder à cette page.");
-    }
-}
-
-// }}}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/varstream.php b/classes/varstream.php
deleted file mode 100644 (file)
index e57b60f..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-class VarStream
-{
-    // Stream handler to read from global variables
-    private $varname;
-    private $position;
-
-    public function stream_open($path, $mode, $options, &$opened_path)
-    {
-        $url            = parse_url($path);
-        $this->varname  = $url['host'];
-        $this->position = 0;
-        if (!isset($GLOBALS[$this->varname]))
-        {
-            trigger_error('Global variable '.$this->varname.' does not exist', E_USER_WARNING);
-            return false;
-        }
-        return true;
-    }
-
-    public function stream_close()
-    {
-    }
-
-    public function stream_read($count)
-    {
-        $ret = substr($GLOBALS[$this->varname], $this->position, $count);
-        $this->position += strlen($ret);
-        return $ret;
-    }
-
-    public function stream_write($data)
-    {
-        $len = strlen($data);
-        if ($len > $this->position + strlen($GLOBALS[$this->varname])) {
-            str_pad($GLOBALS[$this->varname], $len);
-        }
-
-        $GLOBALS[$this->varname] = substr_replace($GLOBALS[$this->varname], $data, $this->position, $len);
-        $this->position += $len;
-    }
-
-    public function stream_eof()
-    {
-        return $this->position >= strlen($GLOBALS[$this->varname]);
-    }
-
-    public function stream_tell()
-    {
-        return $this->position;
-    }
-
-    public function stream_seek($offs, $whence)
-    {
-        switch ($whence) {
-            case SEEK_SET:
-                $final = $offs;
-                break;
-
-            case SEEK_CUR:
-                $final += $offs;
-                break;
-
-            case SEEK_END:
-                $final = strlen($GLOBALS[$this->varname]) + $offs;
-                break;
-        }
-
-        if ($final < 0) {
-            return -1;
-        }
-        $this->position = $final;
-        return 0;
-    }
-
-    public function stream_flush()
-    {
-    }
-
-    static public function init()
-    {
-        stream_wrapper_register('var','VarStream');
-    }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/xdb.php b/classes/xdb.php
deleted file mode 100644 (file)
index ad63364..0000000
+++ /dev/null
@@ -1,366 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- **************************************************************************/
-
-class XDB
-{
-    private static $mysqli = null;
-
-    public static function connect()
-    {
-        global $globals;
-        XDB::$mysqli = new mysqli($globals->dbhost, $globals->dbuser, $globals->dbpwd, $globals->dbdb);
-        if ($globals->debug & DEBUG_BT) {
-            $bt = new PlBacktrace('MySQL');
-            if (mysqli_connect_errno()) {
-                $bt->newEvent("MySQLI connection", 0, mysqli_connect_error());
-                return false;
-            }
-        }
-        XDB::$mysqli->autocommit(true);
-        XDB::$mysqli->set_charset($globals->dbcharset);
-        return true;
-    }
-
-    public static function _prepare($args)
-    {
-        $query    = array_map(Array('XDB', 'escape'), $args);
-        $query[0] = str_replace('{?}', '%s', str_replace('%',   '%%', $args[0]));
-        return call_user_func_array('sprintf', $query);
-    }
-
-    public static function _reformatQuery($query)
-    {
-        $query  = preg_split("/\n\\s*/", trim($query));
-        $length = 0;
-        foreach ($query as $key=>$line) {
-            $local = -2;
-            if (preg_match('/^([A-Z]+(?:\s+(?:JOIN|BY|FROM|INTO))?)\s+(.*)/u', $line, $matches)
-            && $matches[1] != 'AND' && $matches[1] != 'OR')
-            {
-                $local  = strlen($matches[1]);
-                $line   = $matches[1] . '  ' . $matches[2];
-                $length = max($length, $local);
-            }
-            $query[$key] = array($line, $local);
-        }
-        $res = '';
-        foreach ($query as $array) {
-            list($line, $local) = $array;
-            $local   = max(0, $length - $local);
-            $res    .= str_repeat(' ', $local) . $line . "\n";
-            $length += 2 * (substr_count($line, '(') - substr_count($line, ')'));
-        }
-        return $res;
-    }
-
-    public static function _query($query)
-    {
-        global $globals;
-
-        if (!XDB::$mysqli && !XDB::connect()) {
-            return false;
-        }
-
-        if ($globals->debug & DEBUG_BT) {
-            $explain = array();
-            if (strpos($query, 'FOUND_ROWS()') === false) {
-                $res = XDB::$mysqli->query("EXPLAIN $query");
-                if ($res) {
-                    while ($row = $res->fetch_assoc()) {
-                        $explain[] = $row;
-                    }
-                    $res->free();
-                }
-            }
-            PlBacktrace::$bt['MySQL']->start(XDB::_reformatQuery($query));
-        }
-
-        $res = XDB::$mysqli->query($query);
-
-        if ($globals->debug & DEBUG_BT) {
-            PlBacktrace::$bt['MySQL']->stop(@$res->num_rows ? $res->num_rows : XDB::$mysqli->affected_rows,
-                                            XDB::$mysqli->error,
-                                            $explain);
-        }
-        return $res;
-    }
-
-    public static function query()
-    {
-        return new XOrgDBResult(XDB::_prepare(func_get_args()));
-    }
-
-    public static function execute()
-    {
-        global $globals;
-        $args = func_get_args();
-        if ($globals->mode != 'rw' && !strpos($args[0], 'logger')) {
-            return;
-        }
-        return XDB::_query(XDB::_prepare($args));
-    }
-
-    public static function iterator()
-    {
-        return new XOrgDBIterator(XDB::_prepare(func_get_args()));
-    }
-
-    public static function iterRow()
-    {
-        return new XOrgDBIterator(XDB::_prepare(func_get_args()), MYSQL_NUM);
-    }
-
-    public static function insertId()
-    {
-        return XDB::$mysqli->insert_id;
-    }
-
-    public static function errno()
-    {
-        return XDB::$mysqli->errno;
-    }
-
-    public static function error()
-    {
-        return XDB::$mysqli->error;
-    }
-
-    public static function affectedRows()
-    {
-        return XDB::$mysqli->affected_rows;
-    }
-
-    public static function escape($var)
-    {
-        switch (gettype($var)) {
-          case 'boolean':
-            return $var ? 1 : 0;
-
-          case 'integer':
-          case 'double':
-          case 'float':
-            return $var;
-
-          case 'string':
-            return "'".addslashes($var)."'";
-
-          case 'NULL':
-            return 'NULL';
-
-          case 'object':
-            if ($var instanceof FlagSet) {
-                return "'" . addslashes($var->flags()) . "'";
-            }
-          case 'array':
-            return "'".addslashes(serialize($var))."'";
-
-          default:
-            die(var_export($var, true).' is not a valid for a database entry');
-        }
-    }
-}
-
-class XOrgDBResult
-{
-
-    private $_res;
-
-    public function __construct($query)
-    {
-        $this->_res = XDB::_query($query);
-    }
-
-    public function free()
-    {
-        if ($this->_res) {
-            $this->_res->free();
-        }
-        unset($this);
-    }
-
-    protected function _fetchRow()
-    {
-        return $this->_res ? $this->_res->fetch_row() : null;
-    }
-
-    protected function _fetchAssoc()
-    {
-        return $this->_res ? $this->_res->fetch_assoc() : null;
-    }
-
-    public function fetchAllRow()
-    {
-        $result = Array();
-        if (!$this->_res) {
-            return $result;
-        }
-        while ($result[] = $this->_res->fetch_row());
-        array_pop($result);
-        $this->free();
-        return $result;
-    }
-
-    public function fetchAllAssoc()
-    {
-        $result = Array();
-        if (!$this->_res) {
-            return $result;
-        }
-        while ($result[] = $this->_res->fetch_assoc());
-        array_pop($result);
-        $this->free();
-        return $result;
-    }
-
-    public function fetchOneAssoc()
-    {
-        $tmp = $this->_fetchAssoc();
-        $this->free();
-        return $tmp;
-    }
-
-    public function fetchOneRow()
-    {
-        $tmp = $this->_fetchRow();
-        $this->free();
-        return $tmp;
-    }
-
-    public function fetchOneCell()
-    {
-        $tmp = $this->_fetchRow();
-        $this->free();
-        return $tmp[0];
-    }
-
-    public function fetchColumn($key = 0)
-    {
-        $res = Array();
-        if (is_numeric($key)) {
-            while($tmp = $this->_fetchRow()) {
-                $res[] = $tmp[$key];
-            }
-        } else {
-            while($tmp = $this->_fetchAssoc()) {
-                $res[] = $tmp[$key];
-            }
-        }
-        $this->free();
-        return $res;
-    }
-
-    public function fetchOneField()
-    {
-        return $this->_res ? $this->_res->fetch_field() : null;
-    }
-
-    public function fetchFields()
-    {
-        $res = array();
-        while ($res[] = $this->fetchOneField());
-        return $res;
-    }
-
-    public function numRows()
-    {
-        return $this->_res ? $this->_res->num_rows : 0;
-    }
-
-    public function fieldCount()
-    {
-        return $this->_res ? $this->_res->field_count : 0;
-    }
-}
-
-require_once dirname(__FILE__) . '/pliterator.php';
-
-class XOrgDBIterator extends XOrgDBResult implements PlIterator
-{
-    private $_result;
-    private $_pos;
-    private $_total;
-    private $_fpos;
-    private $_fields;
-    private $_mode = MYSQL_ASSOC;
-
-    public function __construct($query, $mode = MYSQL_ASSOC)
-    {
-        parent::__construct($query);
-        $this->_pos    = 0;
-        $this->_total  = $this->numRows();
-        $this->_fpost  = 0;
-        $this->_fields = $this->fieldCount();
-        $this->_mode   = $mode;
-    }
-
-    public function next()
-    {
-        $this->_pos ++;
-        if ($this->_pos > $this->_total) {
-            $this->free();
-            unset($this);
-            return null;
-        }
-        return $this->_mode != MYSQL_ASSOC ? $this->_fetchRow() : $this->_fetchAssoc();
-    }
-
-    public function first()
-    {
-        return $this->_pos == 1;
-    }
-
-    public function last()
-    {
-        return $this->_pos == $this->_total;
-    }
-
-    public function total()
-    {
-        return $this->_total;
-    }
-
-    public function nextField()
-    {
-        $this->_fpos++;
-        if ($this->_fpos > $this->_fields) {
-            return null;
-        }
-        return $this->fetchOneField();
-    }
-
-    public function firstField()
-    {
-        return $this->_fpos == 1;
-    }
-
-    public function lastField()
-    {
-        return $this->_fpos == $this->_fields;
-    }
-
-    public function totalFields()
-    {
-        return $this->_fields;
-    }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/classes/xmlrpcclient.php b/classes/xmlrpcclient.php
deleted file mode 100644 (file)
index be47a70..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-/* taken from : http://fr2.php.net/xml-rpc
- * Author mboeren@php.net
- *
- * Usage:
- * $client = new xmlrpc_client("http://localhost:7080");
- * print $client->echo('x')."\n";
- * print $client->add(1, 3)."\n";
- */
-
-class XmlrpcClient
-{
-    private $url;
-    private $urlparts;
-    public $bt = null;
-
-    public function __construct($url)
-    {
-        $this->url = $url;
-        $this->urlparts = parse_url($this->url);
-
-        if (empty($this->urlparts['port'])) {
-            $this->urlparts['port'] = 80;
-        }
-
-        if (empty($this->urlparts['path'])) {
-            $this->urlparts['path'] = '/';
-        }
-    }
-
-    private function http_post($request)
-    {
-        $host = $path = $port = $user = $pass = null;
-        extract($this->urlparts);
-
-        if ($scheme == 'https') {
-            $host = 'ssl://'.$host;
-        }
-
-        $query_fd    = fsockopen($host, $port, $errno, $errstr, 10);
-        if (!$query_fd)
-            return null;
-
-        $auth = '';
-        if ($user) {
-            $auth = 'Authorization: Basic ' . base64_encode("$user:$pass") . "\r\n";
-        }
-
-        $content_len = strlen($request);
-        $http_request =
-            "POST $path HTTP/1.0\r\n" .
-            $auth .
-            "Content-Type: text/xml\r\n" .
-            "Content-Length: $content_len\r\n" .
-            "Connection: Close\r\n" .
-            "Host: $host:$port\r\n" .
-            "\r\n" .
-            $request;
-
-        fputs($query_fd, $http_request, strlen($http_request));
-
-        $buf = '';
-        while (!feof($query_fd)) {
-            $buf .= fread($query_fd, 8192);
-        }
-
-        fclose($query_fd);
-        return $buf;
-    }
-
-    private function find_and_decode_xml($buf)
-    {
-        $pos = strpos($buf, '<?xml');
-        if ($pos !== false) {
-            return xmlrpc_decode(substr($buf, $pos));
-        }
-        trigger_error("Cannot parse XML\n".$buf);
-    }
-
-    public function __call($method, $args)
-    {
-        $query  = xmlrpc_encode_request($method, $args);
-        if ($this->bt) {
-            $this->bt->start($method . "\n" . var_export($args, true));
-        }
-        $answer = $this->http_post($query, $this->urlparts);
-        if ($this->bt) {
-            $this->bt->stop();
-        }
-        $result = $this->find_and_decode_xml($answer);
-        if ($this->bt) {
-            if (is_array($result) && isset($result['faultCode'])) {
-                $this->bt->update(0, $result['faultString']);
-            } else {
-                $this->bt->update(count($result));
-            }
-        }
-
-        if (is_array($result) && isset($result['faultCode'])) {
-            trigger_error("Error in xmlrpc call $function\n".
-                          "  code   : {$result['faultCode']}\n".
-                          "  message: {$result['faultString']}\n");
-            return null;
-        }
-        return $result;
-    }
-}
-
-// vim:set et sw=4 sts=4 sws=4 enc=utf-8:
-?>
index a5a739a..9e5096b 100644 (file)
@@ -74,7 +74,7 @@ class Xnet extends Platal
         return $ans;
     }
 
-    public function force_login(&$page)
+    public function force_login(PlPage &$page)
     {
         http_redirect(S::v('loginX'));
     }
similarity index 93%
rename from include/xnet/page.inc.php
rename to classes/xnetpage.php
index b32adc4..f020535 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-class XnetPage extends PlatalPage
+class XnetPage extends PlPage
 {
     public $nomenu = false;
 
     // {{{ function XnetPage()
 
-    public function __construct($tpl, $type=SKINNED)
+    public function __construct()
     {
-        parent::__construct($tpl, $type);
+        parent::__construct();
 
         $this->register_function('list_all_my_groups', 'list_all_my_groups');
         $this->register_modifier('cat_pp', 'cat_pp');
         $this->assign('it_is_xnet', true);
 
-        if (!S::logged() && Get::has('auth')) {
-            XnetSession::doAuthX();
+        global $globals;
+        $this->assign('is_logged', S::logged());
+        if ($globals->asso('id')) {
+            $this->assign('asso', $globals->asso());
+            $this->setType($globals->asso('cat'));
+            $this->assign('is_admin', may_update());
+            $this->assign('is_member', is_member());
         }
+        $this->addJsLink('xorg.js');
     }
 
     // }}}
@@ -50,22 +56,6 @@ class XnetPage extends PlatalPage
     }
 
     // }}}
-    // {{{ function changeTpl()
-
-    public function changeTpl($tpl, $type = SKINNED)
-    {
-        global $globals;
-        parent::changeTpl($tpl, $type);
-        $this->assign('is_logged', S::logged());
-        if ($globals->asso('id')) {
-            $this->assign('asso', $globals->asso());
-            $this->setType($globals->asso('cat'));
-            $this->assign('is_admin', may_update());
-            $this->assign('is_member', is_member());
-        }
-    }
-
-    // }}}
     // {{{ function setType
 
     public function setType($type)
@@ -83,7 +73,7 @@ class XnetPage extends PlatalPage
         $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;
similarity index 65%
rename from include/xnet/session.inc.php
rename to classes/xnetsession.php
index 92c189a..a1a6cf8 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-class XnetSession
+class XnetSession extends XorgSession
 {
-    // {{{ function init
-
-    public static function init()
+    public function __construct()
     {
-        global $globals;
+        parent::__construct();
+    }
 
-        S::init();
+    public function startAvailableAuth()
+    {
+        if (!S::logged() && Get::has('auth')) {
+            if (!$this->start(AUTH_MDP)) {
+                return false;
+            }
+        }
 
+        global $globals;
         if (!S::logged()) {
-            // prevent connexion to be linked to deconnexion
+            // prevent connection to be linked to disconnection
             if (($i = strpos($_SERVER['REQUEST_URI'], 'exit')) !== false)
                 $returl = "http://{$_SERVER['SERVER_NAME']}".substr($_SERVER['REQUEST_URI'], 0, $i);
             else
@@ -40,7 +46,7 @@ class XnetSession
             $url .= "&challenge=" . S::v('challenge');
             $url .= "&pass=" . md5(S::v('challenge') . $globals->xnet->secret);
             $url .= "&url=".urlencode($returl);
-            $_SESSION['loginX'] = $url;
+            S::set('loginX', $url);
         }
 
         if (S::logged() && $globals->asso()) {
@@ -62,123 +68,85 @@ class XnetSession
             if ($globals->asso('cat') == 'Promotions') {
                 $perms->addFlag('groupannu');
             }
-            $_SESSION['perms'] = $perms;
+            S::set('perms', $perms);
         }
+        return true;
     }
 
-    // }}}
-    // {{{ public static function destroy()
-
-    public static function destroy() {
-        S::destroy();
-        XnetSession::init();
-    }
-
-    // }}}
-    // {{{ public static function doAuth()
-
-    /** Try to do an authentication.
-     *
-     * @param page the calling page (by reference)
-     */
-    public static function doAuth()
+    protected function doAuth($level)
     {
-       if (S::identified()) { // ok, c'est bon, on n'a rien à faire
-               return true;
-       }
-
-        if (Get::has('auth')) {
-            return XnetSession::doAuthX();
+        if (S::identified()) { // ok, c'est bon, on n'a rien à faire
+            return S::i('uid');
         }
-
-        return false;
-    }
-
-    // }}}
-    // {{{ doAuthCookie
-
-    public static function doAuthCookie() {
-        return XnetSession::doAuth();
+        if (!Get::has('auth')) {
+            return null;
+        }
+        global $globals;
+        if (md5('1' . S::v('challenge') . $globals->xnet->secret . Get::i('uid') . '1') != Get::v('auth')) {
+            return null;
+        }
+        Get::kill('auth');
+        S::set('auth', AUTH_MDP);
+        return Get::i('uid');
     }
 
-    // }}}
-    // {{{ doAuthX
-
-    public static function doAuthX()
+    protected function startSessionAs($user, $level)
     {
-        global $globals, $page;
+        global $globals;
 
-        if (md5('1'.S::v('challenge').$globals->xnet->secret.Get::i('uid').'1') != Get::v('auth')) {
-            Get::kill('auth');
-            if (!$page) {
-                require_once 'xnet.inc.php';
-                new_skinned_page('platal/index.tpl');
-            }
-            $page->kill("Erreur d'authentification avec polytechnique.org !");
+        if ($level == -1) {
+            S::set('auth', AUTH_MDP);
         }
-
-        $res  = XDB::query("
-            SELECT  u.user_id AS uid, prenom, nom, perms, promo, password, FIND_IN_SET('femme', u.flags) AS femme,
-                    a.alias AS forlife, a2.alias AS bestalias, q.core_mail_fmt AS mail_fmt, q.core_rss_hash
-              FROM  auth_user_md5   AS u
-        INNER JOIN  auth_user_quick AS q  USING(user_id)
-        INNER JOIN  aliases         AS a  ON (u.user_id = a.id AND a.type='a_vie')
-        INNER JOIN  aliases         AS a2 ON (u.user_id = a2.id AND FIND_IN_SET('bestalias',a2.flags))
-             WHERE  u.user_id = {?} AND u.perms IN('admin','user')
-             LIMIT  1", Get::i('uid'));
-        $_SESSION = array_merge($_SESSION, $res->fetchOneAssoc());
-        $_SESSION['auth'] = AUTH_MDP;
-        require_once 'xorg/session.inc.php';
-        $_SESSION['perms'] =& XorgSession::make_perms(S::v('perms'));
+        $res  = XDB::query('SELECT  u.user_id AS uid, prenom, nom, perms, promo, password, FIND_IN_SET(\'femme\', u.flags) AS femme,
+                                    a.alias AS forlife, a2.alias AS bestalias, q.core_mail_fmt AS mail_fmt, q.core_rss_hash
+                              FROM  auth_user_md5   AS u
+                        INNER JOIN  auth_user_quick AS q  USING(user_id)
+                        INNER JOIN  aliases         AS a  ON (u.user_id = a.id AND a.type = \'a_vie\')
+                        INNER JOIN  aliases         AS a2 ON (u.user_id = a2.id AND FIND_IN_SET(\'bestalias\', a2.flags))
+                             WHERE  u.user_id = {?} AND u.perms IN(\'admin\', \'user\')
+                             LIMIT  1', $user);
+        $sess = $res->fetchOneAssoc();
+        $perms = $sess['perms'];
+        unset($sess['perms']);
+        $_SESSION = array_merge($_SESSION, $sess);
+        $this->makePerms($perms);
         S::kill('challenge');
         S::kill('loginX');
         S::kill('may_update');
         S::kill('is_member');
-        Get::kill('auth');
         Get::kill('uid');
-        $path = Get::v('n');
-        Get::kill('n');
         Get::kill('PHPSESSID');
 
         $args = array();
         foreach($_GET as $key => $val) {
-            $args[] = urlencode($key).'='.urlencode($val);
+            $args[] = urlencode($key). '=' .urlencode($val);
         }
-
-        http_redirect($globals->baseurl . '/' . $path, join('&', $args));
+        return true;
     }
 
-    // }}}
-    // {{{ doSelfSuid
-
-    public static function doSelfSuid()
+    public function doSelfSuid()
     {
-        if (!S::has('suid')) {
-            $_SESSION['suid'] = $_SESSION;
+        if (!$this->startSUID(S::i('uid'))) {
+            return false;
         }
-        require_once 'xorg/session.inc.php';
-        $_SESSION['perms'] =& XorgSession::make_perms('user');
+        $this->makePerms('user');
+        return true;
     }
 
-    // }}}
-    // {{{ killSuid
-
-    public static function killSuid()
+    public function stopSUID()
     {
-        if (!S::has('suid')) {
-            return;
-        }
         $suid = S::v('suid');
+        if (!parent::stopSUID()) {
+            return false;
+        }
         S::kill('suid');
         S::kill('may_update');
         S::kill('is_member');
-        $_SESSION['perms'] = $suid['perms'];
+        S::set('perms', $suid['perms']);
+        return true;
     }
-
-    // }}}
 }
 
-// }}}
 // {{{ function may_update
 
 /** Return administration rights for the current asso
similarity index 75%
rename from classes/mmlist.php
rename to classes/xorg.php
index a16b1c6..1049ca6 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-class MMList extends XmlrpcClient
+class Xorg extends Platal
 {
-    public function __construct($uid, $pass, $fqdn = null)
+    public function force_login(PlPage &$page)
     {
-        global $globals;
-
-        $dom = is_null($fqdn) ? $globals->mail->domain : $fqdn;
-        $url = "http://$uid:$pass@{$globals->lists->rpchost}:{$globals->lists->rpcport}/$dom";
-        parent::__construct($url);
-        if ($globals->debug & DEBUG_BT) {
-            $this->bt = new PlBacktrace('MMList');
+        header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
+        if (S::logged()) {
+            $page->changeTpl('core/password_prompt_logged.tpl');
+            $page->addJsLink('do_challenge_response_logged.js');
+        } else {
+            $page->changeTpl('core/password_prompt.tpl');
+            $page->addJsLink('do_challenge_response.js');
         }
+        $page->assign_by_ref('platal', $this);
+        $page->run();
     }
 }
 
similarity index 74%
rename from plugins/function.xsrf_token_field.php
rename to classes/xorgpage.php
index 3b6932e..d2bb501 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-function smarty_function_xsrf_token_field($params, &$smarty) {
-    if (S::has('xsrf_token')) {
-        return '<div style="display: none"><input type="hidden" name="token" value="' . S::v('xsrf_token') . '" /></div>';
+class XorgPage extends PlPage
+{
+    public function __construct()
+    {
+        parent::__construct();
+
+        // Set the default page
+        $this->changeTpl('platal/index.tpl');
+        $this->addJsLink('xorg.js');
+    }
+
+    public function run()
+    {
+        global $globals, $platal;
+        if (isset($platal) && $platal->path == 'register') {
+            $skin = $globals->register_skin . ".tpl";
+        } else {
+            $skin = S::v('skin', $globals->skin . ".tpl");
+        }
+        $this->_run('skin/' . $skin);
     }
-    return '';
 }
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
diff --git a/classes/xorgsession.php b/classes/xorgsession.php
new file mode 100644 (file)
index 0000000..025af61
--- /dev/null
@@ -0,0 +1,343 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2008 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************/
+
+class XorgSession extends PlSession
+{
+    public function __construct()
+    {
+        parent::__construct();
+    }
+
+    public function startAvailableAuth()
+    {
+        if (!S::logged()) {
+            $cookie = $this->tryCookie();
+            if ($cookie == 0) {
+                return $this->start(AUTH_COOKIE);
+            } else if ($cookie == 1 || $cookie == -2) {
+                return false;
+            }
+        }
+        if ((check_ip('dangerous') && S::has('uid')) || check_account()) {
+            $_SESSION['log']->log("view_page", $_SERVER['REQUEST_URI']);
+        }
+        return true;
+    }
+
+    /** Check the cookie and set the associated user_id in the auth_by_cookie session variable.
+     */
+    private function tryCookie()
+    {
+        S::kill('auth_by_cookie');
+        if (Cookie::v('ORGaccess') == '' || !Cookie::has('ORGuid')) {
+            return -1;
+        }
+
+        $res = XDB::query('SELECT  user_id, password
+                             FROM  auth_user_md5
+                            WHERE  user_id = {?} AND perms IN(\'admin\', \'user\')',
+                         Cookie::i('ORGuid'));
+        if ($res->numRows() != 0) {
+            list($uid, $password) = $res->fetchOneRow();
+            require_once 'secure_hash.inc.php';
+            $expected_value = hash_encrypt($password);
+            if ($expected_value == Cookie::v('ORGaccess')) {
+                S::set('auth_by_cookie', $uid);
+                return 0;
+            } else {
+                return 1;
+            }
+        }
+        return -2;
+    }
+
+    private function checkPassword($uname, $login, $response, $login_type)
+    {
+        $res = XDB::query('SELECT  u.user_id, u.password
+                             FROM  auth_user_md5 AS u
+                       INNER JOIN  aliases       AS a ON (a.id = u.user_id AND type != \'homonyme\')
+                             WHERE  a.' . $login_type . ' = {?} AND u.perms IN(\'admin\', \'user\')',
+                          $login);
+        if (list($uid, $password) = $res->fetchOneRow()) {
+            require_once 'secure_hash.inc.php';
+            $expected_response = hash_encrypt("$uname:$password:" . S::v('challenge'));
+            if ($response != $expected_response) {
+                $new_password = hash_xor(Env::v('xorpass'), $password);
+                $expected_response = hash_encrypt("$uname:$new_password:" . S::v('challenge'));
+                if ($response == $expected_response) {
+                      XDB::execute('UPDATE  auth_user_md5
+                                       SET  password = {?}
+                                     WHERE  user_id = {?}',
+                                   $new_password, $uid);
+                }
+            }
+            if ($response != $expected_response) {
+                S::logger($uid)->log('auth_fail', 'bad password');
+                return null;
+            }
+            return $uid;
+        }
+        return null;
+    }
+
+
+    /** Check auth.
+     */
+    protected function doAuth($level)
+    {
+        global $globals;
+
+        /* Cookie authentication
+         */
+        if ($level == AUTH_COOKIE && !S::has('auth_by_cookie')) {
+            $this->tryCookie();
+        }
+        if ($level == AUTH_COOKIE && S::has('auth_by_cookie')) {
+            if (!S::logged()) {
+                S::set('auth', AUTH_COOKIE);
+            }
+            return S::i('auth_by_cookie');
+        }
+
+
+        /* We want to do auth... we must have infos from a form.
+         */
+        if (!Post::has('username') || !Post::has('response') || !S::has('challenge')) {
+            return null;
+        }
+
+        /** We come from an authentication form.
+         */
+        if (S::has('suid')) {
+            $suid  = S::v('suid');
+            $login = $uname = $suid['forlife'];
+            $redirect = false;
+        } else {
+            $uname = Env::v('username');
+
+            if (Env::v('domain') == "alias") {
+                $res = XDB::query('SELECT  redirect
+                                     FROM  virtual
+                               INNER JOIN  virtual_redirect USING(vid)
+                                    WHERE  alias LIKE {?}',
+                                   $uname . '@' . $globals->mail->alias_dom);
+                $redirect = $res->fetchOneCell();
+                if ($redirect) {
+                    $login = substr($redirect, 0, strpos($redirect, '@'));
+                } else {
+                    $login = '';
+                }
+            } else {
+                $login = $uname;
+                $redirect = false;
+            }
+        }
+
+        $uid = $this->checkPassword($uname, $login, Post::v('response'), (!$redirect && preg_match('/^\d*$/', $uname)) ? 'id' : 'alias');
+        if (!is_null($uid)) {
+            S::set('auth', AUTH_MDP);
+            if (Post::has('domain')) {
+                if (($domain = Post::v('domain', 'login')) == 'alias') {
+                    setcookie('ORGdomain', "alias", (time() + 25920000), '/', '', 0);
+                } else {
+                    setcookie('ORGdomain', '', (time() - 3600), '/', '', 0);
+                }
+                // pour que la modification soit effective dans le reste de la page
+                $_COOKIE['ORGdomain'] = $domain;
+            }
+            S::kill('challenge');
+            S::logger($uid)->log('auth_ok');
+        }
+        return $uid;
+    }
+
+    protected function startSessionAs($uid, $level)
+    {
+        if ((!is_null(S::v('user')) && S::i('user') != $uid) || (S::has('uid') && S::i('uid') != $uid)) {
+            return false;
+        } else if (S::has('uid')) {
+            return true;
+        }
+        if ($level == -1) {
+            S::set('auth', AUTH_COOKIE);
+        }
+        unset($_SESSION['log']);
+
+        // Retrieves main user properties.
+        $res  = XDB::query('SELECT  u.user_id AS uid, prenom, prenom_ini, nom, nom_ini, nom_usage, perms, promo, promo_sortie,
+                                    matricule, password, FIND_IN_SET(\'femme\', u.flags) AS femme,
+                                    a.alias AS forlife, a2.alias AS bestalias,
+                                    q.core_mail_fmt AS mail_fmt, UNIX_TIMESTAMP(q.banana_last) AS banana_last, q.watch_last, q.core_rss_hash,
+                                    FIND_IN_SET(\'watch\', u.flags) AS watch_account, q.last_version, g.g_account_name IS NOT NULL AS googleapps
+                              FROM  auth_user_md5   AS u
+                        INNER JOIN  auth_user_quick AS q  USING(user_id)
+                        INNER JOIN  aliases         AS a  ON (u.user_id = a.id AND a.type = \'a_vie\')
+                        INNER JOIN  aliases         AS a2 ON (u.user_id = a2.id AND FIND_IN_SET(\'bestalias\', a2.flags))
+                         LEFT JOIN  gapps_accounts  AS g  ON (u.user_id = g.l_userid AND g.g_status = \'active\')
+                             WHERE  u.user_id = {?} AND u.perms IN(\'admin\', \'user\')', $uid);
+        $sess = $res->fetchOneAssoc();
+        $perms = $sess['perms'];
+        unset($sess['perms']);
+
+        // Retrieves account usage information (last login, last host).
+        $res = XDB::query('SELECT  UNIX_TIMESTAMP(s.start) AS lastlogin, s.host
+                             FROM  logger.sessions AS s
+                            WHERE  s.uid = {?} AND s.suid = 0
+                         ORDER BY  s.start DESC
+                            LIMIT  1', $uid);
+        if ($res->numRows()) {
+            $sess = array_merge($sess, $res->fetchOneAssoc());
+        }
+
+        // Loads the data into the real session.
+        $_SESSION = array_merge($_SESSION, $sess);
+
+        // Starts the session's logger, and sets up the permanent cookie.
+        if (S::has('suid')) {
+            $suid = S::v('suid');
+            $logger = S::logger($uid);
+            $logger->log("suid_start", S::v('forlife') . " by " . $suid['uid']);
+        } else {
+            $logger = S::logger($uid);
+            setcookie('ORGuid', $uid, (time() + 25920000), '/', '', 0);
+
+            if (S::i('auth_by_cookie') == $uid || Post::v('remember', 'false') == 'true') {
+                $cookie = hash_encrypt($sess['password']);
+                setcookie('ORGaccess', $cookie, (time() + 25920000), '/', '', 0);
+                if ($logger && S::i('auth_by_cookie') != $uid) {
+                    $logger->log("cookie_on");
+                }
+            } else {
+                setcookie('ORGaccess', '', time() - 3600, '/', '', 0);
+                if ($logger) {
+                    $logger->log("cookie_off");
+                }
+            }
+        }
+
+        // Finalizes the session setup.
+        $this->makePerms($perms);
+        $this->securityChecks();
+        $this->setSkin();
+        $this->updateNbNotifs();
+        check_redirect();
+
+        // We should not have to use this private data anymore
+        S::kill('auth_by_cookie');
+        return true;
+    }
+
+    private function securityChecks()
+    {
+        $mail_subject = array();
+        if (check_account()) {
+            $mail_subject[] = 'Connexion d\'un utilisateur surveillé';
+        }
+        if (check_ip('unsafe')) {
+            $mail_subject[] = 'Une IP surveillee a tente de se connecter';
+            if (check_ip('ban')) {
+                send_warning_mail(implode(' - ', $mail_subject));
+                $this->destroy();
+                Platal::page()->kill('Une erreur est survenue lors de la procédure d\'authentification. '
+                                    . 'Merci de contacter au plus vite '
+                                    . '<a href="mailto:support@polytechnique.org">support@polytechnique.org</a>');
+                return false;
+            }
+        }
+        if (count($mail_subject)) {
+            send_warning_mail(implode(' - ', $mail_subject));
+        }
+    }
+
+    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 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 setSkin()
+    {
+        global $globals;
+        if (S::logged() && (!S::has('skin') || S::has('suid'))) {
+            $uid = S::v('uid');
+            $res = XDB::query("SELECT  skin_tpl
+                                 FROM  auth_user_quick AS a
+                           INNER JOIN  skins           AS s ON a.skin = s.id
+                                WHERE  user_id = {?} AND skin_tpl != ''", $uid);
+            S::set('skin', $res->fetchOneCell());
+        }
+    }
+
+    public function loggedLevel()
+    {
+        return AUTH_COOKIE;
+    }
+
+    public function sureLevel()
+    {
+        return AUTH_MDP;
+    }
+
+
+    public function updateNbNotifs()
+    {
+        require_once 'notifs.inc.php';
+        $n = select_notifs(false, S::i('uid'), S::v('watch_last'), false);
+        S::set('notifs', $n->numRows());
+    }
+}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
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
new file mode 160000 (submodule)
index 0000000..5177a1b
--- /dev/null
+++ b/core
@@ -0,0 +1 @@
+Subproject commit 5177a1b50e47e7d62a66aba9565580af3abf15dd
index 8a379b2..9a526ff 100644 (file)
@@ -286,7 +286,7 @@ div.contact-list div.grayed {
 
 div.contact div.identity {
     float: left;
-    width: 89%;
+    width: 85%;
 }
 
 div.contact div.nom {
@@ -296,7 +296,7 @@ div.contact div.nom {
 div.contact div.bits {
     text-align: right;
     float: right;
-    width: 10%;
+    width: 14%;
 }
 
 div.contact div.long {
index 33cd83b..71797f0 100644 (file)
@@ -76,6 +76,8 @@ function AjaxEngine()
                     }
                 } else if (ajax.xml_client.status == 403) {
                     window.location.reload();
+                } else if (ajax.xml_client.status >= 500) {
+                    alert("Une erreur s'est produite lors du traitement de la requête");
                 }
             }
         };
index 739c58d..432ca6f 100644 (file)
@@ -19,7 +19,7 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-require_once dirname(__FILE__).'/../include/xorg.inc.php';
+require_once 'xorg.inc.php';
 
 preg_match('!^/(moderate|admin|members|archives)/(.*)_([^_]*)(/.*)?$!', $_SERVER['REQUEST_URI'], $matches);
 
index cca10b1..0de8baa 100644 (file)
@@ -19,7 +19,9 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-require_once dirname(__FILE__).'/../include/xorg.inc.php';
+require_once 'xorg.inc.php';
+
+new Platal('core');
 
 global $globals;
 list($username, $path) = preg_split('/\//', $_SERVER["REQUEST_URI"], 2, PREG_SPLIT_NO_EMPTY);
@@ -53,5 +55,7 @@ header("HTTP/1.0 404 Not Found");
     <hr>
     <address>Apache Server at www.carva.org Port 80</address>
   </body>
+</html>
+<?php
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
 ?>
index 592ba18..5847fff 100644 (file)
  ***************************************************************************/
 
 $GLOBALS['IS_XNET_SITE'] = true;
-global $platal, $globals, $page;
 
 require_once dirname(__FILE__).'/../include/xnet.inc.php';
 
+$platal = new Xnet('xnet', 'xnetgrp', 'xnetlists', 'xnetevents', 'geoloc', 'payment', 'bandeau');
 if (!($path = Env::v('n')) || substr($path, 0, 4) != 'Xnet') {
-    $platal = new Xnet('xnet', 'xnetgrp', 'xnetlists', 'xnetevents', 'geoloc', 'payment', 'bandeau');
     $platal->run();
-
     exit;
 }
 
 /*** WIKI CODE ***/
 
-include 'wiki/engine.php';
+include pl_core_include('wiki.engine.inc.php');
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
 ?>
index 93226b9..e43ef73 100644 (file)
  ***************************************************************************/
 
 require_once dirname(__FILE__).'/../include/xorg.inc.php';
-global $globals, $platal, $page;
 
-if (!($path = Env::v('n')) || ($path{0} < 'A' || $path{0} > 'Z')) {
+$platal = new Xorg('auth', 'carnet', 'email', 'events', 'forums',
+                   'geoloc', 'lists', 'marketing', 'payment', 'platal',
+                   'profile', 'register', 'search', 'stats', 'admin',
+                   'newsletter', 'axletter', 'bandeau', 'survey',
+                   'gadgets', 'googleapps');
 
-    $platal = new Platal('auth', 'carnet', 'email', 'events', 'forums',
-                         'geoloc', 'lists', 'marketing', 'payment', 'platal',
-                         'profile', 'register', 'search', 'stats', 'admin',
-                         'newsletter', 'axletter', 'bandeau', 'survey',
-                         'gadgets', 'googleapps');
+if (!($path = Env::v('n')) || ($path{0} < 'A' || $path{0} > 'Z')) {
     $platal->run();
-
     exit;
 }
 
 /*** WIKI CODE ***/
 
-include 'wiki/engine.php';
+include pl_core_include('wiki.engine.inc.php');
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
 ?>
diff --git a/include/.gitignore b/include/.gitignore
deleted file mode 100644 (file)
index c68a431..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/globals.inc.php
index 849adc3..82235db 100644 (file)
@@ -19,8 +19,6 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-global $page;
-
 function applis_options($current=0) {
     $html = '<option value="-1"></option>';
     $res  = XDB::iterator("select * from applis_def order by text");
@@ -38,7 +36,7 @@ function _applis_options_smarty($params){
         $params['selected'] = 0;
     return applis_options($params['selected']);
 }
-$page->register_function('applis_options','_applis_options_smarty');
+Platal::page()->register_function('applis_options','_applis_options_smarty');
 
 
 /** affiche un Array javascript contenant les types de chaque appli
@@ -54,7 +52,7 @@ function applis_type(){
     }
     return $html;
 }
-$page->register_function('applis_type','applis_type');
+Platal::page()->register_function('applis_type','applis_type');
 
 /** affiche tous les types possibles d'applis
  */
@@ -63,7 +61,7 @@ function applis_type_all(){
     $arr_appli = $res->fetchOneAssoc();
     return str_replace(")","",str_replace("set(","",$arr_appli["Type"]));
 }
-$page->register_function('applis_type_all','applis_type_all');
+Platal::page()->register_function('applis_type_all','applis_type_all');
 
 /** formatte une ecole d'appli pour l'affichage
  */
@@ -87,7 +85,7 @@ function _applis_fmt($params, &$smarty) {
     extract($params);
     return applis_fmt($type, $text, $url);
 }
-$page->register_function('applis_fmt','_applis_fmt');
+Platal::page()->register_function('applis_fmt','_applis_fmt');
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
 ?>
index 3e14a78..53d01c6 100644 (file)
@@ -179,7 +179,8 @@ class ForumsBanana extends Banana
 
     protected function action_updateProfile()
     {
-        global $page, $globals;
+        global $globals;
+        $page = Platal::page();
 
         $colors = glob(dirname(__FILE__) . '/../../htdocs/images/banana/m2*.gif');
         foreach ($colors as $key=>$path) {
index f0a2362..71e4aff 100644 (file)
@@ -200,8 +200,7 @@ function hook_getXFace($headers)
 
 function hook_makeJs($src)
 {
-    global $page;
-    $page->addJsLink("$src.js");
+    Platal::page()->addJsLink("$src.js");
     return ' ';
 }
 
@@ -290,12 +289,12 @@ class PlatalBananaPage extends BananaPage
     protected function prepare()
     {
         $tpl = parent::prepare();
-        global $wiz, $page;
-        $wiz = new PlWizard('Banana', 'core/plwizard.tpl', true, false);
+        global $wiz;
+        $wiz = new PlWizard('Banana', PlPage::getCoreTpl('plwizard.tpl'), true, false);
         foreach ($this->pages as $name=>&$mpage) {
             $wiz->addPage($this->handler, $mpage['text'], $name);
         }
-        $wiz->apply($page, $this->base, $this->page);
+        $wiz->apply(Platal::page(), $this->base, $this->page);
         return $tpl;
     }
 }
@@ -311,7 +310,7 @@ class BananaHandler
         return 'banana/index.tpl';
     }
 
-    public function prepare(PlatalPage &$page, $id)
+    public function prepare(PlPage &$page, $id)
     {
     }
 
index a410cbf..9e5588a 100644 (file)
@@ -91,10 +91,7 @@ class ModerationPage extends BananaPage
 
     public function trig($msg)
     {
-        global $page;
-        if ($page) {
-            $page->trigError($msg);
-        }
+        Platal::page()->trigError($msg);
         return true;
     }
 }
similarity index 79%
rename from plugins/modifier.miniwiki.php
rename to include/common.inc.php
index d47e221..35296b4 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-require_once 'platal.inc.php';
-
-function smarty_modifier_miniwiki($string, $format = 'no_title', $type = 'html')
+function __autoload($cls)
 {
-    if ($type == 'html') {
-        return MiniWiki::wikiToHTML($string, $format == 'title');
-    } else {
-        return MiniWiki::wikiToText($string, false, 0, 80, $format == 'title');
+    if (!pl_autoload($cls)) {
+        $cls = strtolower($cls);
+        if (substr($cls, -3, 3) == 'req') {
+            @include 'validations.inc.php';
+            return;
+        } else if (substr($cls, 0, 6) == 'banana') {
+            require_once 'banana/banana.inc.php';
+            Banana::load(substr($cls, 6));
+            return;
+        }
+        @include "$cls.inc.php";
     }
 }
 
index 7f4f17d..792d099 100644 (file)
@@ -19,8 +19,6 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-require_once("xorg.misc.inc.php");
-
 define("SUCCESS", 1);
 define("ERROR_INACTIVE_REDIRECTION", 2);
 define("ERROR_INVALID_EMAIL", 3);
@@ -65,6 +63,17 @@ function valide_email($str)
     return $ident . '@' . $dom;
 }
 
+// function isvalid_email_redirection() {{{1
+/** vérifie si une adresse email convient comme adresse de redirection
+ * @param $email l'adresse email a verifier
+ * @return BOOL
+ */
+function isvalid_email_redirection($email)
+{
+    return isvalid_email($email) &&
+        !preg_match("/@(polytechnique\.(org|edu)|melix\.(org|net)|m4x\.org)$/", $email);
+}
+
 // class Bogo {{{1
 // The Bogo class represents a spam filtering level in plat/al architecture.
 class Bogo
@@ -186,7 +195,7 @@ class EmailRedirection extends Email
                              SET  panne_level = IF(flags = 'panne', panne_level - 1, panne_level),
                                   flags = 'active'
                            WHERE  uid={?} AND email={?}", $this->uid, $this->email);
-            $_SESSION['log']->log("email_on", $this->email.($this->uid!=S::v('uid') ? "(admin on {$this->uid})" : ""));
+            S::logger()->log("email_on", $this->email.($this->uid!=S::v('uid') ? "(admin on {$this->uid})" : ""));
             $this->active = true;
             $this->broken = false;
         }
@@ -199,7 +208,7 @@ class EmailRedirection extends Email
         if ($this->active) {
             XDB::execute("UPDATE  emails SET flags =''
                            WHERE  uid={?} AND email={?}", $this->uid, $this->email);
-            $_SESSION['log']->log("email_off",$this->email.($this->uid != S::v('uid') ? "(admin on {$this->uid})" : "") );
+            S::logger()->log("email_off",$this->email.($this->uid != S::v('uid') ? "(admin on {$this->uid})" : "") );
             $this->active = false;
         }
     }
@@ -273,7 +282,7 @@ class EmailStorage extends Email
         $res = XDB::query("SELECT  mail_storage
                              FROM  auth_user_md5
                             WHERE  user_id = {?}", $this->uid);
-        return new FlagSet($res->fetchOneCell());
+        return new PlFlagSet($res->fetchOneCell());
     }
 
     // Updates the list of active storages.
@@ -411,7 +420,7 @@ class Redirect
             return ERROR_INACTIVE_REDIRECTION;
         }
         XDB::execute('DELETE FROM emails WHERE uid={?} AND email={?}', $this->uid, $email);
-        $_SESSION['log']->log('email_del',$email.($this->uid!=S::v('uid') ? " (admin on {$this->uid})" : ""));
+        S::logger()->log('email_del',$email.($this->uid!=S::v('uid') ? " (admin on {$this->uid})" : ""));
         foreach ($this->emails as $i => $mail) {
             if ($email == $mail->email) {
                 unset($this->emails[$i]);
@@ -434,7 +443,7 @@ class Redirect
         }
         XDB::execute('REPLACE INTO emails (uid,email,flags) VALUES({?},{?},"active")', $this->uid, $email);
         if ($logger = S::v('log', null)) { // may be absent --> step4.php
-            $logger->log('email_add',$email.($this->uid!=S::v('uid') ? " (admin on {$this->uid})" : ""));
+            S::logger()->log('email_add',$email.($this->uid!=S::v('uid') ? " (admin on {$this->uid})" : ""));
         }
         foreach ($this->emails as $mail) {
             if ($mail->email == $email_stripped) {
diff --git a/include/globals.inc.php.in b/include/globals.inc.php.in
deleted file mode 100644 (file)
index f052c6b..0000000
+++ /dev/null
@@ -1,235 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-class PlatalGlobals
-{
-    public $session;
-
-    /** The x.org version */
-    public $version = '@VERSION@';
-    public $debug   = 0;
-    public $mode    = 'rw';    // 'rw' => read/write,
-                               // 'r'  => read/only
-                               // ''   => site down
-
-    /** db params */
-    public $dbdb               = 'x4dat';
-    public $dbhost             = 'localhost';
-    public $dbuser             = 'x4dat';
-    public $dbpwd              = 'x4dat';
-    public $dbcharset          = 'utf8';
-
-    /** default skin */
-    public $skin;
-    public $register_skin;
-
-    /** paths */
-    public $baseurl;
-    public $baseurl_http;
-    public $spoolroot;
-
-    public $locale;
-    public $timezone;
-
-    public function __construct($sess)
-    {
-        $this->session   = $sess;
-        $this->spoolroot = dirname(dirname(__FILE__));
-
-        $this->read_config();
-        if (isset($_SERVER) && isset($_SERVER['SERVER_NAME'])) {
-            $base = empty($_SERVER['HTTPS']) ? 'http://' : 'https://';
-            $this->baseurl      = @trim($base    .$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF']), '/');
-            $this->baseurl_http = @trim('http://'.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF']), '/');
-        }
-
-        $this->setlocale();
-    }
-
-    private function read_ini_file($filename)
-    {
-        $array = parse_ini_file($filename, true);
-        if (!is_array($array)) {
-            return;
-        }
-        foreach ($array as $cat => $conf) {
-            $c = strtolower($cat);
-            foreach ($conf as $k => $v) {
-                if ($c == 'core' && property_exists($this, $k)) {
-                    $this->$k=$v;
-                } else {
-                    if (!isset($this->$c)) {
-                        $this->$c = new stdClass;
-                    }
-                    $this->$c->$k = $v;
-                }
-            }
-        }
-    }
-
-    private function read_config()
-    {
-        $this->read_ini_file($this->spoolroot.'/configs/platal.ini');
-        $this->read_ini_file($this->spoolroot.'/configs/platal.conf');
-        if (file_exists($this->spoolroot.'/spool/conf/platal.dynamic.conf')) {
-            $this->read_ini_file($this->spoolroot.'/spool/conf/platal.dynamic.conf');
-        }
-    }
-
-    /** Writes an ini file separated in categories
-     * @param filename the name of the file to write (overwrite existing)
-     * @param categories an array of categories (array of keys and values)
-     */              
-    private static function write_ini_file($filename, &$categories)
-    {
-        // [category]
-        // key = value
-        $f = fopen($filename, 'w');
-        foreach ($categories as $cat => $conf) {
-            fwrite($f, '; {{{ '.$cat."\n\n");
-            fwrite($f, '['.$cat.']'."\n\n");
-            foreach ($conf as $k => $v) {
-                fwrite($f, $k.' = "'.str_replace('"','\\"',$v).'"'."\n");
-            }
-            fwrite($f, "\n".'; }}}'."\n");
-        }
-        fwrite($f, '; vim:set syntax=dosini foldmethod=marker:'."\n");
-        fclose($f);
-    }
-
-    /** Change dynamic config file
-     * @param conf array of keys and values to add or replace
-     * @param category name of category to change
-     * 
-     * Opens the dynamic conf file and set values from conf in specified
-     * category. Updates config vars too.
-     */ 
-    public function change_dynamic_config($conf, $category = 'Core')
-    {
-        $dynamicfile = $this->spoolroot.'/spool/conf/platal.dynamic.conf';
-        if (file_exists($dynamicfile)) {
-            $array = parse_ini_file($dynamicfile, true);
-        } else {
-            $array = null;
-        }
-        if (!is_array($array)) {
-            // dynamic conf is empty
-            $array = array($category => $conf);
-        } else {
-            // looks for a category that looks the same (case insensitive)
-            $same = false;
-            foreach ($array as $m => &$c) {
-                if (strtolower($m) == strtolower($category)) {
-                    $same = $m;
-                    break;
-                }
-            }
-            if (!$same) {
-                // this category doesn't exist yet
-                $array[$category] = $conf;
-            } else {
-                // this category already exists
-                $conflower = array();
-                foreach ($conf as $k => $v) {
-                    $conflower[strtolower($k)] = $v;
-                }
-                // $conflower is now same as $conf but with lower case keys
-                // replaces values of keys that already exists
-                foreach ($array[$same] as $k => $v) {
-                    if (isset($conflower[strtolower($k)])) {
-                        $array[$same][$k] = $conflower[strtolower($k)];
-                        unset($conflower[strtolower($k)]);
-                    }
-                }
-                // add new keys
-                foreach ($conf as $k => $v) {
-                    if (isset($conflower[strtolower($k)])) {
-                        $array[$same][$k] = $v;
-                    }
-                } 
-            }
-        }
-        // writes the file over
-        PlatalGlobals::write_ini_file($dynamicfile, $array);
-        // rereads the new config to correctly set vars
-        $this->read_ini_file($dynamicfile);
-    }
-
-    public function bootstrap($conf, $callback, $category = 'Core')
-    {
-        $bootstrap = false;
-        $category = strtolower($category);
-        foreach ($conf as $key) {
-            if (!isset($this->$category->$key)) {
-                $bootstrap = true;
-                break;
-            }
-        }
-        if ($bootstrap) {
-            call_user_func($callback);
-        }
-    }
-
-    private function setlocale()
-    {
-        setlocale(LC_MESSAGES, $this->locale);
-        setlocale(LC_TIME,     $this->locale);
-        setlocale(LC_CTYPE,    $this->locale);
-        date_default_timezone_set($this->timezone);
-        mb_internal_encoding("UTF-8");
-    }
-
-    public function asso($key=null)
-    {
-        static $aid = null;
-
-        if (is_null($aid)) {
-            $gp = Get::v('n');
-            if ($p = strpos($gp, '/')) {
-                $gp = substr($gp, 0, $p);
-            }
-
-            if ($gp) {
-                $res = XDB::query('SELECT  a.*, d.nom AS domnom,
-                                           FIND_IN_SET(\'wiki_desc\', a.flags) AS wiki_desc,
-                                           FIND_IN_SET(\'notif_unsub\', a.flags) AS notif_unsub
-                                     FROM  groupex.asso AS a
-                                LEFT JOIN  groupex.dom  AS d ON d.id = a.dom
-                                    WHERE  diminutif = {?}', $gp);
-                if (!($aid = $res->fetchOneAssoc())) {
-                    $aid = array();
-                }
-            } else {
-                $aid = array();
-            }
-        }
-        if (empty($key)) {
-            return $aid;
-        } elseif ( isset($aid[$key]) ) {
-            return $aid[$key];
-        } else {
-            return null;
-        }
-    }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
index f6dd15d..f397ad0 100644 (file)
@@ -53,7 +53,6 @@ class Marketing
 
     private function getUser($uid, $email)
     {
-        require_once("xorg.misc.inc.php");
         $res = XDB::query("SELECT  FIND_IN_SET('femme', flags) AS sexe, nom, prenom, promo
                              FROM  auth_user_md5
                             WHERE  user_id = {?}", $uid);
@@ -276,7 +275,7 @@ class AnnuaireMarketing implements MarketingEngine
         return $this->signature;
     }
 
-    protected function prepareText(PlatalPage &$page, array $user)
+    protected function prepareText(PlPage &$page, array $user)
     {
         $page->assign('intro', $this->getIntro());
         $page->assign('u', $user);
@@ -287,7 +286,8 @@ class AnnuaireMarketing implements MarketingEngine
 
     public function getText(array $user)
     {
-        $page = new XorgPage('marketing/marketing.mail.tpl', NO_SKIN);
+        $page = new XorgPage();
+        $page->changeTpl('marketing/marketing.mail.tpl', NO_SKIN);
         $this->prepareText($page, $user);
         return $page->raw();
     }
index 19996fe..a1d49f3 100644 (file)
@@ -19,8 +19,6 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-require_once("xorg.misc.inc.php");
-
 // {{{ class MassMailer
 
 abstract class MassMailer
index 0bcf655..d48f010 100644 (file)
@@ -54,8 +54,7 @@ function register_watch_op($uid, $cid, $date='', $info='')
                              WHERE  ni_id={?}', $uid);
         XDB::execute('DELETE FROM watch_nonins WHERE ni_id={?}', $uid);
     }
-    require_once 'xorg.misc.inc.php';
-    update_NbNotifs();
+    Platal::session()->updateNbNotifs();
 }
 
 // }}}
diff --git a/include/platal.inc.php b/include/platal.inc.php
deleted file mode 100644 (file)
index 6bfd24f..0000000
+++ /dev/null
@@ -1,185 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-$TIME_BEGIN = microtime(true);
-
-define('AUTH_PUBLIC', 0);
-define('AUTH_COOKIE', 1);
-define('AUTH_MDP',    2);
-
-define('PERMS_EXT',   'ext');
-define('PERMS_USER',  'user');
-define('PERMS_ADMIN', 'admin');
-
-define('SKINNED', 0);
-define('SIMPLE',  1);
-define('NO_SKIN', 2);
-
-define('NO_AUTH', 0);
-define('DO_AUTH', 1);
-define('NO_HTTPS', 2);
-
-define('DEBUG_BT', 1);
-define('DEBUG_VALID', 2);
-define('DEBUG_SMARTY', 4);
-
-function __autoload($cls)
-{
-    $cls  = strtolower($cls);
-    $path = dirname(dirname(__FILE__));
-    if (!@include "$path/classes/$cls.php") {
-        if (substr($cls, -3, 3) == 'req') {
-            @include 'validations.inc.php';
-            return;
-        } else if (substr($cls, 0, 6) == 'banana') {
-            require_once 'banana/banana.inc.php';
-            Banana::load(substr($cls, 6));
-            return;
-        }
-        @include "$cls.inc.php";
-    }
-}
-__autoload('Env');
-
-function pl_error_handler($errno, $errstr, $errfile, $errline)
-{
-    static $errortype;
-    if (!error_reporting())
-        return;
-
-    if (!isset($errortype)) {
-        $errortype = array (
-            E_ERROR           => "Error",
-            E_WARNING         => "Warning",
-            E_PARSE           => "Parsing Error",
-            E_NOTICE          => "Notice",
-            E_CORE_ERROR      => "Core Error",
-            E_CORE_WARNING    => "Core Warning",
-            E_COMPILE_ERROR   => "Compile Error",
-            E_COMPILE_WARNING => "Compile Warning",
-            E_USER_ERROR      => "User Error",
-            E_USER_WARNING    => "User Warning",
-            E_USER_NOTICE     => "User Notice",
-            E_STRICT          => "Runtime Notice",
-            E_RECOVERABLE_ERROR => "Recoverable Error"
-        );
-    }
-
-    global $globals;
-    if (isset($globals) && !$globals->debug) {
-        if ($errno == E_NOTICE || $errno == E_USER_NOTICE || $errno == E_STRICT) {
-            return;
-        }
-    }
-
-    $type = isset($errortype[$errno]) ? $errortype[$errno] : $errno;
-    $errstr = utf8_encode(htmlentities($errstr));
-    $GLOBALS['pl_errors'][] =
-        "<div class='phperror'>".
-        "<strong>{$type}</strong> <em>$errstr</em><br />".
-        "<tt>$errfile : $errline</tt>".
-        "</div>";
-}
-
-function pl_clear_errors()
-{
-    unset($GLOBALS['pl_errors']);
-}
-
-function pl_dump_env()
-{
-    echo "<div class='phperror'><pre>";
-    echo "\nSESSION: "; var_export($_SESSION);
-    echo "\nPOST:    "; var_export($_POST);
-    echo "\nGET:     "; var_export($_GET);
-    echo "\nCOOKIE:  "; var_export($_COOKIE);
-    echo "</pre></div>";
-}
-
-function pl_print_errors()
-{
-    if (!empty($GLOBALS['pl_errors'])) {
-        print join("\n", $GLOBALS['pl_errors']);
-    }
-}
-
-set_error_handler('pl_error_handler', E_ALL | E_STRICT);
-register_shutdown_function('pl_print_errors');
-// register_shutdown_function('pl_dump_env');
-
-/** Check if the string is utf8
- */
-function is_utf8($s)
-{
-    return @iconv('utf-8', 'utf-8', $s) == $s;
-}
-
-/** vérifie si une adresse email est bien formatée  * ATTENTION, cette fonction ne doit pas être appelée sur une chaîne ayant subit un addslashes (car elle accepte le "'" qui it alors un "\'"
- * @param $email l'adresse email a verifier
- * @return BOOL  */
-function isvalid_email($email)
-{
-    // la rfc2822 authorise les caractères "a-z", "0-9", "!", "#", "$", "%", "&", "'", "*", "+", "-", "/", "=", "?", "^",  `", "{", "|", "}", "~" aussi bien dans la partie locale que dans le domaine.
-    // Pour la partie locale, on réduit cet ensemble car il n'est pas utilisé.
-    // Pour le domaine, le système DNS limite à [a-z0-9.-], on y ajoute le "_" car il est parfois utilisé.
-    return preg_match("/^[a-z0-9_.'+-]+@[a-z0-9._-]+\.[a-z]{2,6}$/i", $email);
-}
-
-function pl_url($path, $query = null, $fragment = null)
-{
-    global $platal;
-
-    $base = $platal->ns . $path . ($query ? '?'.$query : '');
-    return $fragment ? $base.'#'.$fragment : $base;
-}
-
-function pl_self($n = null) {
-    global $platal;
-    return $platal->pl_self($n);
-}
-
-function http_redirect($fullurl)
-{
-    if (count($_SESSION)) {
-        session_write_close();
-    }
-    header('Location: '.$fullurl);
-    exit;
-}
-
-function pl_redirect($path, $query = null, $fragment = null)
-{
-    global $globals;
-    http_redirect($globals->baseurl . '/' . pl_url($path, $query, $fragment));
-}
-
-function pl_entities($text, $mode = ENT_COMPAT)
-{
-    return htmlentities($text, $mode, 'UTF-8');
-}
-
-function pl_entity_decode($text, $mode = ENT_COMPAT)
-{
-    return html_entity_decode($text, $mode, 'UTF-8');
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
index 0117fc0..9d38d31 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-function _rss_encode_date($d) {
-    if (preg_match('/^\d{14}$/', $d)) {
-        $t = mktime(substr($d,8,2), substr($d,10,2), substr($d,12,2), substr($d,4,2), substr($d,6,2), substr($d,0,4));
-    } else {
-        $t = strtotime($d);
-    }
-    return date('r', $t);
-}
-
 function init_rss($template, $alias, $hash, $require_uid = true)
 {
-    global $page;
+    $page =& Platal::page();
     $page->changeTpl($template, NO_SKIN);
-    $page->register_modifier('rss_date', '_rss_encode_date');
-
-    $res = XDB::query(
-        'SELECT  a.id
-           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"', $hash, $alias);
-    $uid = $res->fetchOneCell();
-
+    $uid = Platal::session()->tokenAuth($alias, $hash);
     if (empty($uid)) {
         if ($require_uid) {
             exit;
diff --git a/include/security.inc.php b/include/security.inc.php
new file mode 100644 (file)
index 0000000..e0b1d14
--- /dev/null
@@ -0,0 +1,110 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2008 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************/
+
+/******************************************************************************
+ * Security functions
+ *****************************************************************************/
+
+function check_ip($level)
+{
+    if (empty($_SERVER['REMOTE_ADDR'])) {
+        return false;
+    }
+    if (empty($_SESSION['check_ip'])) {
+        $ips = array();
+        if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
+            $ips = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
+        }
+        $ips[] = $_SERVER['REMOTE_ADDR'];
+        foreach ($ips as &$ip) {
+            $ip = '(ip & mask) = (' . ip_to_uint($ip) . '& mask)';
+        }
+        $res = XDB::query('SELECT  state, description
+                             FROM  ip_watch
+                            WHERE  ' . implode(' OR ', $ips) . '
+                         ORDER BY  state DESC');
+        if ($res->numRows()) {
+            $state = $res->fetchOneAssoc();
+            $_SESSION['check_ip'] = $state['state'];
+            $_SESSION['check_ip_desc'] = $state['description'];
+        } else {
+            $_SESSION['check_ip'] = 'safe';
+        }
+    }
+    $test = array();
+    switch ($level) {
+      case 'unsafe': $test[] = 'unsafe';
+      case 'dangerous': $test[] = 'dangerous';
+      case 'ban': $test[] = 'ban'; break;
+      default: return false;
+    }
+    return in_array($_SESSION['check_ip'], $test);
+}
+
+function check_email($email, $message)
+{
+    $res = XDB::query("SELECT state, description
+        FROM emails_watch
+        WHERE state != 'safe' AND email = {?}", $email);
+    if ($res->numRows()) {
+        send_warning_mail($message);
+        return true;
+    }
+    return false;
+}
+
+function check_account()
+{
+    return S::v('watch_account');
+}
+
+function check_redirect($red = null)
+{
+    require_once 'emails.inc.php';
+    if (is_null($red)) {
+        $red = new Redirect(S::v('uid'));
+    }
+    if ($red->get_uid() == S::v('uid')) {
+        $_SESSION['no_redirect'] = !$red->other_active('');
+        $_SESSION['mx_failures'] = $red->get_broken_mx();
+    }
+}
+
+function send_warning_mail($title)
+{
+    global $globals;
+    $mailer = new PlMailer();
+    $mailer->setFrom("webmaster@" . $globals->mail->domain);
+    $mailer->addTo($globals->core->admin_email);
+    $mailer->setSubject("[Plat/al Security Alert] $title");
+    $mailer->setTxtBody("Identifiants de session :\n" . var_export($_SESSION, true) . "\n\n"
+        ."Identifiants de connexion :\n" . var_export($_SERVER, true));
+    $mailer->send();
+}
+
+function kill_sessions()
+{
+    assert(S::has_perms());
+    shell_exec('sudo -u root ' . dirname(dirname(__FILE__)) . '/bin/kill_sessions.sh');
+}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
index 208272f..6b06c12 100644 (file)
@@ -19,9 +19,6 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-
-require_once("xorg.inc.php");
-
 require_once('user.func.inc.php');
 
 function is_ax_key_missing() {
index a7b422c..d9232a3 100644 (file)
@@ -87,8 +87,7 @@ function user_clear_all_subs($user_id, $really_del=true)
 // Defaut callback to call when a login is not found
 function _default_user_callback($login)
 {
-    global $page;
-    $page->trigError("Il n'y a pas d'utilisateur avec l'identifiant : $login");
+    Platal::page()->trigError("Il n'y a pas d'utilisateur avec l'identifiant : $login");
     return;
 }
 
@@ -99,7 +98,7 @@ function _silent_user_callback($login)
 
 function get_user_login($data, $get_forlife = false, $callback = '_default_user_callback')
 {
-    global $globals, $page;
+    global $globals;
 
     if (is_numeric($data)) {
         $res = XDB::query("SELECT alias FROM aliases WHERE type='a_vie' AND id={?}", $data);
@@ -171,7 +170,7 @@ function get_user_login($data, $get_forlife = false, $callback = '_default_user_
             default:
                 if (S::has_perms()) {
                     $aliases = $res->fetchColumn();
-                    $page->trigError("Il y a $i utilisateurs avec cette adresse email : ".join(', ', $aliases));
+                    Platal::page()->trigError("Il y a $i utilisateurs avec cette adresse mail : ".join(', ', $aliases));
                 } else {
                     $res->free();
                 }
@@ -359,6 +358,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
                FROM  adresses AS a
           LEFT JOIN  geoloc_pays AS gp ON (gp.a2=a.country)
index 0a4a95f..c05f5ac 100644 (file)
@@ -19,7 +19,6 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-require_once('xorg.misc.inc.php');
 require_once('user.func.inc.php');
 
 global $globals;
@@ -64,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;
         }
@@ -80,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');
@@ -180,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(n.nat='',n.pays,n.nat) AS nat, n.a2 AS iso3166,
                 ad0.text AS app0text, ad0.url AS app0url, ai0.type AS app0type,
                 ad1.text AS app1text, ad1.url AS app1url, ai1.type AS app1type,
@@ -321,7 +319,7 @@ class TrombiView extends MultipageView
         return 'include/plview.trombi.tpl';
     }
 
-    public function apply(PlatalPage &$page)
+    public function apply(PlPage &$page)
     {
         if (!empty($GLOBALS['IS_XNET_SITE'])) {
             global $globals;
@@ -358,7 +356,7 @@ class GeolocView implements PlView
         return $args;
     }
 
-    public function apply(PlatalPage &$page)
+    public function apply(PlPage &$page)
     {
         require_once 'geoloc.inc.php';
         require_once '../modules/search/search.inc.php';
@@ -456,7 +454,7 @@ class GadgetView implements PlView
                  : "");
     }
 
-    public function apply(PlatalPage &$page)
+    public function apply(PlPage &$page)
     {
         $page->assign_by_ref('set',
           $this->set->get($this->fields(), $this->joins(), null, null, null, 5, 0));
index 9ef58e6..d5cd9e0 100644 (file)
@@ -21,7 +21,8 @@
 
 define('SIZE_MAX', 32768);
 
-require_once dirname(__FILE__) . '/../classes/xdb.php';
+global $globals;
+require_once $globals->spoolroot . '/core/classes/xdb.php';
 
 /**
  * Iterator class, that lists objects through the database
@@ -116,7 +117,7 @@ abstract class Validate
                 $this->uid, $this->type, $this, $this->stamp);
 
         global $globals;
-        update_NbValid();
+        $globals->updateNbValid();
         return true;
     }
 
@@ -139,6 +140,8 @@ abstract class Validate
      */
     public function clean()
     {
+        global $globals;
+
         if ($this->unique) {
             $success = XDB::execute('DELETE FROM requests WHERE user_id={?} AND type={?}',
                                     $this->uid, $this->type);
@@ -146,7 +149,7 @@ abstract class Validate
             $success =  XDB::execute('DELETE FROM requests WHERE user_id={?} AND type={?} AND stamp={?}',
                                       $this->uid, $this->type, $this->stamp);
         }
-        update_NbValid();
+        $globals->updateNbValid();
         return $success;
     }
 
@@ -258,20 +261,17 @@ abstract class Validate
 
     protected function trigError($msg)
     {
-        global $page;
-        $page->trigError($msg);
+        Platal::page()->trigError($msg);
     }
 
     protected function trigWarning($msg)
     {
-        global $page;
-        $page->trigWarning($msg);
+        Platal::page()->trigWarning($msg);
     }
 
     protected function trigSuccess($msg)
     {
-        global $page;
-        $page->trigSuccess($msg);
+        Platal::page()->trigSuccess($msg);
     }
 
     // }}}
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 a5ba225..15f3e8e 100644 (file)
@@ -49,7 +49,6 @@ class UsageReq extends Validate
         parent::__construct($_uid, true, 'usage');
         $this->nom_usage  = $_usage;
         $this->reason = $_reason;
-        require_once 'xorg.misc.inc.php';
         $this->alias   = make_username($this->prenom, $this->nom_usage);
         if (!$this->nom_usage) $this->alias = "";
 
index b11f878..2be89de 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-require_once('xorg.misc.inc.php');
 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) {
@@ -44,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
@@ -90,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
@@ -102,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:
diff --git a/include/wiki.inc.php b/include/wiki.inc.php
deleted file mode 100644 (file)
index 906c0e1..0000000
+++ /dev/null
@@ -1,319 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-function wiki_pagename()
-{
-    if (!Get::v('n')) {
-        return null;
-    }
-
-    $words = explode('/', trim(Get::v('n'), '/'));
-    if (count($words) == 2) {
-        return join('.', $words);
-    }
-
-    array_unshift($words, $words[0]);
-    $b = array_pop($words);
-    $a = array_pop($words);
-
-    pl_redirect($a.'/'.$b);
-}
-
-function wiki_filename($s)
-{
-    if (@iconv('utf-8', 'utf-8', $s) == $s) {
-        return $s;
-    }
-    return utf8_encode($s);
-}
-
-function wiki_work_dir()
-{
-    global $globals;
-    return $globals->spoolroot.'/spool/wiki.d';
-}
-
-function wiki_clear_all_cache()
-{
-    system('rm -f '.wiki_work_dir().'/cache_*');
-}
-
-function wiki_perms_options() {
-    return array('public' => 'Public', 'logged' => 'Connecté',
-                  'mdp' => 'Authentifié', 'admin' => 'Admin');
-}
-
-function wiki_get_perms($n)
-{
-    $file  = wiki_work_dir().'/'.wiki_filename(str_replace('/', '.', $n));
-    $lines = explode("\n", @file_get_contents($file));
-    foreach ($lines as $line) {
-        @list($k, $v) = explode('=', $line, 2);
-        if ($k == 'platal_perms') {
-            return explode(':', $v);
-        }
-    }
-    return array('logged', 'admin');
-}
-
-function wiki_putfile($f, $s)
-{
-    $fp = fopen($f, 'w');
-    fputs($fp, $s);
-    fclose($fp);
-}
-
-function wiki_set_perms($n, $pr, $pw)
-{
-    $file  = wiki_work_dir().'/'.wiki_filename(str_replace('/', '.', $n));
-    if (!file_exists($file)) {
-        return false;
-    }
-
-    $p = $pr . ':' . $pw;
-
-    $lines = explode("\n", file_get_contents($file));
-    foreach ($lines as $i => $line) {
-        list($k, $v) = explode('=', $line, 2);
-        if ($k == 'platal_perms') {
-            $lines[$i] = 'platal_perms='.$p;
-            wiki_putfile($file, join("\n", $lines));
-            return true;
-        }
-    }
-
-    array_splice($lines, 1, 0, array('platal_perms='.$p));
-    wiki_putfile($file, join("\n", $lines));
-    return true;
-}
-
-function wiki_may_have_perms($perm) {
-    switch ($perm) {
-      case 'public': return true;
-      case 'logged': return S::logged();
-      case 'mdp':    return S::logged();
-      default:       return S::has_perms();
-    }
-}
-
-function wiki_apply_feed_perms($perm)
-{
-    if ($perm == 'public') {
-        return;
-    }
-
-    require_once 'rss.inc.php';
-    $uid = init_rss(null, Env::v('user'), Env::v('hash'));
-    $res = XDB::query('SELECT user_id AS uid, IF (nom_usage <> \'\', nom_usage, nom) AS nom, prenom, perms
-                         FROM auth_user_md5
-                        WHERE user_id = {?}', $uid);
-    if (!$res->numRows()) {
-        exit;
-    }
-    $table = $res->fetchOneAssoc();
-    $_SESSION = array_merge($_SESSION, $table, array('forlife' => Env::v('user')));
-    require_once 'xorg/session.inc.php';
-    $_SESSION['perms'] =& XorgSession::make_perms($_SESSION['perms']);
-    if ($perm == 'logged' || $_SESSION['perms']->hasFlag('admin')) {
-        return;
-    }
-    exit;
-}
-
-function wiki_apply_perms($perm) {
-    global $page, $platal, $globals;
-
-    switch ($perm) {
-      case 'public':
-        return;
-
-      case 'logged':
-        if (!call_user_func(array($globals->session, 'doAuthCookie'))) {
-            $platal =  empty($GLOBALS['IS_XNET_SITE']) ? new Platal() : new Xnet();
-            $platal->force_login($page);
-        }
-        return;
-
-      default:
-        if (!call_user_func(array($globals->session, 'doAuth'))) {
-            $platal = empty($GLOBALS['IS_XNET_SITE']) ? new Platal() : new Xnet();
-            $platal->force_login($page);
-        }
-        if ($perm == 'admin') {
-            check_perms();
-        }
-        return;
-    }
-}
-
-function wiki_require_page($pagename)
-{
-    global $globals;
-    $pagename_slashes = str_replace('.','/',$pagename);
-    $pagename_dots = str_replace('/','.',$pagename);
-    if (is_file(wiki_work_dir().'/cache_'.$pagename_dots.'.tpl')) {
-        return;
-    }
-    system('wget --no-check-certificate '. escapeshellarg($globals->baseurl.'/'.$pagename_slashes) . ' -O /dev/null');
-}
-
-function wiki_delete_page($pagename)
-{
-    $pagename_dots = str_replace('/','.',$pagename);
-    if (!strpos($pagename_dots, '.')) {
-        return false;
-    }
-    $file  = wiki_work_dir().'/'.wiki_filename($pagename_dots);
-    $cachefile = wiki_work_dir().'/cache_'.$pagename_dots.'.tpl';
-    if (is_file($cachefile)) {
-        unlink($cachefile);
-    }
-    if (!is_file($file)) {
-        return false;
-    }
-    unlink($file);
-    return true;
-}
-
-function wiki_links_in_line($line, $groupname)
-{
-    $links = array();
-    if (preg_match_all('@\[\[([^~][^\]\|\?#]*)((\?|#)[^\]\|]+)?(\\|[^\]]+)?\]\]@', $line, $matches, PREG_OFFSET_CAPTURE)) {
-        foreach ($matches[1] as $j => $link) if (!preg_match('@http://@', $link[0])) {
-            $mylink = str_replace('/','.',trim($link[0]));
-            $sup = trim(substr($matches[2][$j][0],1));
-            $alt = trim(substr($matches[4][$j][0],1));
-            $newlink = str_replace(' ','',ucwords($mylink));
-            if (strpos($newlink,'.') === false) {
-                $newlink = $groupname.'.'.$newlink;
-            }
-            if (!$alt && $mylink != $newlink) {
-                $alt = trim($link[0]);
-            }
-            $links[] = array(
-              'pos' => $matches[0][$j][1],
-              'size' => strlen($matches[0][$j][0]),
-              'href' => $newlink,
-              'sup' => $sup,
-              'alt' => $alt,
-              'group' => substr($mylink, 0, strpos($mylink, '.')));
-        }
-    }
-    return $links;
-}
-
-function wiki_rename_page($pagename, $newname, $changeLinks = true)
-{
-    $pagename_dots = str_replace('/','.',$pagename);
-    $newname_dots = str_replace('/','.',$newname);
-    if (!strpos($pagename_dots, '.') || !strpos($newname_dots, '.')) {
-        return false;
-    }
-    $groupname = substr($pagename_dots, 0, strpos($pagename_dots,'.'));
-    $newgroupname = substr($newname_dots, 0, strpos($pagename_dots,'.'));
-
-    $file  = wiki_work_dir().'/'.wiki_filename($pagename_dots);
-    $newfile  = wiki_work_dir().'/'.wiki_filename($newname_dots);
-    if (!is_file($file)) {
-        // old page doesn't exist
-        return false;
-    }
-    if (!rename($file, $newfile)) {
-        // impossible to renama page
-        return false;
-    }
-
-    if (!$changeLinks) {
-        return true;
-    }
-
-    $changedLinks = 0;
-    // change name inside this folder and ingroup links if changing group
-    $lines = explode("\n", file_get_contents($newfile));
-    $changed = false;
-    foreach ($lines as $i => $line) {
-        list($k, $v) = explode('=', $line, 2);
-        if ($k == 'name' && $v == $pagename_dots) {
-            $lines[$i] = 'name='.$newname_dots;
-            $changed = true;
-        } else if ($groupname != $newgroupname) {
-            $links = wiki_links_in_line($line, $groupname);
-            $newline = ''; $last = 0;
-            foreach ($links as $link) if ($link['group'] == $groupname) {
-                $newline .= substr($line, $last, $link['pos']);
-                $newline .= '[['.$link['href'].$link['sup'].($link['alt']?(' |'.$link['alt']):'').']]';
-                $last = $link['pos']+$link['size'];
-                $changedLinks++;
-            }
-            if ($last != 0) {
-                $newline .= substr($line, $last);
-                $lines[$i] = $newline;
-                $changed = true;
-            }
-        }
-    }
-    wiki_putfile($newfile, join("\n", $lines));
-
-    // change wiki links in all wiki pages
-    $endname = substr($pagename_dots, strpos($pagename_dots,'.')+1);
-    $pages = array();
-    exec("grep ".$endname."  ".wiki_work_dir()."/* -sc", $pages);
-    foreach($pages as $line) {
-        if (preg_match('%/([^/:]+):([0-9]+)$%', $line, $vals) && $vals[2] > 0) {
-            $inpage = $vals[1];
-            $lines = explode("\n", file_get_contents(wiki_work_dir().'/'.$inpage));
-            $changed = false;
-            // find all wiki links in page and change if linked to this page
-            foreach ($lines as $i => $line) {
-                $links = wiki_links_in_line($line, substr($inpage, 0, strpos($inpage, '.')));
-                $newline = ''; $last = 0;
-                foreach ($links as $link) {
-                    if ($link['href'] == $pagename_dots) {
-                        $newline .= substr($line, $last, $link['pos']);
-                        $newline .= '[['.$newname_dots.$link['sup'].($link['alt']?(' |'.$link['alt']):'').']]';
-                        $last = $link['pos']+$link['size'];
-                        $changedLinks++;
-                    }
-                }
-                if ($last != 0) {
-                    $newline .= substr($line, $last);
-                    $lines[$i] = $newline;
-                    $changed = true;
-                }
-            }
-            if ($changed)
-            {
-                wiki_putfile(wiki_work_dir().'/'.$inpage, join("\n", $lines));
-            }
-        }
-    }
-    if ($changedLinks > 0) {
-        return $changedLinks;
-    }
-    return true;
-}
-
-function wiki_rename_folder($pagename, $newname, $changeLinks = true)
-{
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/include/wiki/engine.php b/include/wiki/engine.php
deleted file mode 100644 (file)
index f8c01fc..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-require_once 'wiki.inc.php';
-
-$n    = wiki_pagename();
-if (!$n) {
-    pl_redirect('');
-}
-
-new_skinned_page('core/wiki.tpl');
-$perms = wiki_get_perms($n);
-$feed  = false;
-
-// Check user perms
-switch (Env::v('action')) {
-  case 'rss': case 'atom': case 'sdf': case 'dc':
-    wiki_apply_feed_perms($perms[0]);
-    $feed = true;
-  case '': case 'search':
-    break;
-
-  case 'edit':
-    wiki_apply_perms($perms[1]);
-    break;
-
-  default:
-    wiki_apply_perms('admin');
-    break;
-}
-
-if ($p = Post::v('setrperms')) {
-    wiki_apply_perms('admin');
-    if (wiki_set_perms($n, $p, $perms[1])) {
-        $perms = wiki_get_perms($n);
-        $page->trigSuccess('Permissions mises à jour');
-    }
-}
-
-if ($p = Post::v('setwperms')) {
-    wiki_apply_perms('admin');
-    if (wiki_set_perms($n, $perms[0], $p)) {
-        $perms = wiki_get_perms($n);
-        $page->trigSuccess('Permissions mises à jour');
-    }
-}
-
-// Generate cache even if we don't have access rights
-$wiki_cache   = wiki_work_dir().'/cache_'.wiki_filename($n).'.tpl';
-$cache_exists = file_exists($wiki_cache);
-if (Env::v('action') || !$cache_exists) {
-    if ($cache_exists && !$feed) {
-        unlink($wiki_cache);
-        $files = glob($globals->spoolroot . '/spool/templates_c/*cache_' . wiki_filename($n) . '.tpl*');
-        foreach ($files as $file) {
-            unlink($file);
-        }
-    }
-
-    // we leave pmwiki do whatever it wants and store everything
-    ob_start();
-    require_once($globals->spoolroot.'/wiki/pmwiki.php');
-
-    $wikiAll = ob_get_clean();
-    pl_clear_errors();
-
-    // the pmwiki skin we are using (almost empty) has these keywords:
-    $i = strpos($wikiAll, "<!--/HeaderText-->");
-    $j = strpos($wikiAll, "<!--/PageLeftFmt-->", $i);
-}
-
-$wiki_exists = file_exists(wiki_work_dir() . '/' . wiki_filename($n));
-
-if ($feed) {
-    $wikiAll = str_replace('dc:contributor', 'author', $wikiAll);
-    $wikiAll = preg_replace('!<author>.*?\..*?\.(\d{4})\|(.*?)</author>!u', '<author>$2 (X$1)</author>', $wikiAll);
-    $wikiAll = str_replace('<link>./', '<link>' . $globals->baseurl . '/' . $platal->ns, $wikiAll);
-    echo $wikiAll;
-    pl_clear_errors();
-    exit;
-} elseif (Env::v('action')) {
-    $page->assign('xorg_extra_header', substr($wikiAll, 0, $i));
-    $wikiAll = substr($wikiAll, $j);
-} else {
-    if (!$cache_exists && $wiki_exists) {
-        $wikiAll = substr($wikiAll, $j);
-        wiki_putfile($wiki_cache, $wikiAll);
-    } elseif ($cache_exists) {
-        $wikiAll = file_get_contents($wiki_cache);
-    } elseif (S::has_perms()) {
-        $wikiAll = "<p>La page de wiki $n n'existe pas. "
-                 . "Il te suffit de <a href='" . str_replace('.', '/', $n) . "?action=edit'>l'éditer</a></p>";
-    } else {
-        $page->changeTpl('core/404.tpl');
-    }
-}
-
-// Check user perms
-wiki_apply_perms($perms[0]);
-
-$page->assign('perms', $perms);
-$page->assign('perms_opts', wiki_perms_options());
-
-$page->assign('canedit',    wiki_may_have_perms($perms[1]));
-$page->assign('has_perms',  wiki_may_have_perms('admin'));
-
-$page->assign('wikipage', str_replace('.', '/', $n));
-if (!$feed && $perms[1] == 'admin' && !Env::v('action') && $wiki_exists) {
-    $page->assign('pmwiki_cache', $wiki_cache);
-} else {
-    $page->assign('pmwiki',   $wikiAll);
-    $page->assign('text', true);
-}
-$page->addCssLink('wiki.css');
-$page->addJsLink('wiki.js');
-if (!Env::v('action')) {
-    $url = '/' . str_replace('.', '/', $n) . '?action=rss';
-    if (S::logged()) {
-        $url .= '&user=' . S::v('forlife') . '&hash=' . S::v('core_rss_hash');
-    }
-    $page->setRssLink($n, $url);
-}
-
-$page->run();
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
index e9689e3..a8431e3 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-require_once('platal.inc.php');
-require_once('globals.inc.php');
-require_once('xnet/session.inc.php');
-$globals = new PlatalGlobals('XnetSession');
-XnetSession::init();
+define('PL_GLOBALS_CLASS', 'PlatalGlobals');
+define('PL_SESSION_CLASS', 'XnetSession');
+define('PL_PAGE_CLASS', 'XnetPage');
 
-function new_skinned_page($tpl_name)
-{
-    global $page;
-    require_once("xnet/page.inc.php");
-    if (!$page instanceof XnetPage) {
-        $page = new XnetPage($tpl_name);
-    } else {
-        $page->changeTpl($tpl_name);
-    }
-}
+require_once dirname(dirname(__FILE__)) . '/core/include/platal.inc.php';
+require_once 'common.inc.php';
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
 ?>
index 0d4274c..b67126b 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-require_once('platal.inc.php');
-require_once('globals.inc.php');
-require_once('xorg/session.inc.php');
-$globals = new PlatalGlobals('XorgSession');
-$globals->bootstrap(array('NbIns'), 'update_NbIns');
-$globals->bootstrap(array('NbValid'), 'update_NbValid');
+define('PL_GLOBALS_CLASS', 'PlatalGlobals');
+define('PL_SESSION_CLASS', 'XorgSession');
+define('PL_PAGE_CLASS', 'XorgPage');
 
-// {{{ class XorgPage
-
-class XorgPage extends PlatalPage
-{
-    public function __construct($tpl, $type = SKINNED)
-    {
-        parent::__construct($tpl, $type);
-    }
-
-    public function run()
-    {
-        global $globals, $platal;
-        $this->assign('globals', $globals);
-        if (isset($platal) && $platal->path == 'register') {
-            $skin = $globals->register_skin . ".tpl";
-        } else {
-            $skin = S::v('skin', $globals->skin . ".tpl");
-        }
-        $this->_run('skin/' . $skin);
-    }
-}
-
-// {{{ function new_skinned_page()
-
-function new_skinned_page($tpl_name)
-{
-    global $page;
-    if (!$page instanceof XorgPage) {
-        $page = new XorgPage($tpl_name);
-    } else {
-        $page->changeTpl($tpl_name);
-    }
-}
-
-XorgSession::init();
+require_once dirname(dirname(__FILE__)) . '/core/include/platal.inc.php';
+require_once 'security.inc.php';
+require_once 'common.inc.php';
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
 ?>
diff --git a/include/xorg.misc.inc.php b/include/xorg.misc.inc.php
deleted file mode 100644 (file)
index eefbfb2..0000000
+++ /dev/null
@@ -1,376 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-function quoted_printable_encode($input, $line_max = 76)
-{
-    $lines = preg_split("/(?:\r\n|\r|\n)/", $input);
-    $eol = "\n";
-    $linebreak = "=0D=0A=\n    ";
-    $escape = "=";
-    $output = "";
-
-    foreach ($lines as $j => $line) {
-        $linlen = strlen($line);
-        $newline = "";
-        for($i = 0; $i < $linlen; $i++) {
-            $c = $line{$i};
-            $dec = ord($c);
-            if ( ($dec == 32) && ($i == ($linlen - 1)) ) {
-                // convert space at eol only
-                $c = "=20";
-            } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) {
-                // always encode "\t", which is *not* required
-                $c = $escape.strtoupper(sprintf("%02x",$dec));
-            }
-            if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted
-                $output .= $newline.$escape.$eol;
-                $newline = "    ";
-            }
-            $newline .= $c;
-        } // end of for
-        $output .= $newline;
-        if ($j<count($lines)-1) $output .= $linebreak;
-    }
-    return trim($output);
-}
-
-/** vérifie si une adresse email convient comme adresse de redirection
- * @param $email l'adresse email a verifier
- * @return BOOL
- */
-function isvalid_email_redirection($email)
-{
-    return isvalid_email($email) &&
-        !preg_match("/@(polytechnique\.(org|edu)|melix\.(org|net)|m4x\.org)$/", $email);
-}
-
-/** genere une chaine aleatoire de 22 caracteres ou moins
- * @param $len longueur souhaitée, 22 par défaut
- * @return la chaine aleatoire qui contient les caractères [A-Za-z0-9+/]
- */
-function rand_token($len = 22)
-{
-    $len = max(2, $len);
-    $len = min(50, $len);
-    $fp = fopen('/dev/urandom', 'r');
-    // $len * 2 is certainly an overkill,
-    // but HEY, reading 40 bytes from /dev/urandom is not that slow !
-    $token = fread($fp, $len * 2);
-    fclose($fp);
-    $token = base64_encode($token);
-    $token = preg_replace("![Il10O+/]!", "", $token);
-    $token = substr($token,0,$len);
-    return $token;
-}
-
-/** genere une chaine aleatoire convenable pour une url
- * @param $len longueur souhaitée, 22 par défaut
- * @return la chaine aleatoire
- */
-function rand_url_id($len = 22)
-{
-    return rand_token($len);
-}
-
-
-/** genere une chaine aleatoire convenable pour un mot de passe
- * @return la chaine aleatoire
- */
-function rand_pass()
-{
-    return rand_token(8);
-}
-
-/** Remove accent from a string and replace them by the nearest letter
- */
-global $lc_convert, $uc_convert;
-$lc_convert = array('é' => 'e', 'è' => 'e', 'ë' => 'e', 'ê' => 'e',
-    'á' => 'a', 'à' => 'a', 'ä' => 'a', 'â' => 'a', 'å' => 'a', 'ã' => 'a',
-    'ï' => 'i', 'î' => 'i', 'ì' => 'i', 'í' => 'i',
-    'ô' => 'o', 'ö' => 'o', 'ò' => 'o', 'ó' => 'o', 'õ' => 'o', 'ø' => 'o',
-    'ú' => 'u', 'ù' => 'u', 'û' => 'u', 'ü' => 'u',
-    'ç' => 'c', 'ñ' => 'n');
-$uc_convert = array('É' => 'E', 'È' => 'E', 'Ë' => 'E', 'Ê' => 'E',
-    'Á' => 'A', 'À' => 'A', 'Ä' => 'A', 'Â' => 'A', 'Å' => 'A', 'Ã' => 'A',
-    'Ï' => 'I', 'Î' => 'I', 'Ì' => 'I', 'Í' => 'I',
-    'Ô' => 'O', 'Ö' => 'O', 'Ò' => 'O', 'Ó' => 'O', 'Õ' => 'O', 'Ø' => 'O',
-    'Ú' => 'U', 'Ù' => 'U', 'Û' => 'U', 'Ü' => 'U',
-    'Ç' => 'C', 'Ñ' => 'N');
-
-function replace_accent($string)
-{
-    global $lc_convert, $uc_convert;
-    $string = strtr($string, $lc_convert);
-    return strtr($string, $uc_convert);
-}
-
-/** creates a username from a first and last name
- *
- * @param $prenom the firstname
- * @param $nom the last name
- *
- * return STRING the corresponding username
- */
-function make_username($prenom,$nom)
-{
-    /* on traite le prenom */
-    $prenomUS=replace_accent(trim($prenom));
-    $prenomUS=stripslashes($prenomUS);
-
-    /* on traite le nom */
-    $nomUS=replace_accent(trim($nom));
-    $nomUS=stripslashes($nomUS);
-
-    // calcul du login
-    $username = strtolower($prenomUS.".".$nomUS);
-    $username = str_replace(" ","-",$username);
-    $username = str_replace("'","",$username);
-    return $username;
-}
-
-/* Un soundex en français posté par Frédéric Bouchery
-   Voici une adaptation en PHP de la fonction soundex2 francisée de Frédéric BROUARD (http://sqlpro.developpez.com/Soundex/).
-   C'est une bonne démonstration de la force des expressions régulières compatible Perl.
-trouvé sur http://expreg.com/voirsource.php?id=40&type=Chaines%20de%20caract%E8res */
-function soundex_fr($sIn)
-{
-    static $convVIn, $convVOut, $convGuIn, $convGuOut, $accents;
-    if (!isset($convGuIn)) {
-        global $uc_convert, $lc_convert;
-        $convGuIn  = array( 'GUI', 'GUE', 'GA', 'GO', 'GU', 'SCI', 'SCE', 'SC', 'CA', 'CO',
-                            'CU', 'QU', 'Q', 'CC', 'CK', 'G', 'ST', 'PH');
-        $convGuOut = array( 'KI', 'KE', 'KA', 'KO', 'K', 'SI', 'SE', 'SK', 'KA', 'KO',
-                            'KU', 'K', 'K', 'K', 'K', 'J', 'T', 'F');
-        $convVIn   = array( '/E?(AU)/', '/([EA])?[UI]([NM])([^EAIOUY]|$)/', '/[AE]O?[NM]([^AEIOUY]|$)/',
-            '/[EA][IY]([NM]?[^NM]|$)/', '/(^|[^OEUIA])(OEU|OE|EU)([^OEUIA]|$)/', '/OI/',
-            '/(ILLE?|I)/', '/O(U|W)/', '/O[NM]($|[^EAOUIY])/', '/(SC|S|C)H/',
-            '/([^AEIOUY1])[^AEIOUYLKTPNR]([UAO])([^AEIOUY])/', '/([^AEIOUY]|^)([AUO])[^AEIOUYLKTP]([^AEIOUY1])/', '/^KN/',
-            '/^PF/', '/C([^AEIOUY]|$)/',
-            '/C/', '/Z$/', '/(?<!^)Z+/', '/ER$/', '/H/', '/W/');
-        $convVOut  = array( 'O', '1\3', 'A\1',
-            'E\1', '\1E\3', 'O',
-            'Y', 'U', 'O\1', '9',
-            '\1\2\3', '\1\2\3', 'N',
-            'F', 'K\1',
-            'S', 'SE', 'S', 'E', '', 'V');
-        $accents = $uc_convert + $lc_convert;
-        $accents['Ç'] = 'S';
-        $accents['¿'] = 'E';
-    }
-    // Si il n'y a pas de mot, on sort immédiatement
-    if ( $sIn === '' ) return '    ';
-    // On supprime les accents
-    $sIn = strtr( $sIn, $accents);
-    // On met tout en minuscule
-    $sIn = strtoupper( $sIn );
-    // On supprime tout ce qui n'est pas une lettre
-    $sIn = preg_replace( '`[^A-Z]`', '', $sIn );
-    // Si la chaîne ne fait qu'un seul caractère, on sort avec.
-    if ( strlen( $sIn ) === 1 ) return $sIn . '   ';
-    // on remplace les consonnances primaires
-    $sIn = str_replace( $convGuIn, $convGuOut, $sIn );
-    // on supprime les lettres répétitives
-    $sIn = preg_replace( '`(.)\1`', '$1', $sIn );
-    // on réinterprète les voyelles
-    $sIn = preg_replace( $convVIn, $convVOut, $sIn);
-    // on supprime les terminaisons T, D, S, X (et le L qui précède si existe)
-    $sIn = preg_replace( '`L?[TDX]S?$`', '', $sIn );
-    // on supprime les E, A et Y qui ne sont pas en première position
-    $sIn = preg_replace( '`(?!^)Y([^AEOU]|$)`', '\1', $sIn);
-    $sIn = preg_replace( '`(?!^)[EA]`', '', $sIn);
-    return substr( $sIn . '    ', 0, 4);
-}
-
-/** met les majuscules au debut de chaque atome du prénom
- * @param $prenom le prénom à formater
- * return STRING le prénom avec les majuscules
- */
-function make_firstname_case($prenom)
-{
-    $prenom = strtolower($prenom);
-    $pieces = explode('-',$prenom);
-
-    foreach ($pieces as $piece) {
-        $subpieces = explode("'",$piece);
-        $usubpieces="";
-        foreach ($subpieces as $subpiece)
-            $usubpieces[] = ucwords($subpiece);
-        $upieces[] = implode("'",$usubpieces);
-    }
-    return implode('-',$upieces);
-}
-
-
-function make_forlife($prenom, $nom, $promo)
-{
-    $prenomUS = replace_accent(trim($prenom));
-    $nomUS    = replace_accent(trim($nom));
-
-    $forlife = strtolower($prenomUS.".".$nomUS.".".$promo);
-    $forlife = str_replace(" ","-",$forlife);
-    $forlife = str_replace("'","",$forlife);
-    return $forlife;
-}
-
-/** Convert ip to uint (to store it in a database)
- */
-function ip_to_uint($ip)
-{
-    $part = explode('.', $ip);
-    if (count($part) != 4) {
-        return null;
-    }
-    $v = 0;
-    $fact = 0x1000000;
-    for ($i = 0 ; $i < 4 ; ++$i) {
-        $v += $fact * $part[$i];
-        $fact >>= 8;
-    }
-    return $v;
-}
-
-/** Convert uint to ip (to build a human understandable ip)
- */
-function uint_to_ip($uint)
-{
-    return long2ip($uint);
-}
-
-
-/******************************************************************************
- * Security functions
- *****************************************************************************/
-
-function check_ip($level)
-{
-    if (empty($_SERVER['REMOTE_ADDR'])) {
-        return false;
-    }
-    if (empty($_SESSION['check_ip'])) {
-        $ips = array();
-        if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
-            $ips = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
-        }
-        $ips[] = $_SERVER['REMOTE_ADDR'];
-        foreach ($ips as &$ip) {
-            $ip = '(ip & mask) = (' . ip_to_uint($ip) . '& mask)';
-        }
-        $res = XDB::query('SELECT  state, description
-                             FROM  ip_watch
-                            WHERE  ' . implode(' OR ', $ips) . '
-                         ORDER BY  state DESC');
-        if ($res->numRows()) {
-            $state = $res->fetchOneAssoc();
-            $_SESSION['check_ip'] = $state['state'];
-            $_SESSION['check_ip_desc'] = $state['description'];
-        } else {
-            $_SESSION['check_ip'] = 'safe';
-        }
-    }
-    $test = array();
-    switch ($level) {
-      case 'unsafe': $test[] = 'unsafe';
-      case 'dangerous': $test[] = 'dangerous';
-      case 'ban': $test[] = 'ban'; break;
-      default: return false;
-    }
-    return in_array($_SESSION['check_ip'], $test);
-}
-
-function check_email($email, $message)
-{
-    $res = XDB::query("SELECT state, description
-        FROM emails_watch
-        WHERE state != 'safe' AND email = {?}", $email);
-    if ($res->numRows()) {
-        send_warning_mail($message);
-        return true;
-    }
-    return false;
-}
-
-function check_account()
-{
-    return S::v('watch_account');
-}
-
-function check_redirect($red = null)
-{
-    require_once 'emails.inc.php';
-    if (is_null($red)) {
-        $red = new Redirect(S::v('uid'));
-    }
-    if ($red->get_uid() == S::v('uid')) {
-        $_SESSION['no_redirect'] = !$red->other_active('');
-        $_SESSION['mx_failures'] = $red->get_broken_mx();
-    }
-}
-
-function send_warning_mail($title)
-{
-    global $globals;
-    $mailer = new PlMailer();
-    $mailer->setFrom("webmaster@" . $globals->mail->domain);
-    $mailer->addTo($globals->core->admin_email);
-    $mailer->setSubject("[Plat/al Security Alert] $title");
-    $mailer->setTxtBody("Identifiants de session :\n" . var_export($_SESSION, true) . "\n\n"
-        ."Identifiants de connexion :\n" . var_export($_SERVER, true));
-    $mailer->send();
-}
-
-function kill_sessions()
-{
-    assert(S::has_perms());
-    shell_exec('sudo -u root ' . dirname(dirname(__FILE__)) . '/bin/kill_sessions.sh');
-}
-
-
-/******************************************************************************
- * Dynamic configuration update/edition stuff
- *****************************************************************************/
-
-function update_NbIns()
-{
-    global $globals;
-    $res = XDB::query("SELECT  COUNT(*)
-                         FROM  auth_user_md5
-                        WHERE  perms IN ('admin','user') AND deces=0");
-    $cnt = $res->fetchOneCell();
-    $globals->change_dynamic_config(array('NbIns' => $cnt));
-}
-
-function update_NbValid()
-{
-    global $globals;
-    $res = XDB::query("SELECT  COUNT(*)
-                         FROM  requests");
-    $globals->change_dynamic_config(array('NbValid' => $res->fetchOneCell()));
-}
-
-function update_NbNotifs()
-{
-    require_once 'notifs.inc.php';
-    $n = select_notifs(false, S::i('uid'), S::v('watch_last'), false);
-    $_SESSION['notifs'] = $n->numRows();
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/include/xorg/session.inc.php b/include/xorg/session.inc.php
deleted file mode 100644 (file)
index 9ce9c2f..0000000
+++ /dev/null
@@ -1,334 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-require_once 'xorg.misc.inc.php';
-
-class XorgSession
-{
-    // {{{ public static function init
-
-    public static function init()
-    {
-        S::init();
-        if (!S::has('uid')) {
-            try_cookie();
-        }
-        if ((check_ip('dangerous') && S::has('uid')) || check_account()) {
-            $_SESSION['log']->log("view_page", $_SERVER['REQUEST_URI']);
-        }
-    }
-
-    // }}}
-    // {{{ public static function destroy()
-
-    public static function destroy()
-    {
-        S::destroy();
-        XorgSession::init();
-    }
-
-    // }}}
-    // {{{ public static function doAuth()
-
-    public static function doAuth($new_name = false)
-    {
-        global $globals;
-        if (S::identified()) { // ok, c'est bon, on n'a rien à faire
-            return true;
-        }
-
-        if (!Env::has('username') || !Env::has('response')
-        ||  !S::has('challenge'))
-        {
-            return false;
-        }
-
-        // si on vient de recevoir une identification par passwordpromptscreen.tpl
-        // ou passwordpromptscreenlogged.tpl
-        if (S::has('suid')) {
-            $suid = S::v('suid');
-            $login = $uname = $suid['forlife'];
-            $redirect = false;
-        } else {
-            $uname = Env::v('username');
-
-            if (Env::v('domain') == "alias") {
-                $res = XDB::query(
-                    "SELECT redirect
-                       FROM virtual
-                 INNER JOIN virtual_redirect USING(vid)
-                      WHERE alias LIKE {?}", $uname."@".$globals->mail->alias_dom);
-                $redirect = $res->fetchOneCell();
-                if ($redirect) {
-                    $login = substr($redirect, 0, strpos($redirect, '@'));
-                } else {
-                    $login = "";
-                }
-            } else {
-                $login = $uname;
-                $redirect = false;
-            }
-        }
-
-        $field = (!$redirect && preg_match('/^\d*$/', $uname)) ? 'id' : 'alias';
-        $res   = XDB::query(
-                    "SELECT  u.user_id, u.password
-                       FROM  auth_user_md5 AS u
-                 INNER JOIN  aliases       AS a ON ( a.id=u.user_id AND type!='homonyme' )
-                      WHERE  a.$field = {?} AND u.perms IN('admin','user')", $login);
-
-        $logger = S::v('log');
-        if (list($uid, $password) = $res->fetchOneRow()) {
-            require_once('secure_hash.inc.php');
-            $expected_response = hash_encrypt("$uname:$password:".S::v('challenge'));
-            // le password de la base est peut-être encore encodé en md5
-            if (Env::v('response') != $expected_response) {
-                $new_password = hash_xor(Env::v('xorpass'), $password);
-                $expected_response = hash_encrypt("$uname:$new_password:".S::v('challenge'));
-                if (Env::v('response') == $expected_response) {
-                      XDB::execute("UPDATE auth_user_md5 SET password = {?} WHERE user_id = {?}",
-                                   $new_password, $uid);
-                }
-            }
-            if (Env::v('response') == $expected_response) {
-                if (Env::has('domain')) {
-                    if (($domain = Env::v('domain', 'login')) == 'alias') {
-                        setcookie('ORGdomain', "alias", (time()+25920000), '/', '', 0);
-                    } else {
-                        setcookie('ORGdomain', '', (time()-3600), '/', '', 0);
-                    }
-                    // pour que la modification soit effective dans le reste de la page
-                    $_COOKIE['ORGdomain'] = $domain;
-                }
-
-                S::kill('challenge');
-                if ($logger) {
-                    $logger->log('auth_ok');
-                }
-                if (!start_connexion($uid, true)) {
-                    return false;
-                }
-                if (Env::v('remember', 'false') == 'true') {
-                    $cookie = hash_encrypt(S::v('password'));
-                    setcookie('ORGaccess',$cookie,(time()+25920000),'/','',0);
-                    if ($logger) {
-                        $logger->log("cookie_on");
-                    }
-                } else {
-                    setcookie('ORGaccess', '', time() - 3600, '/', '', 0);
-
-                    if ($logger) {
-                        $logger->log("cookie_off");
-                    }
-                }
-                return true;
-            } elseif ($logger) {
-                $logger->log('auth_fail','bad password');
-            }
-        } elseif ($logger) {
-            $logger->log('auth_fail','bad login');
-        }
-
-        return false;
-    }
-
-    // }}}
-    // {{{ public static function doAuthCookie()
-
-    /** Try to do a cookie-based authentication.
-     *
-     * @param page the calling page (by reference)
-     */
-    public static function doAuthCookie()
-
-    {
-        if (S::logged()) {
-            return true;
-        }
-
-        if (Env::has('username') and Env::has('response')) {
-            return XorgSession::doAuth();
-        }
-
-        if ($r = try_cookie()) {
-            return XorgSession::doAuth(($r > 0));
-        }
-
-        return false;
-    }
-
-    // }}}
-    // {{{ public static function make_perms()
-
-    public static function &make_perms($perm)
-    {
-        $flags = new FlagSet();
-        if ($perm == 'disabled' || $perm == 'ext') {
-            return $flags;
-        }
-        $flags->addFlag(PERMS_USER);
-        if ($perm == 'admin') {
-            $flags->addFlag(PERMS_ADMIN);
-        }
-        return $flags;
-    }
-
-    // }}}
-}
-
-// {{{ function try_cookie()
-
-/** réalise la récupération de $_SESSION pour qqn avec cookie
- * @return  int     0 if all OK, -1 if no cookie, 1 if cookie with bad hash,
- *                  -2 should not happen
- */
-function try_cookie()
-{
-    if (Cookie::v('ORGaccess') == '' or !Cookie::has('ORGuid')) {
-        return -1;
-    }
-
-    $res = @XDB::query(
-            "SELECT user_id,password FROM auth_user_md5
-              WHERE user_id = {?} AND perms IN('admin','user')",
-            Cookie::i('ORGuid'));
-
-    if ($res->numRows() != 0) {
-        list($uid, $password) = $res->fetchOneRow();
-        require_once('secure_hash.inc.php');
-        $expected_value       = hash_encrypt($password);
-        if ($expected_value == Cookie::v('ORGaccess')) {
-            if (!start_connexion($uid, false)) {
-                return -3;
-            }
-            return 0;
-        } else {
-            return 1;
-        }
-    }
-
-    return -2;
-}
-
-// }}}
-// {{{ function start_connexion()
-
-/** place les variables de session dépendants de auth_user_md5
- * et met à jour les dates de dernière connexion si nécessaire
- * @return void
- * @see controlpermanent.inc.php controlauthentication.inc.php
- */
-function start_connexion ($uid, $identified)
-{
-    $res  = XDB::query("
-        SELECT  u.user_id AS uid, prenom, prenom_ini, nom, nom_ini, nom_usage, perms, promo, promo_sortie,
-                matricule, password, FIND_IN_SET('femme', u.flags) AS femme,
-                a.alias AS forlife, a2.alias AS bestalias,
-                q.core_mail_fmt AS mail_fmt, UNIX_TIMESTAMP(q.banana_last) AS banana_last, q.watch_last, q.core_rss_hash,
-                FIND_IN_SET('watch', u.flags) AS watch_account, q.last_version, g.g_account_name IS NOT NULL AS googleapps
-          FROM  auth_user_md5   AS u
-    INNER JOIN  auth_user_quick AS q  USING(user_id)
-    INNER JOIN  aliases         AS a  ON (u.user_id = a.id AND a.type='a_vie')
-    INNER JOIN  aliases         AS a2 ON (u.user_id = a2.id AND FIND_IN_SET('bestalias',a2.flags))
-     LEFT JOIN  gapps_accounts  AS g  ON (u.user_id = g.l_userid AND g.g_status = 'active')
-         WHERE  u.user_id = {?} AND u.perms IN('admin','user')", $uid);
-    $sess = $res->fetchOneAssoc();
-    $res = XDB::query("SELECT  UNIX_TIMESTAMP(s.start) AS lastlogin, s.host
-                         FROM  logger.sessions AS s
-                        WHERE  s.uid = {?} AND s.suid = 0
-                     ORDER BY  s.start DESC
-                        LIMIT  1", $uid);
-    if ($res->numRows()) {
-        $sess = array_merge($sess, $res->fetchOneAssoc());
-    }
-    $suid = S::v('suid');
-
-    if ($suid) {
-        $logger = new CoreLogger($uid, $suid['uid']);
-        $logger->log("suid_start", S::v('forlife')." by {$suid['uid']}");
-        $sess['suid'] = $suid;
-    } else {
-        $logger = S::v('log', new CoreLogger($uid));
-        $logger->log("connexion", Env::v('n'));
-        setcookie('ORGuid', $uid, (time()+25920000), '/', '', 0);
-    }
-
-    $_SESSION         = array_merge($_SESSION, $sess);
-    $_SESSION['log']  = $logger;
-    $_SESSION['auth'] = ($identified ? AUTH_MDP : AUTH_COOKIE);
-    $_SESSION['perms'] =& XorgSession::make_perms($_SESSION['perms']);
-    $mail_subject = null;
-    if (check_account()) {
-        $mail_subject = "Connexion d'un utilisateur surveillé";
-    }
-    if (check_ip('unsafe')) {
-        if ($mail_subject) {
-            $mail_subject .= ' - ';
-        }
-        $mail_subject .= "Une IP surveillee a tente de se connecter";
-        if (check_ip('ban')) {
-            send_warning_mail($mail_subject);
-            $_SESSION = array();
-            $_SESSION['perms'] = new FlagSet();
-            global $page;
-            $newpage = false;
-            if (!$page) {
-                require_once 'xorg.inc.php';
-                new_skinned_page('platal/index.tpl');
-                $newpage = true;
-            }
-            $page->trigError("Une erreur est survenue lors de la procédure d'authentification. "
-                       ."Merci de contacter au plus vite "
-                       ."<a href='mailto:support@polytechnique.org'>support@polytechnique.org</a>");
-            if ($newpage) {
-                $page->run();
-            }
-            return false;
-        }
-    }
-    if ($mail_subject) {
-        send_warning_mail($mail_subject);
-    }
-    set_skin();
-    update_NbNotifs();
-    check_redirect();
-    return true;
-}
-
-// }}}
-
-function set_skin()
-{
-    global $globals;
-    if (S::logged() && (!S::has('skin') || S::has('suid'))) {
-        $uid = S::v('uid');
-        $res = XDB::query("SELECT  skin_tpl
-                          FROM  auth_user_quick AS a
-                          INNER JOIN  skins           AS s ON a.skin = s.id
-                          WHERE  user_id = {?} AND skin_tpl != ''", $uid);
-        if ($_SESSION['skin'] = $res->fetchOneCell()) {
-            return;
-        }
-    }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
index a4ee8fd..9cf0c46 100644 (file)
@@ -59,13 +59,13 @@ class AdminModule extends PLModule
     function handler_default(&$page)
     {
         $page->changeTpl('admin/index.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Administration');
+        $page->setTitle('Administration');
     }
 
     function handler_postfix_delayed(&$page)
     {
         $page->changeTpl('admin/postfix_delayed.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Administration - Postfix : Retardés');
+        $page->setTitle('Administration - Postfix : Retardés');
 
         if (Env::has('del')) {
             $crc = Env::v('crc');
@@ -90,7 +90,7 @@ class AdminModule extends PLModule
 
     function handler_postfix_regexpsbounces(&$page, $new = null) {
         $page->changeTpl('admin/emails_bounces_re.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Administration - Postfix : Regexps Bounces');
+        $page->setTitle('Administration - Postfix : Regexps Bounces');
         $page->assign('new', $new);
 
         if (Post::has('submit')) {
@@ -347,14 +347,14 @@ class AdminModule extends PLModule
 
         $page->changeTpl('admin/logger-view.tpl');
 
-        $page->assign('xorg_title','Polytechnique.org - Administration - Logs des sessions');
+        $page->setTitle('Administration - Logs des sessions');
     }
 
     function handler_user(&$page, $login = false)
     {
         global $globals;
         $page->changeTpl('admin/utilisateurs.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Administration - Edit/Su/Log');
+        $page->setTitle('Administration - Edit/Su/Log');
         require_once("emails.inc.php");
         require_once("user.func.inc.php");
 
@@ -380,12 +380,17 @@ class AdminModule extends PLModule
         }
 
         if(Env::has('suid_button') && $login) {
-            $_SESSION['log']->log("suid_start", "login by ".S::v('forlife'));
-            $_SESSION['suid'] = $_SESSION;
-            $r = XDB::query("SELECT id FROM aliases WHERE alias={?}", $login);
+            S::logger()->log("suid_start", "login by ".S::v('forlife'));
+            $r = XDB::query("SELECT  id
+                               FROM  aliases
+                              WHERE  alias={?}", $login);
             if($uid = $r->fetchOneCell()) {
-                start_connexion($uid, true);
-                pl_redirect("");
+                if (!Platal::session()->startSUID($uid)) {
+                    $page->trigError('Impossible d\'effectuer un SUID sur ' . $uid);
+                } else {
+                    $page->kill("coucou");
+                    pl_redirect("");
+                }
             }
         }
 
@@ -573,12 +578,11 @@ class AdminModule extends PLModule
                             $mailer->send();
 
                             // update number of subscribers (perms or deceased may have changed)
-                            update_NbIns();
+                            $globals->updateNbIns();
 
                             $page->trigSuccess("updaté correctement.");
                         }
                         if (Env::v('nomusageN') != $mr['nom_usage']) {
-                            require_once "xorg.misc.inc.php";
                             set_new_usage($mr['user_id'], Env::v('nomusageN'), make_username(Env::v('prenomN'), Env::v('nomusageN')));
                         }
                         if (Env::v('decesN') != $mr['deces']) {
@@ -617,7 +621,7 @@ class AdminModule extends PLModule
                     case "u_kill":
                         user_clear_all_subs($mr['user_id']);
                         // update number of subscribers (perms or deceased may have changed)
-                        update_NbIns();
+                        $globals->updateNbIns();
                         $page->trigSuccess("'{$mr['user_id']}' a été désinscrit !");
                         $mailer = new PlMailer("admin/useredit.mail.tpl");
                         $mailer->assign("admin", S::v('forlife'));
@@ -728,7 +732,7 @@ class AdminModule extends PLModule
 
     function handler_homonyms(&$page, $op = 'list', $target = null) {
         $page->changeTpl('admin/homonymes.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Administration - Homonymes');
+        $page->setTitle('Administration - Homonymes');
         require_once("homonymes.inc.php");
 
         if ($target) {
@@ -791,7 +795,7 @@ class AdminModule extends PLModule
 
     function handler_ax_xorg(&$page) {
         $page->changeTpl('admin/ax-xorg.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Administration - AX/X.org');
+        $page->setTitle('Administration - AX/X.org');
 
         // liste des différences
         $res = XDB::query(
@@ -819,7 +823,7 @@ class AdminModule extends PLModule
 
     function handler_deaths(&$page, $promo = 0, $validate = false) {
         $page->changeTpl('admin/deces_promo.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Administration - Deces');
+        $page->setTitle('Administration - Deces');
 
         if (!$promo)
             $promo = Env::i('promo');
@@ -859,7 +863,7 @@ class AdminModule extends PLModule
 
     function handler_dead_but_active(&$page) {
         $page->changeTpl('admin/dead_but_active.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Administration - Décédés');
+        $page->setTitle('Administration - Décédés');
 
         $res = XDB::iterator(
                 "SELECT  u.promo, u.nom, u.prenom, u.deces, u.matricule_ax, a.alias, DATE(MAX(s.start)) AS last
@@ -874,7 +878,7 @@ class AdminModule extends PLModule
 
     function handler_synchro_ax(&$page, $user = null, $action = null) {
         $page->changeTpl('admin/synchro_ax.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Administration - Synchro AX');
+        $page->setTitle('Administration - Synchro AX');
 
         require_once('synchro_ax.inc.php');
 
@@ -922,7 +926,7 @@ class AdminModule extends PLModule
     function handler_validate(&$page, $action = 'list', $id = null)
     {
         $page->changeTpl('admin/valider.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Administration - Valider une demande');
+        $page->setTitle('Administration - Valider une demande');
                 $page->addCssLink('nl.css');
         $page->addJsLink('ajax.js');
         require_once("validations.inc.php");
@@ -964,12 +968,13 @@ class AdminModule extends PLModule
 
         // Update the count of item to validate here... useful in development configuration
         // where several copies of the site use the same DB, but not the same "dynamic configuration"
-        update_NbValid();
+        global $globals;
+        $globals->updateNbValid();
         $page->assign('vit', new ValidateIterator());
     }
 
     function handler_validate_answers(&$page, $action = 'list', $id = null) {
-        $page->assign('xorg_title','Polytechnique.org - Administration - Réponses automatiques de validation');
+        $page->setTitle('Administration - Réponses automatiques de validation');
         $page->assign('title', 'Gestion des réponses automatiques');
         $table_editor = new PLTableEditor('admin/validate/answers','requests_answers','id');
         $table_editor->describe('category','catégorie',true);
@@ -978,7 +983,7 @@ class AdminModule extends PLModule
         $table_editor->apply($page, $action, $id);
     }
     function handler_skins(&$page, $action = 'list', $id = null) {
-        $page->assign('xorg_title','Polytechnique.org - Administration - Skins');
+        $page->setTitle('Administration - Skins');
         $page->assign('title', 'Gestion des skins');
         $table_editor = new PLTableEditor('admin/skins','skins','id');
         $table_editor->describe('name','nom',true);
@@ -991,7 +996,7 @@ class AdminModule extends PLModule
     }
 
     function handler_postfix_blacklist(&$page, $action = 'list', $id = null) {
-        $page->assign('xorg_title','Polytechnique.org - Administration - Postfix : Blacklist');
+        $page->setTitle('Administration - Postfix : Blacklist');
         $page->assign('title', 'Blacklist de postfix');
         $table_editor = new PLTableEditor('admin/postfix/blacklist','postfix_blacklist','email', true);
         $table_editor->describe('reject_text','Texte de rejet',true);
@@ -999,14 +1004,14 @@ class AdminModule extends PLModule
         $table_editor->apply($page, $action, $id);
     }
     function handler_postfix_whitelist(&$page, $action = 'list', $id = null) {
-        $page->assign('xorg_title','Polytechnique.org - Administration - Postfix : Whitelist');
+        $page->setTitle('Administration - Postfix : Whitelist');
         $page->assign('title', 'Whitelist de postfix');
         $table_editor = new PLTableEditor('admin/postfix/whitelist','postfix_whitelist','email', true);
         $table_editor->describe('email','email',true);
         $table_editor->apply($page, $action, $id);
     }
     function handler_mx_broken(&$page, $action = 'list', $id = null) {
-        $page->assign('xorg_title', 'Polytechnique.org - Administration - MX Défaillants');
+        $page->setTitle('Administration - MX Défaillants');
         $page->assign('title', 'MX Défaillant');
         $table_editor = new PLTableEditor('admin/mx/broken', 'mx_watch', 'host', true);
         $table_editor->describe('host', 'Masque', true);
@@ -1015,7 +1020,7 @@ class AdminModule extends PLModule
         $table_editor->apply($page, $action, $id);
     }
     function handler_logger_actions(&$page, $action = 'list', $id = null) {
-        $page->assign('xorg_title','Polytechnique.org - Administration - Actions');
+        $page->setTitle('Administration - Actions');
         $page->assign('title', 'Gestion des actions de logger');
         $table_editor = new PLTableEditor('admin/logger/actions','logger.actions','id');
         $table_editor->describe('text','intitulé',true);
@@ -1023,7 +1028,7 @@ class AdminModule extends PLModule
         $table_editor->apply($page, $action, $id);
     }
     function handler_downtime(&$page, $action = 'list', $id = null) {
-        $page->assign('xorg_title','Polytechnique.org - Administration - Coupures');
+        $page->setTitle('Administration - Coupures');
         $page->assign('title', 'Gestion des coupures');
         $table_editor = new PLTableEditor('admin/downtime','coupures','id');
         $table_editor->describe('debut','date',true);
@@ -1034,10 +1039,8 @@ class AdminModule extends PLModule
         $table_editor->apply($page, $action, $id);
     }
 
-    function handler_wiki(&$page, $action='list', $wikipage='', $wikipage2='')
+    function handler_wiki(&$page, $action = 'list', $wikipage = null, $wikipage2 = null)
     {
-        require_once 'wiki.inc.php';
-
         if (S::v('core_rss_hash')) {
            $page->setRssLink('Changement Récents',
                              '/Site/AllRecentChanges?action=rss&user=' . S::v('forlife') . '&hash=' . S::v('core_rss_hash'));
@@ -1048,62 +1051,47 @@ class AdminModule extends PLModule
             S::assert_xsrf_token();
 
             $perms_read = Post::v('read');
-            $perms_edot = Post::v('edit');
+            $perms_edit = Post::v('edit');
             if ($perms_read || $perms_edit) {
-                foreach ($_POST as $wiki_page => $val) if ($val == 'on') {
-                    $wiki_page = str_replace('_', '/', $wiki_page);
-                    if (!$perms_read || !$perms_edit)
-                        list($perms0, $perms1) = wiki_get_perms($wiki_page);
-                    if ($perms_read)
-                        $perms0 = $perms_read;
-                    if ($perms_edit)
-                        $perms1 = $perms_edit;
-                    wiki_set_perms($wiki_page, $perms0, $perms1);
+                foreach ($_POST as $wiki_page => $val) {
+                    if ($val == 'on') {
+                        $wp = new PlWikiPage(str_replace(array('_', '/'), '.', $wiki_page));
+                        if ($wp->setPerms($perms_read ? $perms_read : $wp->readPerms(),
+                                          $perms_edit ? $perms_edit : $wp->writePerms())) {
+                            $page->trigSuccess("Permission de la page $wiki_page mises à jour");
+                        } else {
+                            $page->trigError("Impossible de mettre les permissions de la page $wiki_page à jour");
+                        }
+                    }
                 }
             }
-        }
-
-        if ($action == 'delete' && $wikipage != '') {
-            S::assert_xsrf_token();
-
-            if (wiki_delete_page($wikipage)) {
-                $page->trigSuccess("La page ".$wikipage." a été supprimée.");
-            } else {
-                $page->trigError("Impossible de supprimer la page ".$wikipage.".");
-            }
-        }
-
-        if ($action == 'rename' && $wikipage != '' && $wikipage2 != '' && $wikipage != $wikipage2) {
+        } else if ($action != 'list' && !empty($wikipage)) {
+            $wp = new PlWikiPage($wikipage);
             S::assert_xsrf_token();
 
-            if ($changedLinks = wiki_rename_page($wikipage, $wikipage2)) {
-                $s = 'La page <em>'.$wikipage.'</em> a été déplacée en <em>'.$wikipage2.'</em>.';
-                if (is_numeric($changedLinks)) {
-                    $s .= $changedLinks.' lien'.(($changedLinks>1)?'s ont été modifiés.':' a été modifié.');
+            if ($action == 'delete') {
+                if ($wp->delete()) {
+                    $page->trigSuccess("La page ".$wikipage." a été supprimée.");
+                } else {
+                    $page->trigError("Impossible de supprimer la page ".$wikipage.".");
+                }
+            } else if ($action == 'rename' && !empty($wikipage2) && $wikipage != $wikipage2) {
+                if ($changedLinks = $wp->rename($wikipage2)) {
+                    $s = 'La page <em>'.$wikipage.'</em> a été déplacée en <em>'.$wikipage2.'</em>.';
+                    if (is_numeric($changedLinks)) {
+                        $s .= $changedLinks.' lien'.(($changedLinks>1)?'s ont été modifiés.':' a été modifié.');
+                    }
+                    $page->trigSuccess($s);
+                } else {
+                    $page->trigError("Impossible de déplacer la page ".$wikipage);
                 }
-                $page->trigSuccess($s);
-            } else {
-                $page->trigError("Impossible de déplacer la page ".$wikipage);
             }
         }
 
-        $perms = wiki_perms_options();
+        $perms = PlWikiPage::permOptions();
 
         // list wiki pages and their perms
-        $wiki_pages = array();
-        $dir = wiki_work_dir();
-        if (is_dir($dir)) {
-            if ($dh = opendir($dir)) {
-                while (($file = readdir($dh)) !== false) if (substr($file,0,1) >= 'A' && substr($file,0,1) <= 'Z') {
-                    list($read,$edit) = wiki_get_perms($file);
-                    $wiki_pages[$file] = array('read' => $perms[$read], 'edit' => $perms[$edit]);
-                    if (is_file($dir . '/cache_' . wiki_filename($file) . '.tpl')) {
-                        $wiki_pages[$file]['cached'] = true;
-                    }
-                }
-                closedir($dh);
-            }
-        }
+        $wiki_pages = PlWikiPage::listPages();
         ksort($wiki_pages);
         $wiki_tree = array();
         foreach ($wiki_pages as $file => $desc) {
index ca07e32..1459721 100644 (file)
@@ -132,7 +132,7 @@ class AuthModule extends PLModule
 
     function handler_groupex(&$page, $charset = 'utf8')
     {
-        require_once dirname(__FILE__).'/auth/auth.inc.php';
+        $this->load('auth.inc.php');
         $page->assign('referer', true);
 
         $gpex_pass = $_GET["pass"];
@@ -153,9 +153,9 @@ class AuthModule extends PLModule
         $uid = S::i('uid');
         if (!isset($_SESSION['suid'])) {
             $logger = (isset($_SESSION['log']) && $_SESSION['log']->uid == $uid)
-                            ? $_SESSION['log'] : new CoreLogger($uid);
+                            ? $_SESSION['log'] : new PlLogger($uid);
             global $platal;
-            $logger->log('connexion_auth_ext', $platal->path);
+            S::logger()->log('connexion_auth_ext', $platal->path);
         }
 
         /* on parcourt les entrees de groupes_auth */
@@ -174,7 +174,7 @@ class AuthModule extends PLModule
 
     function handler_admin_authgroupesx(&$page, $action = 'list', $id = null)
     {
-        $page->assign('xorg_title','Polytechnique.org - Administration - Auth groupes X');
+        $page->setTitle('Administration - Auth groupes X');
         $page->assign('title', 'Gestion de l\'authentification centralisée');
         $table_editor = new PLTableEditor('admin/auth-groupes-x','groupesx_auth','id');
         $table_editor->describe('name','nom',true);
index 6914e52..0839734 100644 (file)
@@ -43,17 +43,17 @@ class AXLetterModule extends PLModule
                 return $this->handler_index($page, 'out');
             }
         }
-        require_once dirname(__FILE__) . '/axletter/axletter.inc.php';
+        $this->load('axletter.inc.php');
         $page->changeTpl('axletter/unsubscribe.tpl');
         $page->assign('success', AXLetter::unsubscribe($hash, true));
     }
 
     function handler_index(&$page, $action = null)
     {
-        require_once dirname(__FILE__) . '/axletter/axletter.inc.php';
+        $this->load('axletter.inc.php');
 
         $page->changeTpl('axletter/index.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Envois de l\'AX');
+        $page->setTitle('Envois de l\'AX');
 
         switch ($action) {
           case 'in':  AXLetter::subscribe(); break;
@@ -73,7 +73,7 @@ class AXLetterModule extends PLModule
 
     function handler_submit(&$page, $action = null)
     {
-        require_once dirname(__FILE__) . '/axletter/axletter.inc.php';
+        $this->load('axletter.inc.php');
         if (!AXLetter::hasPerms()) {
             return PL_FORBIDDEN;
         }
@@ -149,7 +149,7 @@ class AXLetterModule extends PLModule
 
             switch (@Post::v('valid')) {
               case 'Aperçu':
-                require_once dirname(__FILE__) . '/axletter/axletter.inc.php';
+                $this->load('axletter.inc.php');
                 $al = new AXLetter(array($id, $short_name, $subject, $title, $body, $signature,
                                          $promo_min, $promo_max, $echeance, 0, 'new'));
                 $al->toHtml($page, S::v('prenom'), S::v('nom'), S::v('femme'));
@@ -225,7 +225,7 @@ class AXLetterModule extends PLModule
 
     function handler_cancel(&$page, $force = null)
     {
-        require_once dirname(__FILE__) . '/axletter/axletter.inc.php';
+        $this->load('axletter.inc.php');
         if (!AXLetter::hasPerms() || !S::has_xsrf_token()) {
             return PL_FORBIDDEN;
         }
@@ -245,7 +245,7 @@ class AXLetterModule extends PLModule
 
     function handler_valid(&$page, $force = null)
     {
-        require_once dirname(__FILE__) . '/axletter/axletter.inc.php';
+        $this->load('axletter.inc.php');
         if (!AXLetter::hasPerms() || !S::has_xsrf_token()) {
             return PL_FORBIDDEN;
         }
@@ -265,7 +265,7 @@ class AXLetterModule extends PLModule
 
     function handler_show(&$page, $nid = 'last')
     {
-        require_once dirname(__FILE__) . '/axletter/axletter.inc.php';
+        $this->load('axletter.inc.php');
         $page->changeTpl('axletter/show.tpl');
 
         $nl  = new AXLetter($nid);
@@ -283,7 +283,7 @@ class AXLetterModule extends PLModule
 
     function handler_admin(&$page, $action = null, $uid = null)
     {
-        require_once dirname(__FILE__) . '/axletter/axletter.inc.php';
+        $this->load('axletter.inc.php');
         if (Post::has('action')) {
             $action = Post::v('action');
             $uid    = Post::v('uid');
index 65aae6c..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')) {
@@ -56,7 +49,7 @@ class CarnetModule extends PLModule
     function handler_index(&$page)
     {
         $page->changeTpl('carnet/index.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Mon carnet');
+        $page->setTitle('Mon carnet');
         $this->_add_rss_link($page);
     }
 
@@ -65,8 +58,8 @@ class CarnetModule extends PLModule
         $page->changeTpl('carnet/panel.tpl');
 
         if (Get::has('read')) {
-            $_SESSION['watch_last'] = Get::v('read');
-            update_NbNotifs();
+            S::set('watch_last', Get::v('read'));
+            Platal::session()->updateNbNotifs();
             pl_redirect('carnet/panel');
         }
 
@@ -195,14 +188,14 @@ class CarnetModule extends PLModule
     }
 
     function searchErrorHandler($explain) {
-        global $page;
+        $page =& Platal::page();
         $page->trigError($explain);
         $this->handler_contacts($page);
     }
 
     function handler_contacts(&$page, $action = null, $subaction = null, $ssaction = null)
     {
-        $page->assign('xorg_title','Polytechnique.org - Mes contacts');
+        $page->setTitle('Mes contacts');
         $this->_add_rss_link($page);
 
         $uid  = S::v('uid');
@@ -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 {
@@ -278,10 +271,10 @@ class CarnetModule extends PLModule
 
     function handler_pdf(&$page, $arg0 = null, $arg1 = null)
     {
-        require_once dirname(__FILE__).'/carnet/contacts.pdf.inc.php';
+        $this->load('contacts.pdf.inc.php');
         require_once 'user.func.inc.php';
 
-        session_write_close();
+        Platal::session()->close();
 
         $sql = "SELECT  a.alias
                   FROM  aliases       AS a
@@ -313,12 +306,9 @@ class CarnetModule extends PLModule
 
     function handler_rss(&$page, $user = null, $hash = null)
     {
-        require_once 'rss.inc.php';
-        require_once 'notifs.inc.php';
-
-        $uid    = init_rss('carnet/rss.tpl', $user, $hash);
-        $notifs = new Notifs($uid, false);
-        $page->assign('notifs', $notifs);
+        $this->load('feed.inc.php');
+        $feed = new CarnetFeed();
+        return $feed->run($page, $user, $hash);
     }
 
     function handler_ical(&$page, $alias = null, $hash = null)
@@ -329,7 +319,6 @@ class CarnetModule extends PLModule
             if (!$uid) {
                 $uid = S::i('uid');
             } else if ($uid != S::i('uid')) {
-                require_once 'xorg.misc.inc.php';
                 send_warning_email("Récupération d\'un autre utilisateur ($uid)");
             }
         } else if (!$uid) {
@@ -375,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();
     }
 }
 
diff --git a/modules/carnet/feed.inc.php b/modules/carnet/feed.inc.php
new file mode 100644 (file)
index 0000000..fad227c
--- /dev/null
@@ -0,0 +1,94 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2008 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************/
+
+require_once 'notifs.inc.php';
+
+class CarnetFeedIterator implements PlIterator
+{
+    private $notifs;
+    private $it;
+
+    public function __construct(Notifs& $notifs)
+    {
+        $this->notifs =& $notifs;
+        $this->it = PlIteratorUtils::fromArray($notifs->_data, 3);
+    }
+
+    public function next()
+    {
+        $data = $this->it->next();
+        if (is_null($data)) {
+            return null;
+        }
+        $cid  = $data['keys'][0];
+        $x    = $data['value'];
+
+        global $globals;
+        @require_once 'Date.php';
+        @$date = new Date($x['date']);
+        @$date = $date->format('%e %B %Y');
+        $author = $x['prenom'] . ' ' . $x['nom'] . ' (X' . $x['promo'] . ')';
+        return array_merge($x, 
+                    array('author' => $author,
+                          'publication' => $x['known'],
+                          'id' => 'carnet' . $x['known'] . $cid . $x['bestalias'],
+                          'link' => $globals->baseurl . '/profile/private/'
+                                    . $x['bestalias'],
+                          'title' => '[' . $this->notifs->_cats[$cid]['short'] . '] '
+                                     . $author . ' - le ' . $date));
+    }
+
+    public function total()
+    {
+        return $this->it->total();
+    }
+
+    public function first()
+    {
+        return $this->it->first();
+    }
+
+    public function last()
+    {
+        return $this->it->last();
+    }
+}
+
+class CarnetFeed extends PlFeed
+{
+    public function __construct()
+    {
+        global $globals;
+        parent::__construct($globals->core->sitename . ' :: Carnet',
+                            $globals->baseurl . '/carnet/panel',
+                            'Ton carnet polytechnicien',
+                            $globals->baseurl . '/images/logo.png',
+                            'carnet/rss.tpl');
+    }
+
+    protected function fetch($user)
+    {
+        return new CarnetFeedIterator(new Notifs($user, false));
+    }
+}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
diff --git a/modules/core.php b/modules/core.php
deleted file mode 100644 (file)
index 67da706..0000000
+++ /dev/null
@@ -1,181 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-class CoreModule extends PLModule
-{
-    function handlers()
-    {
-        return array(
-            '403'         => $this->make_hook('403', AUTH_PUBLIC),
-            '404'         => $this->make_hook('404', AUTH_PUBLIC),
-            'login'       => $this->make_hook('login',      AUTH_COOKIE),
-            'send_bug'    => $this->make_hook('bug', AUTH_COOKIE),
-            'purge_cache' => $this->make_hook('purge_cache', AUTH_COOKIE, 'admin'),
-            'kill_sessions' => $this->make_hook('kill_sessions', AUTH_COOKIE, 'admin'),
-            'get_rights'  => $this->make_hook('get_rights', AUTH_MDP, 'admin'),
-
-            'wiki_help'    => $this->make_hook('wiki_help', AUTH_PUBLIC),
-            'wiki_preview' => $this->make_hook('wiki_preview', AUTH_COOKIE, 'user', NO_AUTH),
-
-            'valid.html'  => $this->make_hook('valid', AUTH_PUBLIC),
-            'favicon.ico' => $this->make_hook('favicon', AUTH_PUBLIC),
-            'robots.txt'  => $this->make_hook('robotstxt', AUTH_PUBLIC, 'user', NO_HTTPS),
-        );
-    }
-
-    function handler_valid(&$page)
-    {
-        readfile($page->compile_dir.'/valid.html');
-        exit;
-    }
-
-    function handler_403(&$page)
-    {
-        global $globals;
-        header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
-        $page->changeTpl('core/403.tpl');
-    }
-
-    function handler_404(&$page)
-    {
-        global $globals, $platal;
-        header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
-        $page->changeTpl('core/404.tpl');
-        $page->assign('near', $platal->near_hook());
-    }
-
-    function handler_login(&$page)
-    {
-        $allkeys = func_get_args();
-        unset($allkeys[0]);
-        $url = join('/',$allkeys);
-        pl_redirect($url);
-    }
-
-    function handler_favicon(&$page)
-    {
-        $data = file_get_contents(dirname(__FILE__).'/../htdocs/images/favicon.ico');
-        header('Content-Type: image/x-icon');
-        echo $data;
-        exit;
-    }
-
-    function handler_robotstxt(&$page)
-    {
-        global $globals;
-        if (!$globals->core->restricted_platal) {
-            return PL_NOT_FOUND;
-        }
-
-        header('Content-Type: text/plain');
-        echo "User-agent: *\n";
-        echo "Disallow: /\n";
-        exit;
-    }
-
-    function handler_purge_cache(&$page)
-    {
-        require_once 'wiki.inc.php';
-        S::assert_xsrf_token();
-
-        $page->clear_compiled_tpl();
-        wiki_clear_all_cache();
-
-        http_redirect(empty($_SERVER['HTTP_REFERER']) ? './' : $_SERVER['HTTP_REFERER']);
-    }
-
-    function handler_kill_sessions(&$page)
-    {
-        kill_sessions();
-    }
-
-    function handler_get_rights(&$page, $level)
-    {
-        if (S::has('suid')) {
-            $page->kill('Déjà en SUID');
-        }
-
-        if (isset($_SESSION['log'])) {
-            $_SESSION['log']->log("suid_start", "login by ".S::v('forlife'));
-        }
-        $_SESSION['suid'] = $_SESSION;
-        $_SESSION['perms'] =& XorgSession::make_perms($level);
-
-        pl_redirect('/');
-    }
-
-    function handler_bug(&$page)
-    {
-        global $globals;
-
-        if (empty($_SERVER['HTTP_REFERER'])) {
-            // We don't have a valid referer, we need to use the url
-            list($currentPage, $location) = explode('//', $_SERVER['REQUEST_URI'], 2);
-
-            $location = 'http'.(empty($_SERVER['HTTPS']) ? '' : 's').'://'.$_SERVER['SERVER_NAME'].'/'.$location;
-        } else {
-            $location = $_SERVER['HTTP_REFERER'];
-        }
-
-        $page->changeTpl('core/bug.tpl', SIMPLE);
-        $page->assign('location', $location);
-        $page->addJsLink('close_on_esc.js');
-
-        if (Env::has('send') && trim(Env::v('detailed_desc'))) {
-            S::assert_xsrf_token();
-
-            $body = wordwrap(Env::v('detailed_desc'), 78) . "\n\n"
-                  . "----------------------------\n"
-                  . "Page        : " . Env::v('page') . "\n\n"
-                  . "Utilisateur : " . S::v('forlife') . "\n"
-                  . "Navigateur  : " . $_SERVER['HTTP_USER_AGENT'] . "\n"
-                  . "Skin        : " . S::v('skin') . "\n";
-            $page->assign('bug_sent',1);
-            $mymail = new PlMailer();
-            $mymail->setFrom('"'.S::v('prenom').' '.S::v('nom').'" <'.S::v('bestalias').'@' . $globals->mail->domain . '>');
-            $mymail->addTo('support+platal@' . $globals->mail->domain);
-            $mymail->addCc('"'.S::v('prenom').' '.S::v('nom').'" <'.S::v('bestalias').'@' . $globals->mail->domain . '>');
-            $mymail->setSubject('Plat/al '.Env::v('task_type').' : '.Env::v('item_summary'));
-            $mymail->setTxtBody($body);
-            $mymail->send();
-        } elseif (Env::has('send')) {
-            $page->trigError("Merci de remplir une explication du problème rencontré");
-        }
-    }
-
-    function handler_wiki_help(&$page, $action = 'title')
-    {
-        $page->changeTpl('core/wiki.help.tpl', SIMPLE);
-        $page->assign('wiki_help', MiniWiki::help($action == 'title'));
-    }
-
-    /// Shared handler for wiki syntax result preview
-    function handler_wiki_preview(&$page, $action = 'title')
-    {
-        header('Content-Type: text/html; charset=utf-8');
-        $text = Get::v('text');
-        echo MiniWiki::wikiToHtml($text, $action == 'title');
-        exit;
-    }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
index 3576030..f499509 100644 (file)
@@ -47,7 +47,7 @@ class EmailModule extends PLModule
         require_once 'emails.inc.php';
 
         $page->changeTpl('emails/index.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Mes emails');
+        $page->setTitle('Mes emails');
 
         $uid = S::v('uid');
 
@@ -98,7 +98,7 @@ class EmailModule extends PLModule
         global $globals;
 
         $page->changeTpl('emails/alias.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Alias melix.net');
+        $page->setTitle('Alias melix.net');
 
         $uid     = S::v('uid');
         $forlife = S::v('forlife');
@@ -277,8 +277,8 @@ class EmailModule extends PLModule
     function handler_antispam(&$page, $statut_filtre = null)
     {
         require_once 'emails.inc.php';
-        require_once('wiki.inc.php');
-        wiki_require_page('Xorg.Antispam');
+        $wp = new PlWikiPage('Xorg.Antispam');
+        $wp->buildCache();
 
         $page->changeTpl('emails/antispam.tpl');
 
@@ -291,8 +291,8 @@ class EmailModule extends PLModule
 
     function handler_submit(&$page)
     {
-        require_once('wiki.inc.php');
-        wiki_require_page('Xorg.Mails');
+        $wp = new PlWikiPage('Xorg.Mails');
+        $wp->buildCache();
         $page->changeTpl('emails/submit_spam.tpl');
 
         if (Post::has('send_email')) {
@@ -328,7 +328,7 @@ class EmailModule extends PLModule
         $page->changeTpl('emails/send.tpl');
         $page->addJsLink('ajax.js');
 
-        $page->assign('xorg_title','Polytechnique.org - Envoyer un email');
+        $page->setTitle('Envoyer un email');
 
         // action si on recoit un formulaire
         if (Post::has('save')) {
@@ -499,8 +499,8 @@ class EmailModule extends PLModule
     function handler_broken(&$page, $warn = null, $email = null)
     {
         require_once 'emails.inc.php';
-        require_once('wiki.inc.php');
-        wiki_require_page('Xorg.PatteCassée');
+        $wp = new PlWikiPage('Xorg.PatteCassée');
+        $wp->buildCache();
 
         global $globals;
 
index 12ac485..36c501e 100644 (file)
@@ -81,7 +81,7 @@ class EventsModule extends PLModule
         return $res->fetchOneAssoc();
     }
 
-    private function upload_image(PlatalPage &$page, PlUpload &$upload)
+    private function upload_image(PlPage &$page, PlUpload &$upload)
     {
         if (@!$_FILES['image']['tmp_name'] && !Env::v('image_url')) {
             return true;
@@ -144,7 +144,7 @@ class EventsModule extends PLModule
 
         // cache les evenements lus et raffiche les evenements a relire
         if ($action == 'read' && $eid) {
-            XDB::execute('DELETE evenements_vus.*
+            XDB::execute('DELETE ev.*
                             FROM evenements_vus AS ev
                       INNER JOIN evenements AS e ON e.id = ev.evt_id
                            WHERE peremption < NOW()');
@@ -233,22 +233,9 @@ class EventsModule extends PLModule
 
     function handler_rss(&$page, $user = null, $hash = null)
     {
-        require_once 'rss.inc.php';
-
-        $uid = init_rss('events/rss.tpl', $user, $hash);
-
-        $rss = XDB::iterator(
-                'SELECT  e.id, e.titre, e.texte, e.creation_date, e.post_id, p.attachmime IS NOT NULL AS photo,
-                         IF(u2.nom_usage = "", u2.nom, u2.nom_usage) AS nom, u2.prenom, u2.promo,
-                         FIND_IN_SET(\'wiki\', e.flags) AS wiki
-                   FROM  auth_user_md5   AS u
-             INNER JOIN  evenements      AS e ON ( (e.promo_min = 0 || e.promo_min <= u.promo)
-                                                 AND (e.promo_max = 0 || e.promo_max >= u.promo) )
-              LEFT JOIN  evenements_photo AS p ON (p.eid = e.id)
-             INNER JOIN  auth_user_md5   AS u2 ON (u2.user_id = e.user_id)
-                  WHERE  u.user_id = {?} AND FIND_IN_SET("valide", e.flags)
-                                         AND peremption >= NOW()', $uid);
-        $page->assign('rss', $rss);
+        $this->load('feed.inc.php');
+        $feed = new EventFeed();
+        return $feed->run($page, $user, $hash);
     }
 
     function handler_preview(&$page)
@@ -272,8 +259,8 @@ class EventsModule extends PLModule
         $page->changeTpl('events/submit.tpl');
         $page->addJsLink('ajax.js');
 
-        require_once('wiki.inc.php');
-        wiki_require_page('Xorg.Annonce');
+        $wp = new PlWikiPage('Xorg.Annonce');
+        $wp->buildCache();
 
         $titre      = Post::v('titre');
         $texte      = Post::v('texte');
@@ -329,7 +316,7 @@ class EventsModule extends PLModule
 
     function handler_admin_tips(&$page, $action = 'list', $id = null)
     {
-        $page->assign('xorg_title', 'Polytechnique.org - Administration - Astuces');
+        $page->setTitle('Administration - Astuces');
         $page->assign('title', 'Gestion des Astuces');
         $table_editor = new PLTableEditor('admin/tips', 'tips', 'id');
         $table_editor->describe('peremption', 'date de péremption', true);
@@ -350,7 +337,7 @@ class EventsModule extends PLModule
     {
         $page->changeTpl('events/admin.tpl');
         $page->addJsLink('ajax.js');
-        $page->assign('xorg_title','Polytechnique.org - Administration - Evenements');
+        $page->setTitle('Administration - Evenements');
         $page->register_modifier('hde', 'html_entity_decode');
 
         $arch = $action == 'archives';
@@ -382,7 +369,7 @@ class EventsModule extends PLModule
                 $action = 'edit';
             } else {
                 $res = XDB::query('SELECT flags FROM evenements WHERE id = {?}', $eid);
-                $flags = new FlagSet($res->fetchOneCell());
+                $flags = new PlFlagSet($res->fetchOneCell());
                 $flags->addFlag('wiki');
                 if (Post::v('important')) {
                     $flags->addFlag('important');
similarity index 53%
rename from classes/plprofiler.php
rename to modules/events/feed.inc.php
index 1734ff5..ac3ee0f 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-class PlProfiler
+class EventFeed extends PlFeed
 {
-    static public function start($name, $info = "action")
+    public function __construct()
     {
         global $globals;
-        if (!($globals->debug & DEBUG_BT)) {
-            return false;
-        }
-        if (!isset(PlBacktrace::$bt[$name])) {
-            new PlBacktrace($name);
-        }
-        PlBacktrace::$bt[$name]->start($info);
-        return true;
+        parent::__construct($globals->core->sitename . ' :: News',
+                            $globals->baseurl,
+                            'Informations et Activités polytechniciennes',
+                            $globals->baseurl . '/images/logo.png',
+                            'events/rss.tpl');
     }
 
-    static public function step($name, $info = "action")
-    {
-        PlProfiler::stop($name);
-        PlProfiler::start($name, $info);
-    }
-
-    static public function stop($name)
+    protected function fetch($user)
     {
         global $globals;
-        if (!($globals->debug & DEBUG_BT)) {
-            return false;
-        }
-        PlBacktrace::$bt[$name]->stop();
-        return true;
+        return XDB::iterator(
+                'SELECT  e.id, e.titre AS title, e.texte, e.creation_date AS publication, e.post_id, p.attachmime IS NOT NULL AS photo,
+                         CONCAT(u2.prenom, " ", IF(u2.nom_usage = "", u2.nom, u2.nom_usage), " (X", u2.promo, ")") AS author,
+                         FIND_IN_SET(\'wiki\', e.flags) AS wiki,
+                         CONCAT({?}, "/events#newsid", e.id) AS link
+                   FROM  auth_user_md5   AS u
+             INNER JOIN  evenements      AS e ON ( (e.promo_min = 0 || e.promo_min <= u.promo)
+                                                 AND (e.promo_max = 0 || e.promo_max >= u.promo) )
+              LEFT JOIN  evenements_photo AS p ON (p.eid = e.id)
+             INNER JOIN  auth_user_md5   AS u2 ON (u2.user_id = e.user_id)
+                  WHERE  u.user_id = {?} AND FIND_IN_SET("valide", e.flags)
+                                         AND peremption >= NOW()', $globals->baseurl, $user);
     }
 }
 
index c9538c9..e67966d 100644 (file)
@@ -24,42 +24,16 @@ 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');
-        $page->assign('xorg_title','Polytechnique.org - Forums & PA');
+        $page->setTitle('Forums & PA');
 
         $get = Array();
         if (Post::has('updateall')) {
@@ -97,7 +71,7 @@ class ForumsModule extends PLModule
 
     function handler_forums_bans(&$page, $action = 'list', $id = null)
     {
-        $page->assign('xorg_title','Polytechnique.org - Administration - Bannissements des forums');
+        $page->setTitle('Administration - Bannissements des forums');
         $page->assign('title', 'Gestion des mises au ban');
         $table_editor = new PLTableEditor('admin/forums','forums.innd','id_innd');
         $table_editor->add_sort_field('priority', true, true);
@@ -113,7 +87,7 @@ class ForumsModule extends PLModule
     static function run_banana(&$page, $params = null)
     {
         $page->changeTpl('banana/index.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Forums & PA');
+        $page->setTitle('Forums & PA');
 
         require_once 'banana/forum.inc.php';
         run_banana($page, 'ForumsBanana', $params);
index 613c2df..a778b3f 100644 (file)
 // iGoogle gadgets helpers.
 function init_igoogle_xml($template)
 {
-    global $page;
-    $page->changeTpl($template, NO_SKIN);
+    Platal::page()->changeTpl($template, NO_SKIN);
 
     header('Content-Type: application/xml; charset=utf-8');
 }
 
 function init_igoogle_html($template, $auth = AUTH_PUBLIC)
 {
-    global $page;
+    $page =& Platal::page();
     $page->changeTpl('gadgets/ig-skin.tpl', NO_SKIN);
     $page->register_modifier('escape_html', 'escape_html');
     $page->default_modifiers = Array('@escape_html');
index 895c5f4..0a83602 100644 (file)
@@ -42,7 +42,7 @@ class GeolocModule extends PLModule
     function handler_admin(&$page, $action = false) {
         $page->changeTpl('geoloc/admin.tpl');
         require_once("geoloc.inc.php");
-        $page->assign('xorg_title','Polytechnique.org - Administration - Geolocalisation');
+        $page->setTitle('Administration - Geolocalisation');
 
         $nb_synchro = 0;
 
@@ -100,7 +100,7 @@ class GeolocModule extends PLModule
         $noCoordinates = $countNoCoordinates->fetchOneCell();
 
         if (isset($refresh) && $missing) {
-            $page->assign("xorg_extra_header", "<meta http-equiv='Refresh' content='3'/>");
+            $page->assign("pl_extra_header", "<meta http-equiv='Refresh' content='3'/>");
         }
         $page->assign("nb_cities_not_on_map", $missing);
         $page->assign("no_smallest", $noSmallest);
index fcfb153..553aeaf 100644 (file)
@@ -42,7 +42,7 @@ class GoogleAppsModule extends PLModule
         require_once("googleapps.inc.php");
         $page->changeTpl('googleapps/index.tpl');
         $page->addJsLink('motdepasse.js');
-        $page->assign('xorg_title', 'Polytechnique.org - Compte Google Apps');
+        $page->setTitle('Compte Google Apps');
 
         $account = new GoogleAppsAccount(S::v('uid'), S::v('forlife'));
 
@@ -117,7 +117,7 @@ class GoogleAppsModule extends PLModule
     function handler_admin(&$page, $action = null) {
         require_once("googleapps.inc.php");
         $page->changeTpl('googleapps/admin.tpl');
-        $page->assign('xorg_title', 'Polytechnique.org - Administration Google Apps');
+        $page->setTitle('Administration Google Apps');
         $page->assign('googleapps_admin', GoogleAppsAccount::is_administrator(S::v('uid')));
 
         if ($action == 'ack') {
@@ -163,7 +163,7 @@ class GoogleAppsModule extends PLModule
     function handler_admin_job(&$page, $job = null) {
         require_once("googleapps.inc.php");
         $page->changeTpl('googleapps/admin.job.tpl');
-        $page->assign('xorg_title', 'Polytechnique.org - Administration Google Apps');
+        $page->setTitle('Administration Google Apps');
         $page->assign('googleapps_admin', GoogleAppsAccount::is_administrator(S::v('uid')));
 
         if ($job) {
@@ -183,7 +183,7 @@ class GoogleAppsModule extends PLModule
         require_once("emails.inc.php");
         require_once("googleapps.inc.php");
         $page->changeTpl('googleapps/admin.user.tpl');
-        $page->assign('xorg_title', 'Polytechnique.org - Administration Google Apps');
+        $page->setTitle('Administration Google Apps');
         $page->assign('googleapps_admin', GoogleAppsAccount::is_administrator(S::v('uid')));
 
         if (!$user && Post::has('login')) {
index 0333db8..36b247b 100644 (file)
@@ -46,17 +46,11 @@ 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;
 
-        require_once dirname(__FILE__).'/lists/lists.inc.php';
+        $this->load('lists.inc.php');
 
         $this->client = new MMList(S::v('uid'), S::v('password'));
         return $globals->mail->domain;
@@ -94,7 +88,7 @@ class ListsModule extends PLModule
 
         $page->changeTpl('lists/index.tpl');
         $page->addJsLink('ajax.js');
-        $page->assign('xorg_title','Polytechnique.org - Listes de diffusion');
+        $page->setTitle('Listes de diffusion');
 
 
         if (Get::has('del')) {
@@ -884,7 +878,7 @@ class ListsModule extends PLModule
 
     function handler_admin_all(&$page) {
         $page->changeTpl('lists/admin_all.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Administration - Mailing lists');
+        $page->setTitle('Administration - Mailing lists');
 
         $client = new MMList(S::v('uid'), S::v('password'));
         $listes = $client->get_all_lists();
index b40c90a..9507cf5 100644 (file)
@@ -40,7 +40,7 @@ class MarketingModule extends PLModule
     {
         $page->changeTpl('marketing/index.tpl');
 
-        $page->assign('xorg_title','Polytechnique.org - Marketing');
+        $page->setTitle('Marketing');
 
         // Quelques statistiques
 
@@ -198,8 +198,8 @@ class MarketingModule extends PLModule
         $page->assign('user', $user);
 
         $email = null;
+        require_once 'emails.inc.php';
         if (Post::has('mail')) {
-            require_once 'emails.inc.php';
             $email = valide_email(Post::v('mail'));
         }
         if (Post::has('valide') && isvalid_email_redirection($email)) {
@@ -268,10 +268,9 @@ class MarketingModule extends PLModule
 
             if (Post::has('valide')) {
                 S::assert_xsrf_token();
-
-                require_once('xorg.misc.inc.php');
                 $email = trim(Post::v('mail'));
 
+                require_once 'emails.inc.php';
                 if (!isvalid_email_redirection($email)) {
                     $page->trigError("Email invalide !");
                 } else {
index 5a41e9a..9dfe318 100644 (file)
@@ -38,7 +38,7 @@ class NewsletterModule extends PLModule
         require_once 'newsletter.inc.php';
 
         $page->changeTpl('newsletter/index.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Lettres mensuelles');
+        $page->setTitle('Lettres mensuelles');
 
         switch ($action) {
           case 'out': Newsletter::unsubscribe(); break;
@@ -76,8 +76,8 @@ class NewsletterModule extends PLModule
         $page->changeTpl('newsletter/submit.tpl');
 
         require_once 'newsletter.inc.php';
-        require_once 'wiki.inc.php';
-        wiki_require_page('Xorg.LettreMensuelle');
+        $wp = new PlWikiPage('Xorg.LettreMensuelle');
+        $wp->buildCache();
 
         if (Post::has('see') || (Post::has('valid') && (!trim(Post::v('title')) || !trim(Post::v('body'))))) {
             if (!Post::has('see')) {
@@ -97,7 +97,7 @@ class NewsletterModule extends PLModule
 
     function handler_admin_nl(&$page, $new = false) {
         $page->changeTpl('newsletter/admin.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Administration - Newsletter : liste');
+        $page->setTitle('Administration - Newsletter : liste');
         require_once("newsletter.inc.php");
 
         if($new) {
@@ -111,7 +111,7 @@ class NewsletterModule extends PLModule
     function handler_admin_nl_edit(&$page, $nid = 'last', $aid = null, $action = 'edit') {
         $page->changeTpl('newsletter/edit.tpl');
         $page->addCssLink('nl.css');
-        $page->assign('xorg_title','Polytechnique.org - Administration - Newsletter : Edition');
+        $page->setTitle('Administration - Newsletter : Edition');
         require_once("newsletter.inc.php");
 
         $nl  = new NewsLetter($nid);
@@ -157,7 +157,7 @@ class NewsletterModule extends PLModule
     }
 
     function handler_admin_nl_cat(&$page, $action = 'list', $id = null) {
-        $page->assign('xorg_title','Polytechnique.org - Administration - Newsletter : Catégories');
+        $page->setTitle('Administration - Newsletter : Catégories');
         $page->assign('title', 'Gestion des catégories de la newsletter');
         $table_editor = new PLTableEditor('admin/newsletter/categories','newsletter_cat','cid');
         $table_editor->describe('titre','intitulé',true);
index 9de57d1..7d2493c 100644 (file)
@@ -34,7 +34,7 @@ function cb_erreur($text) {
 /* sort en affichant une erreur */
 function paypal_erreur($text, $send=true)
 {
-    global $page, $erreur, $globals;
+    global $erreur, $globals;
     if ($erreur) return;
     $erreur = $text;
     if (!$send) return;
@@ -46,7 +46,7 @@ function paypal_erreur($text, $send=true)
     $mymail->setTxtBody("\n\n".var_export($_REQUEST,true));
     $mymail->send();
 
-    $page->trigError($text);
+    Platal::page()->trigError($text);
 }
 
 /* http://fr.wikipedia.org/wiki/Formule_de_Luhn */
@@ -105,7 +105,7 @@ class PaymentModule extends PLModule
         global $globals;
 
         require_once 'profil.func.inc.php' ;
-        require_once dirname(__FILE__).'/payment/money.inc.php' ;
+        $this->load('money.inc.php');
 
         if (!empty($GLOBALS['IS_XNET_SITE'])) {
             if (!$globals->asso('id')) {
@@ -120,7 +120,7 @@ class PaymentModule extends PLModule
             }
         }
         $page->changeTpl('payment/index.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Télépaiements');
+        $page->setTitle('Télépaiements');
 
         // initialisation
         $op   = Env::v('op', 'select');
@@ -467,7 +467,7 @@ class PaymentModule extends PLModule
     }
 
     function handler_admin(&$page, $action = 'list', $id = null) {
-        $page->assign('xorg_title','Polytechnique.org - Administration - Paiements');
+        $page->setTitle('Administration - Paiements');
         $page->assign('title', 'Gestion des télépaiements');
         $table_editor = new PLTableEditor('admin/payments','paiement.paiements','id');
         $table_editor->add_join_table('paiement.transactions','ref',true);
index 65cdf6a..c38d1c3 100644 (file)
@@ -49,7 +49,7 @@ class Payment
 
         $this->montant_min = (float)$this->montant_min;
         $this->montant_max = (float)$this->montant_max;
-        $this->flags       = new Flagset($flags);
+        $this->flags       = new PlFlagSet($flags);
     }
 
     // }}}
index 407fa18..c79935c 100644 (file)
@@ -55,7 +55,6 @@ class CyberPayment
         $name = $req->fetchOneCell();
 
         // on constuit la reference de la transaction
-        require_once 'xorg.misc.inc.php';
         $prefix = ($pay->flags->hasflag('unique')) ? str_pad("",15,"0") : rand_url_id();
         $fullref = substr("$prefix-xorg-{$pay->id}",-15);
 
index 48e740f..e1b4d0f 100644 (file)
@@ -89,7 +89,6 @@ class PayPal
         $this->infos['client'] = array_map('replace_accent', array_merge($info_client, $res->fetchOneAssoc()));
 
         // on constuit la reference de la transaction
-        require_once 'xorg.misc.inc.php';
         $prefix = ($pay->flags->hasflag('unique')) ? str_pad("",15,"0") : rand_url_id();
         $fullref = substr("$prefix-xorg-{$pay->id}",-15);
 
index 14f5bc0..4ce3c3c 100644 (file)
@@ -122,7 +122,7 @@ class PlatalModule extends PLModule
     function handler_prefs(&$page)
     {
         $page->changeTpl('platal/preferences.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Mes préférences');
+        $page->setTitle('Mes préférences');
 
         if (Post::has('mail_fmt')) {
             $fmt = Post::v('mail_fmt');
@@ -143,7 +143,7 @@ class PlatalModule extends PLModule
     {
         $page->changeTpl('platal/webredirect.tpl');
 
-        $page->assign('xorg_title','Polytechnique.org - Redirection de page WEB');
+        $page->setTitle('Redirection de page WEB');
 
         $log =& S::v('log');
         $url = Env::v('url');
@@ -152,14 +152,14 @@ class PlatalModule extends PLModule
             XDB::execute('UPDATE auth_user_quick
                                        SET redirecturl = {?} WHERE user_id = {?}',
                                    $url, S::v('uid'));
-            $log->log('carva_add', 'http://'.Env::v('url'));
+            S::logger()->log('carva_add', 'http://'.Env::v('url'));
             $page->trigSuccess("Redirection activée vers <a href='http://$url'>$url</a>");
         } elseif (Env::v('submit') == "Supprimer") {
             XDB::execute("UPDATE auth_user_quick
                                        SET redirecturl = ''
                                      WHERE user_id = {?}",
                                    S::v('uid'));
-            $log->log("carva_del", $url);
+            S::logger()->log("carva_del", $url);
             Post::kill('url');
             $page->trigSuccess('Redirection supprimée');
         }
@@ -209,7 +209,7 @@ class PlatalModule extends PLModule
             }
 
             $log =& S::v('log');
-            $log->log('passwd', '');
+            S::logger()->log('passwd', '');
 
             if (Cookie::v('ORGaccess')) {
                 setcookie('ORGaccess', hash_encrypt($password), (time()+25920000), '/', '' ,0);
@@ -221,17 +221,18 @@ class PlatalModule extends PLModule
 
         $page->changeTpl('platal/motdepasse.tpl');
         $page->addJsLink('motdepasse.js');
-        $page->assign('xorg_title','Polytechnique.org - Mon mot de passe');
+        $page->setTitle('Mon mot de passe');
     }
 
     function handler_smtppass(&$page)
     {
         $page->changeTpl('platal/acces_smtp.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Acces SMTP/NNTP');
+        $page->setTitle('Acces SMTP/NNTP');
 
-        require_once 'wiki.inc.php';
-        wiki_require_page('Xorg.SMTPSécurisé');
-        wiki_require_page('Xorg.NNTPSécurisé');
+        $wp = new PlWikiPage('Xorg.SMTPSécurisé');
+        $wp->buildCache();
+        $wp = new PlWikiPage('Xorg.NNTPSécurisé');
+        $wp->buildCache();
 
         $uid  = S::v('uid');
         $pass = Env::v('smtppass1');
@@ -243,12 +244,12 @@ class PlatalModule extends PLModule
             XDB::execute('UPDATE auth_user_md5 SET smtppass = {?}
                                      WHERE user_id = {?}', $pass, $uid);
             $page->trigSuccess('Mot de passe enregistré');
-            $log->log("passwd_ssl");
+            S::logger()->log("passwd_ssl");
         } elseif (Env::v('op') == "Supprimer") {
             XDB::execute('UPDATE auth_user_md5 SET smtppass = ""
                                      WHERE user_id = {?}', $uid);
             $page->trigSuccess('Compte SMTP et NNTP supprimé');
-            $log->log("passwd_del");
+            S::logger()->log("passwd_del");
         }
 
         $res = XDB::query("SELECT IF(smtppass != '', 'actif', '')
@@ -334,8 +335,8 @@ Adresse de secours : " . Post::v('email') : ""));
             $mymail->send();
 
             // on cree un objet logger et on log l'evenement
-            $logger = $_SESSION['log'] = new CoreLogger($uid);
-            $logger->log('recovery', $mails);
+            $logger = $_SESSION['log'] = new PlLogger($uid);
+            S::logger()->log('recovery', $mails);
         } else {
             $page->trigError('Les informations que tu as rentrées ne permettent pas de récupérer ton mot de passe.<br />'.
                         'Si tu as un homonyme, utilise prenom.nom.promo comme login');
@@ -373,8 +374,8 @@ Adresse de secours : " . Post::v('email') : ""));
                 }
             }
 
-            $logger = new CoreLogger($uid);
-            $logger->log("passwd","");
+            $logger = new PlLogger($uid);
+            S::logger()->log("passwd","");
             $page->changeTpl('platal/tmpPWD.success.tpl');
         } else {
             $page->changeTpl('platal/motdepasse.tpl');
@@ -387,14 +388,14 @@ Adresse de secours : " . Post::v('email') : ""));
         global $globals;
 
         $page->changeTpl('platal/skins.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Skins');
+        $page->setTitle('Skins');
 
         if (Env::has('newskin'))  {  // formulaire soumis, traitons les données envoyées
             XDB::execute('UPDATE auth_user_quick
                              SET skin={?} WHERE user_id={?}',
                          Env::i('newskin'), S::v('uid'));
             S::kill('skin');
-            set_skin();
+            Platal::session()->setSkin();
         }
 
         $res = XDB::query('SELECT id FROM skins WHERE skin_tpl={?}', S::v('skin'));
@@ -414,9 +415,8 @@ Adresse de secours : " . Post::v('email') : ""));
             $a4l  = S::v('forlife');
             $suid = S::v('suid');
             $log  = S::v('log');
-            $log->log("suid_stop", S::v('forlife') . " by " . $suid['forlife']);
-            $_SESSION = $suid;
-            S::kill('suid');
+            S::logger()->log("suid_stop", S::v('forlife') . " by " . $suid['forlife']);
+            Platal::session()->stopSUID();
             pl_redirect('admin/user/' . $a4l);
         }
 
@@ -424,7 +424,7 @@ Adresse de secours : " . Post::v('email') : ""));
             setcookie('ORGaccess', '', time() - 3600, '/', '', 0);
             Cookie::kill('ORGaccess');
             if (isset($_SESSION['log']))
-                $_SESSION['log']->log("cookie_off");
+                S::logger()->log("cookie_off");
         }
 
         if ($level == 'forgetuid' || $level == 'forgetall') {
@@ -436,10 +436,9 @@ Adresse de secours : " . Post::v('email') : ""));
 
         if (isset($_SESSION['log'])) {
             $ref = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
-            $_SESSION['log']->log('deconnexion',$ref);
+            S::logger()->log('deconnexion',$ref);
         }
-
-        XorgSession::destroy();
+        Platal::session()->destroy();
 
         if (Get::has('redirect')) {
             http_redirect(rawurldecode(Get::v('redirect')));
@@ -450,22 +449,14 @@ Adresse de secours : " . Post::v('email') : ""));
 
     function handler_review(&$page, $action = null, $mode = null) 
     {
-        require_once 'wiki.inc.php';
-        require_once dirname(__FILE__) . '/platal/review.inc.php';
-        $dir = wiki_work_dir();
+        $this->load('review.inc.php');
         $dom = 'Review';
         if (@$GLOBALS['IS_XNET_SITE']) {
             $dom .= 'Xnet';
         }
-        if (!is_dir($dir)) {
-            $page->kill("Impossible de trouver le wiki");
-        }
-        if (!file_exists($dir . '/' . $dom . '.Admin')) {
-            $page->kill("Impossible de trouver la page d'administration");
-        }
-        $conf = preg_grep('/^text=/', explode("\n", file_get_contents($dir . '/' . $dom . '.Admin')));
-        $conf = preg_split('/(text\=|\%0a)/', array_shift($conf), -1, PREG_SPLIT_NO_EMPTY);
-        $wiz = new PlWizard('Tour d\'horizon', 'core/plwizard.tpl', true);
+        $wp = new PlWikiPage($dom . '.Admin');
+        $conf = explode('%0a', $wp->getField('text'));
+        $wiz = new PlWizard('Tour d\'horizon', PlPage::getCoreTpl('plwizard.tpl'), true);
         foreach ($conf as $line) {
             $list = preg_split('/\s*[*|]\s*/', $line, -1, PREG_SPLIT_NO_EMPTY);
             $wiz->addPage('ReviewPage', $list[0], $list[1]);
index 96e6aab..2b48319 100644 (file)
@@ -27,13 +27,12 @@ class ReviewPage implements PlWizardPage
     public function template() { return 'platal/review.tpl'; }
     public function process() { }
 
-    public function prepare(PlatalPage &$page, $id)
+    public function prepare(PlPage &$page, $id)
     {
-        require_once 'wiki.inc.php';
-        $dom = (@$GLOBALS['IS_XNET_SITE'] ? 'ReviewXnet' : 'Review') . '.' . ucfirst($id);
-        wiki_require_page($dom);
-        $page->assign('cacheExists', wiki_work_dir() . '/cache_' . $dom . '.tpl');
-        $page->assign('article', $dom);
+        $wp = new PlWikiPage((@$GLOBALS['IS_XNET_SITE'] ? 'ReviewXnet' : 'Review') . '.' . ucfirst($id));
+        $wp->buildCache();
+        $page->assign('cacheExists', $wp->cacheFilename());
+        $page->assign('article', $wp->name);
     }
 }
 
index f663dc1..039f71a 100644 (file)
@@ -125,6 +125,7 @@ class ProfileModule extends PLModule
 
     function handler_photo_change(&$page)
     {
+        global $globals;
         $page->changeTpl('profile/trombino.tpl');
 
         require_once('validations.inc.php');
@@ -164,14 +165,14 @@ class ProfileModule extends PLModule
             XDB::execute('DELETE FROM  requests
                                 WHERE  user_id = {?} AND type="photo"',
                          S::v('uid'));
-            update_NbValid();
+            $globals->updateNbValid();
         } elseif (Env::v('cancel')) {
             S::assert_xsrf_token();
 
             $sql = XDB::query('DELETE FROM  requests
                                      WHERE  user_id={?} AND type="photo"',
                               S::v('uid'));
-            update_NbValid();
+            $globals->updateNbValid();
         }
 
         $sql = XDB::query('SELECT  COUNT(*)
@@ -225,11 +226,11 @@ class ProfileModule extends PLModule
         }
 
         if (S::logged()) {
-            $_SESSION['log']->log('view_profile', $login);
+            S::logger()->log('view_profile', $login);
         }
 
         $title = $user['prenom'] . ' ' . ( empty($user['nom_usage']) ? $user['nom'] : $user['nom_usage'] );
-        $page->assign('xorg_title', $title);
+        $page->setTitle($title);
 
         // photo
 
@@ -316,8 +317,8 @@ class ProfileModule extends PLModule
         $page->addJsLink('grades.js');
         $page->addJsLink('profile.js');
         $page->addJsLink('jquery.autocomplete.js');
-        $wiz = new PlWizard('Profil', 'core/plwizard.tpl', true, true);
-        require_once dirname(__FILE__) . '/profile/page.inc.php';
+        $wiz = new PlWizard('Profil', PlPage::getCoreTpl('plwizard.tpl'), true, true);
+        $this->load('page.inc.php');
         $wiz->addPage('ProfileGeneral', 'Général', 'general');
         $wiz->addPage('ProfileAddresses', 'Adresses personnelles', 'adresses');
         $wiz->addPage('ProfileGroups', 'Groupes X - Binets', 'poly');
@@ -336,7 +337,7 @@ class ProfileModule extends PLModule
                       . " la procédure de récupération de mot de passe si un jour tu le perdais");
         }
 
-       $page->assign('xorg_title', 'Polytechnique.org - Mon Profil');
+       $page->setTitle('Mon Profil');
     }
 
     function handler_applis_js(&$page)
@@ -455,7 +456,6 @@ class ProfileModule extends PLModule
         $page->changeTpl('profile/orange.tpl');
 
         require_once 'validations.inc.php';
-        require_once 'xorg.misc.inc.php';
 
         $res = XDB::query(
                 "SELECT  u.promo, u.promo_sortie
@@ -568,9 +568,10 @@ class ProfileModule extends PLModule
 
     function handler_ref_search(&$page, $action = null, $subaction = null)
     {
-        require_once 'wiki.inc.php';
-        wiki_require_page('Docs.Emploi');
-        $page->assign('xorg_title', 'Polytechnique.org - Conseil Pro');
+        $wp = new PlWikiPage('Docs.Emploi');
+        $wp->buildCache();
+
+        $page->setTitle('Conseil Pro');
 
         //recuperation des noms de secteurs
         $res = XDB::iterRow("SELECT id, label FROM emploi_secteur");
@@ -654,7 +655,6 @@ class ProfileModule extends PLModule
         $page->changeTpl('profile/nomusage.tpl');
 
         require_once 'validations.inc.php';
-        require_once 'xorg.misc.inc.php';
 
         $res = XDB::query(
                 "SELECT  u.nom, u.nom_usage, u.flags, e.alias
@@ -664,7 +664,7 @@ class ProfileModule extends PLModule
                   WHERE  user_id={?}", S::v('uid'));
 
         list($nom, $usage_old, $flags, $alias_old) = $res->fetchOneRow();
-        $flags = new flagset($flags);
+        $flags = new PlFlagSet($flags);
         $page->assign('usage_old', $usage_old);
         $page->assign('alias_old',  $alias_old);
 
@@ -694,7 +694,7 @@ class ProfileModule extends PLModule
     function handler_xnet(&$page)
     {
         $page->changeTpl('profile/groupesx.tpl');
-        $page->assign('xorg_title', 'Polytechnique.org - Promo, Groupes X, Binets');
+        $page->setTitle('Promo, Groupes X, Binets');
 
         $req = XDB::query('
             SELECT m.asso_id, a.nom, diminutif, a.logo IS NOT NULL AS has_logo,
@@ -718,13 +718,14 @@ 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) {
         $page->changeTpl('profile/admin_trombino.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Administration - Trombino');
+        $page->setTitle('Administration - Trombino');
         $page->assign('uid', $uid);
 
         $q   = XDB::query(
@@ -763,7 +764,7 @@ class ProfileModule extends PLModule
         $page->assign('forlife', $forlife);
     }
     function handler_admin_binets(&$page, $action = 'list', $id = null) {
-        $page->assign('xorg_title','Polytechnique.org - Administration - Binets');
+        $page->setTitle('Administration - Binets');
         $page->assign('title', 'Gestion des binets');
         $table_editor = new PLTableEditor('admin/binets', 'binets_def', 'id');
         $table_editor->add_join_table('binets_ins','binet_id',true);
@@ -771,7 +772,7 @@ class ProfileModule extends PLModule
         $table_editor->apply($page, $action, $id);
     }
     function handler_admin_formations(&$page, $action = 'list', $id = null) {
-        $page->assign('xorg_title','Polytechnique.org - Administration - Formations');
+        $page->setTitle('Administration - Formations');
         $page->assign('title', 'Gestion des formations');
         $table_editor = new PLTableEditor('admin/formations','applis_def','id');
         $table_editor->add_join_table('applis_ins','aid',true);
@@ -780,21 +781,21 @@ class ProfileModule extends PLModule
         $table_editor->apply($page, $action, $id);
     }
     function handler_admin_sections(&$page, $action = 'list', $id = null) {
-        $page->assign('xorg_title','Polytechnique.org - Administration - Sections');
+        $page->setTitle('Administration - Sections');
         $page->assign('title', 'Gestion des sections');
         $table_editor = new PLTableEditor('admin/sections','sections','id');
         $table_editor->describe('text','intitulé',true);
         $table_editor->apply($page, $action, $id);
     }
     function handler_admin_ss_secteurs(&$page, $action = 'list', $id = null) {
-        $page->assign('xorg_title', 'Polytechnique.org - Administration - Sous-secteurs');
+        $page->setTitle('Administration - Sous-secteurs');
         $page->assign('title', 'Gestion des sous-secteurs');
         $table_editor = new PLTableEditor('admin/ss_secteurs', 'emploi_ss_secteur', 'id', true);
         $table_editor->describe('label', 'intitulé', true);
         $table_editor->apply($page, $action, $id);
     }
     function handler_admin_fonctions(&$page, $action = 'list', $id = null) {
-        $page->assign('xorg_title', 'Polytechnique.org - Administration - Fonctions');
+        $page->setTitle('Administration - Fonctions');
         $page->assign('title', 'Gestion des fonctions');
         $table_editor = new PLTableEditor('admin/fonctions', 'fonctions_def', 'id', true);
         $table_editor->describe('fonction_fr', 'intitulé', true);
@@ -803,14 +804,14 @@ class ProfileModule extends PLModule
         $table_editor->apply($page, $action, $id);
     }
     function handler_admin_secteurs(&$page, $action = 'list', $id = null) {
-        $page->assign('xorg_title', 'Polytechnique.org - Administration - Secteurs');
+        $page->setTitle('Administration - Secteurs');
         $page->assign('title', 'Gestion des secteurs');
         $table_editor = new PLTableEditor('admin/secteurs', 'emploi_secteur', 'id', true);
         $table_editor->describe('label', 'intitulé', true);
         $table_editor->apply($page, $action, $id);
     }
     function handler_admin_medals(&$page, $action = 'list', $id = null) {
-        $page->assign('xorg_title','Polytechnique.org - Administration - Distinctions');
+        $page->setTitle('Administration - Distinctions');
         $page->assign('title', 'Gestion des Distinctions');
         $table_editor = new PLTableEditor('admin/medals','profile_medals','id');
         $table_editor->describe('text', 'intitulé',  true);
index ec0f031..780ee03 100644 (file)
@@ -117,7 +117,7 @@ class ProfileAddress extends ProfileGeoloc
 
     private function saveAddress($adrid, array &$address)
     {
-        $flags = new FlagSet();
+        $flags = new PlFlagSet();
         if ($address['secondaire']) {
             $flags->addFlag('res-secondaire');
         }
index 0753966..df97147 100644 (file)
@@ -114,7 +114,7 @@ class ProfileDecos extends ProfilePage
         }
     }
 
-    public function _prepare(PlatalPage &$page, $id)
+    public function _prepare(PlPage &$page, $id)
     {
         $res    = XDB::iterator("SELECT  *, FIND_IN_SET('validation', flags) AS validate
                                    FROM  profile_medals
index 1382658..8227f36 100644 (file)
@@ -52,9 +52,8 @@ class ProfileNom implements ProfileSetting
                 || $this->matchWord($ini, $new, $newLen)
                 || ($field == 'nom' && $new == 'DE ' . $old);
         if (!$success) {
-            global $page;
-            $page->trigError("Le $field que tu as choisi ($value) est trop loin de ton $field initial ($init)"
-                       . (($init == $current)? "" : " et de ton prénom précédent ($current)"));
+            Platal::page()->trigError("Le $field que tu as choisi ($value) est trop loin de ton $field initial ($init)"
+                                    . (($init == $current)? "" : " et de ton prénom précédent ($current)"));
         }
         return $success ? $value : $current;
     }
@@ -197,7 +196,7 @@ class ProfileGeneral extends ProfilePage
         }
     }
 
-    public function _prepare(PlatalPage &$page, $id)
+    public function _prepare(PlPage &$page, $id)
     {
         require_once "applis.func.inc.php";
     }
index cd2b705..cd2c447 100644 (file)
@@ -106,7 +106,7 @@ class ProfileGroups extends ProfilePage
         $this->watched['section'] = $this->watched['binets'] = true;
     }
 
-    public function _prepare(PlatalPage &$page, $id)
+    public function _prepare(PlPage &$page, $id)
     {
         $page->assign('mygroups', XDB::iterator("SELECT  a.nom, a.site, a.diminutif, a.unsub_url, a.pub, m.perms
                                                    FROM  groupex.asso    AS a
index 33690c4..ad1e921 100644 (file)
@@ -202,7 +202,7 @@ class ProfileJobs extends ProfilePage
         }
     }
 
-    public function _prepare(PlatalPage &$page, $id)
+    public function _prepare(PlPage &$page, $id)
     {
         $page->assign('secteurs', XDB::iterator("SELECT  id, label
                                                    FROM  emploi_secteur"));
index cbe6a23..bf577d9 100644 (file)
@@ -42,8 +42,7 @@ class ProfileSecteurs implements ProfileSetting
         } else if (!is_array($value)) {
             $value = array();
         } else if (count($value) > 10) {
-            global $page;
-            $page->trigError("Le nombre de secteurs d'expertise est limité à 10");
+            Platal::page()->trigError("Le nombre de secteurs d'expertise est limité à 10");
             $success = false;
         }
         ksort($value);
@@ -90,8 +89,7 @@ class ProfileCountry implements ProfileSetting
         } else if (!is_array($value)) {
             $value = array();
         } else if (count($value) > 10) {
-            global $page;
-            $page->trigError("Le nombre de secteurs d'expertise est limité à 10");
+            Platal::page()->trigError("Le nombre de secteurs d'expertise est limité à 10");
             $success = false;
         }
         ksort($value);
@@ -151,7 +149,7 @@ class ProfileMentor extends ProfilePage
         }
     }
 
-    public function _prepare(PlatalPage &$page, $id)
+    public function _prepare(PlPage &$page, $id)
     {
         $page->assign('secteurs_sel', XDB::iterator("SELECT  id, label
                                                        FROM  emploi_secteur"));
index 139178e..433947e 100644 (file)
@@ -53,9 +53,8 @@ class ProfileWeb extends ProfileNoSave
         $value = trim($value);
         $success = empty($value) || preg_match("{^(https?|ftp)://[a-zA-Z0-9._%#+/?=&~-]+$}i", $value);
         if (!$success) {
-            global $page;
-            $page->trigError('URL Incorrecte : une url doit commencer par http:// ou https:// ou ftp://'
-                      . ' et ne pas contenir de caractères interdits');
+            Platal::page()->trigError('URL Incorrecte : une url doit commencer par http:// ou https:// ou ftp://'
+                                    . ' et ne pas contenir de caractères interdits');
         }
         return $value;
     }
@@ -69,11 +68,9 @@ class ProfileEmail extends ProfileNoSave
             return isset($page->values[$field]) ? $page->values[$field] : S::v($field);
         }
         $value = trim($value);
-        require_once 'xorg.misc.inc.php';
         $success = empty($value) || isvalid_email($value);
         if (!$success) {
-            global $page;
-            $page->trigError('Adresse Email invalide');
+            Platal::page()->trigError('Adresse Email invalide');
         }
         return $value;
     }
@@ -89,8 +86,7 @@ class ProfileTel extends ProfileNoSave
         }
         $success = !preg_match('/[<>{}@&#~\/:;?,!§*_`\[\]|%$^=]/', $value, $matches);
         if (!$success) {
-            global $page;
-            $page->trigError('Le numéro de téléphone contient un caractère interdit : ' . pl_entities($matches[0][0]));
+            Platal::page()->trigError('Le numéro de téléphone contient un caractère interdit : ' . pl_entities($matches[0][0]));
         }
         return $value;
     }
@@ -135,16 +131,14 @@ class ProfileDate extends ProfileNoSave
         } else {
             $success = preg_match('@(\d{2})/(\d{2})/(\d{4})@', $value, $matches);
             if (!$success) {
-                global $page;
-                $page->trigError("Les dates doivent être au format jj/mm/aaaa");
+                Platal::page()->trigError("Les dates doivent être au format jj/mm/aaaa");
            } else {
                 $day   = (int)$matches[1];
                 $month = (int)$matches[2];
                 $year  = (int)$matches[3];
                 $success = ($day > 0 && $day <= 31) && ($month > 0 && $month <= 12) && ($year > 1900 && $year <= 2020);
                 if (!$success) {
-                    global $page;
-                    $page->trigError("La date n'a pas une valeur valide");
+                    Platal::page()->trigError("La date n'a pas une valeur valide");
                 }
             }
         }
@@ -260,7 +254,7 @@ abstract class ProfilePage implements PlWizardPage
         }
         global $platal;
         $log =& $_SESSION['log'];
-        $log->log('profil', $platal->pl_self(1));
+        S::logger()->log('profil', $platal->pl_self(1));
     }
 
     protected function checkChanges()
@@ -290,11 +284,11 @@ abstract class ProfilePage implements PlWizardPage
         return 'profile/base.tpl';
     }
 
-    protected function _prepare(PlatalPage &$page, $id)
+    protected function _prepare(PlPage &$page, $id)
     {
     }
 
-    public function prepare(PlatalPage &$page, $id)
+    public function prepare(PlPage &$page, $id)
     {
         if (count($this->values) == 0) {
             $this->fetchData();
@@ -329,9 +323,8 @@ abstract class ProfilePage implements PlWizardPage
             }
             return Post::has('next_page') ? PlWizard::NEXT_PAGE : PlWizard::CURRENT_PAGE;
         }
-        global $page;
-        $page->trigError("Certains champs n'ont pas pu être validés, merci de corriger les informations "
-                  . "de ton profil et de revalider ta demande");
+        Platal::page()->trigError("Certains champs n'ont pas pu être validés, merci de corriger les informations "
+                                . "de ton profil et de revalider ta demande");
         return PlWizard::CURRENT_PAGE;
     }
 }
index 8f0ec5e..c3da4f9 100644 (file)
@@ -89,7 +89,7 @@ class ProfileSkills extends ProfilePage
         $this->settings['langues'] = new ProfileSkill('langues', 'lid', 'langue_fr');
     }
 
-    public function _prepare(PlatalPage &$page, $id)
+    public function _prepare(PlPage &$page, $id)
     {
         $page->assign('comp_list', XDB::iterator("SELECT  id, text_fr, FIND_IN_SET('titre',flags) AS title
                                                     FROM  competences_def"));
index 2b04a7e..8d30088 100644 (file)
@@ -83,13 +83,13 @@ class RegisterModule extends PLModule
 
         switch ($sub_state['step']) {
             case 0:
-                require_once('wiki.inc.php');
-                wiki_require_page('Reference.Charte');
+                $wp = new PlWikiPage('Reference.Charte');
+                $wp->buildCache();
                 if (Post::has('step1')) {
                     $sub_state['step'] = 1;
                     if (isset($sub_state['hash'])) {
                         $sub_state['step'] = 3;
-                        require_once(dirname(__FILE__) . '/register/register.inc.php');
+                        $this->load('register.inc.php');
                         create_aliases($sub_state);
                     }
                 }
@@ -119,7 +119,7 @@ class RegisterModule extends PLModule
 
             case 2:
                 if (count($_POST)) {
-                    require_once(dirname(__FILE__) . '/register/register.inc.php');
+                    $this->load('register.inc.php');
                     $sub_state['prenom'] = Post::v('prenom');
                     $sub_state['nom']    = Post::v('nom');
                     $sub_state['mat']    = Post::v('mat');
@@ -136,7 +136,8 @@ class RegisterModule extends PLModule
 
             case 3:
                 if (count($_POST)) {
-                    require_once(dirname(__FILE__) . '/register/register.inc.php');
+                    $this->load('register.inc.php');
+                    require_once 'emails.inc.php';
                     if (!isvalid_email(Post::v('email'))) {
                         $err[] = "Le champ 'E-mail' n'est pas valide.";
                     } elseif (!isvalid_email_redirection(Post::v('email'))) {
@@ -300,24 +301,45 @@ class RegisterModule extends PLModule
         $redirect->add_email($email);
 
         // on cree un objet logger et on log l'inscription
-        $logger = new CoreLogger($uid);
-        $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)
-        update_NbIns();
+        $globals->updateNbIns();
 
         if (!start_connexion($uid, false)) {
             return PL_FORBIDDEN;
@@ -336,7 +358,8 @@ class RegisterModule extends PLModule
              INNER JOIN  aliases            AS sa ON ( sa.id = m.sender
                                                        AND FIND_IN_SET('bestalias', sa.flags) )
                   WHERE  m.uid = {?}
-               GROUP BY  m.sender", $uid);
+               GROUP BY  m.sender
+               ORDER BY  dateDernier DESC", $uid);
         XDB::execute("UPDATE register_mstats SET success=NOW() WHERE uid={?}", $uid);
 
         $market = array();
@@ -379,7 +402,7 @@ class RegisterModule extends PLModule
                 $msg .= "Les marketings suivants avaient été effectués :\n"
                      . implode("\n", $market);
             } else {
-                $msg .= "$prenom $nom n'a jamais reçu dmail de marketing.";
+                $msg .= "$prenom $nom n'a jamais reçu d\'email de marketing.";
             }
             $mymail->setTxtBody($msg);
             $mymail->send();
@@ -416,7 +439,7 @@ class RegisterModule extends PLModule
             }
 
             $log = S::v('log');
-            $log->log('passwd', '');
+            S::logger()->log('passwd', '');
 
             if (Cookie::v('ORGaccess')) {
                 require_once('secure_hash.inc.php');
@@ -462,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 2d9a3c2..4839e36 100644 (file)
@@ -19,8 +19,6 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-require_once 'xorg.misc.inc.php';
-
 // {{{ function user_cmp
 
 function user_cmp($prenom, $nom, $_prenom, $_nom)
@@ -151,7 +149,6 @@ function create_aliases (&$sub)
     global $globals;
     extract ($sub);
 
-    require_once "xorg.misc.inc.php";
     $mailorg  = make_username($prenom, $nom);
     $mailorg2 = $mailorg.sprintf(".%02u", ($promo%100));
     $forlife  = make_forlife($prenom, $nom, $promo);
index c97996c..c9ca317 100644 (file)
@@ -38,18 +38,9 @@ class SearchModule extends PLModule
         exit;
     }
 
-    function on_subscribe($forlife, $uid, $promo, $pass)
-    {
-        require_once 'user.func.inc.php';
-        user_reindex($uid);
-    }
-
-
     function form_prepare()
     {
-        global $page;
-
-        $page->assign('formulaire',1);
+        Platal::page()->assign('formulaire',1);
     }
 
     function get_diplomas($school = null)
@@ -72,8 +63,7 @@ class SearchModule extends PLModule
             $types = explode('(',$row[1]);
             $types = str_replace("'","",substr($types[1],0,-1));
         }
-        global $page;
-        $page->assign('choix_diplomas', explode(',',$types));
+        Platal::page()->assign('choix_diplomas', explode(',',$types));
     }
 
     function handler_quick(&$page, $action = null, $subaction = null)
@@ -90,7 +80,7 @@ class SearchModule extends PLModule
         if (Env::has('quick') || $action == 'geoloc') {
             $quick = trim(Env::v('quick'));
             if (S::logged() && !Env::has('page')) {
-                $_SESSION['log']->log('search', 'quick=' . $quick);
+                S::logger()->log('search', 'quick=' . $quick);
             }
             $list = 'profile|prf|fiche|fic|referent|ref|mentor';
             if (S::has_perms()) {
@@ -155,16 +145,16 @@ class SearchModule extends PLModule
             $page->addJsLink('ajax.js');
         }
 
-        require_once dirname(__FILE__) . '/search/search.inc.php';
+        $this->load('search.inc.php');
         $page->changeTpl('search/index.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Annuaire');
+        $page->setTitle('Annuaire');
     }
 
     function handler_advanced(&$page, $action = null, $subaction = null)
     {
         global $globals;
         require_once 'geoloc.inc.php';
-        require_once dirname(__FILE__) . '/search/search.inc.php';
+        $this->load('search.inc.php');
         $page->assign('advanced',1);
         $page->addJsLink('jquery.autocomplete.js');
 
@@ -185,7 +175,7 @@ class SearchModule extends PLModule
                 'city' => array('table' => 'geoloc_city', 'text' => 'name', 'exact' => false)
             );
             if (!Env::has('page')) {
-                $_SESSION['log']->log('search', 'adv=' . var_export($_GET, true));
+                S::logger()->log('search', 'adv=' . var_export($_GET, true));
             }
             foreach ($textFields as $field=>&$query) {
                 if (!Env::v($field) && Env::v($field . 'Txt')) {
index 91c924d..5f01c97 100644 (file)
@@ -19,8 +19,6 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-require_once("xorg.misc.inc.php");
-
 // {{{ Global variables used for the search Queries
 
 @$globals->search->result_fields = '
@@ -92,9 +90,10 @@ class ThrowError
      */
     private static function defaultHandler($explain)
     {
-        global $page, $globals;
+        global $globals;
+        $page =& Platal::page();
         $page->changeTpl('search/index.tpl');
-        $page->assign('xorg_title','Polytechnique.org - Annuaire');
+        $page->setTitle('Polytechnique.org - Annuaire');
         $page->assign('baseurl', $globals->baseurl);
         $page->trigError($explain);
         $page->run();
@@ -253,8 +252,7 @@ class QuickSearch extends SField
         $s = preg_replace('!\d+!', ' ', $s);
         $this->strings = preg_split("![^a-zA-Z%]+!",$s, -1, PREG_SPLIT_NO_EMPTY);
         if (count($this->strings) > 5) {
-            global $page;
-            $page->trigWarning("Tu as indiqué trop d'éléments dans ta recherche, seuls les 5 premiers seront pris en compte");
+            Platal::page()->trigWarning("Tu as indiqué trop d'éléments dans ta recherche, seuls les 5 premiers seront pris en compte");
             $this->strings = array_slice($this->strings, 0, 5);
         }
 
@@ -279,6 +277,8 @@ class QuickSearch extends SField
             if (Env::i('with_soundex') && strlen($s) > 1) {
                 $t = soundex_fr($s);
                 $where[] = "sn$i.soundex = '$t'";
+            } elseif (Env::i('exact')) {
+                $where[] = "sn$i.token = '$s'";
             } else {
                 $t = str_replace('*', '%', $s).'%';
                 $t = str_replace('%%', '%', $t);
@@ -445,6 +445,7 @@ class RefSField extends SField
     function compare()
     {
         $val = addslashes($this->value);
+        if (Env::i('exact')) return "='$val'";
         return $this->exact ? "='$val'" : " LIKE '%$val%'";
     }
 
@@ -583,7 +584,9 @@ class StringSField extends SField
      * @param field nom de champ de la bdd concerné par la clause */
     function get_single_where_statement($field)
     {
-        $regexp = strtr(addslashes($this->value), '-*', '_%');
+        $val = addslashes($this->value);
+        if (Env::i('exact')) return "$field = '$val'";
+        $regexp = strtr($val, '-*', '_%');
         return "$field LIKE '$regexp%'";
     }
 
@@ -614,7 +617,9 @@ class NameSField extends StringSField
 
     function get_single_where_statement($field)
     {
-        $regexp = strtr(addslashes($this->value), '-*', '_%');
+        $val = addslashes($this->value);
+        if (Env::i('exact')) return "$field = '$val'";
+        $regexp = strtr($val, '-*', '_%');
         return "$field LIKE '$regexp%' OR $field LIKE '% $regexp%' OR $field LIKE '%-$regexp%'";
     }
 
index 0d23a78..985a398 100644 (file)
@@ -48,9 +48,9 @@ function advancedSearchFromInput()
     }
 
     if (!Env::i('cityid')) {
-        $townField      = new RefSField('city',array('ac.city'),'adresses','ac',getadr_join('ac'),false);
+        $townField  = new RefSField('city',array('ac.city', 'ac.postcode'),'adresses','ac',getadr_join('ac'),false);
     } else {
-        $townField    = new RefSField('cityid',array('av.cityid'),'adresses','av',getadr_join('av'));
+        $townField  = new RefSField('cityid',array('av.cityid', 'av.postcode'),'adresses','av',getadr_join('av'));
     }
     $countryField   = new RefSField('country',array('ap.country'),'adresses','ap',getadr_join('ap'));
     $regionField    = new RefSField('region',array('ar.region'),'adresses','ar',getadr_join('ar'));
index ff3bb05..f493b4e 100644 (file)
@@ -41,7 +41,7 @@ class SurveyModule extends PLModule
     // {{{ function handler_index() : lists all available surveys
     function handler_index(&$page, $action = null)
     {
-        require_once dirname(__FILE__).'/survey/survey.inc.php';
+        $this->load('survey.inc.php');
         $page->changeTpl('survey/index.tpl');
         $page->assign('survey_current', Survey::retrieveList('c'));
         $page->assign('survey_old', Survey::retrieveList('o'));
@@ -59,7 +59,7 @@ class SurveyModule extends PLModule
         if ($id == -1) {
             return $this->show_error($page, "Un identifiant de sondage doit être précisé.", 'survey');
         }
-        require_once dirname(__FILE__).'/survey/survey.inc.php';
+        $this->load('survey.inc.php');
         $survey = Survey::retrieveSurvey($id); // retrieves the survey object structure
         if ($survey == null || !$survey->isValid()) {
             return $this->show_error($page, "Sondage ".$id." introuvable.", 'survey');
@@ -98,7 +98,7 @@ class SurveyModule extends PLModule
         if ($id == -1) {
             return $this->show_error($page, "Un identifiant de sondage doit être précisé.", 'survey');
         }
-        require_once dirname(__FILE__).'/survey/survey.inc.php';
+        $this->load('survey.inc.php');
         $survey = Survey::retrieveSurvey($id); // retrieves the survey object structure
         if ($survey == null || !$survey->isValid()) {
             return $this->show_error($page, "Sondage ".$id." introuvable.", 'survey');
@@ -122,7 +122,7 @@ class SurveyModule extends PLModule
     // {{{ function handler_admin() : index of admin mode
     function handler_admin(&$page, $id = -1)
     {
-        require_once dirname(__FILE__).'/survey/survey.inc.php';
+        $this->load('survey.inc.php');
         $this->clear_session();
         if ($id == -1) {
             $page->changeTpl('survey/admin.tpl');
@@ -148,7 +148,7 @@ class SurveyModule extends PLModule
         if ($id == -1 || ($id == 'req' && $req == -1)) {
             return $this->show_error($page, "Un identifiant de sondage doit être précisé.", 'survey/admin');
         }
-        require_once dirname(__FILE__).'/survey/survey.inc.php';
+        $this->load('survey.inc.php');
         $this->clear_session(); // cleans session (in case there would have been a problem before)
         if ($id == 'req') {
             $survey = Survey::retrieveSurveyReq($req);
@@ -180,7 +180,7 @@ class SurveyModule extends PLModule
             return $this->show_error($page, "Un identifiant de sondage doit être précisé.", 'survey/admin');
         }
         $id = intval($id);
-        require_once dirname(__FILE__).'/survey/survey.inc.php';
+        $this->load('survey.inc.php');
         $surveyInfo = Survey::retrieveSurveyInfo($id); // retrieves information about the survey (does not retrieve and unserialize the object structure)
         if ($surveyInfo == null) {
             return $this->show_error($page, "Sondage ".$id." introuvable.", 'survey/admin');
@@ -209,7 +209,7 @@ class SurveyModule extends PLModule
             return $this->show_error($page, "Un identifiant de sondage doit être précisé.", 'survey/admin');
         }
         $id = intval($id);
-        require_once dirname(__FILE__).'/survey/survey.inc.php';
+        $this->load('survey.inc.php');
         $surveyInfo = Survey::retrieveSurveyInfo($id); // retrieves information about the survey (does not retrieve and unserialize the object structure)
         if ($surveyInfo == null) {
             return $this->show_error($page, "Sondage ".$id." introuvable.", 'survey/admin');
@@ -229,7 +229,7 @@ class SurveyModule extends PLModule
     // {{{ function handler_edit() : edits a survey (in normal mode unless called by handler_adminEdit() )
     function handler_edit(&$page, $action = 'show', $qid = 'root')
     {
-        require_once dirname(__FILE__).'/survey/survey.inc.php';
+        $this->load('survey.inc.php');
         $action = Post::v('survey_action', $action);
         $qid    = Post::v('survey_qid', $qid);
         if (Post::has('survey_cancel')) { // after cancelling changes, shows the survey
@@ -363,7 +363,7 @@ class SurveyModule extends PLModule
     // {{{ function handler_ajax() : some ajax in editing a new question (for now, there may be a little more later)
     function handler_ajax(&$page, $type)
     {
-        require_once dirname(__FILE__).'/survey/survey.inc.php';
+        $this->load('survey.inc.php');
         header('Content-Type: text/html; charset="UTF-8"');
         if (Survey::isType($type)) { // when type has been chosen, the form is updated to fit exactly the type of question chosen
             $page->changeTpl('survey/edit_new.tpl', NO_SKIN);
@@ -398,7 +398,7 @@ class SurveyModule extends PLModule
     // {{{ function check_surveyPerms() : checks the particular surveys access permissions
     function check_surveyPerms(&$page, $survey)
     {
-        require_once dirname(__FILE__).'/survey/survey.inc.php';
+        $this->load('survey.inc.php');
         if (!$survey->isMode(Survey::MODE_ALL)) { // if the survey is reserved to alumni
             global $globals;
             if (!call_user_func(array($globals->session, 'doAuth'))) { // checks authentification
index b0d0151..d3c9c4e 100644 (file)
@@ -65,8 +65,8 @@ class XnetModule extends PLModule
 
     function handler_exit(&$page)
     {
-        XnetSession::killSuid();
-        XnetSession::destroy();
+        Platal::session()->stopSUID();
+        Platal::session()->destroy();
         $page->changeTpl('xnet/deconnexion.tpl');
     }
 
index d7f5301..a879db9 100644 (file)
@@ -98,7 +98,7 @@ class XnetEventsModule extends PLModule
             XDB::execute("DELETE FROM requests
                                     WHERE type = 'paiements' AND data LIKE {?}",
                                    PayReq::same_event($eid, $globals->asso('id')));
-            update_NbValid();
+            $globals->updateNbValid();
         }
 
         if ($action == 'archive') {
@@ -179,7 +179,7 @@ class XnetEventsModule extends PLModule
 
     function handler_sub(&$page, $eid = null)
     {
-        require_once dirname(__FILE__).'/xnetevents/xnetevents.inc.php';
+        $this->load('xnetevents.inc.php');
         $page->changeTpl('xnetevents/subscribe.tpl');
 
         $evt = get_event_detail($eid);
@@ -275,7 +275,7 @@ class XnetEventsModule extends PLModule
 
     function handler_csv(&$page, $eid = null, $item_id = null)
     {
-        require_once dirname(__FILE__).'/xnetevents/xnetevents.inc.php';
+        $this->load('xnetevents.inc.php');
 
         if (!is_numeric($item_id)) {
             $item_id = null;
@@ -310,7 +310,7 @@ class XnetEventsModule extends PLModule
     {
         global $globals;
 
-        require_once dirname(__FILE__).'/xnetevents/xnetevents.inc.php';
+        $this->load('xnetevents.inc.php');
         $evt = get_event_detail($eid);
         if (!$evt) {
             return PL_FORBIDDEN;
@@ -375,7 +375,7 @@ class XnetEventsModule extends PLModule
         if (Post::v('intitule')) {
             S::assert_xsrf_token();
 
-            require_once dirname(__FILE__).'/xnetevents/xnetevents.inc.php';
+            $this->load('xnetevents.inc.php');
             $short_name = event_change_shortname($page, $eid,
                                                  $infos['short_name'],
                                                  Env::v('short_name', ''));
@@ -526,7 +526,7 @@ class XnetEventsModule extends PLModule
     {
         global $globals;
 
-        require_once dirname(__FILE__).'/xnetevents/xnetevents.inc.php';
+        $this->load('xnetevents.inc.php');
 
         $evt = get_event_detail($eid, $item_id);
         if (!$evt) {
index b0fab12..9c2f4ff 100644 (file)
@@ -205,7 +205,8 @@ function get_event_participants(&$evt, $item_id, $tri, $limit = '') {
 function subscribe_lists_event($participate, $uid, $evt)
 {
     require_once('user.func.inc.php');
-    global $globals,$page;
+    global $globals;
+    $page =& Platal::page();
 
     $participant_list = $evt['participant_list'];
     $absent_list      = $evt['absent_list'];
@@ -218,7 +219,7 @@ function subscribe_lists_event($participate, $uid, $evt)
         $res = XDB::query("SELECT email
                              FROM groupex.membres
                             WHERE uid = {?} AND asso_id = {?}",
-                            S::v('uid'), $globals->asso('id'));
+                          $uid, $globals->asso('id'));
         $email = $res->fetchOneCell();
     }
 
@@ -304,7 +305,7 @@ function event_change_shortname(&$page, $eid, $old, $new)
 
         $lastid = XDB::insertId();
         XDB::execute(
-          "INSERT INTO virtual_redirect (
+          "INSERT IGNORE INTO virtual_redirect (
                 SELECT {?} AS vid, IF(u.nom IS NULL, m.email, CONCAT(a.alias, {?})) AS redirect
                   FROM groupex.evenements_participants AS ep
              LEFT JOIN groupex.membres AS m ON (ep.uid = m.uid)
index 232b2c6..afe992d 100644 (file)
@@ -122,7 +122,7 @@ class XnetGrpModule extends PLModule
 
         if (S::logged()) {
             if (Env::has('read')) {
-                XDB::query('DELETE r.*
+                XDB::query('DELETE groupex.r.*
                               FROM groupex.announces_read AS r
                         INNER JOIN groupex.announces AS a ON a.id = r.announce_id
                              WHERE peremption < CURRENT_DATE()');
@@ -233,10 +233,19 @@ class XnetGrpModule extends PLModule
         if (Post::has('submit')) {
             S::assert_xsrf_token();
 
-            $flags = new FlagSet('wiki_desc');
+            $flags = new PlFlagSet('wiki_desc');
             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'),
@@ -320,7 +329,7 @@ class XnetGrpModule extends PLModule
             $mls = array_keys(Env::v('ml', array()));
             $mbr = array_keys(Env::v('membres', array()));
 
-            require_once dirname(__FILE__) . '/xnetgrp/mail.inc.php';
+            $this->load('mail.inc.php');
             set_time_limit(120);
             $tos = get_all_redirects($mbr,  $mls, $mmlist);
             $upload = PlUpload::get($_FILES['uploaded'], S::v('forlife'), 'xnet.emails', true);
@@ -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)
@@ -708,25 +718,26 @@ class XnetGrpModule extends PLModule
         if (Env::has('right') && (may_update() || S::has('suid'))) {
             switch (Env::v('right')) {
               case 'admin':
-                XnetSession::killSuid();
+                Platal::session()->stopSUID();
                 break;
               case 'anim':
-                XnetSession::doSelfSuid();
+                Platal::session()->doSelfSuid();
                 may_update(true);
                 is_member(true);
                 break;
               case 'member':
-                XnetSession::doSelfSuid();
+                Platal::session()->doSelfSuid();
                 may_update(false, true);
                 is_member(true);
                 break;
               case 'logged':
-                XnetSession::doSelfSuid();
+                Platal::session()->doSelfSuid();
                 may_update(false, true);
                 is_member(false, true);
                 break;
             }
         }
+//        var_dump($_SESSION);
         http_redirect($_SERVER['HTTP_REFERER']);
     }
 
@@ -734,7 +745,7 @@ class XnetGrpModule extends PLModule
     {
         global $globals;
 
-        require_once dirname(__FILE__) . '/xnetgrp/mail.inc.php';
+        $this->load('mail.inc.php');
         $page->changeTpl('xnetgrp/annuaire-admin.tpl');
         $mmlist = new MMList(S::v('uid'), S::v('password'),
                              $globals->asso('mail_domain'));
@@ -811,7 +822,6 @@ class XnetGrpModule extends PLModule
                 $page->trigError($email." n'est pas un alias polytechnique.org valide.");
             }
         } else {
-            require_once 'xorg.misc.inc.php';
             if (isvalid_email($email)) {
                 if (Env::v('x') && Env::has('userid') && Env::i('userid')) {
                     $uid = Env::i('userid');
@@ -884,7 +894,7 @@ class XnetGrpModule extends PLModule
 
     function unsubscribe(&$user)
     {
-        global $globals, $page;
+        global $globals;
         XDB::execute(
                 "DELETE FROM  groupex.membres WHERE uid={?} AND asso_id={?}",
                 $user['uid'], $globals->asso('id'));
@@ -928,9 +938,9 @@ class XnetGrpModule extends PLModule
                     $mmlist->unsubscribe($liste['list']);
                 }
             } elseif ($liste['sub']) {
-                $page->trigWarning("{$user['prenom']} {$user['nom']} a une"
-                                  ." demande d'inscription en cours sur la"
-                                  ." liste {$liste['list']}@ !");
+                Platal::page()->trigWarning("{$user['prenom']} {$user['nom']} a une"
+                                           ." demande d'inscription en cours sur la"
+                                           ." liste {$liste['list']}@ !");
                 $warning = true;
             }
         }
@@ -989,7 +999,7 @@ class XnetGrpModule extends PLModule
         }
     }
 
-    private function changeLogin(PlatalPage &$page, array &$user, MMList &$mmlist, $login)
+    private function changeLogin(PlPage &$page, array &$user, MMList &$mmlist, $login)
     {
         require_once 'user.func.inc.php';
         // Search the uid of the user...
@@ -1183,32 +1193,14 @@ class XnetGrpModule extends PLModule
     function handler_rss(&$page, $user = null, $hash = null)
     {
         global $globals;
-        require_once('rss.inc.php');
-        $uid = init_rss('xnetgrp/announce-rss.tpl', $user, $hash, false);
-
-        if ($uid) {
-            $rss = XDB::iterator("SELECT a.id, a.titre, a.texte, a.contacts, a.create_date,
-                                         IF(u2.nom_usage != '', u2.nom_usage, u2.nom) AS nom, u2.prenom, u2.promo,
-                                         FIND_IN_SET('photo', a.flags) AS photo
-                                   FROM auth_user_md5 AS u
-                             INNER JOIN groupex.announces AS a ON ( (a.promo_min = 0 OR a.promo_min <= u.promo)
-                                                                  AND (a.promo_max = 0 OR a.promo_max <= u.promo))
-                             INNER JOIN auth_user_md5 AS u2 ON (u2.user_id = a.user_id)
-                             WHERE u.user_id = {?} AND peremption >= NOW() AND a.asso_id = {?}",
-                                   $uid, $globals->asso('id'));
-        } else {
-            $rss = XDB::iterator("SELECT a.id, a.titre, a.texte, a.create_date,
-                                         IF(u.nom_usage != '', u.nom_usage, u.nom) AS nom, u.prenom, u.promo
-                                    FROM groupex.announces AS a
-                             INNER JOIN auth_user_md5 AS u USING(user_id)
-                             WHERE FIND_IN_SET('public', a.flags) AND peremption >= NOW() AND a.asso_id = {?}",
-                                  $globals->asso('id'));
-        }
         $page->assign('asso', $globals->asso());
-        $page->assign('rss', $rss);
+
+        $this->load('feed.inc.php');
+        $feed = new XnetGrpEventFeed();
+        return $feed->run($page, $user, $hash, false);
     }
 
-    private function upload_image(PlatalPage &$page, PlUpload &$upload)
+    private function upload_image(PlPage &$page, PlUpload &$upload)
     {
         if (@!$_FILES['image']['tmp_name'] && !Env::v('image_url')) {
             return true;
@@ -1316,7 +1308,7 @@ class XnetGrpModule extends PLModule
         if (Post::v('valid') == 'Enregistrer') {
             $promo_min = ($art['public'] ? 0 : $art['promo_min']);
             $promo_max = ($art['public'] ? 0 : $art['promo_max']);
-            $flags = new FlagSet();
+            $flags = new PlFlagSet();
             if ($art['public']) {
                 $flags->addFlag('public');
             }
diff --git a/modules/xnetgrp/feed.inc.php b/modules/xnetgrp/feed.inc.php
new file mode 100644 (file)
index 0000000..caee580
--- /dev/null
@@ -0,0 +1,66 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2008 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************/
+
+class XnetGrpEventFeed extends PlFeed
+{
+    public function __construct()
+    {
+        global $globals;
+        $name = $globals->asso('nom');
+        $url = $globals->baseurl . '/' . $globals->asso('diminutif');
+        parent::__construct('Polytechnique.net :: ' . $name . ' :: News',
+                            $url,
+                            'L\'actualité du groupe ' . $name,
+                            $url . '/logo',
+                            'xnetgrp/announce-rss.tpl');
+    }
+
+    protected function fetch($user)
+    {
+        global $globals;
+        if (!is_null($user)) {
+            return XDB::iterator("SELECT a.id, a.titre AS title, a.texte, a.contacts,
+                                         a.create_date AS publication,
+                                         CONCAT(u2.prenom, ' ', IF(u2.nom_usage != '', u2.nom_usage, u2.nom), ' (X',  u2.promo, ')') AS author,
+                                         FIND_IN_SET('photo', a.flags) AS photo,
+                                         CONCAT({?}, '/#art', a.id) AS link
+                                   FROM auth_user_md5 AS u
+                             INNER JOIN groupex.announces AS a ON ( (a.promo_min = 0 OR a.promo_min <= u.promo)
+                                                                  AND (a.promo_max = 0 OR a.promo_max <= u.promo))
+                             INNER JOIN auth_user_md5 AS u2 ON (u2.user_id = a.user_id)
+                             WHERE u.user_id = {?} AND peremption >= NOW() AND a.asso_id = {?}",
+                                   $this->link, $user, $globals->asso('id'));
+        } else {
+            return  XDB::iterator("SELECT a.id, a.titre AS title, a.texte, a.create_date AS publication,
+                                         CONCAT(u.prenom, ' ', IF(u.nom_usage != '', u.nom_usage, u.nom), ' (X',  u.promo, ')') AS author,
+                                         CONCAT({?}, '/#art', a.id) AS link,
+                                         NULL AS photo, NULL AS contacts
+                                    FROM groupex.announces AS a
+                              INNER JOIN auth_user_md5 AS u USING(user_id)
+                                   WHERE FIND_IN_SET('public', a.flags) AND peremption >= NOW() AND a.asso_id = {?}",
+                                  $this->link, $globals->asso('id'));
+        }
+    }
+}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+
+?>
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'));
diff --git a/plugins/block.tidy.php b/plugins/block.tidy.php
deleted file mode 100644 (file)
index d74de2f..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-global $tidy_config;
-$tidy_config = array(
-    'drop-empty-paras' => true,
-    'drop-font-tags' => true,
-    'drop-proprietary-attributes' => true,
-    'hide-comments' => true,
-    'logical-emphasis' => true,
-    'output-xhtml' => true,
-    'replace-color' => true,
-    'show-body-only' => true,
-    'clean' => false,
-    'join-styles' => false,
-    'join-classes' => false,
-    'alt-text' => '[ inserted by TIDY ]',
-    'wrap' => '120');
-
-/*
- * Smarty plugin
- * -------------------------------------------------------------
- * File:     block.min_perms.php
- * Type:     block
- * Name:     min_perms
- * Purpose:
- * -------------------------------------------------------------
- */
-function smarty_block_tidy($params, $content, &$smarty)
-{
-    global $tidy_config;
-    return tidy_repair_string($content, $tidy_config, 'utf8');
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/plugins/compiler.checkpasswd.php b/plugins/compiler.checkpasswd.php
deleted file mode 100644 (file)
index 5c10a2a..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-require_once 'platal.inc.php';
-
-function smarty_compiler_checkpasswd($tag_attrs, &$compiler)
-{
-    extract($compiler->_parse_attrs($tag_attrs));
-    if (!isset($width)) {
-      $width = '230px';
-    }
-    if (!isset($prompt)) {
-      $prompt = "'nouveau'";
-    }
-    if (!isset($submit)) {
-      $submit = "'submitn'";
-    }
-
-    return '?><script type="text/javascript" src="javascript/jquery.js" ></script>
-              <script type="text/javascript" src="javascript/jquery.color.js" ></script>
-              <script type="text/javascript">//<![CDATA[
-                var passwordprompt_name = '.  $prompt . ';
-                var passwordprompt_submit = ' . $submit . ';
-                $(":input[@name=' . $prompt . ']").keyup(function(event) { checkPassword(event.target); });
-                $(document).ready(function() {
-                  checkPassword($(":input[@name=' . $prompt . ']").get(0));
-                });
-              //]]></script>
-              <div>
-                <div style="border: 1px solid white; width: ' . $width . '; height: 7px; background-color: #444; margin-top: 4px; float: left">
-                  <div id="passwords_measure" style="height: 100%; background-color: red; width: 0px"></div>
-                </div>
-                <a href="Xorg/MDP?display=light" style="display: block; float: left; margin-left: 4px;" class="popup_600x800">
-                  <img src="images/icons/information.gif" alt="Aide" title="Comment construire un mot de passe fort..." />
-                </a>
-              </div><?php';
-}
-
-/* vim: set expandtab enc=utf-8: */
-
-?>
index c675903..d464900 100644 (file)
@@ -18,7 +18,6 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
-require_once 'platal.inc.php';
 
 function smarty_compiler_icon($tag_attrs, &$compiler)
 {
diff --git a/plugins/compiler.iterate.php b/plugins/compiler.iterate.php
deleted file mode 100644 (file)
index 1ab1a01..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-function iterate_end($tag_attrs, &$compiler) {
-    return 'endwhile;';
-}
-
-function smarty_compiler_iterate($tag_attrs, &$compiler)
-{
-    static $reg = false;
-    if (!$reg) {
-        $reg = true;
-        $compiler->register_compiler_function("/iterate", 'iterate_end');
-    }
-
-    $_params = $compiler->_parse_attrs($tag_attrs);
-
-    if (!isset($_params['from'])) {
-        $compiler->_syntax_error("iterate: missing 'from' parameter", E_USER_ERROR, __FILE__, __LINE__);
-        return;
-    }
-
-    if (empty($_params['item'])) {
-        $compiler->_syntax_error("iterate: missing 'item' attribute", E_USER_ERROR, __FILE__, __LINE__);
-        return;
-    }
-
-    $_from = $compiler->_dequote($_params['from']);
-    $_item = $compiler->_dequote($_params['item']);
-
-    return "\$_iterate_$_item = $_from;\n"
-        .  "while ((\$this->_tpl_vars['$_item'] = \$_iterate_{$_item}->next()) !== null):";
-}
-
-/* vim: set expandtab enc=utf-8: */
-
-?>
diff --git a/plugins/compiler.javascript.php b/plugins/compiler.javascript.php
deleted file mode 100644 (file)
index b17d370..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-require_once 'platal.inc.php';
-
-function smarty_compiler_javascript($tag_attrs, &$compiler)
-{
-    extract($compiler->_parse_attrs($tag_attrs));
-
-    if (!isset($name)) {
-        return null;
-    }
-    $name = pl_entities(trim($name, '\'"'), ENT_QUOTES);
-    $name = "javascript/$name.js";
-    if ($full) {
-        global $globals;
-        $name = $globals->baseurl . '/' . $name;
-    }
-
-    return "?><script type='text/javascript' src='$name'></script><?php";
-}
-
-/* vim: set expandtab enc=utf-8: */
-
-?>
index a9c94e7..faa8684 100644 (file)
@@ -18,7 +18,6 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
-require_once 'platal.inc.php';
 
 function smarty_function_make_forlife($params, &$smarty)
 {
diff --git a/plugins/function.select_db_table.php b/plugins/function.select_db_table.php
deleted file mode 100644 (file)
index 41d1bae..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-require_once 'platal.inc.php';
-
-function select_options($table,$valeur,$champ="text",$pad=false,
-                        $where="",$join="",$group="")
-{
-    $fields = 't.id,' . $champ;
-    $order = $champ;
-    if ($group) {
-        $fields .= ',' . $group;
-        $order = $group . ',' . $order;
-    }
-    $sql = "SELECT $fields FROM $table AS t $join $where ORDER BY $order";
-    $res = XDB::iterRow($sql);
-    $sel = ' selected="selected"';
-
-    // on ajoute une entree vide si $pad est vrai
-    $html = "";
-    if ($pad) {
-        $html.= '<option value="0"'.($valeur==0?$sel:"")."></option>\n";
-    }
-    $optgrp = null;
-    while (list($my_id,$my_text,$my_grp) = $res->next()) {
-        if ($my_grp != $optgrp) {
-            if (!is_null($optgrp)) {
-                $html .= '</optgroup>';
-            }
-            $html .= '<optgroup label="' . pl_entities($my_grp, ENT_QUOTES) . '">';
-            $optgrp = $my_grp;
-        }
-        $html .= sprintf("<option value=\"%s\" %s>%s</option>\n",
-                         $my_id, $valeur==$my_id ? $sel : "", pl_entities($my_text));
-    }
-    if (!is_null($optgrp)) {
-        $html .= '</optgroup>';
-    }
-    return $html;
-}
-
-function smarty_function_select_db_table($params, &$smarty) {
-    if(empty($params['table']))
-        return;
-    if(empty($params['champ']))
-        $params['champ'] = 'text';
-    if(empty($params['pad']) || !($params['pad']))
-        $pad = false;
-    else
-        $pad = true;
-    if(empty($params['where']))
-        $params['where'] = '';
-    return select_options($params['table'], $params['valeur'], $params['champ'], $pad,
-                          $params['where'], $params['join'], $params['group']);
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
index bc0401c..e17b738 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"';
 
diff --git a/plugins/function.valid_date.php b/plugins/function.valid_date.php
deleted file mode 100644 (file)
index 8613c3a..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-require_once 'platal.inc.php';
-
-function smarty_function_valid_date($params, &$smarty)
-{
-    extract($params);
-
-    if (!isset($name)) {
-        $name = 'valid_date';
-    }
-    $text = "<select name=\"$name\">";
-    if (!isset($from)) {
-        $from = 1;
-    }
-    if (!isset($to)) {
-        $to = 30;
-    }
-    $value = strtr($value, array('-' => ''));
-    $time = time() + 3600 * 24 * $from;
-    $mth  = '';
-    for ($i = $from ; $i <= $to ; $i++) {
-        $p_stamp = date('Ymd', $time);
-        $date    = date('d / m / Y', $time);
-        $select  = ($p_stamp == $value) ? 'selected="selected"' : '';
-        $month   = pl_entities(strftime('%B', $time), ENT_QUOTES);
-        if ($mth != $month) {
-            if ($i != $from) {
-                $text .= '</optgroup>';
-            }
-            $text .= "<optgroup label=\"$month\">";
-            $mth = $month;
-        }
-        $time += 3600 * 24;
-        $text .= "<option value=\"$p_stamp\" $select>$date</option>";
-    }
-    return $text . "</optgroup></select>";
-}
-
-/* vim: set expandtab enc=utf-8: */
-?>
diff --git a/plugins/function.xsrf_token.php b/plugins/function.xsrf_token.php
deleted file mode 100644 (file)
index caa0a10..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-function smarty_function_xsrf_token($params, &$smarty) {
-    return S::v('xsrf_token', '');
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/plugins/modifier.date_format.php b/plugins/modifier.date_format.php
deleted file mode 100644 (file)
index 7714f16..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-function smarty_modifier_date_format($string, $format = '%x', $default_date=null)
-{
-    $d = empty($string) ? $default_date : $string;
-    if (empty($format) || preg_match('/^[ 0\-]*$/', $d)) return;
-    $f = str_replace('%X', '%T', str_replace('%x', '%e %B %Y', $format));
-
-    if (preg_match('/^\d{14}$/', $d)) {
-        $t = mktime(substr($d,8,2), substr($d,10,2), substr($d,12,2), substr($d,4,2), substr($d,6,2), substr($d,0,4));
-    } elseif (preg_match('/^\d{8}$/', $d)) {
-        $t = mktime(0, 0, 0, substr($d,4,2), substr($d,6,2), substr($d,0,4));
-    } elseif (is_numeric($d)) {
-        $t = intval($d);
-    } else {
-        $t = strtotime($d);
-    }
-
-    if ( $t != -1 ) {
-        return strftime($f , $t);
-    } else {
-        require_once('Date.php');
-        $date = new Date($d);
-        return $date->format($f);
-    }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/plugins/modifier.htmlentities.php b/plugins/modifier.htmlentities.php
deleted file mode 100644 (file)
index 01dae76..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-require_once 'platal.inc.php';
-
-function smarty_modifier_htmlentities($string, $format = ENT_COMPAT)
-{
-    return pl_entities($string, $format);
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/plugins/modifier.number_format.php b/plugins/modifier.number_format.php
deleted file mode 100644 (file)
index 4b09833..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-function smarty_modifier_number_format($string, $decimal = 0)
-{
-    return number_format($string, $decimal, ',', '.');
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/plugins/modifier.uint_to_ip.php b/plugins/modifier.uint_to_ip.php
deleted file mode 100644 (file)
index a7076fa..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-function smarty_modifier_uint_to_ip($string)
-{
-    return uint_to_ip($string);
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
index d92c1c5..3a53289 100644 (file)
@@ -36,7 +36,7 @@
 </form>
 
 {if $promo}
-{include file="include/csv-importer.tpl"}
+{include core=csv-importer.tpl}
 {/if}
 
 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index a4ab3e3..f4c3bac 100644 (file)
@@ -46,6 +46,6 @@
 
 <h1>Ajout d'utilisateurs</h1>
 
-{include file="include/csv-importer.tpl"}
+{include core=csv-importer.tpl}
 
 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index e865ee2..af32d67 100644 (file)
@@ -87,7 +87,7 @@
     <tr class="pair">
       <td class="titre" colspan="2">
         <input type="checkbox" {if $xface}checked="checked"{/if} name="bananaxface" id="xface" />
-        <label for="xface">Afficher mon X-Face plutôt que ma photo sil est disponible</label>
+        <label for="xface">Afficher mon X-Face plutôt que ma photo s'il est disponible</label>
       </td>
     </tr>
   </table>
index 06d7647..2ae0319 100644 (file)
@@ -90,7 +90,7 @@
   Rechercher dans tes contacts&nbsp;:
 </p>
 
-{include file="core/plset.tpl"}
+{include core=plset.tpl}
 
 {/if}
 
index e8e2eb5..07725fc 100644 (file)
@@ -35,7 +35,7 @@ Tu trouveras les mêmes informations sur [[https://www.polytechnique.org/carnet/
 
 {foreach from=$u.data key=cid item=d}
 
-!{if $d|@count eq 1}{if $d[0].sexe}{$cats[$cid].mail_sg_xette}{else}{$cats[$cid].mail_sg}{/if}{else}{$cats[$cid].mail}{/if}:
+!{if $d|@count eq 1}{if $d[0].sexe}{$cats[$cid].mail_sg_xette}{else}{$cats[$cid].mail_sg}{/if}{else}{$cats[$cid].mail}{/if} :
 
 {foreach from=$d item=x}
 * (X{$x.promo}), le {$x.date|date_format:"%d %B %Y"}, [[https://www.polytechnique.org/profile/private/{$x.bestalias}|{$x.prenom} {$x.nom}]]
@@ -45,7 +45,7 @@ Tu trouveras les mêmes informations sur [[https://www.polytechnique.org/carnet/
 --
 L'Équipe de Polytechnique.org
 
-'''''Note:'''''  Tu reçois cet email car tu as activé la notification automatique par email des événements que tu surveilles.\\
+'''''Note :'''''  Tu reçois cet email car tu as activé la notification automatique par email des événements que tu surveilles.\\
 Tu peux changer cette option sur la [[https://www.polytechnique.org/carnet/notifs|page de configuration des notifications]].
 
 {/if}
index f1ccab1..8ffb32c 100644 (file)
@@ -31,7 +31,7 @@ S'il n'y a rien à te signaler l'email ne t'est pas envoyé.</p>
   <fieldset>
     <legend>Email</legend>
     <input type='checkbox' name='mail' onclick="this.form.submit();" {if $watch->watch_mail}checked="checked"{/if} />
-    Recevoir un email hebdomadaire des événements que je n'ai pas déjà vus sur le site<br />
+    Recevoir un email hebdomadaire des événements que je n'ai pas déjà vus sur le site.<br />
     <input type='hidden' name='flags_mail' value='valider' />
   </fieldset>
 </form>
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 0ec701e..b1b468a 100644 (file)
 {*                                                                        *}
 {**************************************************************************}
 
-<?xml version="1.0"?>
-<rss version="2.0">
-  <channel>
-    <title>Polytechnique.org :: Carnet</title>
-    <language>fr</language>
-    <link>{#globals.baseurl#}/carnet/panel</link>
-    <description>Ton carnet polytechnicien...</description>
-    <image>
-      <title>Polytechnique.org</title>
-      <url>{#globals.baseurl#}/images/logo.png</url>
-      <link>{#globals.baseurl#}/</link>
-    </image>
-    {foreach from=$notifs->_data item=c key=cid}
-    {foreach from=$c item=promo}
-    {foreach from=$promo item=x}
-    <item>
-      <title>
-        [{$notifs->_cats[$cid].short}] {$x.prenom} {$x.nom} ({$x.promo}) - le {$x.date|date_format}
-      </title>
-      <link>{#globals.baseurl#}/profile/private/{$x.bestalias}</link>
-      <guid isPermaLink="false">carnet{$x.known}{$cid}{$x.bestalias}</guid>
-      <description><![CDATA[
-        {if $x.data}{$x.prenom} {$x.nom} a mis à jours les données suivantes&nbsp;:<br />{$x.data}<br />{/if}
-        {if !$x.contact and !$x.dcd}
-        <a href="{#globals.baseurl#}/carnet/contacts?action=ajouter&amp;user={$x.bestalias}&amp;token={$rss_hash}">
-          {icon name=add title="Ajouter" full=true} Ajouter &agrave; mes contacts
-        </a><br />
-        {/if}
-        {if !$x.dcd}
-        <a href="{#globals.baseurl#}/vcard/{$x.bestalias}.vcf">
-          {icon name=vcard title="Carte de visite" full=true} T&eacute;l&eacute;charger la carte de visite &eacute;lectronique
-        </a>
-        {/if}
-        ]]></description>
-      <author>{$x.prenom} {$x.nom} (X{$x.promo})</author>
-      <pubDate>{$x.known|rss_date}</pubDate>
-    </item>
-    {/foreach}
-    {/foreach}
-    {/foreach}
-  </channel>
-</rss>
+{if $article->data}{$article->prenom} {$article->nom} a mis à jours les données suivantes&nbsp;:<br />{$article->data}<br />{/if}
+{if !$article->contact and !$article->dcd}
+<a href="{#globals.baseurl#}/carnet/contacts?action=ajouter&amp;user={$article->bestalias}&amp;token={$rss_hash}">
+  {icon name=add title="Ajouter" full=true} Ajouter &agrave; mes contacts
+</a><br />
+{/if}
+{if !$article->dcd}
+<a href="{#globals.baseurl#}/vcard/{$article->bestalias}.vcf">
+  {icon name=vcard title="Carte de visite" full=true} T&eacute;l&eacute;charger la carte de visite &eacute;lectronique
+</a>
+{/if}
 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
diff --git a/templates/core/403.tpl b/templates/core/403.tpl
deleted file mode 100644 (file)
index aeea268..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-{**************************************************************************}
-{*                                                                        *}
-{*  Copyright (C) 2003-2008 Polytechnique.org                             *}
-{*  http://opensource.polytechnique.org/                                  *}
-{*                                                                        *}
-{*  This program is free software; you can redistribute it and/or modify  *}
-{*  it under the terms of the GNU General Public License as published by  *}
-{*  the Free Software Foundation; either version 2 of the License, or     *}
-{*  (at your option) any later version.                                   *}
-{*                                                                        *}
-{*  This program is distributed in the hope that it will be useful,       *}
-{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}
-{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}
-{*  GNU General Public License for more details.                          *}
-{*                                                                        *}
-{*  You should have received a copy of the GNU General Public License     *}
-{*  along with this program; if not, write to the Free Software           *}
-{*  Foundation, Inc.,                                                     *}
-{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
-{*                                                                        *}
-{**************************************************************************}
-
-<h1 class="erreur">Tu n'as pas les permissions nécessaires pour accéder à cette page.</h1>
-
-{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
diff --git a/templates/core/404.tpl b/templates/core/404.tpl
deleted file mode 100644 (file)
index a606b54..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-{**************************************************************************}
-{*                                                                        *}
-{*  Copyright (C) 2003-2008 Polytechnique.org                             *}
-{*  http://opensource.polytechnique.org/                                  *}
-{*                                                                        *}
-{*  This program is free software; you can redistribute it and/or modify  *}
-{*  it under the terms of the GNU General Public License as published by  *}
-{*  the Free Software Foundation; either version 2 of the License, or     *}
-{*  (at your option) any later version.                                   *}
-{*                                                                        *}
-{*  This program is distributed in the hope that it will be useful,       *}
-{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}
-{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}
-{*  GNU General Public License for more details.                          *}
-{*                                                                        *}
-{*  You should have received a copy of the GNU General Public License     *}
-{*  along with this program; if not, write to the Free Software           *}
-{*  Foundation, Inc.,                                                     *}
-{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
-{*                                                                        *}
-{**************************************************************************}
-
-<h1 class="erreur">Cette page n'existe pas !!!</h1>
-
-{if $near}
-<p>L'adresse suivante semble correspondre à ta demande&nbsp;:<br />
-{icon name="lightbulb" title="Cherchais-tu ?"} <a href="{$globals->baseurl}/{$near}">{$globals->baseurl}/{$near}</a>
-</p>
-{/if}
-{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
diff --git a/templates/core/bug.tpl b/templates/core/bug.tpl
deleted file mode 100644 (file)
index 4b3d80a..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-{**************************************************************************}\r
-{*                                                                        *}\r
-{*  Copyright (C) 2003-2008 Polytechnique.org                             *}\r
-{*  http://opensource.polytechnique.org/                                  *}\r
-{*                                                                        *}\r
-{*  This program is free software; you can redistribute it and/or modify  *}\r
-{*  it under the terms of the GNU General Public License as published by  *}\r
-{*  the Free Software Foundation; either version 2 of the License, or     *}\r
-{*  (at your option) any later version.                                   *}\r
-{*                                                                        *}\r
-{*  This program is distributed in the hope that it will be useful,       *}\r
-{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}\r
-{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}\r
-{*  GNU General Public License for more details.                          *}\r
-{*                                                                        *}\r
-{*  You should have received a copy of the GNU General Public License     *}\r
-{*  along with this program; if not, write to the Free Software           *}\r
-{*  Foundation, Inc.,                                                     *}\r
-{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}\r
-{*                                                                        *}\r
-{**************************************************************************}\r
-\r
-<script type="text/javascript">//<![CDATA[\r
-{literal}\r
-var edited=false;\r
-\r
-function cleanContent()\r
-{\r
-  if (edited == false) {\r
-    var field = document.getElementById('flyspray_detail');\r
-    field.value = '';\r
-    field.style.color = "black";\r
-    field.style.textAlign = "left";\r
-  }\r
-}\r
-\r
-function fillContent()\r
-{\r
-  var field = document.getElementById('flyspray_detail');\r
-  if (field.value == '' || (field.value.toUpperCase() == field.value && field.value.toLowerCase() == field.value)) {\r
-    field.value = "** Explique ici le problème ou l'amélioration proposée **";\r
-    field.style.color = "gray";\r
-    field.style.textAlign = "center";\r
-    edited = false;\r
-  } else {\r
-    edited = true;\r
-  }\r
-}\r
-{/literal}\r
-//]]></script>\r
-\r
-<div style="width:800px;height:600px">\r
-{if $bug_sent}\r
-<p class="erreur">\r
-  Ton message a bien été envoyé au support de Polytechnique.org, tu devrais en\r
-  recevoir une copie d'ici quelques minutes. Nous allons le traiter et y répondre\r
-  dans les plus brefs délais.\r
-</p>\r
-\r
-<div class="center"><input type="submit" onclick="window.close()" name="close" value="Fermer" /></div>\r
-{else}\r
-<form action="send_bug" method="post" onsubmit="cleanContent()">\r
-  {xsrf_token_field}\r
-  <h1>Signaler un bug ou demander une amélioration</h1>\r
-  <div style="margin-left:10%;margin-right:10%">\r
-    <select name="task_type">\r
-      <option value="bug">Erreur</option>\r
-      <option value="wish">Souhait</option>\r
-      <option value="help">Aide/Dépannage</option>\r
-    </select>\r
-    &nbsp;&nbsp;Sujet&nbsp;: <input type="text" name="item_summary" id="flyspray_title" value="sur la page { $location }" size="50" maxlength="100"/>\r
-    <textarea name="detailed_desc" id="flyspray_detail" cols="70" rows="10" style="width:100%;margin-top:10px;margin-bottom:10px;height:400px;display:block;" onFocus="cleanContent()" onBlur="fillContent()"></textarea>\r
-    <input type="hidden" name="page" value="{$smarty.server.HTTP_REFERER|default:$smarty.request.page}" />\r
-    <div class="center">\r
-      <input type="button" value="Abandonner" onclick="window.close()"/>\r
-      <input type="submit" name="send" value="Envoyer"/>\r
-    </div>\r
-  </div>\r
-</form>\r
-<script type="text/javascript">\r
-  fillContent();\r
-</script>\r
-</div>\r
-{/if}\r
-\r
-{* vim:set et sws=2 sts=2 sw=2 enc=utf-8: *}\r
index 4bc7bb4..f3be2ff 100644 (file)
@@ -172,6 +172,7 @@ Si tu n'es pas {insert name="getName"}, change le login ci-dessous, ou rends-toi
 <!-- Set up the form with the challenge value and an empty reply value //-->
 <form action="{$smarty.server.REQUEST_URI}" method="post" id="loginsub">
   <div>
+    {xsrf_token_field}
     <input type="hidden" name="challenge" value="{$smarty.session.challenge}" />
     <input type="hidden" name="response"  value="" />
     <input type="hidden" name="xorpass"  value="" />
index 363959e..f3efb71 100644 (file)
@@ -51,7 +51,7 @@
       </td>
       <td>
         <input type="password" name="password" size="10" maxlength="10" />
-        &nbsp;<a href="recovery">Perdu ?</a>
+        &nbsp;<a href="recovery">Perdu&nbsp;?</a>
       </td>
       <td class="right" rowspan="2" style="vertical-align: middle">
         <input  type="submit" name="submitbtn" value="Envoyer" />
diff --git a/templates/core/plset.tpl b/templates/core/plset.tpl
deleted file mode 100644 (file)
index a0e4de1..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-{**************************************************************************}
-{*                                                                        *}
-{*  Copyright (C) 2003-2008 Polytechnique.org                             *}
-{*  http://opensource.polytechnique.org/                                  *}
-{*                                                                        *}
-{*  This program is free software; you can redistribute it and/or modify  *}
-{*  it under the terms of the GNU General Public License as published by  *}
-{*  the Free Software Foundation; either version 2 of the License, or     *}
-{*  (at your option) any later version.                                   *}
-{*                                                                        *}
-{*  This program is distributed in the hope that it will be useful,       *}
-{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}
-{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}
-{*  GNU General Public License for more details.                          *}
-{*                                                                        *}
-{*  You should have received a copy of the GNU General Public License     *}
-{*  along with this program; if not, write to the Free Software           *}
-{*  Foundation, Inc.,                                                     *}
-{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
-{*                                                                        *}
-{**************************************************************************}
-
-<div id="pl_set_top" style="clear: both">
-<h1 style="display: block; float: left">
-  {$plset_mods[$plset_mod]}
-  {if $plset_mods|@count > 1}[
-  {assign var=has_prev value=false}
-  {foreach from=$plset_mods key=mod item=desc name=mods}
-    {if $mod neq $plset_mod}
-    {if $has_prev}| {/if}
-    <a href="{$platal->ns}{$plset_base}/{$mod}{$plset_search}#pl_set_top">{$desc}</a>
-    {assign var=has_prev value=true}
-    {/if}
-  {/foreach}
-  ]
-  {/if}
-</h1>
-<h1 style="display: block; float: right"> 
-  {if !$plset_count} 
-  Aucune entrée 
-  {elseif $plset_count eq 1} 
-  1 entrée 
-  {else} 
-  {$plset_count} entrées 
-  {/if} 
-</h1> 
-</div>
-
-<div id="plset_content" style="clear: both">
-{include file=$plset_content}
-</div>
-
-{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
diff --git a/templates/core/plwizard.tpl b/templates/core/plwizard.tpl
deleted file mode 100644 (file)
index df409dd..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-{**************************************************************************}
-{*                                                                        *}
-{*  Copyright (C) 2003-2008 Polytechnique.org                             *}
-{*  http://opensource.polytechnique.org/                                  *}
-{*                                                                        *}
-{*  This program is free software; you can redistribute it and/or modify  *}
-{*  it under the terms of the GNU General Public License as published by  *}
-{*  the Free Software Foundation; either version 2 of the License, or     *}
-{*  (at your option) any later version.                                   *}
-{*                                                                        *}
-{*  This program is distributed in the hope that it will be useful,       *}
-{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}
-{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}
-{*  GNU General Public License for more details.                          *}
-{*                                                                        *}
-{*  You should have received a copy of the GNU General Public License     *}
-{*  along with this program; if not, write to the Free Software           *}
-{*  Foundation, Inc.,                                                     *}
-{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
-{*                                                                        *}
-{**************************************************************************}
-
-<script type="text/javascript">//<![CDATA[
-  {if ($stateless || $id gt $current) && $wiz_ajax}
-  {literal}
-  function changePage(obj, id)
-  {
-    var myUrl = obj.href;
-    $.ajax({ url: myUrl + "/ajax",
-             global: false,
-             dataTye: 'html',
-             error: function(request, error) {
-                      document.location = myUrl;
-                    },
-             success: function(data) {
-                        if (is_IE) {
-                          $(".wiz_tab").removeClass("active");
-                          $("#wiz_tab_" + id).addClass("active");
-                          $(".wiz_content").html(data);
-                          if (typeof wizPage_onLoad == 'function') {
-                              wizPage_onLoad(id);
-                          }
-                          auto_links();
-                        } else {
-                          $(".wiz_content").fadeOut('normal',
-                              function() {
-                                $(".wiz_tab").removeClass("active");
-                                $("#wiz_tab_" + id).addClass("active");
-                                $(".wiz_content").html(data).fadeIn('normal');
-                                if (typeof wizPage_onLoad == 'function') {
-                                  wizPage_onLoad(id);
-                                }
-                                auto_links();
-                              });
-                        }
-                      }
-          });
-    return false;
-  }
-  {/literal}
-  {else}
-  {literal}
-  function changePage(obj)
-  {
-    return true;
-  }
-  {/literal}
-  {/if}
-//]]></script>
-
-<div class="wizard" style="clear: both">
-  <div class="wiz_header">
-    {foreach from=$pages item=title key=id}
-    {if $stateless || $id gt $current}
-    {assign var=tag value="a"}
-    {else}
-    {assign var=tag value="div"}
-    {/if}
-    <{$tag} class="wiz_tab {if $id eq $current}active{/if} {if !$stateless && $current gt $id}grayed{/if}"
-            style="display: block; float: left; width: {$tab_width}%; vertical-align: middle"
-            id="wiz_tab_{$lookup[$id]}"
-            {if $tag eq "a"}
-            href="{$wiz_baseurl}/{$lookup[$id]}"
-            onclick="return changePage(this, '{$lookup[$id]}')"
-            {/if}
-            >
-      <span style="vertical-align: middle">{$title}</span>
-    </{$tag}>
-    {/foreach}
-    <div style="clear: both"></div>
-  </div>
-  <div class="wiz_content" style="clear: both">
-    {include file="skin/common.triggers.tpl"}
-    {include file=$wiz_page}
-  </div>
-</div>
-
-<script type="text/javascript">
-{literal}
-if (typeof wizPage_onLoad == 'function') {
-    wizPage_onLoad({/literal}'{$lookup[$current]}'{literal});
-}
-{/literal}
-</script>
-
-{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
diff --git a/templates/core/table-editor.tpl b/templates/core/table-editor.tpl
deleted file mode 100644 (file)
index df3b459..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-{**************************************************************************}
-{*                                                                        *}
-{*  Copyright (C) 2003-2008 Polytechnique.org                             *}
-{*  http://opensource.polytechnique.org/                                  *}
-{*                                                                        *}
-{*  This program is free software; you can redistribute it and/or modify  *}
-{*  it under the terms of the GNU General Public License as published by  *}
-{*  the Free Software Foundation; either version 2 of the License, or     *}
-{*  (at your option) any later version.                                   *}
-{*                                                                        *}
-{*  This program is distributed in the hope that it will be useful,       *}
-{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}
-{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}
-{*  GNU General Public License for more details.                          *}
-{*                                                                        *}
-{*  You should have received a copy of the GNU General Public License     *}
-{*  along with this program; if not, write to the Free Software           *}
-{*  Foundation, Inc.,                                                     *}
-{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
-{*                                                                        *}
-{**************************************************************************}
-
-
-<h1>{$title}</h1>
-
-{if $list}
-<script type="text/javascript">
-       {literal}
-       function redirect(a) {
-               document.location = a;
-       }
-       {/literal}
-</script>
-<table class="bicol">
-<tr>
-  {foreach from=$t->vars item=myval key=myvar}{if $myval.display}
-    <th style="cursor:pointer" onclick="redirect('{$t->pl}/sort{if $t->sortfield eq $myvar && !$t->sortdesc}desc{/if}/{$myvar}')">{$myval.desc}{if $t->sortfield eq $myvar}{if $t->sortdesc}{icon name="bullet_arrow_down"}{else}{icon name="bullet_arrow_up"}{/if}{/if}</th>
-  {/if}{/foreach}
-  {if !$hideactions}
-  <th>action</th>
-  {/if}
-</tr>
-{if !$readonly}
-<tr class="impair">
-  <td colspan="{$t->nbfields}">
-    <strong>
-      Nouvelles entrées&nbsp;: <a href="{$t->pl}/new">Manuellement</a> &bull; <a href="{$t->pl}/massadd">Depuis un CSV</a>
-    </strong>
-  </td>
-  <td class="right">
-    <a href="{$t->pl}/new">{icon name=add title='nouvelle entrée'}</a>
-  </td>
-</tr>
-{/if}
-{iterate from=$list item=myrow}
-<tr class="{cycle values="pair,impair"}">
-{foreach from=$t->vars item=myval}{if $myval.display}
-  <td>
-    {assign var="myfield" value=$myval.Field}
-    {if $myfield eq $t->idfield}
-        {assign var="idval" value=$myrow.$myfield}
-    {/if}
-    {if $myval.Type eq 'timestamp'}
-      <span class="smaller">{$myrow.$myfield|date_format:"%x %X"}</span>
-    {elseif $myval.Type eq 'checkbox'}
-      <input type="checkbox" disabled="disabled"{if $myrow.$myfield} checked="checked"{/if}/>
-    {elseif $myval.Type eq 'ip_address'}
-      {$myrow.$myfield|uint_to_ip}
-    {else}
-      {$myrow.$myfield}
-    {/if}
-  </td>
-{/if}{/foreach}
-  {if !$hideactions}
-  <td class="action">
-    {if !$readonly}
-    <a href="{$t->pl}/edit/{$idval}">{icon name=page_edit title='éditer'}</a>
-    <a href="{$t->pl}/delete/{$idval}?token={xsrf_token}">{icon name=delete title='supprimer'}</a>
-    {/if}
-  </td>
-  {/if}
-</tr>
-{/iterate}
-</table>
-
-{if ($p_prev > -1) || ($p_next > -1)}
-<p class="pagenavigation">
-{if $p_prev > -1}<a href="{$platal->path}?start={$p_prev}">{$msg_previous_page}</a>&nbsp;{/if}
-{if $p_next > -1}<a href="{$platal->path}?start={$p_next}">{$msg_next_page}</a>{/if}
-</p>
-{/if}
-
-{elseif $massadd}
-{include file="include/csv-importer.tpl"}
-
-<p>
-<a href="{$t->pl}">back</a>
-</p>
-
-{else}
-
-<form method="post" action="{$t->pl}/update/{$id}">
-  {xsrf_token_field}
-  <table class="bicol">
-    <tr class="impair">
-      <th colspan="2">
-        {if $id}
-            modification de l'entrée 
-        {else}
-            nouvelle entrée
-        {/if}
-      </th>
-    </tr>
-    {foreach from=$t->vars item=myval}{assign var="myfield" value=$myval.Field}{if ($myfield neq $t->idfield) or ($t->idfield_editable)}
-    <tr class="{cycle values="pair,impair"}">
-      <td>
-        <strong>{$myval.desc}</strong>
-      </td>
-      <td>
-        {if $myval.Type eq 'set'}
-          <select name="{$myfield}[]" multiple="multiple">
-            {foreach from=$myval.List item=option}
-              <option value="{$option}" {if $entry.$myfield.$option}selected="selected"{/if}>{$option}</option>
-            {/foreach}
-          </select>
-        {elseif $myval.Type eq 'enum'}
-          <select name="{$myfield}">
-            {foreach from=$myval.List item=option}
-              <option value="{$option}" {if $entry.$myfield eq $option}selected="selected"{/if}>{$option}</option>
-            {/foreach}
-          </select>
-        {elseif ($myval.Type eq 'textarea') or ($myval.Type eq 'varchar200')}
-          <textarea name="{$myfield}" rows="{if $myval.Type eq 'varchar200'}3{else}10{/if}" cols="70">{$entry.$myfield}</textarea>
-        {elseif ($myval.Type eq 'checkbox')}
-          <input type="checkbox" name="{$myfield}" value="{$myval.Value}"{if $entry.$myfield} checked="checked"{/if}/>
-        {else}
-          <input type="text" name="{$myfield}" value="{$entry.$myfield}" {if $myval.Size}size="{$myval.Size}" maxlength="{$myval.Maxlength}"{/if}/>
-          {if $myval.Type eq 'timestamp'}<em>jj/mm/aaaa hh:mm:ss</em>{/if}
-          {if $myval.Type eq 'date'}<em>jj/mm/aaaa</em>{/if}
-          {if $myval.Type eq 'time'}<em>hh:mm:ss</em>{/if}
-        {/if}
-      </td>
-    </tr>
-    {/if}{/foreach}
-  </table>
-
-  <p class="center">
-  <input type="submit" value="enregistrer" />
-  </p>
-
-</form>
-
-<p>
-<a href="{$t->pl}">back</a>
-</p>
-
-{/if}
-
-
-{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
diff --git a/templates/core/vcard.tpl b/templates/core/vcard.tpl
deleted file mode 100644 (file)
index d0524a1..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-{**************************************************************************}
-{*                                                                        *}
-{*  Copyright (C) 2003-2008 Polytechnique.org                             *}
-{*  http://opensource.polytechnique.org/                                  *}
-{*                                                                        *}
-{*  This program is free software; you can redistribute it and/or modify  *}
-{*  it under the terms of the GNU General Public License as published by  *}
-{*  the Free Software Foundation; either version 2 of the License, or     *}
-{*  (at your option) any later version.                                   *}
-{*                                                                        *}
-{*  This program is distributed in the hope that it will be useful,       *}
-{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}
-{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}
-{*  GNU General Public License for more details.                          *}
-{*                                                                        *}
-{*  You should have received a copy of the GNU General Public License     *}
-{*  along with this program; if not, write to the Free Software           *}
-{*  Foundation, Inc.,                                                     *}
-{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
-{*                                                                        *}
-{**************************************************************************}
-{iterate from=$users item=vcard}
-BEGIN:VCARD
-VERSION:3.0
-{if $vcard.nom_usage}
-FN:{$vcard.prenom|vcard_enc} {$vcard.nom_usage|vcard_enc} ({$vcard.nom|vcard_enc})
-{else}
-FN:{$vcard.prenom|vcard_enc} {$vcard.nom|vcard_enc}
-{/if}
-N:{$vcard.nom|vcard_enc};{$vcard.prenom|vcard_enc};{$vcard.nom_usage|vcard_enc};;
-{if $vcard.nickname}
-NICKNAME:{$vcard.nickname|vcard_enc}
-{/if}
-EMAIL;TYPE=internet,pref:{$vcard.bestalias}@{#globals.mail.domain#}
-EMAIL;TYPE=internet:{$vcard.bestalias}@{#globals.mail.domain2#}
-{if $vcard.bestalias neq $vcard.forlife}
-EMAIL;TYPE=internet:{$vcard.forlife}@{#globals.mail.domain#}
-EMAIL;TYPE=internet:{$vcard.forlife}@{#globals.mail.domain2#}
-{/if}
-{if $vcard.virtualalias}
-EMAIL;TYPE=internet:{$vcard.virtualalias}
-{/if}
-{if $vcard.mobile}
-TEL;TYPE=cell:{$vcard.mobile|vcard_enc}
-{/if}
-{if $vcard.adr_pro}
-{if $vcard.adr_pro[0].entreprise}
-ORG:{$vcard.adr_pro[0].entreprise|vcard_enc}
-{/if}
-{if $vcard.adr_pro[0].poste}
-TITLE:{$vcard.adr_pro[0].poste|vcard_enc}
-{/if}
-{if $vcard.adr_pro[0].fonction}
-ROLE:{$vcard.adr_pro[0].fonction|vcard_enc}
-{/if}
-{if $vcard.adr_pro[0].tel}
-TEL;TYPE=work:{$vcard.adr_pro[0].tel|vcard_enc}
-{/if}
-{if $vcard.adr_pro[0].fax}
-FAX;TYPE=work:{$vcard.adr_pro[0].fax|vcard_enc}
-{/if}
-ADR;TYPE=work:{format_adr adr=$vcard.adr_pro[0]}
-{/if}
-{foreach item=adr from=$vcard.adr}
-ADR;TYPE=home{if $adr.courier},postal{/if}:{format_adr adr=$adr}
-{foreach item=tel from=$adr.tels}
-{if $tel.tel}
-{if $tel.tel_type neq 'Fax'}TEL{else}FAX{/if};TYPE=home:{$tel.tel}
-{/if}
-{/foreach}
-{/foreach}
-{if $vcard.web}
-URL:{$vcard.web}
-{/if}
-{if strlen(trim($vcard.freetext)) == 0}
-NOTE:(X{$vcard.promo})
-{else}
-NOTE:(X{$vcard.promo})\n{$vcard.freetext|miniwiki:'no_title':'text'|vcard_enc}
-{/if}
-{if $vcard.section}
-X-SECTION:{$vcard.section}
-{/if}
-{if $vcard.binets_vcardjoin}
-X-BINETS:{$vcard.binets_vcardjoin}
-{/if}
-{if $vcard.gpxs_vcardjoin}
-X-GROUPS:{$vcard.gpxs_vcardjoin}
-{/if}
-{if $vcard.photo}
-PHOTO;ENCODING=b;TYPE={$vcard.photo.attachmime}:{$vcard.photo.attach|base64_encode|vcard_enc}
-{/if}
-SORT-STRING:{$vcard.nom|vcard_enc}
-REV:{$vcard.date|date_format:"%Y%m%dT000000Z"}
-END:VCARD{"\n"}
-{/iterate}
-{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
diff --git a/templates/core/wiki.help.tpl b/templates/core/wiki.help.tpl
deleted file mode 100644 (file)
index 216c6d9..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-{**************************************************************************}
-{*                                                                        *}
-{*  Copyright (C) 2003-2008 Polytechnique.org                             *}
-{*  http://opensource.polytechnique.org/                                  *}
-{*                                                                        *}
-{*  This program is free software; you can redistribute it and/or modify  *}
-{*  it under the terms of the GNU General Public License as published by  *}
-{*  the Free Software Foundation; either version 2 of the License, or     *}
-{*  (at your option) any later version.                                   *}
-{*                                                                        *}
-{*  This program is distributed in the hope that it will be useful,       *}
-{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}
-{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}
-{*  GNU General Public License for more details.                          *}
-{*                                                                        *}
-{*  You should have received a copy of the GNU General Public License     *}
-{*  along with this program; if not, write to the Free Software           *}
-{*  Foundation, Inc.,                                                     *}
-{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
-{*                                                                        *}
-{**************************************************************************}
-
-<h1>Syntaxe wiki</h1>
-
-<table class="bicol">
-  <tr><th>Syntaxe</th><th>Apparence</th></tr>
-  {foreach from=$wiki_help key=syntax item=html}
-  <tr class="{cycle values="pair,impair"}">
-    <td>{$syntax|nl2br}</td>
-    <td>{$html|smarty:nodefaults}</td>
-  </tr>
-  {/foreach}
-</table>
-
-{* vim:set et sws=2 sts=2 sw=2 enc=utf-8: *}
diff --git a/templates/core/wiki.tpl b/templates/core/wiki.tpl
deleted file mode 100644 (file)
index 8a76fa3..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-{**************************************************************************}
-{*                                                                        *}
-{*  Copyright (C) 2003-2008 Polytechnique.org                             *}
-{*  http://opensource.polytechnique.org/                                  *}
-{*                                                                        *}
-{*  This program is free software; you can redistribute it and/or modify  *}
-{*  it under the terms of the GNU General Public License as published by  *}
-{*  the Free Software Foundation; either version 2 of the License, or     *}
-{*  (at your option) any later version.                                   *}
-{*                                                                        *}
-{*  This program is distributed in the hope that it will be useful,       *}
-{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}
-{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}
-{*  GNU General Public License for more details.                          *}
-{*                                                                        *}
-{*  You should have received a copy of the GNU General Public License     *}
-{*  along with this program; if not, write to the Free Software           *}
-{*  Foundation, Inc.,                                                     *}
-{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
-{*                                                                        *}
-{**************************************************************************}
-
-{if $canedit || $has_perms}
-<table class='wiki' cellspacing='0' cellpadding='0'>
-  <tr>
-    <td>
-      <a href='{$wikipage}'>Voir la page</a>
-    </td>
-    {if $canedit}
-    <td>
-      <a href='{$wikipage}?action=edit'>Éditer la page</a>
-    </td>
-    {/if}
-  {if $has_perms}
-    <td>
-      <a href='{$wikipage}?action=diff'>Historique</a>
-    </td>
-    <td>
-      <a href='{$wikipage}?action=upload'>Upload</a>
-    </td>
-  </tr>
-  <tr>
-    <td>
-      <select onchange="dynpostkv('{$wikipage}', 'setrperms', this.value)">
-      {html_options options=$perms_opts selected=$perms[0]}
-      </select>
-    </td>
-    <td>
-      <select onchange="dynpostkv('{$wikipage}', 'setwperms', this.value)">
-      {html_options options=$perms_opts selected=$perms[1]}
-      </select>
-    </td>
-    <td colspan='2' style='text-align: left'>&lt;-- Droits associés</td>
-  {/if}
-  </tr>
-</table>
-{/if}
-
-{if $text}
-{$pmwiki|smarty:nodefaults}
-{else}
-{include file=$pmwiki_cache}
-{/if}
-{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index 41b5cf0..8c7d3aa 100644 (file)
 {/if}
 {if $retour == $smarty.const.ERROR_INVALID_EMAIL}
   <p class="erreur">
-  Erreur: l'email n'est pas valide.
+  Erreur&nbsp;: l'email n'est pas valide.
   </p>
 {/if}
 {if $retour == $smarty.const.ERROR_LOOP_EMAIL}
   <p class="erreur">
-  Erreur: {$smarty.session.forlife}@{#globals.mail.domain#} ne doit pas être renvoyé
+  Erreur&nbsp;: {$smarty.session.forlife}@{#globals.mail.domain#} ne doit pas être renvoyé
   vers lui-même, ni vers son équivalent en {#globals.mail.domain2#} ni vers polytechnique.edu.
   </p>
 {/if}
index feb1e81..ff9f08a 100644 (file)
@@ -22,6 +22,6 @@
 
 <h1>Aperçu de l'astuce</h1>
 {include file="include/tips.tpl" full=true tips=$entry nochange=true}
-{include file="core/table-editor.tpl"}
+{include core=table-editor.tpl}
 
 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index 52ae45d..1caa179 100644 (file)
 {*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
 {*                                                                        *}
 {**************************************************************************}
-
-<?xml version="1.0"?>
-<rss version="2.0">
-  <channel>
-    <title>{#globals.core.sitename#} :: News</title>
-    <language>fr</language>
-    <link>{#globals.baseurl#}/</link>
-    <description>L'actualite polytechnicienne...</description>
-    <image>
-      <title>{#globals.core.sitename#}</title>
-      <url>{#globals.baseurl#}/images/logo.png</url>
-      <link>{#globals.baseurl#}/</link>
-    </image>
-    {iterate item=line from=$rss}
-    <item>
-      <title>{$line.titre|strip_tags|htmlentities}</title>
-      <guid isPermaLink="false">{$line.id}</guid>
-      <link>{#globals.baseurl#}/events#newsid{$line.id}</link>
-      <description><![CDATA[
-        {if $line.photo}
-        <div style="float: left; padding-right: 0.5em">
-          <img src="{#globals.baseurl#}/events/photo/{$line.id}" alt="{$line.title}" />
-        </div>
-        {/if}
-        <div>{if $line.wiki}{$line.texte|miniwiki}{else}{$line.texte}{/if}</div>
-        {if $line.post_id neq -1}
-        <div style="clear: both">
-          <br />
-          <a href="{#globals.baseurl#}/banana/{#globals.banana.event_reply#|default:#globals.banana.event_forum#}/read/{$line.post_id}">
-          {icon name=comments full=true} Suivre la discussion
-          </a>
-        </div>
-        {/if}
-      ]]></description>
-      <author>{$line.prenom} {$line.nom} (X{$line.promo})</author>
-      <pubDate>{$line.creation_date|rss_date}</pubDate>
-    </item>
-    {/iterate}
-  </channel>
-</rss>
+{if $article->photo}
+<div style="float: left; padding-right: 0.5em">
+  <img src="{#globals.baseurl#}/events/photo/{$article->id}" alt="{$article->title|htmlentities}" />
+</div>
+{/if}
+<div>{if $article->wiki}{$article->texte|miniwiki}{else}{$article->texte}{/if}</div>
+{if $article->post_id neq -1}
+<div style="clear: both">
+  <br />
+  <a href="{#globals.baseurl#}/banana/{#globals.banana.event_reply#|default:#globals.banana.event_forum#}/read/{$article->post_id}">
+  {icon name=comments full=true} Suivre la discussion
+  </a>
+</div>
+{/if}
 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index f58fdf2..a8edfa8 100644 (file)
@@ -38,7 +38,7 @@ Dans les masques le <strong>*</strong> remplace n'importe quel texte et le <stro
 Les différentes règles sont appliquées par ordre de priorité décroissante.
 </p>
 
-{include file="core/table-editor.tpl"}
+{include core=table-editor.tpl}
 
 {literal}
 <script type="text/javascript">
index 244fda4..6ff4e13 100644 (file)
     <table cellspacing="0" cellpadding="0">
       {if $c.countrytxt || $c.city}
       <tr>
-        <td class="lt">Géographie:</td>
+        <td class="lt">Géographie&nbsp;:</td>
         <td class="rt">{$c.city}{if $c.city && $c.countrytxt}, {/if}{$c.countrytxt}</td>
       </tr>
       {/if}
       {if $c.mobile && !$c.dcd}
       <tr>
-        <td class="lt">Mobile:</td>
+        <td class="lt">Mobile&nbsp;:</td>
         <td class="rt">{$c.mobile}</td>
       </tr>
       {/if}
index 9292be0..0b8cedd 100644 (file)
   {if $account->g_suspension}
   <tr class="pair">
     <td>
-      Ton compte est actuellement suspendu pour la raison suivante: <em>{$account->g_suspension}</em>.
+      Ton compte est actuellement suspendu pour la raison suivante : <em>{$account->g_suspension}</em>.
     </td>
   </tr>
   {/if}
           Attention, cette opération changera ton mot de passe Google Apps.
         </li>
         <li>
-          Changer le mot de passe de ton compte Google Apps:<br /><br />
+          Changer le mot de passe de ton compte Google Apps&nbsp;:<br /><br />
           <form action="googleapps/password#password" method="post" id="changepass">
             <table class="tinybicol">
               <tr>
diff --git a/templates/include/csv-importer.tpl b/templates/include/csv-importer.tpl
deleted file mode 100644 (file)
index 0660a2c..0000000
+++ /dev/null
@@ -1,243 +0,0 @@
-{**************************************************************************}
-{*                                                                        *}
-{*  Copyright (C) 2003-2008 Polytechnique.org                             *}
-{*  http://opensource.polytechnique.org/                                  *}
-{*                                                                        *}
-{*  This program is free software; you can redistribute it and/or modify  *}
-{*  it under the terms of the GNU General Public License as published by  *}
-{*  the Free Software Foundation; either version 2 of the License, or     *}
-{*  (at your option) any later version.                                   *}
-{*                                                                        *}
-{*  This program is distributed in the hope that it will be useful,       *}
-{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}
-{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}
-{*  GNU General Public License for more details.                          *}
-{*                                                                        *}
-{*  You should have received a copy of the GNU General Public License     *}
-{*  along with this program; if not, write to the Free Software           *}
-{*  Foundation, Inc.,                                                     *}
-{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
-{*                                                                        *}
-{**************************************************************************}
-
-{if $form_title}
-<h1>{$form_title}</h1>
-{/if}
-
-<script type="text/javascript">//<![CDATA[
-{literal}
-  function showValue(key, box)
-  {
-    var span_value = document.getElementById('csv_user_value_span[' + key + ']');
-    var span_cond  = document.getElementById('csv_cond_value_span[' + key + ']');
-    var i    = box.selectedIndex;
-    if (box.options[i].value == "user_value") {
-      span_value.style.display = "";
-      span_cond.style.display = "none";
-    } else if(box.options[i].value == "cond_value") {
-      span_value.style.display = "none";
-      span_cond.style.display = "";
-    } else {
-      span_value.style.display = "none";
-      span_conf.style.display = "none";
-    }
-  }
-  function showCond(key, box)
-  {
-    var line = document.getElementById('csv_cond_value[' + key + ']');
-    var i    = box.selectedIndex;
-    if (box.options[i].value == "defined") {
-      line.style.display = "none";
-    } else {
-      line.style.display = "";
-    }
-  }
-  function gotoPage(page)
-  {
-    document.getElementById('csv_next_page').value = page;
-    document.getElementById('csv_form').submit();
-    return false;
-  }
-{/literal}
-//]]></script>
-<form action="{$csv_path}" method="post" id="csv_form">
-  {xsrf_token_field}
-  <div class="center" style="padding-bottom: 1em">
-    Import d'un CSV&nbsp;:
-    {if $csv_page eq 'source'}
-    <span class="erreur">Choisir la source</span>
-    {else}
-    <a href="{$csv_path}" onclick="return gotoPage('source');">Choisir la source</a>
-    {/if}
-    »
-    {if $csv_page eq 'values'}
-    <span class="erreur">Définir les valeurs</span>
-    {elseif $smarty.session.csv}
-    <a href="{$csv_path}" onclick="return gotoPage('values');">Définir les valeurs</a>
-    {else}
-    Définir les valeurs
-    {/if}
-    »
-    {if $csv_page eq 'valid'}
-    <span class="erreur">Vérifier et valider</span>
-    {elseif $csv_action}
-    <a href="{$csv_path}" onclick="return gotoPage('valid');">Vérifier et valider</a>
-    {else}
-    Vérifier et valider
-    {/if}
-  </div>
-  {if $csv_page eq 'source'}
-  <div>
-    <textarea name="csv_source" rows="20" cols="80">{$smarty.session.csv|default:$smarty.session.csv_source}</textarea><br />
-    Entrez les données sous la forme suivante (avec
-    <input type="text" name="csv_separator" value="{$smarty.session.csv_separator|default:";"}" maxlength="1" size="1" />
-    comme séparateur)&nbsp;:<br/>
-    <pre class="center">TITRE1{$smarty.session.csv_separator|default:";"}TITRE2{$smarty.session.csv_separator|default:";"}...
-val1_1{$smarty.session.csv_separator|default:";"}val1_2{$smarty.session.csv_separator|default:";"}...
-val2_1{$smarty.session.csv_separator|default:";"}val2_2{$smarty.session.csv_separator|default:";"}...
-val3_1{$smarty.session.csv_separator|default:";"}val3_2{$smarty.session.csv_separator|default:";"}...</pre>
-  </div>
-  {elseif $csv_page eq 'values'}
-  <div class="center">
-    Action à effectuer si l'entrée existe&nbsp;: 
-    <select name="csv_action" onchange="this.form.submit()">
-      <option value="insert" {if $smarty.session.csv_action eq 'insert'}selected="selected"{/if}>
-        ne rien faire
-      </option>
-      <option value="replace" {if $smarty.session.csv_action eq 'replace'}selected="selected"{/if}>
-        remplacer par la nouvelle entrée
-      </option>
-      {if $csv_key}
-      <option value="update" {if $smarty.session.csv_action eq 'update'}selected="selected"{/if}>
-        mettre à jour les champs sélectionnés
-      </option>
-      {/if}
-    </select>
-  </div>
-  <table class="bicol">
-    <tr>
-      <th>Champ</th>
-      <th colspan="2">Valeur</th>
-      {if $smarty.session.csv_action eq 'update'}
-      <th>MàJ</th>
-    {/if}
-    </tr>
-    {foreach from=$csv_fields item=f}
-    <tr class="{cycle values="pair,impair"}">
-      <td>{$csv_field_desc[$f]|default:$f}</td>
-      <td>
-        <select name="csv_value[{$f}]" onchange="showValue('{$f}', this);">
-          <option value="" {if !$smarty.session.csv_value[$f]}selected="selected"{/if}>
-            Vide
-          </option>
-          <option value="user_value" {if $smarty.session.csv_value[$f] eq "user_value"}selected="selected"{/if}>
-            Entrer la valeur
-          </option>
-          <option value="cond_value" {if $smarty.session.csv_value[$f] eq "cond_value"}selected="selected"{/if}>
-            Valeur conditionnelle
-          </option>
-          <optgroup label="Colonnes du CSV">
-            {foreach from=$csv_index item=col}
-            <option value="{$col}" {if $smarty.session.csv_value[$f] eq $col}selected="selected"{/if}>{$col}</option>
-            {/foreach}
-          </optgroup>
-          {if $csv_functions|count}
-          <optgroup label="Fonctions">
-            {foreach from=$csv_functions key=func item=desc}
-            <option value="{$func}" {if $smarty.session.csv_value[$f] eq $func}selected="selected"{/if}>{$desc.desc}</option>
-            {/foreach}
-          </optgroup>
-          {/if}
-        </select>
-      </td>
-      <td>
-        <span id="csv_user_value_span[{$f}]" {if $smarty.session.csv_value[$f] neq "user_value"}style="display: none"{/if}>
-          <input type="text" name="csv_user_value[{$f}]" value="{$smarty.session.csv_user_value[$f]}" />
-        </span>
-        <span id="csv_cond_value_span[{$f}]" {if $smarty.session.csv_value[$f] neq "cond_value"}style="display: none"{/if}>
-          Si
-          <select name="csv_cond_field[{$f}]">
-            {foreach from=$csv_index item=col}
-            <option value="{$col}" {if $smarty.session.csv_cond_field_value[$f] eq $col}selected="selected"{/if}>
-              {$col}
-            </option>
-            {/foreach}
-          </select>
-          <select name="csv_cond[{$f}]" onchange="showCond('{$f}', this)">
-            <option value="defined" {if $smarty.session.csv_cond[$f] eq "defined"}selected="selected"{/if}>
-              défini
-            </option>
-            <option value="equals" {if $smarty.session.csv_cond[$f] eq "equals"}selected="selected"{/if}>
-              est égale à
-            </option>
-            <option value="contains" {if $smarty.session.csv_cond[$f] eq "contains"}selected="selected"{/if}>
-              contient
-            </option>
-            <option value="contained" {if $smarty.session.csv_cond[$f] eq "contained"}selected="selected"{/if}>
-              est contenu dans
-            </option>
-            <option value="greater" {if $smarty.session.csv_cond[$f] eq "greater"}selected="selected"{/if}>
-              supérieur à
-            </option>
-            <option value="greater_or_equal" {if $smarty.session.csv_cond[$f] eq "greater_or_equal"}selected="selected"{/if}>
-              supérieur ou égal à
-            </option>
-            <option value="lower" {if $smarty.session.csv_cond[$f] eq "lower"}selected="selected"{/if}>
-              inférieur à
-            </option>
-            <option value="lower_or_equal" {if $smarty.session.csv_cond[$f] eq "lower_or_equal"}selected="selected"{/if}>
-              inférieur ou égal à
-            </option>
-          </select>
-          <span id="csv_cond_value[{$f}]" {if $smarty.session.csv_cond[$f] eq "defined" || !$smarty.session.csv_cond[$f]}style="display: none"{/if}>
-            <input type="text" name="csv_cond_value[{$f}]" value="{$smarty.session.csv_cond_value[$f]}" />
-          </span>
-          <br />Alors <input type="text" name="csv_cond_then[{$f}]" value="{$smarty.session.csv_cond_then[$f]}" />
-          <br />Sinon <input type="text" name="csv_cond_else[{$f}]" value="{$smarty.session.csv_cond_else[$f]}" />
-        </span>
-      </td>
-      {if $smarty.session.csv_action eq 'update'}
-      <td class="center">
-        <input type="checkbox" name="csv_update[{$f}]" {if $smarty.session.csv_update[$f]}checked="checked"{/if} />
-      </td>
-      {/if}
-    </tr>
-    {/foreach}
-  </table>
-  {elseif $csv_page eq 'valid'}
-  {if !$csv_done}
-  <table class="bicol">
-    <tr>
-      {foreach from=$csv_fields item=f}
-      <th>{$csv_field_desc[$f]|default:$f}</th>
-      {/foreach}
-    </tr>
-    {foreach from=$csv_preview item=assoc}
-    <tr class="{cycle values="pair,impair"}">
-      {foreach from=$csv_fields item=f}
-      <td>{$assoc[$f]}</td>
-      {/foreach}
-    <tr>
-    {/foreach}
-  </table>
-  {else}
-  Les données ont été ajoutées.
-  {/if}
-  {/if}
-
-  {if !$csv_done}
-  <div class="center">
-    <input type="hidden" name="csv_page" value="{$csv_page}" />
-    <input type="hidden" id="csv_next_page" name="csv_next_page" value="{$csv_page}" />
-    {if $csv_page eq 'source'}
-    <input type="submit" name="csv_valid" value="Changer le CSV" />
-    {elseif $csv_page eq 'values'}
-    <input type="submit" name="csv_valid" value="Aperçu" />
-    {elseif $csv_page eq 'valid'}
-    <input type="submit" name="csv_valid" value="Valider" />
-    {/if}
-  </div>
-  {/if}
-</form>
-
-{* vim:set et sws=2 sts=2 sw=2 enc=utf-8: *}
index a724ca8..ac48047 100644 (file)
        <table>
         {if $address.entreprise || $address.web}
         <tr>
-          <td><em>Ent/Org: </em></td>
+          <td><em>Ent/Org&nbsp;: </em></td>
           <td><strong>{$address.entreprise}{if $address.web} [<a href='{$address.web}'>site</a>]{/if}</strong></td>
         </tr>
         {/if}
         {if $address.secteur}
         <tr>
-          <td><em>Secteur: </em></td>
+          <td><em>Secteur&nbsp;: </em></td>
           <td><strong>{$address.secteur}{if $address.ss_secteur} ({$address.ss_secteur}){/if}</strong></td>
         </tr>
         {/if}
 
         {if $address.fonction}
         <tr>
-          <td><em>Fonction: </em></td>
+          <td><em>Fonction&nbsp;: </em></td>
           <td><strong>{$address.fonction}</strong></td>
         </tr>
         {/if}
         {if $address.poste}
         <tr>
-          <td><em>Poste: </em></td>
+          <td><em>Poste&nbsp;: </em></td>
           <td><strong>{$address.poste}</strong></td>
         </tr>
         {/if}
index 9cf5cf0..5b881c0 100644 (file)
 {if $withtext}
 <a href="Xorg/FAQ?display=light#flags" class="popup_800x240">Quelle couleur ?</a>
 {/if}
-<input type="radio" name="{$name}" value="public" {if $val eq 'public'}checked="checked"{/if}
+<label><input type="radio" name="{$name}" value="public" {if $val eq 'public'}checked="checked"{/if}
        {if $disabled}disabled="disabled"{/if}/>
 {icon name="flag_green" title="site public"}
-{if $withtext}<span class="texte">site public</span>{/if}
-<input type="radio" name="{$name}" value="ax" {if $val eq 'ax'}checked="checked"{/if}
+{if $withtext}<span class="texte">site public</span>{/if}</label>
+<label><input type="radio" name="{$name}" value="ax" {if $val eq 'ax'}checked="checked"{/if}
        {if $disabled}disabled="disabled"{/if}/>
 {icon name="flag_orange" title="transmis à l'AX"}
-{if $withtext}<span class="texte">transmis à l'AX</span>{/if}
-<input type="radio" name="{$name}" value="private" {if $val eq 'private' || (!$val && !$disabled)}checked="checked"{/if}
+{if $withtext}<span class="texte">transmis à l'AX</span>{/if}</label>
+<label><input type="radio" name="{$name}" value="private" {if $val eq 'private' || (!$val && !$disabled)}checked="checked"{/if}
        {if $disabled}disabled="disabled"{/if}/>
 {icon name="flag_red" title="privé"}
-{if $withtext}<span class="texte">privé</span>{/if}
+{if $withtext}<span class="texte">privé</span>{/if}</label>
 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index 862b22b..50ca5f4 100644 (file)
@@ -64,6 +64,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}
diff --git a/templates/include/plview.multipage.tpl b/templates/include/plview.multipage.tpl
deleted file mode 100644 (file)
index edd3313..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-{**************************************************************************}
-{*                                                                        *}
-{*  Copyright (C) 2003-2008 Polytechnique.org                             *}
-{*  http://opensource.polytechnique.org/                                  *}
-{*                                                                        *}
-{*  This program is free software; you can redistribute it and/or modify  *}
-{*  it under the terms of the GNU General Public License as published by  *}
-{*  the Free Software Foundation; either version 2 of the License, or     *}
-{*  (at your option) any later version.                                   *}
-{*                                                                        *}
-{*  This program is distributed in the hope that it will be useful,       *}
-{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}
-{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}
-{*  GNU General Public License for more details.                          *}
-{*                                                                        *}
-{*  You should have received a copy of the GNU General Public License     *}
-{*  along with this program; if not, write to the Free Software           *}
-{*  Foundation, Inc.,                                                     *}
-{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
-{*                                                                        *}
-{**************************************************************************}
-
-{capture name=pages}
-{if $plview->pages > 1}
-  {if $show_bounds}<div style="float: right"><small><strong>[{$first} - {$last}]&nbsp;</strong></small></div>{/if}
-<div class="center pages" style="float: left">
-  {if $plview->page neq 1}
-  <a href="{$platal->pl_self()}{$plset_search}order={$order}&amp;page=1#pl_set_top">{icon name=resultset_first title="Première page"}</a>{*
-  *}<a href="{$platal->pl_self()}{$plset_search}order={$order}&amp;page={$plview->page-1}#pl_set_top">{icon name=resultset_previous title="Page précédente"}</a>
-  {else}
-  {icon name=null title=""}{icon name=null title=""}
-  {/if}
-  {section name=page loop=$plview->pages+1 start=1}
-  {if $smarty.section.page.index eq $plview->page}
-  <span style="color: red">{$plview->page}</span> 
-  {else}
-  <a href="{$platal->pl_self()}{$plset_search}order={$order}&amp;page={$smarty.section.page.index}#pl_set_top">{$smarty.section.page.index}</a>
-  {/if}
-  {/section}
-  {if $plview->page neq $plview->pages}
-  <a href="{$platal->pl_self()}{$plset_search}order={$order}&amp;page={$plview->page+1}#pl_set_top">{icon name=resultset_next title="Page suivante"}</a>{*
-  *}<a href="{$platal->pl_self()}{$plset_search}order={$order}&amp;page={$plview->pages}#pl_set_top">{icon name=resultset_last title="Dernière page"}</a>
-  {else}
-  {icon name=null title=""}{icon name=null title=""}
-  {/if}
-</div>
-{/if}
-{/capture}
-
-{capture name=order}
-{if $plset_count > 1}
-<div style="clear: both">
-  Trier par&nbsp;:
-  {foreach from=$orders key=name item=sort}
-  [
-  {if $name eq $order}
-  <img src='images/dn.png' alt='tri ascendant' />
-  <a href="{$platal->pl_self()}{$plset_search}order=-{$name}#pl_set_top">{$sort.desc}</a>
-  {elseif $order eq "-$name"}
-  <img src='images/up.png' alt='tri ascendant' />
-  <a href="{$platal->pl_self()}{$plset_search}order={$name}#pl_set_top">{$sort.desc}</a>
-  {else}
-  <a href="{$platal->pl_self()}{$plset_search}order={$name}#pl_set_top">{$sort.desc}</a>
-  {/if}
-  ]&nbsp;
-  {/foreach}
-</div>
-{/if}
-{/capture}
-
-
-{$smarty.capture.order|smarty:nodefaults}
-
-{$smarty.capture.pages|smarty:nodefaults}
-
-<div id="multipage_content" style="padding: 0.5em 0; clear: both">
-  {include file=$plview->templateName()}
-</div>
-
-{$smarty.capture.pages|smarty:nodefaults}<br />
-
-{$smarty.capture.order|smarty:nodefaults}
-
-{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index 1390e1f..b5e214f 100644 (file)
@@ -66,7 +66,7 @@
   </tr>
 </table>
 
-{include file="core/plset.tpl"}
+{include core=plset.tpl}
 
 <h1>
   modérateurs de la liste
index 522fdee..14a12cf 100644 (file)
@@ -26,7 +26,7 @@
 {if $options|@count}
 <table class='bicol' cellpadding='2' cellspacing='0'>
   <tr><th colspan='3'>Options incorrectes pour {$details.addr}</th></tr>
-  <tr><th>champs</th><th>devrait être:</th><th>est ...</th></tr>
+  <tr><th>champs</th><th>devrait être :</th><th>est ...</th></tr>
   {foreach from=$options key=k item=o}
   <tr>
     <td class='titre'>{$k}</td>
index b1066cc..d77a3e1 100644 (file)
@@ -32,7 +32,7 @@
       <td>{$del_user.name}</td>
     </tr>
     <tr>
-      <td>raison:
+      <td>raison&nbsp;:
         <textarea cols='50' rows='10' name='reason'></textarea>
       </td>
     </tr>
index d15d4a6..aee32ff 100644 (file)
@@ -76,7 +76,7 @@ sa dernière relance date du {$relance|date_format}
     {/iterate}
     <tr>
       <td></td>
-      <td colspan='5' class='smaller'>(*): email perso</td>
+      <td colspan='5' class='smaller'>(*)&nbsp;: email perso</td>
     </tr>
     <tr>
       <td>
@@ -103,7 +103,7 @@ sa dernière relance date du {$relance|date_format}
       <th colspan="2">Edition de l'email de relance</th>
     </tr>
     <tr class="pair">
-      <td align="right"><strong>From:</strong></td>
+      <td align="right"><strong>From&nbsp;:</strong></td>
       <td>
         {if $rel_from_staff neq $rel_from_user}
         <select name="from">
@@ -116,18 +116,18 @@ sa dernière relance date du {$relance|date_format}
       </td>
     </tr>
     <tr class="pair">
-      <td align="right"><strong>To:</strong></td>
+      <td align="right"><strong>To&nbsp;:</strong></td>
       <td>
         <input type="text" value="{$rel_to}" name="to" size="40" maxlength="100" />
         <input type="submit" name="valider" value="Envoyer" />
       </td>
     </tr>
     <tr class="pair">
-      <td align="right"><strong>Objet:</strong></td>
+      <td align="right"><strong>Objet&nbsp;:</strong></td>
       <td><input type="text" name="title" value="{$rel_title}" size="50" maxlength="100" /></td>
     </tr>
     <tr class="pair">
-      <td align="right"><strong>Message:</strong></td>
+      <td align="right"><strong>Message&nbsp;:</strong></td>
       <td>
         <textarea name="message" rows="40" cols="60">{$rel_text}</textarea>
       </td>
index c887968..5ba0dbe 100644 (file)
@@ -26,7 +26,7 @@
     <a href="marketing/promo/{$promo-1}" title="-1"><img src="images/icons/resultset_previous.gif" alt="[&lt;]" /></a>
 
     &nbsp;
-    Promo:<input type="text" name="promo" value="{$promo}" size="4" maxlength="4" /><input type="submit" value="GO" />
+    Promo&nbsp;:<input type="text" name="promo" value="{$promo}" size="4" maxlength="4" /><input type="submit" value="GO" />
     &nbsp;
 
     <a href="marketing/promo/{$promo+1}" title="+1"><img src="images/icons/resultset_next.gif" alt="[&gt;]" /></a>
@@ -58,7 +58,7 @@
       <td>{if $it.last_known_email}{mailto address=$it.last_known_email}{/if}</td>
       <td class="center">
         {if $it.dern_rel && $it.dern_rel != '0000-00-00'}
-        Relance le: {$it.dern_rel}
+        Relance le&nbsp;: {$it.dern_rel}
         {elseif $it.email}
         En cours&nbsp;: {$it.email}
         {else}
index 156a1eb..e7b0a49 100644 (file)
@@ -23,7 +23,7 @@
 
 <h1>Télépaiements</h1>
 
-{if $smarty.request.op eq "submit" and !$xorg_errors}
+{if $smarty.request.op eq "submit" and !$pl_errors}
 
 <table class="bicol">
   <tr>
index c7968ff..de808fa 100644 (file)
@@ -63,7 +63,7 @@ En voici les adresses&nbsp;:
 Tu peux le désactiver en allant dans Préférences et en cliquant sur "désactiver les fils RSS".
 </p>
 <p>
-Attention: désactiver, puis réactiver le fil RSS en change l'adresse.
+Attention&nbsp;: désactiver, puis réactiver le fil RSS en change l'adresse.
 </p>
 <p>[<a href="{$goback}">retour à la page dont tu venais</a>]</p>
 {/if}
index 10ec28f..983dbdb 100644 (file)
@@ -31,7 +31,7 @@
 </p>
 <p>
   Pour une sécurité optimale, ton mot de passe circule de manière chiffrée (https) et est
-  stocké chiffrée irréversiblement sur nos serveurs.
+  stocké chiffré irréversiblement sur nos serveurs.
 </p>
 <br />
 <form action="{$smarty.server.REQUEST_URI}" method="post" id="changepass">
index fe8e526..a8e0f9e 100644 (file)
@@ -20,7 +20,7 @@
 {*                                                                        *}
 {**************************************************************************}
 
-{include file="core/table-editor.tpl"}
+{include core=table-editor.tpl}
 
 <h1>Administration Polytechnique.org</h1>
 
index 368671f..84b1409 100644 (file)
@@ -29,8 +29,8 @@
   <tr>
     <td>
       <div class="flags">
-        <input type="checkbox" name="medals_pub"{if $medals_pub eq 'public'} checked="checked"{/if} />
-        {icon name="flag_green" title="site public"}
+        <label><input type="checkbox" name="medals_pub"{if $medals_pub eq 'public'} checked="checked"{/if} />
+        {icon name="flag_green" title="site public"}</label>
         <span class="texte">
           bien que publiques (JO, ...), tu peux choisir de ne pas associer ces informations à ta fiche publique
         </span>
index 8ff2c03..0203991 100644 (file)
 {/if}
 
 <table class="bicol"  style="margin-bottom: 1em"
-  summary="Profil: Trombinoscope">
+  summary="Profil&nbsp;: Trombinoscope">
   <tr>
     <th colspan="2">
       <div class="flags" style="float: left">
-        <input type="checkbox" name="photo_pub" {if $photo_pub eq 'public'}checked="checked" {/if}/>
-        {icon name="flag_green" title="site public"}
+        <label><input type="checkbox" name="photo_pub" {if $photo_pub eq 'public'}checked="checked" {/if}/>
+        {icon name="flag_green" title="site public"}</label>
       </div>
       Trombinoscope
     </th>
 </table>
 
 <table class="bicol" style="margin-bottom: 1em"
-  summary="Profil: Divers">
+  summary="Profil&nbsp;: Divers">
   <tr>
     <th colspan="2">
       Divers
   <tr>
     <td>
       <span class="flags">
-        <input type="checkbox" name="web_pub" {if $web_pub eq 'public'}checked="checked"{/if} />
-        {icon name="flag_green" title="site public"}
+        <label><input type="checkbox" name="web_pub" {if $web_pub eq 'public'}checked="checked"{/if} />
+        {icon name="flag_green" title="site public"}</label>
       </span>&nbsp;
       <span class="titre">Page web Perso</span>
     </td>
     <td>
       <div>
         <span class="flags">
-          <input type="checkbox" name="freetext_pub" {if $freetext_pub eq 'public'}checked="checked"{/if} />
-          {icon name="flag_green" title="site public"}
+          <label><input type="checkbox" name="freetext_pub" {if $freetext_pub eq 'public'}checked="checked"{/if} />
+          {icon name="flag_green" title="site public"}</label>
         </span>&nbsp;
         <span class="titre">Complément libre</span><br />
         <span class="comm">Commentaire ? ICQ ? etc...</span>
index 29829cd..09220c7 100644 (file)
@@ -20,7 +20,7 @@
 {*                                                                        *}
 {**************************************************************************}
 
-<table class="bicol" style="margin-bottom: 1em" summary="Profil: Informations Polytechniciennes">
+<table class="bicol" style="margin-bottom: 1em" summary="Profil&nbsp;: Informations Polytechniciennes">
   <tr>
     <th colspan="2">
       <div class="flags" style="float: left">
index 70c269b..7521a28 100644 (file)
@@ -44,7 +44,7 @@
   <li>ou bien, plus âgés, qui souhaitent réorienter leur carrière.</li>
 </ul>
 
-<table class="bicol" style="margin-bottom: 1em" summary="Profil: Mentoring">
+<table class="bicol" style="margin-bottom: 1em" summary="Profil&nbsp;: Mentoring">
   <tr>
     <th>
       <div class="flags" style="float: left">
@@ -79,7 +79,7 @@
   </tr>
 </table>
 
-<table class="bicol" style="margin-bottom: 1em" summary="Profil: Mentoring">
+<table class="bicol" style="margin-bottom: 1em" summary="Profil&nbsp;: Mentoring">
   <tr>
     <th>
       <div class="flags" style="float: left">
   </tr>
 </table>
 
-<table class="bicol" summary="Profil: Mentoring">
+<table class="bicol" summary="Profil&nbsp;: Mentoring">
   <tr>
     <th>
       <div class="flags" style="float: left">
index 3e3feea..0be0c9b 100644 (file)
@@ -22,7 +22,7 @@
 
 
 {if $plset_count}
-{include file="core/plset.tpl"}
+{include core=plset.tpl}
 {else}
 {include wiki=Docs.Emploi}
 {/if}
index acb6553..1cdde60 100644 (file)
@@ -47,7 +47,7 @@
     <tr class="pair">
       <td></td>
       <td>
-        6 chiffres terminant par le numéro d'entrée (ex: 
+        6 chiffres terminant par le numéro d'entrée (ex 
         {if $promo < 2000}
         {math equation="promo % 100" promo=$promo}0532)<br />
         {else}
index 3c6a5ba..3aba3c2 100644 (file)
@@ -36,7 +36,9 @@
           return '...';
         }
 
-        return name + '<em>&nbsp;&nbsp;-&nbsp;&nbsp;' + row[1] + ' camarades<\/em>';
+        camarades = (row[1] > 1) ? "camarades" : "camarade";
+
+        return name + '<em>&nbsp;&nbsp;-&nbsp;&nbsp;' + row[1] + '&nbsp;' + camarades + '<\/em>';
       };
   }
 
       $("[@name='diploma']").parent().load(baseurl + 'list/diploma/', { school:schoolId }, function() {
           if ($("select[@name='diploma']").children("option").size() > 1) {
             $("select[@name='diploma']").attr('value', '{/literal}{$smarty.request.diploma}{literal}');
-
-            $("tr#diploma_ln").show();
           } else {
             $("select[@name='diploma']").attr('value', '');
-
-            $("tr#diploma_ln").hide();
           }
         });
     } else {
       $(".autocomplete[@name='schoolTxt']").removeClass('hidden_valid');
 
       $("select[@name='diploma']").attr('value', '');
-
-      $("tr#diploma_ln").hide();
     }
   }
 
       <th colspan="2">Géographie</th>
     </tr>
     <tr>
-      <td>Ville</td>
+      <td>Ville ou code postal</td>
       <td><input type="text" class="autocomplete" name="city" size="32" value="{$smarty.request.city}" /></td>
     </tr>
     <tr>
@@ -398,10 +394,10 @@ checked="checked"{/if}/>Chercher uniquement les adresses où les camarades sont
         <a href="school" class="autocompleteToSelect">{icon name="table" title="Toutes les formations"}</a>
       </td>
     </tr>
-    <tr id="diploma_ln">
+    <tr>
       <td>Diplôme</td>
       <td>
-        <input name="diploma" type="hidden" size="32" value="{$smarty.request.diploma}"/>
+        <input name="diploma" size="32" value="{$smarty.request.diploma}"/>
       </td>
     </tr>
     <tr>
@@ -415,6 +411,12 @@ checked="checked"{/if}/>Chercher uniquement les adresses où les camarades sont
           <label for="order">Mettre les fiches modifiées récemment en premier.</label>
       </td>
     </tr>
+    <tr>
+      <td colspan="2">
+           <input type='checkbox' name='exact' id="exact" {if $smarty.request.exact}checked='checked'{/if} value='1'/>
+           <label for="exact">Faire une recherche exacte.</label>
+      </td>
+    </tr>
         {/if}
     <tr><td colspan="2"></td></tr>
     <tr>
index 0f6d2c9..5058d57 100644 (file)
@@ -21,7 +21,7 @@
 {**************************************************************************}
 
 
-{if $formulaire eq 0 and !$xorg_errors}
+{if $formulaire eq 0 and !$pl_errors}
   {if !$simple}
     {if !$advanced}
     {include file=search/quick.form.tpl show_js=1}
@@ -29,8 +29,8 @@
     {include file=search/adv.links.tpl do_title=1 with_soundex=$with_soundex}
     {/if}
   {/if}
-  
-  {include file='core/plset.tpl'}
+
+  {include core=plset.tpl}
 
   {if $search_pages_nb > 1}
   <p>
diff --git a/templates/skin/common.backtrace.tpl b/templates/skin/common.backtrace.tpl
deleted file mode 100644 (file)
index 7df0dee..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-{**************************************************************************}
-{*                                                                        *}
-{*  Copyright (C) 2003-2008 Polytechnique.org                             *}
-{*  http://opensource.polytechnique.org/                                  *}
-{*                                                                        *}
-{*  This program is free software; you can redistribute it and/or modify  *}
-{*  it under the terms of the GNU General Public License as published by  *}
-{*  the Free Software Foundation; either version 2 of the License, or     *}
-{*  (at your option) any later version.                                   *}
-{*                                                                        *}
-{*  This program is distributed in the hope that it will be useful,       *}
-{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}
-{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}
-{*  GNU General Public License for more details.                          *}
-{*                                                                        *}
-{*  You should have received a copy of the GNU General Public License     *}
-{*  along with this program; if not, write to the Free Software           *}
-{*  Foundation, Inc.,                                                     *}
-{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
-{*                                                                        *}
-{**************************************************************************}
-
-{foreach from=$backtraces key=bt_name item=trace}
-<div class="backtrace">
-  <h1>
-    {if $trace->error}<span style="color: #f00">{/if}
-    Exécution de {$bt_name}&nbsp;: {$trace->traces|@count} actions en {$trace->totaltime|string_format:"%.3f"}s (hover-me pour la trace)
-    {if $trace->error}</span>{/if}
-  </h1>
-  <div class="hide">
-{foreach item=query from=$trace->traces}
-{if $query.data}
-{assign var=cols value=$query.data[0]|@count}
-{else}
-{assign var=cols value=1}
-{/if}
-<table class="bicol" style="width: 75%; font-size: smaller; margin-left:2px; margin-top: 3px;">
-  <tr class="impair">
-    <td colspan="{$cols}">
-      <strong>ACTION:</strong>
-      <pre style="padding: 0; margin: 0;">{$query.action}</pre>
-      <br/>
-    </td>
-  </tr>
-  {if $query.error}
-  <tr>
-    <td colspan="{$cols}">
-      <strong style="color: #f00">ERROR:</strong><br />
-      {$query.error|nl2br}
-    </td>
-  </tr>
-  {else}
-  <tr>
-    <td colspan="{$cols}">
-      <strong>INFO:</strong><br />
-      {$query.rows} ligne{if $query.rows > 1}s{/if} en {$query.exectime|string_format:"%.3f"}s
-    </td>
-  </tr>
-  {/if}
-{if $query.data}
-  <tr>
-    {foreach key=key item=item from=$query.data[0]}
-    <th style="font-size: smaller">{$key}</th>
-    {/foreach}
-  </tr>
-  {foreach item=data_row from=$query.data}
-  <tr class="impair">
-    {foreach item=item from=$data_row}
-    <td class="center" style="font-size: smaller">{$item}</td>
-    {/foreach}
-  </tr>
-  {/foreach}
-{/if}
-</table>
-{/foreach}
-</div>
-</div>
-{/foreach}
-
-{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index fdd8ddb..7823905 100644 (file)
@@ -37,10 +37,10 @@ Nous conseillons très vivement d'utiliser des navigateurs récents, tels
 <br />
 {/if}
 
-{if !$xorg_no_errors || $xorg_failure}
-{include file="skin/common.triggers.tpl"}
+{if !$pl_no_errors || $pl_failure}
+{include core=triggers.tpl}
 {/if}
 
-{if !$xorg_failure && $xorg_tpl}{include file=$xorg_tpl}{/if}
+{if !$pl_failure && $pl_tpl}{include file=$pl_tpl}{/if}
 
 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index 65889e4..029f04b 100644 (file)
@@ -26,7 +26,7 @@
 {if $validate}
   <div id="dev">
     @HOOK@
-    Validation:
+    Validation&nbsp;:
     <a href="http://jigsaw.w3.org/css-validator/validator?uri={#globals.baseurl#}/valid.html">CSS</a>
     &nbsp;&nbsp;|&nbsp;&nbsp;
     références&nbsp;:
index da39c5e..568297d 100644 (file)
     <link rel="bookmark" href="http://www.polytechnique.fr/eleves/" title="| Site d'élèves" />
 
     <link rel="stylesheet" type="text/css" href="css/base.css" media="all"/>
-    {foreach from=$xorg_css item=css}
+    {foreach from=$pl_css item=css}
     <link rel="stylesheet" type="text/css" href="css/{$css}" media="all"/>
     {/foreach}
-    {foreach from=$xorg_inline_css item=css}
+    {foreach from=$pl_inline_css item=css}
     <style type="text/css">
     {$css|smarty:nodefaults}
     </style>
@@ -53,7 +53,7 @@
     <script type="text/javascript">
       var platal_baseurl = "{$globals->baseurl}/";
     </script>
-    {foreach from=$xorg_js item=js}
+    {foreach from=$pl_js item=js}
     <script type="text/javascript" src="javascript/{$js}"></script>
     {/foreach}
     {javascript name=overlib}
     {javascript name=sha1}
     {javascript name=secure_hash}
 
-    {if $xorg_rss}
-    <link rel="alternate" type="application/rss+xml" title="{$xorg_rss.title}" href="{$xorg_rss.href}" />
+    {if $pl_rss}
+    <link rel="alternate" type="application/rss+xml" title="{$pl_rss.title}" href="{$pl_rss.href}" />
     {/if}
 
-    {if $xorg_extra_header}
-    {$xorg_extra_header|smarty:nodefaults}
+    {if $pl_extra_header}
+    {$pl_extra_header|smarty:nodefaults}
     {/if}
 
-    <title>{$xorg_title|default:"Polytechnique.org&nbsp;: le site des élèves et anciens élèves de l'École polytechnique"}</title>
+    <title>{$pl_title|default:"Polytechnique.org&nbsp;: le site des élèves et anciens élèves de l'École polytechnique"}</title>
 
 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
diff --git a/templates/skin/common.triggers.tpl b/templates/skin/common.triggers.tpl
deleted file mode 100644 (file)
index 5a310a3..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-{**************************************************************************}
-{*                                                                        *}
-{*  Copyright (C) 2003-2008 Polytechnique.org                             *}
-{*  http://opensource.polytechnique.org/                                  *}
-{*                                                                        *}
-{*  This program is free software; you can redistribute it and/or modify  *}
-{*  it under the terms of the GNU General Public License as published by  *}
-{*  the Free Software Foundation; either version 2 of the License, or     *}
-{*  (at your option) any later version.                                   *}
-{*                                                                        *}
-{*  This program is distributed in the hope that it will be useful,       *}
-{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}
-{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}
-{*  GNU General Public License for more details.                          *}
-{*                                                                        *}
-{*  You should have received a copy of the GNU General Public License     *}
-{*  along with this program; if not, write to the Free Software           *}
-{*  Foundation, Inc.,                                                     *}
-{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
-{*                                                                        *}
-{**************************************************************************}
-
-{foreach from=$xorg_triggers key=type item=triggers}
-{if $triggers|@count}
-<div class="{$type}">
-  <ul>
-    {foreach from=$triggers item=err}
-    <li>{$err|smarty:nodefaults}</li>
-    {/foreach}
-  </ul>
-</div>
-{/if}
-{/foreach}
-
-{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index 1eb652a..9362807 100644 (file)
@@ -36,7 +36,7 @@
 {elseif $survey_message neq ""}
   {$survey_message}
 {else}
-Une erreur inconnue est survenue dans l'&#233;dition de ce sondage. N'hésite pas &#224; <a href='send_bug/{ $smarty.server.REQUEST_URI }'>signaler ce bug</a> sil persiste.
+Une erreur inconnue est survenue dans l'&#233;dition de ce sondage. N'hésite pas &#224; <a href='send_bug/{ $smarty.server.REQUEST_URI }'>signaler ce bug</a> s'il persiste.
 {/if}
 <br/>
 <a href="{$survey_link}">Retour</a>
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 c671dd7..a602df0 100644 (file)
     <link rel="bookmark" href="http://www.polytechnique.org/"       title="| Polytechnique.org" />
     <link rel="bookmark" href="http://www.polytechnique.fr/eleves/" title="| Site d'élèves" />
 
-    {foreach from=$xorg_css item=css}
+    {foreach from=$pl_css item=css}
     <link rel="stylesheet" type="text/css" href="css/{$css}" />
     {/foreach}
-    {foreach from=$xorg_inline_css item=css} 
+    {foreach from=$pl_inline_css item=css} 
     <style type="text/css"> 
     {$css|smarty:nodefaults} 
     </style> 
     if (window.top != window)
       document.write('<link rel="stylesheet" type="text/css" href="css/onlycontent.css" media="all"/>');
     </script>
-    {foreach from=$xorg_js item=js}
+    {foreach from=$pl_js item=js}
     <script type="text/javascript" src="javascript/{$js}"></script>
     {/foreach}
     {javascript name=overlib}
 
-    {if $xorg_rss}
-    <link rel="alternate" type="application/rss+xml" title="{$xorg_rss.title}" href="{$xorg_rss.href}" />
+    {if $pl_rss}
+    <link rel="alternate" type="application/rss+xml" title="{$pl_rss.title}" href="{$pl_rss.href}" />
     {/if}
 
-    {if $xorg_extra_header}
-    {$xorg_extra_header|smarty:nodefaults}
+    {if $pl_extra_header}
+    {$pl_extra_header|smarty:nodefaults}
     {/if}
 
     <title>Les associations polytechniciennes</title>
index 7f63c8d..4005e42 100644 (file)
@@ -180,7 +180,7 @@ A très bientôt,
 
 -- 
 {$smarty.session.prenom} {$smarty.session.nom}{/if}</textarea><br />
-        Page internet de l'événement&nbsp;: <input size="40" name="site" value="{$paiement_site|default:$asso.site|default:$platal->ns}" /><br />
+        Page internet de l'événement&nbsp;: <input size="40" name="site" value="{$paiement_site|default:$asso.site|default:$globals->baseurl|cat:'/'|cat:$platal->ns}" /><br />
         Le nouveau paiement sera activé automatiquement après validation par le trésorier de Polytechnique.org,
         ce qui sera fait sous peu.
         <script type="text/javascript">//<![CDATA[
index fbdffe0..e1172d7 100644 (file)
 {*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
 {*                                                                        *}
 {**************************************************************************}
-
-<?xml version="1.0"?>
-<rss version="2.0">
-  <channel>
-    <title>Polytechnique.net :: {$asso.nom|htmlentities} :: News</title>
-    <language>fr</language>
-    <link>{#globals.baseurl#}/{$asso.diminutif}/</link>
-    <description>L'actualite polytechnicienne...</description>
-    <image>
-      <title>{#globals.core.sitename#}</title>
-      <url>{#globals.baseurl#}/images/logo.png</url>
-      <link>{#globals.baseurl#}/{$asso.diminutif}/</link>
-    </image>
-    {iterate item=line from=$rss}
-    <item>
-      <title>{$line.titre|strip_tags|htmlentities}</title>
-      <guid isPermaLink="false">{$line.id}</guid>
-      <link>{#globals.baseurl#}/{$asso.diminutif}/#art{$line.id}</link>
-      <description><![CDATA[
-        {if $line.photo}
-        <div style="float: left; padding-right: 0.5em">
-          <img src="{#globals.baseurl#}/{$asso.diminutif}/announce/photo/{$line.id}" alt="{$line.titre|strip_tags}" />
-        </div>
-        {/if}
-        <div>{$line.texte|miniwiki}{if $line.contacts}<br/><br/><strong>Contacts&nbsp;:</strong><br/>{$line.contacts|miniwiki}{/if}</div>]]></description>
-      <author>{$line.prenom} {$line.nom} (X{$line.promo})</author>
-      <pubDate>{$line.create_date|rss_date}</pubDate>
-    </item>
-    {/iterate}
-  </channel>
-</rss>
+{if $article->photo}
+<div style="float: left; padding-right: 0.5em">
+  <img src="{#globals.baseurl#}/{$asso.diminutif}/announce/photo/{$article->id}" alt="{$article->titre|strip_tags}" />
+</div>
+{/if}
+<div>{$article->texte|miniwiki}{if $article->contacts}<br/><br/><strong>Contacts&nbsp;:</strong><br/>{$article->contacts|miniwiki}{/if}</div>
 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index b638dcc..6fd19d6 100644 (file)
@@ -57,7 +57,7 @@ Le groupe {$asso.nom} compte {$nb_tot} membres&nbsp;:
 </ul>
 
 {if $plset_base}
-{include file="core/plset.tpl"}
+{include core=plset.tpl}
 {else}
 
 <p class="center">
@@ -143,7 +143,7 @@ Le groupe {$asso.nom} compte {$nb_tot} membres&nbsp;:
 
 {if $broken}
 <p class="smaller">
-  {icon name=error}&nbsp;Un camarade signalé par ce symbole n'a plus d'adresse de redirection et ne peut donc
+  {icon name=error}&nbsp;Un camarade signalé par ce symbole n'a plus d'adresse de redirection et ne peut donc
   plus être contacté via son adresse polytechnique.org. Si tu connais sa nouvelle adresse, tu peux nous la communiquer en
   cliquant sur le symbole.
 </p>
index f36a8f5..ab1561f 100644 (file)
@@ -26,7 +26,7 @@
   {if $asso.site}
   <tr>
     <td class="titre">
-      Site Web:
+      Site Web&nbsp;:
     </td>
     <td><a href="{$asso.site}">{$asso.site}</a></td>
   </tr>
@@ -35,7 +35,7 @@
   {if $asso.resp || $asso.mail}
   <tr>
     <td class="titre">
-      Contact:
+      Contact&nbsp;:
     </td>
     <td>
       {if $asso.mail}
@@ -50,7 +50,7 @@
   {if $asso.forum}
   <tr>
     <td class="titre">
-      Forum:
+      Forum&nbsp;:
     </td>
     <td>
       <a href="{$platal->ns}forum">par le web</a>
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>
 
index 444c38e..bd354b8 100644 (file)
@@ -80,7 +80,7 @@ function searchX()
     <tr>
       <td colspan="2">
         <input type="checkbox" id="x" name="x" onchange="xStateChange(this);" />
-        <label for="x">Coche cette case sil s'agit d'un X non inscrit à Polytechnique.org.</label>
+        <label for="x">Coche cette case s'il s'agit d'un X non inscrit à Polytechnique.org.</label>
       </td>
     </tr>
     <tr id="xnom" style="display: none">
index f30c160..62c2675 100644 (file)
       <td colspan="2">
         <span id="make_X_cb">
           <input type="checkbox" name="is_x" id="is_x" onclick="showXInput(this);" onchange="showXInput(this);" />
-          <label for="is_x">coche cette case sil s'agit d'un X</label>
+          <label for="is_x">coche cette case s'il s'agit d'un X</label>
         </span>
         <span id="make_X_login" style="display: none">
           <span class="titre">Identifiant (prenom.nom.promo)&nbsp;:</span>
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: