Merge branch 'xorg/1.0.2/master' into xorg/master
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 16 Jan 2011 16:45:48 +0000 (17:45 +0100)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 16 Jan 2011 16:45:48 +0000 (17:45 +0100)
553 files changed:
ChangeLog
Makefile
bin/check_security_fixes.py
bin/connect.db.inc.php
bin/cron/axletter.send.php
bin/cron/checkdb.php
bin/cron/clean.php
bin/cron/compliance.php
bin/cron/cron_ml_moderate.php
bin/cron/cron_validations.php
bin/cron/emails.check.php
bin/cron/google_apps.php
bin/cron/homonyms.php
bin/cron/notifs.birthday.php
bin/cron/notifs.send.php
bin/cron/profile_modification.php
bin/csv2sql.php
bin/devel/lists.foreach_template.py
bin/devel/xhtml.classes.pl
bin/devel/xhtml.validate.pl
bin/formatAddresses.php
bin/lists.rpc.py
bin/newsletter.bounces.processor.py
bin/newsletter.send.php
bin/poisonous_email_generator.py
bin/search.rebuild_db.php
classes/address.php
classes/direnum.php
classes/geocoder.php
classes/gmapsgeocoder.php
classes/group.php
classes/jobterms.php
classes/phone.php
classes/platalglobals.php.in
classes/platallogger.php
classes/profile.php
classes/profilevisibility.php
classes/user.php
classes/userfilter.php
classes/userfilter/conditions.inc.php [new file with mode: 0644]
classes/userfilter/orders.inc.php [new file with mode: 0644]
classes/xnet.php
classes/xnetpage.php
classes/xnetsession.php
classes/xorg.php
classes/xorgpage.php
classes/xorgsession.php
configs/mails.conf
configs/platal.ini
core
htdocs/css/ax.css
htdocs/css/bandeau.css
htdocs/css/base.css
htdocs/css/default.css
htdocs/css/espace.css
htdocs/css/humlinux.css
htdocs/css/igoogle.css
htdocs/css/keynote.css
htdocs/css/linux.css
htdocs/css/liteskin.css
htdocs/css/nbviolet.css
htdocs/css/newxorg.css
htdocs/css/nl.css
htdocs/css/oldtimes.css
htdocs/css/openweb.css
htdocs/css/sharky.css
htdocs/css/spectral.css
htdocs/css/trapped.css
htdocs/css/xnet.css
htdocs/javascript/.gitignore
htdocs/javascript/ajax.js [deleted file]
htdocs/javascript/do_challenge_response.js
htdocs/javascript/do_challenge_response_logged.js
htdocs/javascript/igoogle.js
htdocs/javascript/jobtermstree.js
htdocs/javascript/password.js
htdocs/javascript/profile.js
htdocs/javascript/secure_hash.js
htdocs/javascript/sha1.js [deleted file]
htdocs/javascript/survey.js [new file with mode: 0644]
htdocs/javascript/xorg.js
htdocs/listes_redirect.php
htdocs/webredirect.php
htdocs/xnet.php
htdocs/xorg.php
include/banana/forum.inc.php
include/banana/hooks.inc.php
include/banana/ml.inc.php
include/banana/moderate.inc.php
include/common.inc.php
include/education.func.inc.php
include/emails.combobox.inc.php
include/emails.inc.php
include/googleapps.inc.php
include/ical.inc.php
include/marketing.inc.php
include/massmailer.inc.php
include/name.func.inc.php
include/newsletter.inc.php
include/notifs.inc.php
include/profilefields.inc.php
include/reminder.inc.php
include/reminder/ax_letter.inc.php
include/reminder/email_backup.inc.php
include/reminder/email_warning.inc.php
include/reminder/gapps.inc.php
include/reminder/ml.inc.php
include/reminder/nl.inc.php
include/reminder/no_redirection.inc.php
include/reminder/profile_update.inc.php
include/reminder/promotion_ml.inc.php
include/security.inc.php
include/test.inc.php
include/ufbuilder.inc.php
include/userset.inc.php
include/validations.inc.php
include/validations/aliases.inc.php
include/validations/broken.inc.php
include/validations/entreprises.inc.php
include/validations/evts.inc.php
include/validations/googleapps.inc.php
include/validations/homonymes.inc.php
include/validations/listes.inc.php
include/validations/marketing.inc.php
include/validations/medals.inc.php
include/validations/names.inc.php
include/validations/nl.inc.php
include/validations/orange.inc.php
include/validations/paiements.inc.php
include/validations/photos.inc.php
include/validations/surveys.inc.php
include/vcard.inc.php
include/webservices/manageurs.inc.php
include/xnet.inc.php
include/xorg.inc.php
modules/admin.php
modules/admin/homonyms.inc.php
modules/api.php [new file with mode: 0644]
modules/auth.php
modules/auth/auth.inc.php
modules/axletter.php
modules/axletter/axletter.inc.php
modules/bandeau.php
modules/carnet.php
modules/carnet/contacts.pdf.inc.php
modules/carnet/feed.inc.php
modules/carnet/outlook.inc.php
modules/email.php
modules/events.php
modules/events/feed.inc.php
modules/forums.php
modules/fusionax.php
modules/gadgets.php
modules/gadgets/gadgets.inc.php
modules/googleapps.php
modules/lists.php
modules/lists/lists.inc.php
modules/marketing.php
modules/newsletter.php
modules/openid.php
modules/openid/openid.inc.php
modules/payment.php
modules/payment/money.inc.php
modules/payment/money/bplccyberplus.inc.php
modules/payment/money/cyberpaiement.inc.php
modules/payment/money/paypal.inc.php
modules/platal.php
modules/platal/review.inc.php
modules/poison.php
modules/poison/poison.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/reminder.php
modules/search.php
modules/stats.php
modules/survey.php
modules/survey/answer.inc.php [new file with mode: 0644]
modules/survey/multiple.inc.php [new file with mode: 0644]
modules/survey/question.inc.php [new file with mode: 0644]
modules/survey/section.inc.php [moved from htdocs/javascript/close_on_esc.js with 79% similarity]
modules/survey/survey.inc.php
modules/survey/text.inc.php [moved from htdocs/javascript/wiki.js with 61% similarity]
modules/xnet.php
modules/xnetevents.php
modules/xnetevents/xnetevents.inc.php
modules/xnetgrp.php
modules/xnetgrp/feed.inc.php
modules/xnetgrp/mail.inc.php
modules/xnetlists.php
plugins/function.display_address.php
plugins/function.display_education.php
plugins/function.display_phones.php
plugins/function.poison.php
plugins/function.profile.php
plugins/function.select_nat.php
plugins/function.test_email.php
plugins/insert.getUserName.php
templates/admin/account_watch.tpl
templates/admin/accounts.tpl
templates/admin/add_accounts.tpl
templates/admin/dead_but_active.tpl
templates/admin/deces_promo.tpl
templates/admin/emails_bounces_re.tpl [deleted file]
templates/admin/forums-promo.mail.tpl
templates/admin/geocoding.tpl [moved from templates/survey/show_checkboxtable.tpl with 53% similarity]
templates/admin/geocoding_edit.tpl [moved from templates/survey/edit_radiotable.tpl with 59% similarity]
templates/admin/homonymes.tpl
templates/admin/icons.tpl
templates/admin/index.tpl
templates/admin/ipwatcher.tpl
templates/admin/jobs.tpl
templates/admin/logger-view.tpl
templates/admin/postfix_delayed.tpl
templates/admin/profile.tpl
templates/admin/user.tpl
templates/admin/useredit.mail.tpl
templates/admin/validation.tpl
templates/admin/wiki.tpl
templates/axletter/admin.tpl
templates/axletter/edit.tpl
templates/axletter/index.tpl
templates/axletter/letter.mail.tpl
templates/axletter/show.tpl
templates/axletter/unsubscribe.tpl
templates/banana/index.tpl
templates/carnet/calendar.outlook.tpl
templates/carnet/calendar.tpl
templates/carnet/index.tpl
templates/carnet/mescontacts.tpl
templates/carnet/notif.mail.tpl
templates/carnet/notifs.tpl
templates/carnet/panel.tpl
templates/carnet/rss.tpl
templates/carnet/tricontacts.tpl
templates/core/password_prompt.tpl
templates/core/password_prompt_logged.tpl
templates/core/vcard.tpl
templates/emails/alias.tpl
templates/emails/antispam.tpl
templates/emails/broken-web.mail.tpl
templates/emails/broken.mail.tpl
templates/emails/broken.tpl
templates/emails/broken_addr.tpl
templates/emails/duplicated.tpl
templates/emails/imap_register.tpl
templates/emails/index.tpl
templates/emails/lost.tpl
templates/emails/redirect.tpl
templates/emails/rewrite-in.mail.tpl
templates/emails/rewrite.tpl
templates/emails/send.tpl
templates/emails/submit_spam.tpl
templates/emails/test.mail.tpl
templates/events/admin.tpl
templates/events/admin_tips.tpl
templates/events/form.tpl
templates/events/index.tpl
templates/events/preview.tpl
templates/events/rss.tpl
templates/events/submit.tpl
templates/forums/admin.tpl
templates/fusionax/corps.tpl
templates/fusionax/deathdate_issues.tpl
templates/fusionax/deceased.tpl
templates/fusionax/education.tpl
templates/fusionax/ids.tpl
templates/fusionax/idsMissingInAx.tpl
templates/fusionax/idsMissingInXorg.tpl
templates/fusionax/idswrongInXorg.tpl
templates/fusionax/import.tpl
templates/fusionax/index.tpl
templates/fusionax/issues.tpl
templates/fusionax/listFusion.tpl
templates/fusionax/names.tpl
templates/fusionax/other_issues.tpl
templates/fusionax/promo.tpl
templates/fusionax/promo_issues.tpl
templates/fusionax/view.tpl
templates/gadgets/ig-events.tpl
templates/gadgets/ig-events.xml.tpl
templates/gadgets/ig-login.tpl
templates/gadgets/ig-minifiche.tpl
templates/gadgets/ig-search.tpl
templates/gadgets/ig-search.xml.tpl
templates/gadgets/ig-skin.tpl
templates/geoloc/address.tpl
templates/geoloc/form.address.tpl
templates/googleapps/admin.job.tpl
templates/googleapps/admin.tpl
templates/googleapps/admin.user.tpl
templates/googleapps/create.mail.tpl
templates/googleapps/index.tpl
templates/googleapps/unsuspend.mail.tpl
templates/include/emails.combobox.tpl
templates/include/emploi.tpl
templates/include/field.promo.tpl
templates/include/field.select.tpl
templates/include/flags.radio.tpl
templates/include/form.valid.aliases.tpl
templates/include/form.valid.broken.tpl
templates/include/form.valid.edit-entreprises.tpl
templates/include/form.valid.edit-evts.tpl
templates/include/form.valid.edit-listes.tpl
templates/include/form.valid.edit-nl.tpl
templates/include/form.valid.edit-paiements.tpl
templates/include/form.valid.edit-photo.tpl
templates/include/form.valid.entreprises.tpl
templates/include/form.valid.evts.tpl
templates/include/form.valid.gapps-unsuspend.tpl
templates/include/form.valid.homonymes.tpl
templates/include/form.valid.listes.tpl
templates/include/form.valid.mark.tpl
templates/include/form.valid.medals.tpl
templates/include/form.valid.names.tpl
templates/include/form.valid.nl.tpl
templates/include/form.valid.orange.tpl
templates/include/form.valid.paiements.tpl
templates/include/form.valid.photos.tpl
templates/include/form.valid.surveys.tpl
templates/include/jobterms.branch.tpl
templates/include/massmailer-nav.tpl
templates/include/minifiche.tpl
templates/include/plview.minifiche.tpl
templates/include/plview.referent.tpl
templates/include/plview.trombi.entry.tpl
templates/include/plview.trombi.tpl
templates/include/signature.mail.tpl
templates/include/tips.tpl
templates/include/trombi.tpl
templates/lists/admin.tpl
templates/lists/admin_all.tpl
templates/lists/annu.tpl
templates/lists/archives.tpl
templates/lists/check.tpl
templates/lists/create.tpl
templates/lists/delete.tpl
templates/lists/display_list.tpl
templates/lists/header_listes.tpl
templates/lists/index.tpl
templates/lists/liste.inc.tpl
templates/lists/listes.inc.tpl
templates/lists/members.tpl
templates/lists/moderate.tpl
templates/lists/moderate_mail.tpl
templates/lists/moderate_sub.tpl
templates/lists/options.tpl
templates/lists/soptions.tpl
templates/marketing/broken.tpl
templates/marketing/index.tpl
templates/marketing/marketing.mail.tpl
templates/marketing/private.tpl
templates/marketing/promo.tpl
templates/marketing/public.tpl
templates/marketing/relance.mail.tpl
templates/marketing/relance.tpl
templates/marketing/this_week.tpl
templates/marketing/volontaire.tpl
templates/newsletter/admin.tpl
templates/newsletter/edit.tpl
templates/newsletter/index.tpl
templates/newsletter/nl.mail.tpl
templates/newsletter/show.tpl
templates/newsletter/submit.tpl
templates/openid/idp_xrds.tpl
templates/openid/openid.tpl
templates/openid/trust.tpl
templates/openid/user_xrds.tpl
templates/payment/index.tpl
templates/payment/reconcile.tpl
templates/payment/retour_paypal.tpl
templates/payment/xnet.tpl
templates/platal/acces_smtp.tpl
templates/platal/changeLog.tpl
templates/platal/exit.tpl
templates/platal/filrss.tpl
templates/platal/index.tpl
templates/platal/password.success.tpl
templates/platal/password.tpl
templates/platal/preferences.tpl
templates/platal/recovery.tpl
templates/platal/review.tpl
templates/platal/skins.tpl
templates/platal/tmpPWD.success.tpl
templates/platal/webredirect.tpl
templates/profile/admin_decos.tpl
templates/profile/admin_trombino.tpl
templates/profile/adresses.address.tpl
templates/profile/adresses.tpl
templates/profile/base.tpl
templates/profile/deco.medal.tpl
templates/profile/deco.tpl
templates/profile/education.js.tpl
templates/profile/fiche_referent.tpl
templates/profile/general.buildnames.tpl
templates/profile/general.edu.tpl
templates/profile/general.networking.tpl
templates/profile/general.searchname.tpl
templates/profile/general.tpl
templates/profile/geocoding.mail.tpl
templates/profile/grades.js.tpl
templates/profile/groupesx.tpl
templates/profile/groups.tpl
templates/profile/jobs.job.tpl
templates/profile/jobs.tpl
templates/profile/mentor.tpl
templates/profile/name_info.tpl
templates/profile/notification.mail.tpl
templates/profile/phone.tpl
templates/profile/profile.tpl
templates/profile/skill.skill.tpl
templates/profile/skill.tpl
templates/profile/trombino.tpl
templates/register/breadcrumb.tpl
templates/register/end.mail.tpl
templates/register/end.tpl
templates/register/lostalias.mail.tpl
templates/register/marketer.mail.tpl
templates/register/registration.mail.tpl
templates/register/step0.tpl
templates/register/step1.tpl
templates/register/step2.tpl
templates/register/step3.tpl
templates/register/step4.tpl
templates/register/success.mail.tpl
templates/reminder/base.tpl
templates/reminder/email_warning.tpl
templates/reminder/gapps.tpl
templates/reminder/ml.tpl
templates/reminder/no_redirection.tpl
templates/reminder/notification.tpl
templates/reminder/profile_update.tpl
templates/search/adv.form.tpl
templates/search/adv.grade.form.tpl
templates/search/adv.links.tpl
templates/search/index.tpl
templates/search/quick.form.tpl
templates/search/quick.tpl
templates/search/referent.tpl
templates/skin/common.bandeau.head.tpl
templates/skin/common.bandeau.tpl
templates/skin/common.doctype.tpl
templates/skin/common.footer.tpl
templates/skin/common.header.tpl
templates/skin/common.menu.tpl
templates/skin/common.title.header.tpl
templates/skin/default.tpl
templates/skin/espace.tpl
templates/skin/humlinux.tpl
templates/skin/keynote.tpl
templates/skin/linux.tpl
templates/skin/liteskin.tpl
templates/skin/nbviolet.tpl
templates/skin/newxorg.tpl
templates/skin/oldtimes.tpl
templates/skin/openweb.tpl
templates/skin/register.tpl
templates/skin/sharky.tpl
templates/skin/spectral.tpl
templates/skin/trapped.tpl
templates/stats/coupure.tpl
templates/stats/evolution_inscrits.tpl
templates/stats/index.tpl
templates/stats/nb_by_promo.tpl
templates/survey/admin.tpl [deleted file]
templates/survey/edit.questions.tpl [new file with mode: 0644]
templates/survey/edit.tpl [new file with mode: 0644]
templates/survey/edit_checkbox.tpl [deleted file]
templates/survey/edit_new.tpl [deleted file]
templates/survey/edit_newsurvey.tpl [deleted file]
templates/survey/edit_num.tpl [deleted file]
templates/survey/edit_question.tpl [deleted file]
templates/survey/edit_radio.tpl [deleted file]
templates/survey/edit_root.tpl [deleted file]
templates/survey/edit_survey.tpl [deleted file]
templates/survey/edit_text.tpl [deleted file]
templates/survey/edit_textarea.tpl [deleted file]
templates/survey/error.tpl [deleted file]
templates/survey/index.tpl
templates/survey/show_checkbox.tpl [deleted file]
templates/survey/show_num.tpl [deleted file]
templates/survey/show_radio.tpl [deleted file]
templates/survey/show_radiotable.tpl [deleted file]
templates/survey/show_root.tpl [deleted file]
templates/survey/show_text.tpl [deleted file]
templates/survey/show_textarea.tpl [deleted file]
templates/survey/success.tpl [deleted file]
templates/survey/vote.questions.tpl [moved from templates/survey/edit_checkboxtable.tpl with 75% similarity]
templates/survey/vote.tpl [moved from templates/survey/confirm.tpl with 73% similarity]
templates/xnet/admin.tpl
templates/xnet/deconnexion.tpl
templates/xnet/groupes.tpl
templates/xnet/include/descr.tpl
templates/xnet/index.tpl
templates/xnet/plan.tpl
templates/xnet/skin.tpl
templates/xnetevents/admin.tpl
templates/xnetevents/calendar.tpl
templates/xnetevents/csv.tpl
templates/xnetevents/edit.tpl
templates/xnetevents/index.tpl
templates/xnetevents/newpayment.mail.tpl
templates/xnetevents/subscribe.tpl
templates/xnetevents/subscription-notif.mail.tpl [moved from templates/survey/show_question.tpl with 73% similarity]
templates/xnetgrp/announce-admin.tpl
templates/xnetgrp/announce-edit.tpl
templates/xnetgrp/announce-rss.tpl
templates/xnetgrp/annuaire-admin.tpl
templates/xnetgrp/annuaire-csv.tpl
templates/xnetgrp/annuaire.tpl
templates/xnetgrp/asso.tpl
templates/xnetgrp/edit.tpl
templates/xnetgrp/form.announce.tpl
templates/xnetgrp/forum.tpl
templates/xnetgrp/inscrire.tpl
templates/xnetgrp/mail.tpl
templates/xnetgrp/membres-add.tpl
templates/xnetgrp/membres-del.tpl
templates/xnetgrp/membres-edit.tpl
templates/xnetgrp/membres-new-search.tpl
templates/xnetgrp/subscribe-valid.tpl
templates/xnetgrp/unsubscription-notif.mail.tpl
templates/xnetlists/alias-admin.tpl
templates/xnetlists/alias-create.tpl
templates/xnetlists/create.tpl
templates/xnetlists/index.tpl
templates/xnetlists/sync.tpl
upgrade/0.0.0_to_0.9.0/to_mailman.py
upgrade/0.9.1/mailman_update.py
upgrade/0.9.14/connect.db.inc.php
upgrade/0.9.16/connect.db.inc.php
upgrade/1.1.0/01_new_mail_schema.sql [new file with mode: 0644]
upgrade/1.1.0/02_new_mail_insertion.sql [new file with mode: 0644]
upgrade/1.1.0/03_new_mail_delete_old.sql [new file with mode: 0644]
upgrade/1.1.0/04_xnetgrp.sql [new file with mode: 0644]
upgrade/1.1.0/05_permissions.sql [new file with mode: 0644]
upgrade/1.1.0/05_xnetevents.sql [new file with mode: 0644]
upgrade/1.1.0/06_language.sql [new file with mode: 0644]
upgrade/1.1.0/10_surveys.sql [new file with mode: 0644]
upgrade/1.1.0/connect.db.inc.php [new symlink]
upgrade/1.1.0/languages.php [new file with mode: 0755]
upgrade/1.1.0/old_surveys.inc.php [new file with mode: 0644]
upgrade/1.1.0/update.sh [new file with mode: 0755]
ut/checkdb.php
ut/userfiltertest.php

index 46886f1..6e0b06f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,46 @@
 ================================================================================
+VERSION 1.1.0                                                         XX XX XXXX
+
+Bug/Wish:
+
+    * Admin:
+      - #1320: Add administrations pages for country and language edition  -JAC
+      - #1371: Allows email edition before mailing list validation         -JAC
+
+    * Carnet:
+      - #1139: Fixes contact pdf export with pictures                      -JAC
+
+    * Core:
+      - #1040: Adapts login page for non-X users                           -FRU
+      - #1325: Fixes csv downloading with IE8                              -JAC
+
+    * Emails:
+      - #1201: Increases allowed email size                                -JAC
+
+    * Payments:
+      - #1314,1295: Finally fix "has paid" lists                           -Xel
+
+    * Profile:
+      - #1288: Adds explaination about job keywords in profile edition     -JAC
+      - #1294: Fixes email in job information                              -JAC
+      - #1322: Removes duplicated city and postal code in vcard addresses  -JAC
+      - #1323: Displays email aliases in vcards when public                -JAC
+
+    * Search:
+      - #1283: Restricts second operation on promo search                  -Car
+      - #1312: Adds search on subadministrativearea                        -JAC
+      - #1313: Fixes advanced form js in IE7                               -Car
+
+    * Xnet:
+      - #1347: Fixes menu when changing rights in Xnet                     -JAC
+
+    * XnetEvent:
+      - #1233: Enables event subscribtion notification                     -JAC
+
+    * XnetGrp:
+      - #1230: Adds custom welcome message for group subscription          -JAC
+
+================================================================================
 VERSION 1.0.2                                                         XX XX XXXX
 
 Bug/Wish:
index 1fa6d71..0041ae2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -73,7 +73,10 @@ htdocs/.htaccess: htdocs/.htaccess.in Makefile
 ##
 ## static content
 ##
-static: htdocs/javascript@VERSION
+static: htdocs/javascript/core.js htdocs/javascript@VERSION
+
+htdocs/javascript/core.js:
+       cd htdocs/javascript/ && ln -s ../../core/htdocs/javascript/core.js
 
 %@VERSION: % Makefile ChangeLog
        cd $< && rm -f $(VERSION) && ln -sf . $(VERSION)
@@ -173,21 +176,24 @@ $(MEDAL_THUMBNAILS): $(subst /medals/thumb/,/medals/,$(@F))
 ##
 ## jquery
 ##
-JQUERY_VERSION=1.4.2
+JQUERY_VERSION=1.4.4
 JQUERY_PLUGINS=color form
 JQUERY_PLUGINS_PATHES=$(addprefix htdocs/javascript/jquery.,$(addsuffix .js,$(JQUERY_PLUGINS)))
 
-JQUERY_UI_VERSION=1.6
-JQUERY_UI=core tabs
+JQUERY_UI_VERSION=1.8.7
+JQUERY_UI=core tabs datepicker widget
 JQUERY_UI_PATHES=$(addprefix htdocs/javascript/jquery.ui.,$(addsuffix .js,$(JQUERY_UI)))
 
+JQUERY_TMPL_VERSION=vBeta1.0.0
+JQUERY_TMPL_PATH=htdocs/javascript/jquery.tmpl.js
+
 JSTREE_VERSION=1.0rc2
 JSTREE_PATH=htdocs/javascript/jquery.jstree.js
 
 # TODO: jquery.autocomplete.js should rather be downloaded from an official source. The issue
 # is that the version we use is not available anymore on the Internet, and the latest version
 # we could use is not backward compatible with our current code.
-jquery: htdocs/javascript/jquery.js $(JQUERY_PLUGINS_PATHES) $(JQUERY_UI_PATHES) $(JSTREE_PATH)
+jquery: htdocs/javascript/jquery.js $(JQUERY_PLUGINS_PATHES) $(JQUERY_UI_PATHES) $(JQUERY_TMPL_PATH) $(JSTREE_PATH) htdocs/javascript/jquery.ui.datepicker-fr.js
 
 htdocs/javascript/jquery-$(JQUERY_VERSION).min.js: DOWNLOAD_SRC = http://jquery.com/src/$(@F)
 htdocs/javascript/jquery-$(JQUERY_VERSION).min.js:
@@ -202,11 +208,23 @@ $(JQUERY_PLUGINS_PATHES):
        @-rm htdocs/javascript/jquery.ui*.$*.js
        @$(download)
 
-htdocs/javascript/jquery.ui-$(JQUERY_UI_VERSION).%.js: DOWNLOAD_SRC = http://jquery-ui.googlecode.com/svn/tags/$(JQUERY_UI_VERSION)/ui/ui.$*.js
+htdocs/javascript/jquery.ui-$(JQUERY_UI_VERSION).%.js: DOWNLOAD_SRC = http://jquery-ui.googlecode.com/svn/tags/$(JQUERY_UI_VERSION)/ui/minified/jquery.ui.$*.min.js
 htdocs/javascript/jquery.ui-$(JQUERY_UI_VERSION).%.js:
        @$(download)
 
-$(JQUERY_UI_PATHES): htdocs/javascript/jquery.ui.%.js: htdocs/javascript/jquery.ui-$(JQUERY_UI_VERSION).%.js
+htdocs/javascript/jquery.ui-$(JQUERY_UI_VERSION).datepicker-fr.js: DOWNLOAD_SRC = http://jquery-ui.googlecode.com/svn/tags/$(JQUERY_UI_VERSION)/ui/minified/i18n/jquery.ui.datepicker-fr.min.js
+htdocs/javascript/jquery.ui-$(JQUERY_UI_VERSION).datepicker-fr.js:
+       @$(download)
+
+$(JQUERY_UI_PATHES) htdocs/javascript/jquery.ui.datepicker-fr.js: htdocs/javascript/jquery.ui.%.js: htdocs/javascript/jquery.ui-$(JQUERY_UI_VERSION).%.js
+       ln -snf $(<F) $@
+
+htdocs/javascript/jquery.tmpl-$(JQUERY_TMPL_VERSION).js: DOWNLOAD_SRC = https://github.com/jquery/jquery-tmpl/raw/$(JQUERY_TMPL_VERSION)/jquery.tmpl.min.js --no-check-certificate
+htdocs/javascript/jquery.tmpl-$(JQUERY_TMPL_VERSION).js:
+       @-rm htdocs/javascript/jquery.tmpl*.js
+       @$(download)
+
+$(JQUERY_TMPL_PATH): htdocs/javascript/jquery.tmpl-$(JQUERY_TMPL_VERSION).js
        ln -snf $(<F) $@
 
 $(JSTREE_PATH):
index ec73c22..ed31120 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 #***************************************************************************
-#*  Copyright (C) 2003-2010 Polytechnique.org                              *
+#*  Copyright (C) 2003-2011 Polytechnique.org                              *
 #*  http://opensource.polytechnique.org/                                   *
 #*                                                                         *
 #*  This program is free software; you can redistribute it and/or modify   *
index 22ed0a7..7b26657 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -19,6 +19,7 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
+ini_set('memory_limit', '64M');
 ini_set('include_path', dirname(__FILE__) . '/../core/include:'
                       . dirname(__FILE__) . '/../include:'
                       . dirname(__FILE__) . '/../core/classes:'
@@ -28,5 +29,8 @@ require_once('xorg.inc.php');
 
 new Xorg('core');
 
+// Do not store backtraces
+Platal::globals()->debug = 0;
+
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
 ?>
index 6fa2f56..5fa8827 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/php5 -q
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index fa9ae8d..999bf9c 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/php5 -q
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -61,7 +61,8 @@ function checkCount($sql, $comment = '')
     }
 }
 
-function info($sql, $comment = '', $onlyCounts = false) {
+function info($sql, $comment = '', $onlyCounts = false)
+{
     global $opt_verbose;
     if ($opt_verbose) {
         if ($onlyCounts) {
@@ -72,6 +73,20 @@ function info($sql, $comment = '', $onlyCounts = false) {
     }
 }
 
+function infoCountEmpty($table, $field, $nonEmpty = false)
+{
+    $sql = "SELECT COUNT(*) FROM $table";
+    if ($nonEmpty) {
+        $sql .= " WHERE $field IS NOT NULL OR $field != ''";
+        $negation = ' non';
+    } else {
+        $sql .= " WHERE $field IS NULL OR $field = ''";
+        $negation = '';
+    }
+    $comment = "Nombre de champs '$field'$negation vides dans la table '$table'.";
+    info($sql, $comment, true);
+}
+
 /* Parses options. */
 $opts = Console_GetOpt::getopt($argv, 'v');
 $opt_verbose = false;
@@ -128,12 +143,19 @@ check("SELECT  a.alias AS username, b.alias AS loginbis, b.expire
         WHERE  a.type = 'a_vie'",
       "Donne la liste des homonymes qui ont un alias égal à leur loginbis depuis plus d'un mois, il est temps de supprimer leur alias.");
 
+// Counts empty profile fields that should never be empty.
+infoCountEmpty('profile_addresses', 'text');
+infoCountEmpty('profile_addresses', 'postalText');
+infoCountEmpty('profile_education', 'eduid');
+infoCountEmpty('profile_education', 'degreeid');
+infoCountEmpty('profile_job', 'jobid');
+infoCountEmpty('profile_mentor', 'expertise');
+infoCountEmpty('profile_networking', 'address');
+infoCountEmpty('profile_phones', 'search_tel');
+infoCountEmpty('profile_phones', 'display_tel');
+
 // XXX: counts the number of remaining issues due to the merge (to be removed once all merge related issues have been fixed)
-info('SELECT  COUNT(*)
-        FROM  profile_merge_issues
-       WHERE  issues IS NULL OR issues = \'\'',
-     'Dénombre les erreurs dues à la fusion restantes.',
-     true);
+infoCountEmpty('profile_merge_issues', 'issues', true);
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
 ?>
index 84fade9..5925900 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/php5 -q
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -48,7 +48,7 @@ query('ALTER TABLE  profile_education_field_enum
 query('ALTER TABLE  profile_job_enum
           ORDER BY  name');
 query('ALTER TABLE  profile_langskill_enum
-          ORDER BY  langue_fr');
+          ORDER BY  language');
 query('ALTER TABLE  profile_medal_enum
           ORDER BY  text');
 query('ALTER TABLE  profile_networking_enum
index fab5436..3c32305 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/php5 -q
 <?php
 /***************************************************************************
-*  Copyright (C) 2003-2010 Polytechnique.org                              *
+*  Copyright (C) 2003-2011 Polytechnique.org                              *
 *  http://opensource.polytechnique.org/                                   *
 *                                                                         *
 *  This program is free software; you can redistribute it and/or modify   *
index c4d16b5..e77643d 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/php5 -q
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 0b73a49..5c466fd 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/php5 -q
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index e38dfb8..846ef2d 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/php5 -q
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index a145fc4..66138b8 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/php5 -q
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 6de61bc..567fbd8 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/php5 -q
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 7c50fd1..ba5655b 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/php5 -q
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index cdd07b8..a68cc90 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/php5 -q
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index ef7cbdf..ec240cb 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/php5 -q
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 4dcea43..d99a8f5 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/php5
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index a4eecbc..3c74167 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 #***************************************************************************
-#*  Copyright (C) 2003-2010 Polytechnique.org                              *
+#*  Copyright (C) 2003-2011 Polytechnique.org                              *
 #*  http://opensource.polytechnique.org/                                   *
 #*                                                                         *
 #*  This program is free software; you can redistribute it and/or modify   *
index a7b6ecb..23086b3 100755 (executable)
@@ -1,6 +1,6 @@
 #! /usr/bin/perl -w
 #***************************************************************************
-#*  Copyright (C) 2003-2010 Polytechnique.org                              *
+#*  Copyright (C) 2003-2011 Polytechnique.org                              *
 #*  http://opensource.polytechnique.org/                                   *
 #*                                                                         *
 #*  This program is free software; you can redistribute it and/or modify   *
index 87f06bb..fa2a6e4 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 #***************************************************************************
-#*  Copyright (C) 2003-2010 Polytechnique.org                              *
+#*  Copyright (C) 2003-2011 Polytechnique.org                              *
 #*  http://opensource.polytechnique.org/                                   *
 #*                                                                         *
 #*  This program is free software; you can redistribute it and/or modify   *
index a32a17a..4ab19d2 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/php5 -q
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 5f7e921..56067ba 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 #***************************************************************************
-#*  Copyright (C) 2003-2010 Polytechnique.org                              *
+#*  Copyright (C) 2003-2011 Polytechnique.org                              *
 #*  http://opensource.polytechnique.org/                                   *
 #*                                                                         *
 #*  This program is free software; you can redistribute it and/or modify   *
index 8fc3c1a..88f1397 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/env python2.5
 # -*- coding: utf-8 -*-
 #***************************************************************************
-#*  Copyright (C) 2003-2010 Polytechnique.org                              *
+#*  Copyright (C) 2003-2011 Polytechnique.org                              *
 #*  http://opensource.polytechnique.org/                                   *
 #*                                                                         *
 #*  This program is free software; you can redistribute it and/or modify   *
index 7f411c1..bf97705 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/php5 -q
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 82ac78e..ad9d06b 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 #***************************************************************************
-#*  Copyright (C) 2003-2010 Polytechnique.org                              *
+#*  Copyright (C) 2003-2011 Polytechnique.org                              *
 #*  http://opensource.polytechnique.org/                                   *
 #*                                                                         *
 #*  This program is free software; you can redistribute it and/or modify   *
index 7e35247..3084d61 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/php5 -q
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -22,9 +22,6 @@
 
 require './connect.db.inc.php';
 
-ini_set('memory_limit', '16M');
-$globals->debug = 0; // Do not store backtraces
-
 $res = XDB::iterRow('SELECT  pid
                        FROM  profiles');
 $i = 0;
index f4a951e..6c1880b 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -366,7 +366,7 @@ class Address
 
     public function addPhone(Phone &$phone)
     {
-        if ($phone->linkType() == Phone::LINK_ADDRESS && $phone->pid() == $this->pid) {
+        if ($phone->link_type == Phone::LINK_ADDRESS && $phone->pid == $this->pid) {
             $this->phones[$phone->uniqueId()] = $phone;
         }
     }
@@ -897,7 +897,7 @@ class AddressIterator implements PlIterator
         // Adds phones to addresses.
         $it = Phone::iterate(array($data['pid']), array(Phone::LINK_ADDRESS), array($data['id']));
         while ($phone = $it->next()) {
-            $data['phones'][$phone->id()] = $phone->toFormArray();
+            $data['phones'][$phone->id] = $phone->toFormArray();
         }
         return new Address($data);
     }
index 0268ca9..e34d7c0 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -46,6 +46,7 @@ class DirEnum
     const NATIONALITIES  = 'nationalities';
     const COUNTRIES      = 'countries';
     const ADMINAREAS     = 'adminareas';
+    const SUBADMINAREAS  = 'subadminareas';
     const LOCALITIES     = 'localities';
 
     const COMPANIES      = 'companies';
@@ -600,6 +601,19 @@ class DE_AdminAreas extends DE_WithSuboption
 }
 // }}}
 
+// {{{ class DE_SubAdminAreas
+class DE_SubAdminAreas extends DE_WithSuboption
+{
+    protected $idfield   = 'geoloc_subadministrativeareas.id';
+    protected $optfield  = 'geoloc_subadministrativeareas.administrativearea';
+    protected $valfield  = 'geoloc_subadministrativeareas.name';
+    protected $from      = 'geoloc_subadministrativeareas';
+
+    protected $ac_join   = 'INNER JOIN profile_addresses ON (profile_addresses.subadministrativeAreaId = geoloc_subadministrativeareas.id)';
+    protected $ac_unique = 'profile_addresses.pid';
+}
+// }}}
+
 // {{{ class DE_Localities
 class DE_Localities extends DirEnumeration
 {
index 89727a1..fea1be1 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index a48c9b6..3bc8e83 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index b5f4500..63ca84b 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -37,6 +37,9 @@ class Group
         }
         $this->id = intval($this->data['id']);
         $this->shortname = $this->data['diminutif'];
+        if (!is_null($this->axDate)) {
+            $this->axDate = format_datetime($this->axDate, '%d/%m/%Y');
+        }
     }
 
     public function __get($name)
@@ -123,7 +126,13 @@ class Group
             }
             return null;
         }
-        return new Group($res->fetchOneAssoc());
+        $data = $res->fetchOneAssoc();
+        $positions = XDB::fetchAllAssoc('SELECT  position, uid
+                                           FROM  group_members
+                                          WHERE  asso_id = {?} AND position IS NOT NULL
+                                       ORDER BY  position',
+                                        $data['id']);
+        return new Group(array_merge($data, array('positions' => $positions)));
     }
 }
 
index d90a650..ae5c758 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 64dfe0e..8a63d66 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -59,17 +59,17 @@ class Phone
     /** The following fields, but $error, all correspond to the fields of the
      * database table profile_phones.
      */
-    private $id = 0;
-    private $pid = 0;
-    private $search = '';
-    private $link_type = 'user';
-    private $link_id = 0;
+    public $id = 0;
+    public $pid = 0;
+    public $search = '';
+    public $link_type = 'user';
+    public $link_id = 0;
     // The following fields are the fields of the form in the profile edition.
-    private $type = 'fixed';
+    public $type = 'fixed';
     public $display = '';
     public $pub = 'ax';
     public $comment = '';
-    private $error = false;
+    public $error = false;
 
     public function __construct(array $data = array())
     {
@@ -80,31 +80,6 @@ class Phone
         }
     }
 
-    public function linkType()
-    {
-        return $this->link_type;
-    }
-
-    public function linkId()
-    {
-        return $this->link_id;
-    }
-
-    public function id()
-    {
-        return $this->id;
-    }
-
-    public function pid()
-    {
-        return $this->pid;
-    }
-
-    public function search()
-    {
-        return $this->search;
-    }
-
     public function setId($id)
     {
         $this->id = $id;
index 3f0085d..d9151ae 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 55d90fe..965a56e 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /*
- * Copyright (C) 2003-2010 Polytechnique.org
+ * Copyright (C) 2003-2011 Polytechnique.org
  * http://opensource.polytechnique.org/
  *
  * This program is free software; you can redistribute it and/or modify
index 3ca5679..c10b069 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 4b91fcc..e7dbbd4 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index fb9059c..f54d61b 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
 
 class User extends PlUser
 {
-    const PERM_GROUPS            = 'groups';
-    const PERM_MAIL              = 'mail';
+    const PERM_API_USER_READONLY = 'api_user_readonly';
     const PERM_DIRECTORY_AX      = 'directory_ax';
     const PERM_DIRECTORY_PRIVATE = 'directory_private';
     const PERM_EDIT_DIRECTORY    = 'edit_directory';
     const PERM_FORUMS            = 'forums';
+    const PERM_GROUPS            = 'groups';
     const PERM_LISTS             = 'lists';
+    const PERM_MAIL              = 'mail';
     const PERM_PAYMENT           = 'payment';
 
     private $_profile_fetched = false;
@@ -172,6 +173,7 @@ class User extends PlUser
             $joins .= XDB::format("LEFT JOIN group_members AS gpm ON (gpm.uid = a.uid AND gpm.asso_id = {?})\n", $globals->asso('id'));
             $fields[] = 'gpm.perms AS group_perms';
             $fields[] = 'gpm.comm AS group_comm';
+            $fields[] = 'gpm.position AS group_position';
         }
         if (count($fields) > 0) {
             $fields = ', ' . implode(', ', $fields);
index 03a88a0..1fd27a6 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-
-/******************
- * CONDITIONS
- ******************/
-
-// {{{ interface UserFilterCondition
-/** This interface describe objects which filter users based
- *      on various parameters.
- * The parameters of the filter must be given to the constructor.
- * The buildCondition function is called by UserFilter when
- *     actually building the query. That function must call
- *     $uf->addWheteverFilter so that the UserFilter makes
- *     adequate joins. It must return the 'WHERE' condition to use
- *     with the filter.
- */
-interface UserFilterCondition extends PlFilterCondition
-{
-}
-// }}}
-
-// {{{ class UFC_HasProfile
-/** Filters users who have a profile
- */
-class UFC_HasProfile implements UserFilterCondition
-{
-    public function buildCondition(PlFilter &$uf)
-    {
-        $uf->requireProfiles();
-        return '$PID IS NOT NULL';
-    }
-}
-// }}}
-
-// {{{ class UFC_AccountType
-/** Filters users who have one of the given account types
- */
-class UFC_AccountType implements UserFilterCondition
-{
-    private $types;
-
-    public function __construct()
-    {
-        $this->types = pl_flatten(func_get_args());
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        $uf->requireAccounts();
-        return XDB::format('a.type IN {?}', $this->types);
-    }
-}
-// }}}
-
-// {{{ class UFC_AccountPerm
-/** Filters users who have one of the given permissions
- */
-class UFC_AccountPerm implements UserFilterCondition
-{
-    private $perms;
-
-    public function __construct()
-    {
-        $this->perms = pl_flatten(func_get_args());
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        $uf->requirePerms();
-        $conds = array();
-        foreach ($this->perms as $perm) {
-            $conds[] = XDB::format('FIND_IN_SET({?}, IF(a.user_perms IS NULL, at.perms,
-                                                        CONCAT(at.perms, \',\', a.user_perms)))',
-                                   $perm);
-        }
-        if (empty($conds)) {
-            return self::COND_TRUE;
-        } else {
-            return implode(' OR ', $conds);
-        }
-    }
-}
-// }}}
-
-// {{{ class UFC_Hruid
-/** Filters users based on their hruid
- * @param $val Either an hruid, or a list of those
- */
-class UFC_Hruid implements UserFilterCondition
-{
-    private $hruids;
-
-    public function __construct()
-    {
-        $this->hruids = pl_flatten(func_get_args());
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        $uf->requireAccounts();
-        return XDB::format('a.hruid IN {?}', $this->hruids);
-    }
-}
-// }}}
-
-// {{{ class UFC_Hrpid
-/** Filters users based on the hrpid of their profiles
- * @param $val Either an hrpid, or a list of those
- */
-class UFC_Hrpid implements UserFilterCondition
-{
-    private $hrpids;
-
-    public function __construct()
-    {
-        $this->hrpids = pl_flatten(func_get_args());
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        $uf->requireProfiles();
-        return XDB::format('p.hrpid IN {?}', $this->hrpids);
-    }
-}
-// }}}
-
-// {{{ class UFC_Ip
-/** Filters users based on one of their last IPs
- * @param $ip IP from which connection are checked
- */
-class UFC_Ip implements UserFilterCondition
-{
-    private $ip;
-
-    public function __construct($ip)
-    {
-        $this->ip = $ip;
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        $sub = $uf->addLoggerFilter();
-        $ip = ip_to_uint($this->ip);
-        return XDB::format($sub . '.ip = {?} OR ' . $sub . '.forward_ip = {?}', $ip, $ip);
-    }
-}
-// }}}
-
-// {{{ class UFC_Comment
-class UFC_Comment implements UserFilterCondition
-{
-    private $text;
-
-    public function __construct($text)
-    {
-        $this->text = $text;
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        $uf->requireProfiles();
-        return $uf->getVisibilityCondition('p.freetext_pub') . ' AND p.freetext ' . XDB::formatWildcards(XDB::WILDCARD_CONTAINS, $this->text);
-    }
-}
-// }}}
-
-// {{{ class UFC_Promo
-/** Filters users based on promotion
- * @param $comparison Comparison operator (>, =, ...)
- * @param $grade Formation on which to restrict, UserFilter::DISPLAY for "any formation"
- * @param $promo Promotion on which the filter is based
- */
-class UFC_Promo implements UserFilterCondition
-{
-
-    private $grade;
-    private $promo;
-    private $comparison;
-
-    public function __construct($comparison, $grade, $promo)
-    {
-        $this->grade = $grade;
-        $this->comparison = $comparison;
-        $this->promo = $promo;
-        if ($this->grade != UserFilter::DISPLAY) {
-            UserFilter::assertGrade($this->grade);
-        }
-        if ($this->grade == UserFilter::DISPLAY && $this->comparison != '=') {
-            // XXX: we might try to guess the grade from the first char of the promo and forbid only '<= 2004', but allow '<= X2004'
-            Platal::page()->killError("Il n'est pas possible d'appliquer la comparaison '" . $this->comparison . "' aux promotions sans spécifier de formation (X/M/D)");
-        }
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        if ($this->grade == UserFilter::DISPLAY) {
-            $sub = $uf->addDisplayFilter();
-            return XDB::format('pd' . $sub . '.promo ' . $this->comparison . ' {?}', $this->promo);
-        } else {
-            $sub = $uf->addEducationFilter(true, $this->grade);
-            $field = 'pe' . $sub . '.' . UserFilter::promoYear($this->grade);
-            return $field . ' IS NOT NULL AND ' . $field . ' ' . $this->comparison . ' ' . XDB::format('{?}', $this->promo);
-        }
-    }
-}
-// }}}
-
-// {{{ class UFC_SchoolId
-/** Filters users based on their shoold identifier
- * @param type Parameter type (Xorg, AX, School)
- * @param value Array of school ids
- */
-class UFC_SchoolId implements UserFilterCondition
-{
-    const AX     = 'ax';
-    const Xorg   = 'xorg';
-    const School = 'school';
-
-    private $type;
-    private $id;
-
-    static public function assertType($type)
-    {
-        if ($type != self::AX && $type != self::Xorg && $type != self::School) {
-            Platal::page()->killError("Type de matricule invalide: $type");
-        }
-    }
-
-    /** Construct a UFC_SchoolId
-     * The first argument is the type, all following arguments can be either ids
-     * or arrays of ids to use:
-     * $ufc = new UFC_SchoolId(UFC_SchoolId::AX, $id1, $id2, array($id3, $id4));
-     */
-    public function __construct($type)
-    {
-        $this->type = $type;
-        $ids = func_get_args();
-        array_shift($ids);
-        $this->ids   = pl_flatten($ids);
-        self::assertType($type);
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        $uf->requireProfiles();
-        $ids = $this->ids;
-        $type = $this->type;
-        if ($type == self::School) {
-            $type = self::Xorg;
-            $ids  = array_map(array('Profile', 'getXorgId'), $ids);
-        }
-        return XDB::format('p.' . $type . '_id IN {?}', $ids);
-    }
-}
-// }}}
-
-// {{{ class UFC_EducationSchool
-/** Filters users by formation
- * @param $val The formation to search (either ID or array of IDs)
- */
-class UFC_EducationSchool implements UserFilterCondition
-{
-    private $val;
-
-    public function __construct()
-    {
-        $this->val = pl_flatten(func_get_args());
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        $sub = $uf->addEducationFilter();
-        return XDB::format('pe' . $sub . '.eduid IN {?}', $this->val);
-    }
-}
-// }}}
-
-// {{{ class UFC_EducationDegree
-class UFC_EducationDegree implements UserFilterCondition
-{
-    private $diploma;
-
-    public function __construct()
-    {
-        $this->diploma = pl_flatten(func_get_args());
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        $sub = $uf->addEducationFilter();
-        return XDB::format('pe' . $sub . '.degreeid IN {?}', $this->diploma);
-    }
-}
-// }}}
-
-// {{{ class UFC_EducationField
-class UFC_EducationField implements UserFilterCondition
-{
-    private $val;
-
-    public function __construct()
-    {
-        $this->val = pl_flatten(func_get_args());
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        $sub = $uf->addEducationFilter();
-        return XDB::format('pe' . $sub . '.fieldid IN {?}', $this->val);
-    }
-}
-// }}}
-
-// {{{ class UFC_Name
-/** Filters users based on name
- * @param $type Type of name field on which filtering is done (firstname, lastname...)
- * @param $text Text on which to filter
- * @param $mode Flag indicating search type (prefix, suffix, with particule...)
- */
-class UFC_Name implements UserFilterCondition
-{
-    const EXACT    = XDB::WILDCARD_EXACT;    // 0x000
-    const PREFIX   = XDB::WILDCARD_PREFIX;   // 0x001
-    const SUFFIX   = XDB::WILDCARD_SUFFIX;   // 0x002
-    const CONTAINS = XDB::WILDCARD_CONTAINS; // 0x003
-    const PARTICLE = 0x004;
-    const VARIANTS = 0x008;
-
-    private $type;
-    private $text;
-    private $mode;
-
-    public function __construct($type, $text, $mode)
-    {
-        $this->type = $type;
-        $this->text = $text;
-        $this->mode = $mode;
-    }
-
-    private function buildNameQuery($type, $variant, $where, UserFilter &$uf)
-    {
-        $sub = $uf->addNameFilter($type, $variant);
-        return str_replace('$ME', 'pn' . $sub, $where);
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        $left = '$ME.name';
-        if (($this->mode & self::PARTICLE) == self::PARTICLE) {
-            $left = 'CONCAT($ME.particle, \' \', $ME.name)';
-        }
-        $right = XDB::formatWildcards($this->mode & self::CONTAINS, $this->text);
-
-        $cond = $left . $right;
-        $conds = array($this->buildNameQuery($this->type, null, $cond, $uf));
-        if (($this->mode & self::VARIANTS) != 0 && isset(Profile::$name_variants[$this->type])) {
-            foreach (Profile::$name_variants[$this->type] as $var) {
-                $conds[] = $this->buildNameQuery($this->type, $var, $cond, $uf);
-            }
-        }
-        return implode(' OR ', $conds);
-    }
-}
-// }}}
-
-// {{{ class UFC_NameTokens
-/** Selects users based on tokens in their name (for quicksearch)
- * @param $tokens An array of tokens to search
- * @param $flags Flags the tokens must have (e.g 'public' for public search)
- * @param $soundex (bool) Whether those tokens are fulltext or soundex
- */
-class UFC_NameTokens implements UserFilterCondition
-{
-    /* Flags */
-    const FLAG_PUBLIC = 'public';
-
-    private $tokens;
-    private $flags;
-    private $soundex;
-    private $exact;
-
-    public function __construct($tokens, $flags = array(), $soundex = false, $exact = false)
-    {
-        if (is_array($tokens)) {
-            $this->tokens = $tokens;
-        } else {
-            $this->tokens = array($tokens);
-        }
-        if (is_array($flags)) {
-            $this->flags = $flags;
-        } else {
-            $this->flags = array($flags);
-        }
-        $this->soundex = $soundex;
-        $this->exact = $exact;
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        $conds = array();
-        foreach ($this->tokens as $i => $token) {
-            $sub = $uf->addNameTokensFilter($token);
-            if ($this->soundex) {
-                $c = XDB::format($sub . '.soundex = {?}', soundex_fr($token));
-            } else if ($this->exact) {
-                $c = XDB::format($sub . '.token = {?}', $token);
-            } else {
-                $c = $sub . '.token ' . XDB::formatWildcards(XDB::WILDCARD_PREFIX, $token);
-            }
-            if ($this->flags != null) {
-                $c .= XDB::format(' AND ' . $sub . '.flags IN {?}', $this->flags);
-            }
-            $conds[] = $c;
-        }
-
-        return implode(' AND ', $conds);
-    }
-}
-// }}}
-
-// {{{ class UFC_Nationality
-class UFC_Nationality implements UserFilterCondition
-{
-    private $val;
-
-    public function __construct()
-    {
-        $this->val = pl_flatten(func_get_args());
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        $uf->requireProfiles();
-        $nat = XDB::formatArray($this->val);
-        $conds = array(
-            'p.nationality1 IN ' . $nat,
-            'p.nationality2 IN ' . $nat,
-            'p.nationality3 IN ' . $nat,
-        );
-        return implode(' OR ', $conds);
-    }
-}
-// }}}
-
-// {{{ class UFC_Dead
-/** Filters users based on death date
- * @param $comparison Comparison operator
- * @param $date Date to which death date should be compared (DateTime object, string or timestamp)
- */
-class UFC_Dead implements UserFilterCondition
-{
-    private $comparison;
-    private $date;
-
-    public function __construct($comparison = null, $date = null)
-    {
-        $this->comparison = $comparison;
-        $this->date = make_datetime($date);
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        $uf->requireProfiles();
-        $str = 'p.deathdate IS NOT NULL';
-        if (!is_null($this->comparison)) {
-            $str .= ' AND p.deathdate ' . $this->comparison . ' ' . XDB::format('{?}', $this->date->format('Y-m-d'));
-        }
-        return $str;
-    }
-}
-// }}}
-
-// {{{ class UFC_Registered
-/** Filters users based on registration state
- * @param $active Whether we want to use only "active" users (i.e with a valid redirection)
- * @param $comparison Comparison operator
- * @param $date Date to which users registration date should be compared
- */
-class UFC_Registered implements UserFilterCondition
-{
-    private $active;
-    private $comparison;
-    private $date;
-
-    public function __construct($active = false, $comparison = null, $date = null)
-    {
-        $this->active = $active;
-        $this->comparison = $comparison;
-        $this->date = make_datetime($date);
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        $uf->requireAccounts();
-        if ($this->active) {
-            $date = '$UID IS NOT NULL AND a.state = \'active\'';
-        } else {
-            $date = '$UID IS NOT NULL AND a.state != \'pending\'';
-        }
-        if (!is_null($this->comparison)) {
-            $date .= ' AND a.registration_date != \'0000-00-00 00:00:00\' AND a.registration_date ' . $this->comparison . ' ' . XDB::format('{?}', $this->date->format('Y-m-d'));
-        }
-        return $date;
-    }
-}
-// }}}
-
-// {{{ class UFC_ProfileUpdated
-/** Filters users based on profile update date
- * @param $comparison Comparison operator
- * @param $date Date to which profile update date must be compared
- */
-class UFC_ProfileUpdated implements UserFilterCondition
-{
-    private $comparison;
-    private $date;
-
-    public function __construct($comparison = null, $date = null)
-    {
-        $this->comparison = $comparison;
-        $this->date = $date;
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        $uf->requireProfiles();
-        return 'p.last_change ' . $this->comparison . XDB::format(' {?}', date('Y-m-d H:i:s', $this->date));
-    }
-}
-// }}}
-
-// {{{ class UFC_Birthday
-/** Filters users based on next birthday date
- * @param $comparison Comparison operator
- * @param $date Date to which users next birthday date should be compared
- */
-class UFC_Birthday implements UserFilterCondition
-{
-    private $comparison;
-    private $date;
-
-    public function __construct($comparison = null, $date = null)
-    {
-        $this->comparison = $comparison;
-        $this->date = $date;
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        $uf->requireProfiles();
-        return 'p.next_birthday ' . $this->comparison . XDB::format(' {?}', date('Y-m-d', $this->date));
-    }
-}
-// }}}
-
-// {{{ class UFC_Sex
-/** Filters users based on sex
- * @parm $sex One of User::GENDER_MALE or User::GENDER_FEMALE, for selecting users
- */
-class UFC_Sex implements UserFilterCondition
-{
-    private $sex;
-    public function __construct($sex)
-    {
-        $this->sex = $sex;
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        if ($this->sex != User::GENDER_MALE && $this->sex != User::GENDER_FEMALE) {
-            return self::COND_FALSE;
-        } else {
-            $uf->requireProfiles();
-            return XDB::format('p.sex = {?}', $this->sex == User::GENDER_FEMALE ? 'female' : 'male');
-        }
-    }
-}
-// }}}
-
-// {{{ class UFC_Group
-/** Filters users based on group membership
- * @param $group Group whose members we are selecting
- * @param $anim Whether to restrict selection to animators of that group
- */
-class UFC_Group implements UserFilterCondition
-{
-    private $group;
-    private $anim;
-    public function __construct($group, $anim = false)
-    {
-        $this->group = $group;
-        $this->anim = $anim;
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        // Groups have AX visibility.
-        if ($uf->getVisibilityLevel() == ProfileVisibility::VIS_PUBLIC) {
-            return self::COND_TRUE;
-        }
-        $sub = $uf->addGroupFilter($this->group);
-        $where = 'gpm' . $sub . '.perms IS NOT NULL';
-        if ($this->anim) {
-            $where .= ' AND gpm' . $sub . '.perms = \'admin\'';
-        }
-        return $where;
-    }
-}
-// }}}
-
-// {{{ class UFC_Binet
-/** Selects users based on their belonging to a given (list of) binet
- * @param $binet either a binet_id or an array of binet_ids
- */
-class UFC_Binet implements UserFilterCondition
-{
-    private $val;
-
-    public function __construct()
-    {
-        $this->val = pl_flatten(func_get_args());
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        // Binets are private.
-        if ($uf->getVisibilityLevel() != ProfileVisibility::VIS_PRIVATE) {
-            return self::CONF_TRUE;
-        }
-        $sub = $uf->addBinetsFilter();
-        return XDB::format($sub . '.binet_id IN {?}', $this->val);
-    }
-}
-// }}}
-
-// {{{ class UFC_Section
-/** Selects users based on section
- * @param $section ID of the section
- */
-class UFC_Section implements UserFilterCondition
-{
-    private $section;
-
-    public function __construct()
-    {
-        $this->section = pl_flatten(func_get_args());
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        // Sections are private.
-        if ($uf->getVisibilityLevel() != ProfileVisibility::VIS_PRIVATE) {
-            return self::CONF_TRUE;
-        }
-        $uf->requireProfiles();
-        return XDB::format('p.section IN {?}', $this->section);
-    }
-}
-// }}}
-
-// {{{ class UFC_Email
-/** Filters users based on an email or a list of emails
- * @param $emails List of emails whose owner must be selected
- */
-class UFC_Email implements UserFilterCondition
-{
-    private $emails;
-    public function __construct()
-    {
-        $this->emails = pl_flatten(func_get_args());
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        $foreign = array();
-        $virtual = array();
-        $aliases = array();
-        $cond = array();
-
-        if (count($this->emails) == 0) {
-            return PlFilterCondition::COND_TRUE;
-        }
-
-        foreach ($this->emails as $entry) {
-            if (User::isForeignEmailAddress($entry)) {
-                $foreign[] = $entry;
-            } else if (User::isVirtualEmailAddress($entry)) {
-                $virtual[] = $entry;
-            } else {
-                @list($user, $domain) = explode('@', $entry);
-                $aliases[] = $user;
-            }
-        }
-
-        if (count($foreign) > 0) {
-            $sub = $uf->addEmailRedirectFilter($foreign);
-            $cond[] = XDB::format('e' . $sub . '.email IS NOT NULL OR a.email IN {?}', $foreign);
-        }
-        if (count($virtual) > 0) {
-            $sub = $uf->addVirtualEmailFilter($virtual);
-            $cond[] = 'vr' . $sub . '.redirect IS NOT NULL';
-        }
-        if (count($aliases) > 0) {
-            $sub = $uf->addAliasFilter($aliases);
-            $cond[] = 'al' . $sub . '.alias IS NOT NULL';
-        }
-        return '(' . implode(') OR (', $cond) . ')';
-    }
-}
-// }}}
-
-// {{{ class UFC_Address
-abstract class UFC_Address implements UserFilterCondition
-{
-    /** Valid address type ('hq' is reserved for company addresses)
-     */
-    const TYPE_HOME = 1;
-    const TYPE_PRO  = 2;
-    const TYPE_ANY  = 3;
-
-    /** Text for these types
-     */
-    protected static $typetexts = array(
-        self::TYPE_HOME => 'home',
-        self::TYPE_PRO  => 'pro',
-    );
-
-    protected $type;
-
-    /** Flags for addresses
-     */
-    const FLAG_CURRENT = 0x0001;
-    const FLAG_TEMP    = 0x0002;
-    const FLAG_SECOND  = 0x0004;
-    const FLAG_MAIL    = 0x0008;
-    const FLAG_CEDEX   = 0x0010;
-
-    // Binary OR of those flags
-    const FLAG_ANY     = 0x001F;
-
-    /** Text of these flags
-     */
-    protected static $flagtexts = array(
-        self::FLAG_CURRENT => 'current',
-        self::FLAG_TEMP    => 'temporary',
-        self::FLAG_SECOND  => 'secondary',
-        self::FLAG_MAIL    => 'mail',
-        self::FLAG_CEDEX   => 'cedex',
-    );
-
-    protected $flags;
-
-    public function __construct($type = null, $flags = null)
-    {
-        $this->type  = $type;
-        $this->flags = $flags;
-    }
-
-    protected function initConds($sub, $vis_cond)
-    {
-        $conds = array($vis_cond);
-
-        $types = array();
-        foreach (self::$typetexts as $flag => $type) {
-            if ($flag & $this->type) {
-                $types[] = $type;
-            }
-        }
-        if (count($types)) {
-            $conds[] = XDB::format($sub . '.type IN {?}', $types);
-        }
-
-        if ($this->flags != self::FLAG_ANY) {
-            foreach(self::$flagtexts as $flag => $text) {
-                if ($flag & $this->flags) {
-                    $conds[] = 'FIND_IN_SET(' . XDB::format('{?}', $text) . ', ' . $sub . '.flags)';
-                }
-            }
-        }
-        return $conds;
-    }
-
-}
-// }}}
-
-// {{{ class UFC_AddressText
-/** Select users based on their address, using full text search
- * @param $text Text for filter in fulltext search
- * @param $textSearchMode Mode for search (one of XDB::WILDCARD_*)
- * @param $type Filter on address type
- * @param $flags Filter on address flags
- * @param $country Filter on address country
- * @param $locality Filter on address locality
- */
-class UFC_AddressText extends UFC_Address
-{
-
-    private $text;
-    private $textSearchMode;
-
-    public function __construct($text = null, $textSearchMode = XDB::WILDCARD_CONTAINS,
-        $type = null, $flags = self::FLAG_ANY, $country = null, $locality = null)
-    {
-        parent::__construct($type, $flags);
-        $this->text           = $text;
-        $this->textSearchMode = $textSearchMode;
-        $this->country        = $country;
-        $this->locality       = $locality;
-    }
-
-    private function mkMatch($txt)
-    {
-        return XDB::formatWildcards($this->textSearchMode, $txt);
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        $sub = $uf->addAddressFilter();
-        $conds = $this->initConds($sub, $uf->getVisibilityCondition($sub . '.pub'));
-        if ($this->text != null) {
-            $conds[] = $sub . '.text' . $this->mkMatch($this->text);
-        }
-
-        if ($this->country != null) {
-            $subc = $uf->addAddressCountryFilter();
-            $subconds = array();
-            $subconds[] = $subc . '.country' . $this->mkMatch($this->country);
-            $subconds[] = $subc . '.countryFR' . $this->mkMatch($this->country);
-            $conds[] = implode(' OR ', $subconds);
-        }
-
-        if ($this->locality != null) {
-            $subl = $uf->addAddressLocalityFilter();
-            $conds[] = $subl . '.name' . $this->mkMatch($this->locality);
-        }
-
-        return implode(' AND ', $conds);
-    }
-}
-// }}}
-
-// {{{ class UFC_AddressField
-/** Filters users based on their address,
- * @param $val Either a code for one of the fields, or an array of such codes
- * @param $fieldtype The type of field to look for
- * @param $type Filter on address type
- * @param $flags Filter on address flags
- */
-class UFC_AddressField extends UFC_Address
-{
-    const FIELD_COUNTRY    = 1;
-    const FIELD_ADMAREA    = 2;
-    const FIELD_SUBADMAREA = 3;
-    const FIELD_LOCALITY   = 4;
-    const FIELD_ZIPCODE    = 5;
-
-    /** Data of the filter
-     */
-    private $val;
-    private $fieldtype;
-
-    public function __construct($val, $fieldtype, $type = null, $flags = self::FLAG_ANY)
-    {
-        parent::__construct($type, $flags);
-
-        if (!is_array($val)) {
-            $val = array($val);
-        }
-        $this->val       = $val;
-        $this->fieldtype = $fieldtype;
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        $sub = $uf->addAddressFilter();
-        $conds = $this->initConds($sub, $uf->getVisibilityCondition($sub . '.pub'));
-
-        switch ($this->fieldtype) {
-        case self::FIELD_COUNTRY:
-            $field = 'countryId';
-            break;
-        case self::FIELD_ADMAREA:
-            $field = 'administrativeAreaId';
-            break;
-        case self::FIELD_SUBADMAREA:
-            $field = 'subAdministrativeAreaId';
-            break;
-        case self::FIELD_LOCALITY:
-            $field = 'localityId';
-            break;
-        case self::FIELD_ZIPCODE:
-            $field = 'postalCode';
-            break;
-        default:
-            Platal::page()->killError('Invalid address field type: ' . $this->fieldtype);
-        }
-        $conds[] = XDB::format($sub . '.' . $field . ' IN {?}', $this->val);
-
-        return implode(' AND ', $conds);
-    }
-}
-// }}}
-
-// {{{ class UFC_Corps
-/** Filters users based on the corps they belong to
- * @param $corps Corps we are looking for (abbreviation)
- * @param $type Whether we search for original or current corps
- */
-class UFC_Corps implements UserFilterCondition
-{
-    const CURRENT   = 1;
-    const ORIGIN    = 2;
-
-    private $corps;
-    private $type;
-
-    public function __construct($corps, $type = self::CURRENT)
-    {
-        $this->corps = $corps;
-        $this->type  = $type;
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        /** Tables shortcuts:
-         * pc for profile_corps,
-         * pceo for profile_corps_enum - orginal
-         * pcec for profile_corps_enum - current
-         */
-        $sub = $uf->addCorpsFilter($this->type);
-        $cond = $sub . '.abbreviation = ' . $corps;
-        $cond .= ' AND ' . $uf->getVisibilityCondition($sub . '.corps_pub');
-        return $cond;
-    }
-}
-// }}}
-
-// {{{ class UFC_Corps_Rank
-/** Filters users based on their rank in the corps
- * @param $rank Rank we are looking for (abbreviation)
- */
-class UFC_Corps_Rank implements UserFilterCondition
-{
-    private $rank;
-    public function __construct($rank)
-    {
-        $this->rank = $rank;
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        /** Tables shortcuts:
-         * pc for profile_corps
-         * pcr for profile_corps_rank
-         */
-        $sub = $uf->addCorpsRankFilter();
-        $cond = $sub . '.abbreviation = ' . $rank;
-        // XXX(x2006barrois): find a way to get rid of that hardcoded
-        // reference to 'pc'.
-        $cond .= ' AND ' . $uf->getVisibilityCondition('pc.corps_pub');
-        return $cond;
-    }
-}
-// }}}
-
-// {{{ class UFC_Job_Company
-/** Filters users based on the company they belong to
- * @param $type The field being searched (self::JOBID, self::JOBNAME or self::JOBACRONYM)
- * @param $value The searched value
- */
-class UFC_Job_Company implements UserFilterCondition
-{
-    const JOBID = 'id';
-    const JOBNAME = 'name';
-    const JOBACRONYM = 'acronym';
-
-    private $type;
-    private $value;
-
-    public function __construct($type, $value)
-    {
-        $this->assertType($type);
-        $this->type = $type;
-        $this->value = $value;
-    }
-
-    private function assertType($type)
-    {
-        if ($type != self::JOBID && $type != self::JOBNAME && $type != self::JOBACRONYM) {
-            Platal::page()->killError("Type de recherche non valide.");
-        }
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        $sub = $uf->addJobCompanyFilter();
-        $cond  = $sub . '.' . $this->type . XDB::formatWildcards(XDB::WILDCARD_CONTAINS, $this->value);
-        $jsub = $uf->addJobFilter();
-        $cond .= ' AND ' . $uf->getVisibilityCondition($jsub . '.pub');
-        return $cond;
-    }
-}
-// }}}
-
-// {{{ class UFC_Job_Terms
-/** Filters users based on the job terms they assigned to one of their
- * jobs.
- * @param $val The ID of the job term, or an array of such IDs
- */
-class UFC_Job_Terms implements UserFilterCondition
-{
-    private $val;
-
-    public function __construct($val)
-    {
-        if (!is_array($val)) {
-            $val = array($val);
-        }
-        $this->val = $val;
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        $sub = $uf->addJobTermsFilter(count($this->val));
-        $conditions = array();
-        foreach ($this->val as $i => $jtid) {
-            $conditions[] = $sub[$i] . '.jtid_1 = ' . XDB::escape($jtid);
-        }
-        $jsub = $uf->addJobFilter();
-        $conditions[] = $uf->getVisibilityCondition($jsub . '.pub');
-        return implode(' AND ', $conditions);
-    }
-}
-// }}}
-
-// {{{ class UFC_Job_Description
-/** Filters users based on their job description
- * @param $description The text being searched for
- * @param $fields The fields to search for (CV, user-defined)
- */
-class UFC_Job_Description implements UserFilterCondition
-{
-
-    private $description;
-    private $fields;
-
-    public function __construct($description, $fields)
-    {
-        $this->fields = $fields;
-        $this->description = $description;
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        $conds = array();
-
-        $jsub = $uf->addJobFilter();
-        // CV is private => if only CV requested, and not private,
-        // don't do anything. Otherwise restrict to standard job visibility.
-        if ($this->fields == UserFilter::JOB_CV) {
-           if ($uf->getVisibilityLevel() != ProfileVisibility::VIS_PRIVATE) {
-               return self::CONF_TRUE;
-           }
-        } else {
-            $conds[] = $uf->getVisibilityCondition($jsub . '.pub');
-        }
-
-        if ($this->fields & UserFilter::JOB_USERDEFINED) {
-            $conds[] = $jsub . '.description ' . XDB::formatWildcards(XDB::WILDCARD_CONTAINS, $this->description);
-        }
-        if ($this->fields & UserFilter::JOB_CV && $uf->getVisibilityLevel() == ProfileVisibility::VIS_PRIVATE) {
-            $uf->requireProfiles();
-            $conds[] = 'p.cv ' . XDB::formatWildcards(XDB::WILDCARD_CONTAINS, $this->description);
-        }
-        return implode(' OR ', $conds);
-    }
-}
-// }}}
-
-// {{{ class UFC_Networking
-/** Filters users based on network identity (IRC, ...)
- * @param $type Type of network (-1 for any)
- * @param $value Value to search
- */
-class UFC_Networking implements UserFilterCondition
-{
-    private $type;
-    private $value;
-
-    public function __construct($type, $value)
-    {
-        $this->type = $type;
-        $this->value = $value;
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        $sub = $uf->addNetworkingFilter();
-        $conds = array();
-        $conds[] = $uf->getVisibilityCondition($sub . '.pub');
-        $conds[] = $sub . '.address ' . XDB::formatWildcards(XDB::WILDCARD_CONTAINS, $this->value);
-        if ($this->type != -1) {
-            $conds[] = $sub . '.nwid = ' . XDB::format('{?}', $this->type);
-        }
-        return implode(' AND ', $conds);
-    }
-}
-// }}}
-
-// {{{ class UFC_Phone
-/** Filters users based on their phone number
- * @param $num_type Type of number (pro/user/home)
- * @param $phone_type Type of phone (fixed/mobile/fax)
- * @param $number Phone number
- */
-class UFC_Phone implements UserFilterCondition
-{
-    const NUM_PRO   = 'pro';
-    const NUM_USER  = 'user';
-    const NUM_HOME  = 'address';
-    const NUM_ANY   = 'any';
-
-    const PHONE_FIXED   = 'fixed';
-    const PHONE_MOBILE  = 'mobile';
-    const PHONE_FAX     = 'fax';
-    const PHONE_ANY     = 'any';
-
-    private $num_type;
-    private $phone_type;
-    private $number;
-
-    public function __construct($number, $num_type = self::NUM_ANY, $phone_type = self::PHONE_ANY)
-    {
-        $phone = new Phone(array('display' => $number));
-        $phone->format();
-        $this->number = $phone->search();
-        $this->num_type = $num_type;
-        $this->phone_type = $phone_type;
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        $sub = $uf->addPhoneFilter();
-        $conds = array();
-
-        $conds[] = $uf->getVisibilityCondition($sub . '.pub');
-
-        $conds[] = $sub . '.search_tel = ' . XDB::format('{?}', $this->number);
-        if ($this->num_type != self::NUM_ANY) {
-            $conds[] = $sub . '.link_type = ' . XDB::format('{?}', $this->num_type);
-        }
-        if ($this->phone_type != self::PHONE_ANY) {
-            $conds[] = $sub . '.tel_type = ' . XDB::format('{?}', $this->phone_type);
-        }
-        return implode(' AND ', $conds);
-    }
-}
-// }}}
-
-// {{{ class UFC_Medal
-/** Filters users based on their medals
- * @param $medal ID of the medal
- * @param $grade Grade of the medal (null for 'any')
- */
-class UFC_Medal implements UserFilterCondition
-{
-    private $medal;
-    private $grade;
-
-    public function __construct($medal, $grade = null)
-    {
-        $this->medal = $medal;
-        $this->grade = $grade;
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        $conds = array();
-
-        // This will require profiles => table 'p' will be available.
-        $sub = $uf->addMedalFilter();
-
-        $conds[] = $uf->getVisibilityCondition('p.medals_pub');
-
-        $conds[] = $sub . '.mid = ' . XDB::format('{?}', $this->medal);
-        if ($this->grade != null) {
-            $conds[] = $sub . '.gid = ' . XDB::format('{?}', $this->grade);
-        }
-        return implode(' AND ', $conds);
-    }
-}
-// }}}
-
-// {{{ class UFC_Photo
-/** Filters profiles with photo
- */
-class UFC_Photo implements UserFilterCondition
-{
-    public function buildCondition(PlFilter &$uf)
-    {
-        $sub = $uf->addPhotoFilter();
-        return $sub . '.attach IS NOT NULL AND ' . $uf->getVisibilityCondition($sub . '.pub');
-    }
-}
-// }}}
-
-// {{{ class UFC_Mentor
-class UFC_Mentor implements UserFilterCondition
-{
-    public function buildCondition(PlFilter &$uf)
-    {
-        $sub = $uf->addMentorFilter(UserFilter::MENTOR);
-        return $sub . '.expertise IS NOT NULL';
-    }
-}
-// }}}
-
-
-// {{{ class UFC_Mentor_Expertise
-/** Filters users by mentoring expertise
- * @param $expertise Domain of expertise
- */
-class UFC_Mentor_Expertise implements UserFilterCondition
-{
-    private $expertise;
-
-    public function __construct($expertise)
-    {
-        $this->expertise = $expertise;
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        $sub = $uf->addMentorFilter(UserFilter::MENTOR_EXPERTISE);
-        return $sub . '.expertise ' . XDB::formatWildcards(XDB::WILDCARD_CONTAINS, $this->expertise);
-    }
-}
-// }}}
-
-// {{{ class UFC_Mentor_Country
-/** Filters users by mentoring country
- * @param $country Two-letters code of country being searched
- */
-class UFC_Mentor_Country implements UserFilterCondition
-{
-    private $country;
-
-    public function __construct()
-    {
-        $this->country = pl_flatten(func_get_args());
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        $sub = $uf->addMentorFilter(UserFilter::MENTOR_COUNTRY);
-        return $sub . '.country IN ' . XDB::format('{?}', $this->country);
-    }
-}
-// }}}
-
-// {{{ class UFC_Mentor_Terms
-/** Filters users based on the job terms they used in mentoring.
- * @param $val The ID of the job term, or an array of such IDs
- */
-class UFC_Mentor_Terms implements UserFilterCondition
-{
-    private $val;
-
-    public function __construct($val)
-    {
-        $this->val = $val;
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        $sub = $uf->addMentorFilter(UserFilter::MENTOR_TERM);
-        return $sub . '.jtid_1 = ' . XDB::escape($this->val);
-    }
-}
-// }}}
-
-// {{{ class UFC_UserRelated
-/** Filters users based on a relation toward a user
- * @param $user User to which searched users are related
- */
-abstract class UFC_UserRelated implements UserFilterCondition
-{
-    protected $user;
-    public function __construct(PlUser &$user)
-    {
-        $this->user =& $user;
-    }
-}
-// }}}
-
-// {{{ class UFC_Contact
-/** Filters users who belong to selected user's contacts
- */
-class UFC_Contact extends UFC_UserRelated
-{
-    public function buildCondition(PlFilter &$uf)
-    {
-        $sub = $uf->addContactFilter($this->user->id());
-        return 'c' . $sub . '.contact IS NOT NULL';
-    }
-}
-// }}}
-
-// {{{ class UFC_WatchRegistration
-/** Filters users being watched by selected user
- */
-class UFC_WatchRegistration extends UFC_UserRelated
-{
-    public function buildCondition(PlFilter &$uf)
-    {
-        if (!$this->user->watchType('registration')) {
-            return PlFilterCondition::COND_FALSE;
-        }
-        $uids = $this->user->watchUsers();
-        if (count($uids) == 0) {
-            return PlFilterCondition::COND_FALSE;
-        } else {
-            return XDB::format('$UID IN {?}', $uids);
-        }
-    }
-}
-// }}}
-
-// {{{ class UFC_WatchPromo
-/** Filters users belonging to a promo watched by selected user
- * @param $user Selected user (the one watching promo)
- * @param $grade Formation the user is watching
- */
-class UFC_WatchPromo extends UFC_UserRelated
-{
-    private $grade;
-    public function __construct(PlUser &$user, $grade = UserFilter::GRADE_ING)
-    {
-        parent::__construct($user);
-        $this->grade = $grade;
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        $promos = $this->user->watchPromos();
-        if (count($promos) == 0) {
-            return PlFilterCondition::COND_FALSE;
-        } else {
-            $sube = $uf->addEducationFilter(true, $this->grade);
-            $field = 'pe' . $sube . '.' . UserFilter::promoYear($this->grade);
-            return XDB::format($field . ' IN {?}', $promos);
-        }
-    }
-}
-// }}}
-
-// {{{ class UFC_WatchContact
-/** Filters users watched by selected user
- */
-class UFC_WatchContact extends UFC_Contact
-{
-    public function buildCondition(PlFilter &$uf)
-    {
-        if (!$this->user->watchContacts()) {
-            return PlFilterCondition::COND_FALSE;
-        }
-        return parent::buildCondition($uf);
-    }
-}
-// }}}
-
-// {{{ class UFC_MarketingHash
-/** Filters users using the hash generated
- * to send marketing emails to him.
- */
-class UFC_MarketingHash implements UserFilterCondition
-{
-    private $hash;
-
-    public function __construct($hash)
-    {
-        $this->hash = $hash;
-    }
-
-    public function buildCondition(PlFilter &$uf)
-    {
-        $table = $uf->addMarketingHash();
-        return XDB::format('rm.hash = {?}', $this->hash);
-    }
-}
-// }}}
-
-/******************
- * ORDERS
- ******************/
-
-// {{{ class UFO_Promo
-/** Orders users by promotion
- * @param $grade Formation whose promotion users should be sorted by (restricts results to users of that formation)
- * @param $desc Whether sort is descending
- */
-class UFO_Promo extends PlFilterGroupableOrder
-{
-    private $grade;
-
-    public function __construct($grade = null, $desc = false)
-    {
-        parent::__construct($desc);
-        $this->grade = $grade;
-    }
-
-    protected function getSortTokens(PlFilter &$uf)
-    {
-        if (UserFilter::isGrade($this->grade)) {
-            $sub = $uf->addEducationFilter($this->grade);
-            return 'pe' . $sub . '.' . UserFilter::promoYear($this->grade);
-        } else {
-            $sub = $uf->addDisplayFilter();
-            return 'pd' . $sub . '.promo';
-        }
-    }
-}
-// }}}
-
-// {{{ class UFO_Name
-/** Sorts users by name
- * @param $type Type of name on which to sort (firstname...)
- * @param $variant Variant of that name to use (marital, ordinary...)
- * @param $particle Set to true if particles should be included in the sorting order
- * @param $desc If sort order should be descending
- */
-class UFO_Name extends PlFilterOrder
-{
-    private $type;
-    private $variant;
-    private $particle;
-
-    public function __construct($type, $variant = null, $particle = false, $desc = false)
-    {
-        parent::__construct($desc);
-        $this->type = $type;
-        $this->variant = $variant;
-        $this->particle = $particle;
-    }
-
-    protected function getSortTokens(PlFilter &$uf)
-    {
-        if (Profile::isDisplayName($this->type)) {
-            $sub = $uf->addDisplayFilter();
-            $token = 'pd' . $sub . '.' . $this->type;
-            if ($uf->accountsRequired()) {
-                $account_token = Profile::getAccountEquivalentName($this->type);
-                return 'IFNULL(' . $token . ', a.' . $account_token . ')';
-            } else {
-                return $token;
-            }
-        } else {
-            $sub = $uf->addNameFilter($this->type, $this->variant);
-            if ($this->particle) {
-                return 'CONCAT(pn' . $sub . '.particle, \' \', pn' . $sub . '.name)';
-            } else {
-                return 'pn' . $sub . '.name';
-            }
-        }
-    }
-}
-// }}}
-
-// {{{ class UFO_Score
-class UFO_Score extends PlFilterOrder
-{
-    protected function getSortTokens(PlFilter &$uf)
-    {
-        $toks = $uf->getNameTokens();
-        $scores = array();
-
-        // If there weren't any sort tokens, we shouldn't sort by score, sort by NULL instead
-        if (count($toks) == 0) {
-            return 'NULL';
-        }
-
-        foreach ($toks as $sub => $token) {
-            $scores[] = XDB::format('SUM(' . $sub . '.score + IF (' . $sub . '.token = {?}, 5, 0) )', $token);
-        }
-        return implode(' + ', $scores);
-    }
-}
-// }}}
-
-// {{{ class UFO_Registration
-/** Sorts users based on registration date
- */
-class UFO_Registration extends PlFilterOrder
-{
-    protected function getSortTokens(PlFilter &$uf)
-    {
-        $uf->requireAccounts();
-        return 'a.registration_date';
-    }
-}
-// }}}
-
-// {{{ class UFO_Birthday
-/** Sorts users based on next birthday date
- */
-class UFO_Birthday extends PlFilterOrder
-{
-    protected function getSortTokens(PlFilter &$uf)
-    {
-        $uf->requireProfiles();
-        return 'p.next_birthday';
-    }
-}
-// }}}
-
-// {{{ class UFO_ProfileUpdate
-/** Sorts users based on last profile update
- */
-class UFO_ProfileUpdate extends PlFilterOrder
-{
-    protected function getSortTokens(PlFilter &$uf)
-    {
-        $uf->requireProfiles();
-        return 'p.last_change';
-    }
-}
-// }}}
-
-// {{{ class UFO_Death
-/** Sorts users based on death date
- */
-class UFO_Death extends PlFilterOrder
-{
-    protected function getSortTokens(PlFilter &$uf)
-    {
-        $uf->requireProfiles();
-        return 'p.deathdate';
-    }
-}
-// }}}
-
-// {{{ class UFO_Uid
-/** Sorts users based on their uid
- */
-class UFO_Uid extends PlFilterOrder
-{
-    protected function getSortTokens(PlFilter &$uf)
-    {
-        $uf->requireAccounts();
-        return '$UID';
-    }
-}
-// }}}
-
-// {{{ class UFO_Hruid
-/** Sorts users based on their hruid
- */
-class UFO_Hruid extends PlFilterOrder
-{
-    protected function getSortTokens(PlFilter &$uf)
-    {
-        $uf->requireAccounts();
-        return 'a.hruid';
-    }
-}
-// }}}
-
-// {{{ class UFO_Pid
-/** Sorts users based on their pid
- */
-class UFO_Pid extends PlFilterOrder
-{
-    protected function getSortTokens(PlFilter &$uf)
-    {
-        $uf->requireProfiles();
-        return '$PID';
-    }
-}
-// }}}
-
-// {{{ class UFO_Hrpid
-/** Sorts users based on their hrpid
- */
-class UFO_Hrpid extends PlFilterOrder
-{
-    protected function getSortTokens(PlFilter &$uf)
-    {
-        $uf->requireProfiles();
-        return 'p.hrpid';
-    }
-}
-// }}}
-
+require_once dirname(__FILE__) . '/userfilter/conditions.inc.php';
+require_once dirname(__FILE__) . '/userfilter/orders.inc.php';
 
 /***********************************
   *********************************
@@ -2042,13 +452,13 @@ class UserFilter extends PlFilter
         }
     }
 
-    public function setCondition(PlFilterCondition &$cond)
+    public function setCondition(PlFilterCondition $cond)
     {
         $this->root =& $cond;
         $this->query = null;
     }
 
-    public function addSort(PlFilterOrder &$sort)
+    public function addSort(PlFilterOrder $sort)
     {
         if (count($this->sort) == 0 && $sort instanceof PlFilterGroupableOrder)
         {
@@ -2058,6 +468,64 @@ class UserFilter extends PlFilter
         $this->orderby = null;
     }
 
+    public function export()
+    {
+        $export = array('conditions' => $this->root->export());
+        if (!empty($this->sort)) {
+            $export['sorts'] = array();
+            foreach ($this->sort as $sort) {
+                $export['sorts'][] = $sort->export();
+            }
+        }
+        return $export;
+    }
+
+    public function exportConditions()
+    {
+        return $this->root->export();
+    }
+
+    public static function fromExport(array $export)
+    {
+        $export = new PlDict($export);
+        if (!$export->has('conditions')) {
+            throw new Exception("Cannot build a user filter without conditions");
+        }
+        $cond = UserFilterCondition::fromExport($export->v('conditions'));
+        $sorts = null;
+        if ($export->has('sorts')) {
+            $sorts = array();
+            foreach ($export->v('sorts') as $sort) {
+                $sorts[] = UserFilterOrder::fromExport($sort);
+            }
+        }
+        return new UserFilter($cond, $sorts);
+    }
+
+    public static function fromJSon($json)
+    {
+        $export = json_decode($json, true);
+        if (is_null($export)) {
+            throw new Exception("Invalid json: $json");
+        }
+        return self::fromExport($json);
+    }
+
+    public static function fromExportedConditions(array $export)
+    {
+        $cond = UserFilterCondition::fromExport($export);
+        return new UserFilter($cond);
+    }
+
+    public static function fromJSonConditions($json)
+    {
+        $export = json_decode($json, true);
+        if (is_null($export)) {
+            throw new Exception("Invalid json: $json");
+        }
+        return self::fromExportedConditions($json);
+    }
+
     static public function getLegacy($promo_min, $promo_max)
     {
         if ($promo_min != 0) {
@@ -2873,7 +1341,6 @@ class UserFilter extends PlFilter
     }
 }
 // }}}
-
 // {{{ class ProfileFilter
 class ProfileFilter extends UserFilter
 {
diff --git a/classes/userfilter/conditions.inc.php b/classes/userfilter/conditions.inc.php
new file mode 100644 (file)
index 0000000..c7d5bb3
--- /dev/null
@@ -0,0 +1,1592 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2011 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 UserFilterCondition
+/** This class describe objects which filter users based
+ *      on various parameters.
+ * The parameters of the filter must be given to the constructor.
+ * The buildCondition function is called by UserFilter when
+ *     actually building the query. That function must call
+ *     $uf->addWheteverFilter so that the UserFilter makes
+ *     adequate joins. It must return the 'WHERE' condition to use
+ *     with the filter.
+ */
+abstract class UserFilterCondition implements PlFilterCondition
+{
+    const OP_EQUALS     = '==';
+    const OP_GREATER    = '>';
+    const OP_NOTGREATER = '<=';
+    const OP_LESSER     = '<';
+    const OP_NOTLESSER  = '>=';
+    const OP_NULL       = 'null';
+    const OP_NOTNULL    = 'not null';
+    const OP_CONTAINS   = 'contains';
+    const OP_PREFIX     = 'prefix';
+    const OP_SUFFIX     = 'suffix';
+
+    protected function buildExport($type)
+    {
+        $export = array('type' => $type);
+        return $export;
+    }
+
+    public function export()
+    {
+        throw new Exception("This class is not exportable");
+    }
+
+    public static function comparisonFromXDBWildcard($wildcard)
+    {
+        switch ($wildcard) {
+          case XDB::WILDCARD_EXACT:
+            return self::OP_EQUALS;
+          case XDB::WILDCARD_PREFIX:
+            return self::OP_PREFIX;
+          case XDB::WILDCARD_SUFFIX:
+            return self::OP_SUFFIX;
+          case XDB::WILDCARD_CONTAINS:
+            return self::OP_CONTAINS;
+        }
+        throw new Exception("Unknown wildcard mode: $wildcard");
+    }
+
+    public static function xdbWildcardFromComparison($comparison)
+    {
+        if (!self::isStringComparison($comparison)) {
+            throw new Exception("Unknown string coparison: $comparison");
+        }
+        switch ($comparison) {
+          case self::OP_EQUALS:
+            return XDB::WILDCARD_EXACT;
+          case self::OP_PREFIX:
+            return XDB::WILDCARD_PREFIX;
+          case self::OP_SUFFIX:
+            return XDB::WILDCARD_SUFFIX;
+          case self::OP_CONTAINS:
+            return XDB::WILDCARD_CONTAINS;
+        }
+    }
+
+    private static function isNumericComparison($comparison)
+    {
+        return $comparison == self::OP_EQUALS
+            || $comparison == self::OP_GREATER
+            || $comparison == self::OP_NOTGREATER
+            || $comparison == self::OP_LESSER
+            || $comparison == self::OP_NOTLESSER;
+    }
+
+    private static function isStringComparison($comparison)
+    {
+        return $comparison == self::OP_EQUALS
+            || $comparison == self::OP_CONTAINS
+            || $comparison == self::OP_PREFIX
+            || $comparison == self::OP_SUFFIX;
+    }
+
+    public static function fromExport(array $export)
+    {
+        $export = new PlDict($export);
+        if (!$export->has('type')) {
+            throw new Exception("Missing type in export");
+        }
+        $type = $export->s('type');
+        $cond = null;
+        switch ($type) {
+          case 'and':
+          case 'or':
+          case 'not':
+          case 'true':
+          case 'false':
+            $class = 'pfc_' . $type;
+            $cond = new $class();
+            break;
+
+          case 'host':
+            if ($export->has('ip')) {
+                $cond = new UFC_Ip($export->s('ip'));
+            }
+            break;
+
+          case 'comment':
+            if ($export->has('text') && $export->s('comparison') == self::OP_CONTAINS) {
+                $cond = new UFC_Comment($export->s('text'));
+            }
+            break;
+
+          case 'promo':
+            if ($export->has('promo') && self::isNumericComparison($export->s('comparison'))) {
+                $cond = new UFC_Promo($export->s('comparison'),
+                                      $export->s('grade', UserFilter::DISPLAY),
+                                      $export->s('promo'));
+            }
+            break;
+
+          case 'lastname':
+          case 'name':
+          case 'firstname':
+          case 'nickname':
+          case 'pseudonym':
+            if ($export->has('text')) {
+                $flag = self::xdbWildcardFromComparison($export->s('comparison'));
+                if ($export->b('search_in_variants')) {
+                    $flag |= UFC_Name::VARIANTS;
+                }
+                if ($export->b('search_in_particle')) {
+                    $flag |= UFC_Name::PARTICLE;
+                }
+                $cond = new UFC_Name($type, $export->s('text'), $flag);
+            }
+            break;
+
+          case 'account_type':
+          case 'account_perm':
+          case 'hrpid':
+          case 'hruid':
+            $values = $export->v('values', array());
+            $class = 'ufc_' . str_replace('_', '', $type);
+            $cond = new $class($values);
+            break;
+
+          case 'has_profile':
+            $class = 'ufc_' . str_replace('_', '', $type);
+            $cond = new $class();
+            break;
+
+          default:
+            throw new Exception("Unknown condition type: $type");
+        }
+        if (is_null($cond)) {
+            throw new Exception("Unsupported $type definition");
+        }
+        if ($cond instanceof PFC_NChildren) {
+            $children = $export->v('children', array());
+            foreach ($children as $child) {
+                $cond->addChild(self::fromExport($child));
+            }
+        } else if ($cond instanceof PFC_OneChild) {
+            if ($export->has('child')) {
+                $cond->setChild(self::fromExport($export->v('child')));
+            }
+        }
+        return $cond;
+    }
+}
+// }}}
+// {{{ class UFC_HasProfile
+/** Filters users who have a profile
+ */
+class UFC_HasProfile extends UserFilterCondition
+{
+    public function buildCondition(PlFilter $uf)
+    {
+        $uf->requireProfiles();
+        return '$PID IS NOT NULL';
+    }
+
+    public function export()
+    {
+        return $this->buildExport('has_profile');
+    }
+}
+// }}}
+// {{{ class UFC_AccountType
+/** Filters users who have one of the given account types
+ */
+class UFC_AccountType extends UserFilterCondition
+{
+    private $types;
+
+    public function __construct()
+    {
+        $this->types = pl_flatten(func_get_args());
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        $uf->requireAccounts();
+        return XDB::format('a.type IN {?}', $this->types);
+    }
+
+    public function export()
+    {
+        $export = $this->buildExport('account_type');
+        $export['values'] = $this->types;
+        return $export;
+    }
+}
+// }}}
+// {{{ class UFC_AccountPerm
+/** Filters users who have one of the given permissions
+ */
+class UFC_AccountPerm extends UserFilterCondition
+{
+    private $perms;
+
+    public function __construct()
+    {
+        $this->perms = pl_flatten(func_get_args());
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        $uf->requirePerms();
+        $conds = array();
+        foreach ($this->perms as $perm) {
+            $conds[] = XDB::format('FIND_IN_SET({?}, IF(a.user_perms IS NULL, at.perms,
+                                                        CONCAT(at.perms, \',\', a.user_perms)))',
+                                   $perm);
+        }
+        if (empty($conds)) {
+            return self::COND_TRUE;
+        } else {
+            return implode(' OR ', $conds);
+        }
+    }
+
+    public function export()
+    {
+        $export = $this->buildExport('account_perm');
+        $export['values'] = $this->perms;
+        return $export;
+    }
+}
+// }}}
+// {{{ class UFC_Hruid
+/** Filters users based on their hruid
+ * @param $val Either an hruid, or a list of those
+ */
+class UFC_Hruid extends UserFilterCondition
+{
+    private $hruids;
+
+    public function __construct()
+    {
+        $this->hruids = pl_flatten(func_get_args());
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        $uf->requireAccounts();
+        return XDB::format('a.hruid IN {?}', $this->hruids);
+    }
+
+    public function export()
+    {
+        $export = $this->buildExport('hruid');
+        $export['values'] = $this->hruids;
+        return $export;
+    }
+}
+// }}}
+// {{{ class UFC_Hrpid
+/** Filters users based on the hrpid of their profiles
+ * @param $val Either an hrpid, or a list of those
+ */
+class UFC_Hrpid extends UserFilterCondition
+{
+    private $hrpids;
+
+    public function __construct()
+    {
+        $this->hrpids = pl_flatten(func_get_args());
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        $uf->requireProfiles();
+        return XDB::format('p.hrpid IN {?}', $this->hrpids);
+    }
+
+    public function export()
+    {
+        $export = $this->buildExport('hrpid');
+        $export['values'] = $this->hrpids;
+        return $export;
+    }
+}
+// }}}
+// {{{ class UFC_Ip
+/** Filters users based on one of their last IPs
+ * @param $ip IP from which connection are checked
+ */
+class UFC_Ip extends UserFilterCondition
+{
+    private $ip;
+
+    public function __construct($ip)
+    {
+        $this->ip = $ip;
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        $sub = $uf->addLoggerFilter();
+        $ip = ip_to_uint($this->ip);
+        return XDB::format($sub . '.ip = {?} OR ' . $sub . '.forward_ip = {?}', $ip, $ip);
+    }
+
+    public function export()
+    {
+        $export = $this->buildExport('host');
+        $export['ip'] = $this->ip;
+        return $export;
+    }
+}
+// }}}
+// {{{ class UFC_Comment
+class UFC_Comment extends UserFilterCondition
+{
+    private $text;
+
+    public function __construct($text)
+    {
+        $this->text = $text;
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        $uf->requireProfiles();
+        return $uf->getVisibilityCondition('p.freetext_pub') . ' AND p.freetext ' . XDB::formatWildcards(XDB::WILDCARD_CONTAINS, $this->text);
+    }
+
+    public function export()
+    {
+        $export = $this->buildExport('comment');
+        $export['comparison'] = self::OP_CONTAINS;
+        $export['text'] = $this->text;
+        return $export;
+    }
+}
+// }}}
+// {{{ class UFC_Promo
+/** Filters users based on promotion
+ * @param $comparison Comparison operator (>, =, ...)
+ * @param $grade Formation on which to restrict, UserFilter::DISPLAY for "any formation"
+ * @param $promo Promotion on which the filter is based
+ */
+class UFC_Promo extends UserFilterCondition
+{
+
+    private $grade;
+    private $promo;
+    private $comparison;
+
+    public function __construct($comparison, $grade, $promo)
+    {
+        $this->grade = $grade;
+        $this->comparison = $comparison;
+        $this->promo = $promo;
+        if ($this->grade != UserFilter::DISPLAY) {
+            UserFilter::assertGrade($this->grade);
+        }
+        if ($this->grade == UserFilter::DISPLAY && $this->comparison != '=') {
+            // XXX: we might try to guess the grade from the first char of the promo and forbid only '<= 2004', but allow '<= X2004'
+            Platal::page()->killError("Il n'est pas possible d'appliquer la comparaison '" . $this->comparison . "' aux promotions sans spécifier de formation (X/M/D)");
+        }
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        if ($this->grade == UserFilter::DISPLAY) {
+            $sub = $uf->addDisplayFilter();
+            return XDB::format('pd' . $sub . '.promo ' . $this->comparison . ' {?}', $this->promo);
+        } else {
+            $sub = $uf->addEducationFilter(true, $this->grade);
+            $field = 'pe' . $sub . '.' . UserFilter::promoYear($this->grade);
+            return $field . ' IS NOT NULL AND ' . $field . ' ' . $this->comparison . ' ' . XDB::format('{?}', $this->promo);
+        }
+    }
+
+    public function export()
+    {
+        $export['comparison'] = $this->comparison;
+        if ($this->grade != UserFilter::DISPLAY) {
+            $export['grade'] = $this->grade;
+        }
+        $export['promo'] = $this->promo;
+        return $export;
+    }
+}
+// }}}
+// {{{ class UFC_SchoolId
+/** Filters users based on their shoold identifier
+ * @param type Parameter type (Xorg, AX, School)
+ * @param value Array of school ids
+ */
+class UFC_SchoolId extends UserFilterCondition
+{
+    const AX     = 'ax';
+    const Xorg   = 'xorg';
+    const School = 'school';
+
+    private $type;
+    private $id;
+
+    static public function assertType($type)
+    {
+        if ($type != self::AX && $type != self::Xorg && $type != self::School) {
+            Platal::page()->killError("Type de matricule invalide: $type");
+        }
+    }
+
+    /** Construct a UFC_SchoolId
+     * The first argument is the type, all following arguments can be either ids
+     * or arrays of ids to use:
+     * $ufc = new UFC_SchoolId(UFC_SchoolId::AX, $id1, $id2, array($id3, $id4));
+     */
+    public function __construct($type)
+    {
+        $this->type = $type;
+        $ids = func_get_args();
+        array_shift($ids);
+        $this->ids   = pl_flatten($ids);
+        self::assertType($type);
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        $uf->requireProfiles();
+        $ids = $this->ids;
+        $type = $this->type;
+        if ($type == self::School) {
+            $type = self::Xorg;
+            $ids  = array_map(array('Profile', 'getXorgId'), $ids);
+        }
+        return XDB::format('p.' . $type . '_id IN {?}', $ids);
+    }
+}
+// }}}
+// {{{ class UFC_EducationSchool
+/** Filters users by formation
+ * @param $val The formation to search (either ID or array of IDs)
+ */
+class UFC_EducationSchool extends UserFilterCondition
+{
+    private $val;
+
+    public function __construct()
+    {
+        $this->val = pl_flatten(func_get_args());
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        $sub = $uf->addEducationFilter();
+        return XDB::format('pe' . $sub . '.eduid IN {?}', $this->val);
+    }
+}
+// }}}
+// {{{ class UFC_EducationDegree
+class UFC_EducationDegree extends UserFilterCondition
+{
+    private $diploma;
+
+    public function __construct()
+    {
+        $this->diploma = pl_flatten(func_get_args());
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        $sub = $uf->addEducationFilter();
+        return XDB::format('pe' . $sub . '.degreeid IN {?}', $this->diploma);
+    }
+}
+// }}}
+// {{{ class UFC_EducationField
+class UFC_EducationField extends UserFilterCondition
+{
+    private $val;
+
+    public function __construct()
+    {
+        $this->val = pl_flatten(func_get_args());
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        $sub = $uf->addEducationFilter();
+        return XDB::format('pe' . $sub . '.fieldid IN {?}', $this->val);
+    }
+}
+// }}}
+// {{{ class UFC_Name
+/** Filters users based on name
+ * @param $type Type of name field on which filtering is done (firstname, lastname...)
+ * @param $text Text on which to filter
+ * @param $mode Flag indicating search type (prefix, suffix, with particule...)
+ */
+class UFC_Name extends UserFilterCondition
+{
+    const EXACT    = XDB::WILDCARD_EXACT;    // 0x000
+    const PREFIX   = XDB::WILDCARD_PREFIX;   // 0x001
+    const SUFFIX   = XDB::WILDCARD_SUFFIX;   // 0x002
+    const CONTAINS = XDB::WILDCARD_CONTAINS; // 0x003
+    const PARTICLE = 0x004;
+    const VARIANTS = 0x008;
+
+    private $type;
+    private $text;
+    private $mode;
+
+    public function __construct($type, $text, $mode)
+    {
+        $this->type = $type;
+        $this->text = $text;
+        $this->mode = $mode;
+    }
+
+    private function buildNameQuery($type, $variant, $where, UserFilter $uf)
+    {
+        $sub = $uf->addNameFilter($type, $variant);
+        return str_replace('$ME', 'pn' . $sub, $where);
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        $left = '$ME.name';
+        if (($this->mode & self::PARTICLE) == self::PARTICLE) {
+            $left = 'CONCAT($ME.particle, \' \', $ME.name)';
+        }
+        $right = XDB::formatWildcards($this->mode & self::CONTAINS, $this->text);
+
+        $cond = $left . $right;
+        $conds = array($this->buildNameQuery($this->type, null, $cond, $uf));
+        if (($this->mode & self::VARIANTS) != 0 && isset(Profile::$name_variants[$this->type])) {
+            foreach (Profile::$name_variants[$this->type] as $var) {
+                $conds[] = $this->buildNameQuery($this->type, $var, $cond, $uf);
+            }
+        }
+        return implode(' OR ', $conds);
+    }
+
+    public function export()
+    {
+        $export = $this->buildExport($this->type);
+        if ($this->mode & self::VARIANTS) {
+            $export['search_in_variants'] = true;
+        }
+        if ($this->mode & self::PARTICLE) {
+            $export['search_in_particle'] = true;
+        }
+        $export['comparison'] = self::comparisonFromXDBWildcard($this->mode & 0x3);
+        $export['text'] = $this->text;
+        return $export;
+    }
+}
+// }}}
+// {{{ class UFC_NameTokens
+/** Selects users based on tokens in their name (for quicksearch)
+ * @param $tokens An array of tokens to search
+ * @param $flags Flags the tokens must have (e.g 'public' for public search)
+ * @param $soundex (bool) Whether those tokens are fulltext or soundex
+ */
+class UFC_NameTokens extends UserFilterCondition
+{
+    /* Flags */
+    const FLAG_PUBLIC = 'public';
+
+    private $tokens;
+    private $flags;
+    private $soundex;
+    private $exact;
+
+    public function __construct($tokens, $flags = array(), $soundex = false, $exact = false)
+    {
+        if (is_array($tokens)) {
+            $this->tokens = $tokens;
+        } else {
+            $this->tokens = array($tokens);
+        }
+        if (is_array($flags)) {
+            $this->flags = $flags;
+        } else {
+            $this->flags = array($flags);
+        }
+        $this->soundex = $soundex;
+        $this->exact = $exact;
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        $conds = array();
+        foreach ($this->tokens as $i => $token) {
+            $sub = $uf->addNameTokensFilter($token);
+            if ($this->soundex) {
+                $c = XDB::format($sub . '.soundex = {?}', soundex_fr($token));
+            } else if ($this->exact) {
+                $c = XDB::format($sub . '.token = {?}', $token);
+            } else {
+                $c = $sub . '.token ' . XDB::formatWildcards(XDB::WILDCARD_PREFIX, $token);
+            }
+            if ($this->flags != null) {
+                $c .= XDB::format(' AND ' . $sub . '.flags IN {?}', $this->flags);
+            }
+            $conds[] = $c;
+        }
+
+        return implode(' AND ', $conds);
+    }
+}
+// }}}
+// {{{ class UFC_Nationality
+class UFC_Nationality extends UserFilterCondition
+{
+    private $val;
+
+    public function __construct()
+    {
+        $this->val = pl_flatten(func_get_args());
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        $uf->requireProfiles();
+        $nat = XDB::formatArray($this->val);
+        $conds = array(
+            'p.nationality1 IN ' . $nat,
+            'p.nationality2 IN ' . $nat,
+            'p.nationality3 IN ' . $nat,
+        );
+        return implode(' OR ', $conds);
+    }
+}
+// }}}
+// {{{ class UFC_Dead
+/** Filters users based on death date
+ * @param $comparison Comparison operator
+ * @param $date Date to which death date should be compared (DateTime object, string or timestamp)
+ */
+class UFC_Dead extends UserFilterCondition
+{
+    private $comparison;
+    private $date;
+
+    public function __construct($comparison = null, $date = null)
+    {
+        $this->comparison = $comparison;
+        $this->date = make_datetime($date);
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        $uf->requireProfiles();
+        $str = 'p.deathdate IS NOT NULL';
+        if (!is_null($this->comparison)) {
+            $str .= ' AND p.deathdate ' . $this->comparison . ' ' . XDB::format('{?}', $this->date->format('Y-m-d'));
+        }
+        return $str;
+    }
+}
+// }}}
+// {{{ class UFC_Registered
+/** Filters users based on registration state
+ * @param $active Whether we want to use only "active" users (i.e with a valid redirection)
+ * @param $comparison Comparison operator
+ * @param $date Date to which users registration date should be compared
+ */
+class UFC_Registered extends UserFilterCondition
+{
+    private $active;
+    private $comparison;
+    private $date;
+
+    public function __construct($active = false, $comparison = null, $date = null)
+    {
+        $this->active = $active;
+        $this->comparison = $comparison;
+        $this->date = make_datetime($date);
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        $uf->requireAccounts();
+        if ($this->active) {
+            $date = '$UID IS NOT NULL AND a.state = \'active\'';
+        } else {
+            $date = '$UID IS NOT NULL AND a.state != \'pending\'';
+        }
+        if (!is_null($this->comparison)) {
+            $date .= ' AND a.registration_date != \'0000-00-00 00:00:00\' AND a.registration_date ' . $this->comparison . ' ' . XDB::format('{?}', $this->date->format('Y-m-d'));
+        }
+        return $date;
+    }
+}
+// }}}
+// {{{ class UFC_ProfileUpdated
+/** Filters users based on profile update date
+ * @param $comparison Comparison operator
+ * @param $date Date to which profile update date must be compared
+ */
+class UFC_ProfileUpdated extends UserFilterCondition
+{
+    private $comparison;
+    private $date;
+
+    public function __construct($comparison = null, $date = null)
+    {
+        $this->comparison = $comparison;
+        $this->date = $date;
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        $uf->requireProfiles();
+        return 'p.last_change ' . $this->comparison . XDB::format(' {?}', date('Y-m-d H:i:s', $this->date));
+    }
+}
+// }}}
+// {{{ class UFC_Birthday
+/** Filters users based on next birthday date
+ * @param $comparison Comparison operator
+ * @param $date Date to which users next birthday date should be compared
+ */
+class UFC_Birthday extends UserFilterCondition
+{
+    private $comparison;
+    private $date;
+
+    public function __construct($comparison = null, $date = null)
+    {
+        $this->comparison = $comparison;
+        $this->date = $date;
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        $uf->requireProfiles();
+        return 'p.next_birthday ' . $this->comparison . XDB::format(' {?}', date('Y-m-d', $this->date));
+    }
+}
+// }}}
+// {{{ class UFC_Sex
+/** Filters users based on sex
+ * @parm $sex One of User::GENDER_MALE or User::GENDER_FEMALE, for selecting users
+ */
+class UFC_Sex extends UserFilterCondition
+{
+    private $sex;
+    public function __construct($sex)
+    {
+        $this->sex = $sex;
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        if ($this->sex != User::GENDER_MALE && $this->sex != User::GENDER_FEMALE) {
+            return self::COND_FALSE;
+        } else {
+            $uf->requireProfiles();
+            return XDB::format('p.sex = {?}', $this->sex == User::GENDER_FEMALE ? 'female' : 'male');
+        }
+    }
+}
+// }}}
+// {{{ class UFC_Group
+/** Filters users based on group membership
+ * @param $group Group whose members we are selecting
+ * @param $anim Whether to restrict selection to animators of that group
+ */
+class UFC_Group extends UserFilterCondition
+{
+    private $group;
+    private $anim;
+    public function __construct($group, $anim = false)
+    {
+        $this->group = $group;
+        $this->anim = $anim;
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        // Groups have AX visibility.
+        if ($uf->getVisibilityLevel() == ProfileVisibility::VIS_PUBLIC) {
+            return self::COND_TRUE;
+        }
+        $sub = $uf->addGroupFilter($this->group);
+        $where = 'gpm' . $sub . '.perms IS NOT NULL';
+        if ($this->anim) {
+            $where .= ' AND gpm' . $sub . '.perms = \'admin\'';
+        }
+        return $where;
+    }
+}
+// }}}
+// {{{ class UFC_Binet
+/** Selects users based on their belonging to a given (list of) binet
+ * @param $binet either a binet_id or an array of binet_ids
+ */
+class UFC_Binet extends UserFilterCondition
+{
+    private $val;
+
+    public function __construct()
+    {
+        $this->val = pl_flatten(func_get_args());
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        // Binets are private.
+        if ($uf->getVisibilityLevel() != ProfileVisibility::VIS_PRIVATE) {
+            return self::CONF_TRUE;
+        }
+        $sub = $uf->addBinetsFilter();
+        return XDB::format($sub . '.binet_id IN {?}', $this->val);
+    }
+}
+// }}}
+// {{{ class UFC_Section
+/** Selects users based on section
+ * @param $section ID of the section
+ */
+class UFC_Section extends UserFilterCondition
+{
+    private $section;
+
+    public function __construct()
+    {
+        $this->section = pl_flatten(func_get_args());
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        // Sections are private.
+        if ($uf->getVisibilityLevel() != ProfileVisibility::VIS_PRIVATE) {
+            return self::CONF_TRUE;
+        }
+        $uf->requireProfiles();
+        return XDB::format('p.section IN {?}', $this->section);
+    }
+}
+// }}}
+// {{{ class UFC_Email
+/** Filters users based on an email or a list of emails
+ * @param $emails List of emails whose owner must be selected
+ */
+class UFC_Email extends UserFilterCondition
+{
+    private $emails;
+    public function __construct()
+    {
+        $this->emails = pl_flatten(func_get_args());
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        $foreign = array();
+        $virtual = array();
+        $aliases = array();
+        $cond = array();
+
+        if (count($this->emails) == 0) {
+            return PlFilterCondition::COND_TRUE;
+        }
+
+        foreach ($this->emails as $entry) {
+            if (User::isForeignEmailAddress($entry)) {
+                $foreign[] = $entry;
+            } else if (User::isVirtualEmailAddress($entry)) {
+                $virtual[] = $entry;
+            } else {
+                @list($user, $domain) = explode('@', $entry);
+                $aliases[] = $user;
+            }
+        }
+
+        if (count($foreign) > 0) {
+            $sub = $uf->addEmailRedirectFilter($foreign);
+            $cond[] = XDB::format('e' . $sub . '.email IS NOT NULL OR a.email IN {?}', $foreign);
+        }
+        if (count($virtual) > 0) {
+            $sub = $uf->addVirtualEmailFilter($virtual);
+            $cond[] = 'vr' . $sub . '.redirect IS NOT NULL';
+        }
+        if (count($aliases) > 0) {
+            $sub = $uf->addAliasFilter($aliases);
+            $cond[] = 'al' . $sub . '.alias IS NOT NULL';
+        }
+        return '(' . implode(') OR (', $cond) . ')';
+    }
+}
+// }}}
+// {{{ class UFC_Address
+abstract class UFC_Address extends UserFilterCondition
+{
+    /** Valid address type ('hq' is reserved for company addresses)
+     */
+    const TYPE_HOME = 1;
+    const TYPE_PRO  = 2;
+    const TYPE_ANY  = 3;
+
+    /** Text for these types
+     */
+    protected static $typetexts = array(
+        self::TYPE_HOME => 'home',
+        self::TYPE_PRO  => 'pro',
+    );
+
+    protected $type;
+
+    /** Flags for addresses
+     */
+    const FLAG_CURRENT = 0x0001;
+    const FLAG_TEMP    = 0x0002;
+    const FLAG_SECOND  = 0x0004;
+    const FLAG_MAIL    = 0x0008;
+    const FLAG_CEDEX   = 0x0010;
+
+    // Binary OR of those flags
+    const FLAG_ANY     = 0x001F;
+
+    /** Text of these flags
+     */
+    protected static $flagtexts = array(
+        self::FLAG_CURRENT => 'current',
+        self::FLAG_TEMP    => 'temporary',
+        self::FLAG_SECOND  => 'secondary',
+        self::FLAG_MAIL    => 'mail',
+        self::FLAG_CEDEX   => 'cedex',
+    );
+
+    protected $flags;
+
+    public function __construct($type = null, $flags = null)
+    {
+        $this->type  = $type;
+        $this->flags = $flags;
+    }
+
+    protected function initConds($sub, $vis_cond)
+    {
+        $conds = array($vis_cond);
+
+        $types = array();
+        foreach (self::$typetexts as $flag => $type) {
+            if ($flag & $this->type) {
+                $types[] = $type;
+            }
+        }
+        if (count($types)) {
+            $conds[] = XDB::format($sub . '.type IN {?}', $types);
+        }
+
+        if ($this->flags != self::FLAG_ANY) {
+            foreach(self::$flagtexts as $flag => $text) {
+                if ($flag & $this->flags) {
+                    $conds[] = 'FIND_IN_SET(' . XDB::format('{?}', $text) . ', ' . $sub . '.flags)';
+                }
+            }
+        }
+        return $conds;
+    }
+
+}
+// }}}
+// {{{ class UFC_AddressText
+/** Select users based on their address, using full text search
+ * @param $text Text for filter in fulltext search
+ * @param $textSearchMode Mode for search (one of XDB::WILDCARD_*)
+ * @param $type Filter on address type
+ * @param $flags Filter on address flags
+ * @param $country Filter on address country
+ * @param $locality Filter on address locality
+ */
+class UFC_AddressText extends UFC_Address
+{
+
+    private $text;
+    private $textSearchMode;
+
+    public function __construct($text = null, $textSearchMode = XDB::WILDCARD_CONTAINS,
+        $type = null, $flags = self::FLAG_ANY, $country = null, $locality = null)
+    {
+        parent::__construct($type, $flags);
+        $this->text           = $text;
+        $this->textSearchMode = $textSearchMode;
+        $this->country        = $country;
+        $this->locality       = $locality;
+    }
+
+    private function mkMatch($txt)
+    {
+        return XDB::formatWildcards($this->textSearchMode, $txt);
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        $sub = $uf->addAddressFilter();
+        $conds = $this->initConds($sub, $uf->getVisibilityCondition($sub . '.pub'));
+        if ($this->text != null) {
+            $conds[] = $sub . '.text' . $this->mkMatch($this->text);
+        }
+
+        if ($this->country != null) {
+            $subc = $uf->addAddressCountryFilter();
+            $subconds = array();
+            $subconds[] = $subc . '.country' . $this->mkMatch($this->country);
+            $subconds[] = $subc . '.countryFR' . $this->mkMatch($this->country);
+            $conds[] = implode(' OR ', $subconds);
+        }
+
+        if ($this->locality != null) {
+            $subl = $uf->addAddressLocalityFilter();
+            $conds[] = $subl . '.name' . $this->mkMatch($this->locality);
+        }
+
+        return implode(' AND ', $conds);
+    }
+}
+// }}}
+// {{{ class UFC_AddressField
+/** Filters users based on their address,
+ * @param $val Either a code for one of the fields, or an array of such codes
+ * @param $fieldtype The type of field to look for
+ * @param $type Filter on address type
+ * @param $flags Filter on address flags
+ */
+class UFC_AddressField extends UFC_Address
+{
+    const FIELD_COUNTRY    = 1;
+    const FIELD_ADMAREA    = 2;
+    const FIELD_SUBADMAREA = 3;
+    const FIELD_LOCALITY   = 4;
+    const FIELD_ZIPCODE    = 5;
+
+    /** Data of the filter
+     */
+    private $val;
+    private $fieldtype;
+
+    public function __construct($val, $fieldtype, $type = null, $flags = self::FLAG_ANY)
+    {
+        parent::__construct($type, $flags);
+
+        if (!is_array($val)) {
+            $val = array($val);
+        }
+        $this->val       = $val;
+        $this->fieldtype = $fieldtype;
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        $sub = $uf->addAddressFilter();
+        $conds = $this->initConds($sub, $uf->getVisibilityCondition($sub . '.pub'));
+
+        switch ($this->fieldtype) {
+        case self::FIELD_COUNTRY:
+            $field = 'countryId';
+            break;
+        case self::FIELD_ADMAREA:
+            $field = 'administrativeAreaId';
+            break;
+        case self::FIELD_SUBADMAREA:
+            $field = 'subAdministrativeAreaId';
+            break;
+        case self::FIELD_LOCALITY:
+            $field = 'localityId';
+            break;
+        case self::FIELD_ZIPCODE:
+            $field = 'postalCode';
+            break;
+        default:
+            Platal::page()->killError('Invalid address field type: ' . $this->fieldtype);
+        }
+        $conds[] = XDB::format($sub . '.' . $field . ' IN {?}', $this->val);
+
+        return implode(' AND ', $conds);
+    }
+}
+// }}}
+// {{{ class UFC_Corps
+/** Filters users based on the corps they belong to
+ * @param $corps Corps we are looking for (abbreviation)
+ * @param $type Whether we search for original or current corps
+ */
+class UFC_Corps extends UserFilterCondition
+{
+    const CURRENT   = 1;
+    const ORIGIN    = 2;
+
+    private $corps;
+    private $type;
+
+    public function __construct($corps, $type = self::CURRENT)
+    {
+        $this->corps = $corps;
+        $this->type  = $type;
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        /** Tables shortcuts:
+         * pc for profile_corps,
+         * pceo for profile_corps_enum - orginal
+         * pcec for profile_corps_enum - current
+         */
+        $sub = $uf->addCorpsFilter($this->type);
+        $cond = $sub . '.abbreviation = ' . $corps;
+        $cond .= ' AND ' . $uf->getVisibilityCondition($sub . '.corps_pub');
+        return $cond;
+    }
+}
+// }}}
+// {{{ class UFC_Corps_Rank
+/** Filters users based on their rank in the corps
+ * @param $rank Rank we are looking for (abbreviation)
+ */
+class UFC_Corps_Rank extends UserFilterCondition
+{
+    private $rank;
+    public function __construct($rank)
+    {
+        $this->rank = $rank;
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        /** Tables shortcuts:
+         * pc for profile_corps
+         * pcr for profile_corps_rank
+         */
+        $sub = $uf->addCorpsRankFilter();
+        $cond = $sub . '.abbreviation = ' . $rank;
+        // XXX(x2006barrois): find a way to get rid of that hardcoded
+        // reference to 'pc'.
+        $cond .= ' AND ' . $uf->getVisibilityCondition('pc.corps_pub');
+        return $cond;
+    }
+}
+// }}}
+// {{{ class UFC_Job_Company
+/** Filters users based on the company they belong to
+ * @param $type The field being searched (self::JOBID, self::JOBNAME or self::JOBACRONYM)
+ * @param $value The searched value
+ */
+class UFC_Job_Company extends UserFilterCondition
+{
+    const JOBID = 'id';
+    const JOBNAME = 'name';
+    const JOBACRONYM = 'acronym';
+
+    private $type;
+    private $value;
+
+    public function __construct($type, $value)
+    {
+        $this->assertType($type);
+        $this->type = $type;
+        $this->value = $value;
+    }
+
+    private function assertType($type)
+    {
+        if ($type != self::JOBID && $type != self::JOBNAME && $type != self::JOBACRONYM) {
+            Platal::page()->killError("Type de recherche non valide.");
+        }
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        $sub = $uf->addJobCompanyFilter();
+        $cond  = $sub . '.' . $this->type . XDB::formatWildcards(XDB::WILDCARD_CONTAINS, $this->value);
+        $jsub = $uf->addJobFilter();
+        $cond .= ' AND ' . $uf->getVisibilityCondition($jsub . '.pub');
+        return $cond;
+    }
+}
+// }}}
+// {{{ class UFC_Job_Terms
+/** Filters users based on the job terms they assigned to one of their
+ * jobs.
+ * @param $val The ID of the job term, or an array of such IDs
+ */
+class UFC_Job_Terms extends UserFilterCondition
+{
+    private $val;
+
+    public function __construct($val)
+    {
+        if (!is_array($val)) {
+            $val = array($val);
+        }
+        $this->val = $val;
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        $sub = $uf->addJobTermsFilter(count($this->val));
+        $conditions = array();
+        foreach ($this->val as $i => $jtid) {
+            $conditions[] = $sub[$i] . '.jtid_1 = ' . XDB::escape($jtid);
+        }
+        $jsub = $uf->addJobFilter();
+        $conditions[] = $uf->getVisibilityCondition($jsub . '.pub');
+        return implode(' AND ', $conditions);
+    }
+}
+// }}}
+// {{{ class UFC_Job_Description
+/** Filters users based on their job description
+ * @param $description The text being searched for
+ * @param $fields The fields to search for (CV, user-defined)
+ */
+class UFC_Job_Description extends UserFilterCondition
+{
+
+    private $description;
+    private $fields;
+
+    public function __construct($description, $fields)
+    {
+        $this->fields = $fields;
+        $this->description = $description;
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        $conds = array();
+
+        $jsub = $uf->addJobFilter();
+        // CV is private => if only CV requested, and not private,
+        // don't do anything. Otherwise restrict to standard job visibility.
+        if ($this->fields == UserFilter::JOB_CV) {
+           if ($uf->getVisibilityLevel() != ProfileVisibility::VIS_PRIVATE) {
+               return self::CONF_TRUE;
+           }
+        } else {
+            $conds[] = $uf->getVisibilityCondition($jsub . '.pub');
+        }
+
+        if ($this->fields & UserFilter::JOB_USERDEFINED) {
+            $conds[] = $jsub . '.description ' . XDB::formatWildcards(XDB::WILDCARD_CONTAINS, $this->description);
+        }
+        if ($this->fields & UserFilter::JOB_CV && $uf->getVisibilityLevel() == ProfileVisibility::VIS_PRIVATE) {
+            $uf->requireProfiles();
+            $conds[] = 'p.cv ' . XDB::formatWildcards(XDB::WILDCARD_CONTAINS, $this->description);
+        }
+        return implode(' OR ', $conds);
+    }
+}
+// }}}
+// {{{ class UFC_Networking
+/** Filters users based on network identity (IRC, ...)
+ * @param $type Type of network (-1 for any)
+ * @param $value Value to search
+ */
+class UFC_Networking extends UserFilterCondition
+{
+    private $type;
+    private $value;
+
+    public function __construct($type, $value)
+    {
+        $this->type = $type;
+        $this->value = $value;
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        $sub = $uf->addNetworkingFilter();
+        $conds = array();
+        $conds[] = $uf->getVisibilityCondition($sub . '.pub');
+        $conds[] = $sub . '.address ' . XDB::formatWildcards(XDB::WILDCARD_CONTAINS, $this->value);
+        if ($this->type != -1) {
+            $conds[] = $sub . '.nwid = ' . XDB::format('{?}', $this->type);
+        }
+        return implode(' AND ', $conds);
+    }
+}
+// }}}
+// {{{ class UFC_Phone
+/** Filters users based on their phone number
+ * @param $num_type Type of number (pro/user/home)
+ * @param $phone_type Type of phone (fixed/mobile/fax)
+ * @param $number Phone number
+ */
+class UFC_Phone extends UserFilterCondition
+{
+    const NUM_PRO   = 'pro';
+    const NUM_USER  = 'user';
+    const NUM_HOME  = 'address';
+    const NUM_ANY   = 'any';
+
+    const PHONE_FIXED   = 'fixed';
+    const PHONE_MOBILE  = 'mobile';
+    const PHONE_FAX     = 'fax';
+    const PHONE_ANY     = 'any';
+
+    private $num_type;
+    private $phone_type;
+    private $number;
+
+    public function __construct($number, $num_type = self::NUM_ANY, $phone_type = self::PHONE_ANY)
+    {
+        $phone = new Phone(array('display' => $number));
+        $phone->format();
+        $this->number = $phone->search;
+        $this->num_type = $num_type;
+        $this->phone_type = $phone_type;
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        $sub = $uf->addPhoneFilter();
+        $conds = array();
+
+        $conds[] = $uf->getVisibilityCondition($sub . '.pub');
+
+        $conds[] = $sub . '.search_tel = ' . XDB::format('{?}', $this->number);
+        if ($this->num_type != self::NUM_ANY) {
+            $conds[] = $sub . '.link_type = ' . XDB::format('{?}', $this->num_type);
+        }
+        if ($this->phone_type != self::PHONE_ANY) {
+            $conds[] = $sub . '.tel_type = ' . XDB::format('{?}', $this->phone_type);
+        }
+        return implode(' AND ', $conds);
+    }
+}
+// }}}
+// {{{ class UFC_Medal
+/** Filters users based on their medals
+ * @param $medal ID of the medal
+ * @param $grade Grade of the medal (null for 'any')
+ */
+class UFC_Medal extends UserFilterCondition
+{
+    private $medal;
+    private $grade;
+
+    public function __construct($medal, $grade = null)
+    {
+        $this->medal = $medal;
+        $this->grade = $grade;
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        $conds = array();
+
+        // This will require profiles => table 'p' will be available.
+        $sub = $uf->addMedalFilter();
+
+        $conds[] = $uf->getVisibilityCondition('p.medals_pub');
+
+        $conds[] = $sub . '.mid = ' . XDB::format('{?}', $this->medal);
+        if ($this->grade != null) {
+            $conds[] = $sub . '.gid = ' . XDB::format('{?}', $this->grade);
+        }
+        return implode(' AND ', $conds);
+    }
+}
+// }}}
+// {{{ class UFC_Photo
+/** Filters profiles with photo
+ */
+class UFC_Photo extends UserFilterCondition
+{
+    public function buildCondition(PlFilter $uf)
+    {
+        $sub = $uf->addPhotoFilter();
+        return $sub . '.attach IS NOT NULL AND ' . $uf->getVisibilityCondition($sub . '.pub');
+    }
+}
+// }}}
+// {{{ class UFC_Mentor
+class UFC_Mentor extends UserFilterCondition
+{
+    public function buildCondition(PlFilter $uf)
+    {
+        $sub = $uf->addMentorFilter(UserFilter::MENTOR);
+        return $sub . '.expertise IS NOT NULL';
+    }
+}
+// }}}
+// {{{ class UFC_Mentor_Expertise
+/** Filters users by mentoring expertise
+ * @param $expertise Domain of expertise
+ */
+class UFC_Mentor_Expertise extends UserFilterCondition
+{
+    private $expertise;
+
+    public function __construct($expertise)
+    {
+        $this->expertise = $expertise;
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        $sub = $uf->addMentorFilter(UserFilter::MENTOR_EXPERTISE);
+        return $sub . '.expertise ' . XDB::formatWildcards(XDB::WILDCARD_CONTAINS, $this->expertise);
+    }
+}
+// }}}
+// {{{ class UFC_Mentor_Country
+/** Filters users by mentoring country
+ * @param $country Two-letters code of country being searched
+ */
+class UFC_Mentor_Country extends UserFilterCondition
+{
+    private $country;
+
+    public function __construct()
+    {
+        $this->country = pl_flatten(func_get_args());
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        $sub = $uf->addMentorFilter(UserFilter::MENTOR_COUNTRY);
+        return $sub . '.country IN ' . XDB::format('{?}', $this->country);
+    }
+}
+// }}}
+// {{{ class UFC_Mentor_Terms
+/** Filters users based on the job terms they used in mentoring.
+ * @param $val The ID of the job term, or an array of such IDs
+ */
+class UFC_Mentor_Terms extends UserFilterCondition
+{
+    private $val;
+
+    public function __construct($val)
+    {
+        $this->val = $val;
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        $sub = $uf->addMentorFilter(UserFilter::MENTOR_TERM);
+        return $sub . '.jtid_1 = ' . XDB::escape($this->val);
+    }
+}
+// }}}
+// {{{ class UFC_UserRelated
+/** Filters users based on a relation toward a user
+ * @param $user User to which searched users are related
+ */
+abstract class UFC_UserRelated extends UserFilterCondition
+{
+    protected $user;
+    public function __construct(PlUser &$user)
+    {
+        $this->user =& $user;
+    }
+}
+// }}}
+// {{{ class UFC_Contact
+/** Filters users who belong to selected user's contacts
+ */
+class UFC_Contact extends UFC_UserRelated
+{
+    public function buildCondition(PlFilter $uf)
+    {
+        $sub = $uf->addContactFilter($this->user->id());
+        return 'c' . $sub . '.contact IS NOT NULL';
+    }
+}
+// }}}
+// {{{ class UFC_WatchRegistration
+/** Filters users being watched by selected user
+ */
+class UFC_WatchRegistration extends UFC_UserRelated
+{
+    public function buildCondition(PlFilter $uf)
+    {
+        if (!$this->user->watchType('registration')) {
+            return PlFilterCondition::COND_FALSE;
+        }
+        $uids = $this->user->watchUsers();
+        if (count($uids) == 0) {
+            return PlFilterCondition::COND_FALSE;
+        } else {
+            return XDB::format('$UID IN {?}', $uids);
+        }
+    }
+}
+// }}}
+// {{{ class UFC_WatchPromo
+/** Filters users belonging to a promo watched by selected user
+ * @param $user Selected user (the one watching promo)
+ * @param $grade Formation the user is watching
+ */
+class UFC_WatchPromo extends UFC_UserRelated
+{
+    private $grade;
+    public function __construct(PlUser &$user, $grade = UserFilter::GRADE_ING)
+    {
+        parent::__construct($user);
+        $this->grade = $grade;
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        $promos = $this->user->watchPromos();
+        if (count($promos) == 0) {
+            return PlFilterCondition::COND_FALSE;
+        } else {
+            $sube = $uf->addEducationFilter(true, $this->grade);
+            $field = 'pe' . $sube . '.' . UserFilter::promoYear($this->grade);
+            return XDB::format($field . ' IN {?}', $promos);
+        }
+    }
+}
+// }}}
+// {{{ class UFC_WatchContact
+/** Filters users watched by selected user
+ */
+class UFC_WatchContact extends UFC_Contact
+{
+    public function buildCondition(PlFilter $uf)
+    {
+        if (!$this->user->watchContacts()) {
+            return PlFilterCondition::COND_FALSE;
+        }
+        return parent::buildCondition($uf);
+    }
+}
+// }}}
+// {{{ class UFC_MarketingHash
+/** Filters users using the hash generated
+ * to send marketing emails to him.
+ */
+class UFC_MarketingHash extends UserFilterCondition
+{
+    private $hash;
+
+    public function __construct($hash)
+    {
+        $this->hash = $hash;
+    }
+
+    public function buildCondition(PlFilter $uf)
+    {
+        $table = $uf->addMarketingHash();
+        return XDB::format('rm.hash = {?}', $this->hash);
+    }
+}
+// }}}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
diff --git a/classes/userfilter/orders.inc.php b/classes/userfilter/orders.inc.php
new file mode 100644 (file)
index 0000000..c068633
--- /dev/null
@@ -0,0 +1,319 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2011 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 UserFilterOrder
+/** Class providing factories for the UserFilterOrders.
+ */
+abstract class UserFilterOrders
+{
+    public static function fromExport(array $export)
+    {
+        $export = new PlDict($export);
+        if (!$export->has('type')) {
+            throw new Exception("Missing type in export");
+        }
+        $type = $export->s('type');
+        $desc = ($export->s('order') == 'desc');
+        switch ($type) {
+          case 'promo':
+            return new UFO_Promo($export->v('grade'), $desc);
+
+          case 'lastname':
+          case 'name':
+          case 'firstname':
+          case 'nickname':
+          case 'pseudonym':
+            return new UFO_Name($type, $export->v('variant'),
+                                $export->b('particle'), $desc);
+
+          case 'score':
+          case 'registration':
+          case 'birthday':
+          case 'profile_update':
+          case 'death':
+          case 'uid':
+          case 'hruid':
+          case 'pid':
+          case 'hrpid':
+            $class = 'UFO_' . str_replace('_', '', $type);
+            return new $class($desc);
+
+          default:
+            throw new Exception("Unknown order field: $type");
+        }
+    }
+}
+// }}}
+// {{{ class UFO_Promo
+/** Orders users by promotion
+ * @param $grade Formation whose promotion users should be sorted by (restricts results to users of that formation)
+ * @param $desc Whether sort is descending
+ */
+class UFO_Promo extends PlFilterGroupableOrder
+{
+    private $grade;
+
+    public function __construct($grade = null, $desc = false)
+    {
+        parent::__construct($desc);
+        $this->grade = $grade;
+    }
+
+    protected function getSortTokens(PlFilter $uf)
+    {
+        if (UserFilter::isGrade($this->grade)) {
+            $sub = $uf->addEducationFilter($this->grade);
+            return 'pe' . $sub . '.' . UserFilter::promoYear($this->grade);
+        } else {
+            $sub = $uf->addDisplayFilter();
+            return 'pd' . $sub . '.promo';
+        }
+    }
+
+    public function export()
+    {
+        $export = $this->buildExport('promo');
+        if (!is_null($this->grade)) {
+            $export['grade'] = $this->grade;
+        }
+        return $export;
+    }
+}
+// }}}
+// {{{ class UFO_Name
+/** Sorts users by name
+ * @param $type Type of name on which to sort (firstname...)
+ * @param $variant Variant of that name to use (marital, ordinary...)
+ * @param $particle Set to true if particles should be included in the sorting order
+ * @param $desc If sort order should be descending
+ */
+class UFO_Name extends PlFilterOrder
+{
+    private $type;
+    private $variant;
+    private $particle;
+
+    public function __construct($type, $variant = null, $particle = false, $desc = false)
+    {
+        parent::__construct($desc);
+        $this->type = $type;
+        $this->variant = $variant;
+        $this->particle = $particle;
+    }
+
+    protected function getSortTokens(PlFilter $uf)
+    {
+        if (Profile::isDisplayName($this->type)) {
+            $sub = $uf->addDisplayFilter();
+            $token = 'pd' . $sub . '.' . $this->type;
+            if ($uf->accountsRequired()) {
+                $account_token = Profile::getAccountEquivalentName($this->type);
+                return 'IFNULL(' . $token . ', a.' . $account_token . ')';
+            } else {
+                return $token;
+            }
+        } else {
+            $sub = $uf->addNameFilter($this->type, $this->variant);
+            if ($this->particle) {
+                return 'CONCAT(pn' . $sub . '.particle, \' \', pn' . $sub . '.name)';
+            } else {
+                return 'pn' . $sub . '.name';
+            }
+        }
+    }
+
+    public function export()
+    {
+        $export = $this->buildExport($this->type);
+        if (!is_null($this->variant)) {
+            $export['variant'] = $this->variant;
+        }
+        if ($this->particle) {
+            $export['particle'] = true;
+        }
+        return $export;
+    }
+}
+// }}}
+// {{{ class UFO_Score
+class UFO_Score extends PlFilterOrder
+{
+    protected function getSortTokens(PlFilter $uf)
+    {
+        $toks = $uf->getNameTokens();
+        $scores = array();
+
+        // If there weren't any sort tokens, we shouldn't sort by score, sort by NULL instead
+        if (count($toks) == 0) {
+            return 'NULL';
+        }
+
+        foreach ($toks as $sub => $token) {
+            $scores[] = XDB::format('SUM(' . $sub . '.score + IF (' . $sub . '.token = {?}, 5, 0) )', $token);
+        }
+        return implode(' + ', $scores);
+    }
+
+    public function export()
+    {
+        return $this->buildExport('score');
+    }
+}
+// }}}
+// {{{ class UFO_Registration
+/** Sorts users based on registration date
+ */
+class UFO_Registration extends PlFilterOrder
+{
+    protected function getSortTokens(PlFilter $uf)
+    {
+        $uf->requireAccounts();
+        return 'a.registration_date';
+    }
+
+    public function export()
+    {
+        return $this->buildExport('registration');
+    }
+}
+// }}}
+// {{{ class UFO_Birthday
+/** Sorts users based on next birthday date
+ */
+class UFO_Birthday extends PlFilterOrder
+{
+    protected function getSortTokens(PlFilter $uf)
+    {
+        $uf->requireProfiles();
+        return 'p.next_birthday';
+    }
+
+    public function export()
+    {
+        return $this->buildExport('birthday');
+    }
+}
+// }}}
+// {{{ class UFO_ProfileUpdate
+/** Sorts users based on last profile update
+ */
+class UFO_ProfileUpdate extends PlFilterOrder
+{
+    protected function getSortTokens(PlFilter $uf)
+    {
+        $uf->requireProfiles();
+        return 'p.last_change';
+    }
+
+    public function export()
+    {
+        return $this->buildExport('profile_update');
+    }
+}
+// }}}
+// {{{ class UFO_Death
+/** Sorts users based on death date
+ */
+class UFO_Death extends PlFilterOrder
+{
+    protected function getSortTokens(PlFilter $uf)
+    {
+        $uf->requireProfiles();
+        return 'p.deathdate';
+    }
+
+    public function export()
+    {
+        return $this->buildExport('death');
+    }
+}
+// }}}
+// {{{ class UFO_Uid
+/** Sorts users based on their uid
+ */
+class UFO_Uid extends PlFilterOrder
+{
+    protected function getSortTokens(PlFilter $uf)
+    {
+        $uf->requireAccounts();
+        return '$UID';
+    }
+
+    public function export()
+    {
+        return $this->buildExport('uid');
+    }
+}
+// }}}
+// {{{ class UFO_Hruid
+/** Sorts users based on their hruid
+ */
+class UFO_Hruid extends PlFilterOrder
+{
+    protected function getSortTokens(PlFilter $uf)
+    {
+        $uf->requireAccounts();
+        return 'a.hruid';
+    }
+
+    public function export()
+    {
+        return $this->buildExport('hruid');
+    }
+}
+// }}}
+// {{{ class UFO_Pid
+/** Sorts users based on their pid
+ */
+class UFO_Pid extends PlFilterOrder
+{
+    protected function getSortTokens(PlFilter $uf)
+    {
+        $uf->requireProfiles();
+        return '$PID';
+    }
+
+    public function export()
+    {
+        return $this->buildExport('pid');
+    }
+}
+// }}}
+// {{{ class UFO_Hrpid
+/** Sorts users based on their hrpid
+ */
+class UFO_Hrpid extends PlFilterOrder
+{
+    protected function getSortTokens(PlFilter $uf)
+    {
+        $uf->requireProfiles();
+        return 'p.hrpid';
+    }
+
+    public function export()
+    {
+        return $this->buildExport('hrpid');
+    }
+}
+// }}}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
index be74a32..5b42fa1 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 2a63e16..022ab4e 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -43,7 +43,7 @@ class XnetPage extends PlPage
         }
         $this->addJsLink('jquery.js');
         $this->addJsLink('overlib.js');
-        $this->addJsLink('wiki.js');
+        $this->addJsLink('core.js');
         $this->addJsLink('xorg.js');
         $this->setTitle('Les associations polytechniciennes');
     }
index ceaa331..2833d32 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 83bc952..e2a1cef 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -28,7 +28,7 @@ class Xorg extends Platal
                             'profile', 'register', 'search', 'stats', 'admin',
                             'newsletter', 'axletter', 'bandeau', 'survey',
                             'fusionax', 'gadgets', 'googleapps', 'poison',
-                            'openid', 'reminder');
+                            'openid', 'reminder', 'api');
     }
 
     public function find_hook()
index 6a62620..a1a465e 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -30,8 +30,7 @@ class XorgPage extends PlPage
         $this->addJsLink('jquery.js');
         $this->addJsLink('overlib.js');
         $this->addJsLink('secure_hash.js');
-        $this->addJsLink('sha1.js');
-        $this->addJsLink('wiki.js');
+        $this->addJsLink('core.js');
         $this->addJsLink('xorg.js');
         $this->setTitle('le site des élèves et anciens élèves de l\'École polytechnique');
         if (S::logged() && S::user()->checkPerms('admin')) {
index f46107c..2e85275 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -258,6 +258,54 @@ class XorgSession extends PlSession
         }
     }
 
+    /**
+     * The authentication schema is based on three query parameters:
+     *   ?user=<hruid>&timestamp=<timestamp>&sig=<sig>
+     * where:
+     *   - hruid is the hruid of the querying user
+     *   - timestamp is the current UNIX timestamp, which has to be within a
+     *     given distance of the server-side UNIX timestamp
+     *   - sig is the HMAC of "<method>#<resource>#<payload>#<timestamp>" using
+     *     a known secret of the user as the key.
+     *
+     * At the moment, the shared secret of the user is the sha1 hash of its
+     * password. This is temporary, though, until better support for tokens is
+     * implemented in plat/al.
+     * TODO(vzanotti): Switch to dedicated secrets for authentication.
+     */
+    public function apiAuth($method, $resource, $payload)
+    {
+        // Verify that the timestamp is within acceptable bounds.
+        $timestamp = Env::i('timestamp', 0);
+        if (abs($timestamp - time()) > Platal::globals()->api->timestamp_tolerance) {
+            return null;
+        }
+
+        // Retrieve the user corresponding to the forlife. Note that at the
+        // moment, other aliases are also accepted.
+        $user = User::getSilent(Env::s('user', ''));
+        if (is_null($user) || !$user->isActive()) {
+            return null;
+        }
+
+        // Determine the list of tokens associated with the user. At the moment,
+        // this is just the sha1 of the password.
+        $tokens = array($user->password());
+
+        // For each token, try to validate the signature.
+        $message = implode('#', array($method, $resource, $payload, $timestamp));
+        $signature = Env::s('sig');
+        foreach ($tokens as $token) {
+            $expected_signature = hash_hmac(
+                Platal::globals()->api->hmac_algo, $message, $token);
+            if ($signature == $expected_signature) {
+                return $user;
+            }
+        }
+
+        return null;
+    }
+
     public function tokenAuth($login, $token)
     {
         $res = XDB::query('SELECT  a.uid, a.hruid
index 059b0d9..6afd15b 100644 (file)
@@ -71,3 +71,6 @@ replyto=registration+watch@staff.m4x.org
 from="Polytechnique.org" <validation_modification@polytechnique.org>
 cc="Polytechnique.org" <validation_modification@polytechnique.org>
 
+[xnet_notification]
+from="Polytechnique.org" <contact@polytechnique.org>
+
index 4fcbe42..c6ae06f 100644 (file)
@@ -1,5 +1,5 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;  Copyright (C) 2003-2010 Polytechnique.org                               ;
+;  Copyright (C) 2003-2011 Polytechnique.org                               ;
 ;  http://opensource.polytechnique.org/                                    ;
 ;                                                                          ;
 ;  This program is free software; you can redistribute it and/or modify    ;
@@ -77,8 +77,12 @@ robotstxt_disallowed_uris =
 ;   1 - DEBUG_BT: displays the backtraces (SQL, mailman, banana executions)
 ;   2 - DEBUG_VALID: checks that the html of the page is valid
 ;   4 - DEBUG_SMARTY: don't hide error reported during the execution of smarty
+;   8 - DEBUG_NOCACHE: disable data caching
+;  16 - DEBUG_SCRIPTCACHE: cache expires after the execution of the script (no caching
+;                          in session or via memcache)
 ;  - provided by xorg:
-; 256 - DEBUG_NOCACHE: don't cache db content in the session
+; 256 - DEBUG_NOCACHE: don't cache db content in the session (this feature as been moved
+;                      to the core and this flag is deprecated)
 ;
 ; debug = 0
 
@@ -125,6 +129,10 @@ baseurl = "https://www.example.org/"
 ; The charset to use when talking to the database
 ; dbcharset = "utf8"
 
+; $globals->core->memcache
+; List of space separated addresses of memcache servers
+memcache = ""
+
 ; $globals->static_cache_duration
 ; Cache duration for static content
 ; static_cache_duration = "604800"
@@ -148,6 +156,21 @@ register_skin = "register"
 econfiance = ""
 
 
+; The API section contains  the configuration for the web services.
+[Api]
+
+; $globals->api->hmac_algo
+; Algorithm to use for HMAC-based authentication of API requests. Note that this
+; value is shared with clients, and must be changed in all places at once.
+hmac_algo = "sha256"
+
+; $globals->api->timestamp_tolerance
+; Maximum number of seconds of drift allowed between the client-side UNIX clock
+; and the server-side clock. This should be big enough to also allow for network
+; latency, but not too high, to limit replay opportunities.
+timestamp_tolerance = 10
+
+
 ; The banana section contains the configuration of the forums.
 [Banana]
 
@@ -206,6 +229,7 @@ gmaps_hl = "fr"
 ; Default location preference.
 gmaps_gl = "fr"
 
+
 ; The lists section contains parameters used to interact with mailman.
 [Lists]
 
diff --git a/core b/core
index 80c3b57..4836f91 160000 (submodule)
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit 80c3b5792bea15876ef8f79b8a64421733c1c001
+Subproject commit 4836f918dd6180f92e10722f9a01b9013f42da64
index 7b51d05..4bdc6bc 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 5a060f3..2ccb3d8 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index a65b03f..10890c6 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
 
 .ui-tabs-hide { display: none; }
 
+.ui-icon {
+    width: 16px;
+    height: 16px;
+}
+
+.ui-datepicker {
+    background: #ffffff;
+    color: #000000;
+    position: absolute;
+}
+
+.ui-datepicker a {
+    color: black;
+    text-decoration: none;
+    text-align: center;
+}
+
+.ui-datepicker-header {
+    padding: 2px;
+    margin: 1px;
+    background: #777;
+    border: 1px solid;
+    border-color: #333;
+}
+
+.ui-datepicker-title {
+    text-align: center;
+    height: 19px;
+}
+
+.ui-datepicker-prev {
+    background: #777 url('/images/icons/resultset_previous.gif');
+    position: absolute;
+    width: 16px;
+    height: 16px;
+    top: 4px;
+    left: 4px;
+    outline: none;
+    display: block;
+}
+
+.ui-datepicker-next {
+    background: #777 url('/images/icons/resultset_next.gif');
+    position: absolute;
+    width: 16px;
+    height: 16px;
+    top: 4px;
+    right: 4px;
+    outline: none;
+    display: block;
+}
+
+.ui-datepicker-next span, .ui-datepicker-prev span {
+    display: block;
+    position: absolute;
+    text-indent: -99999px;
+    overflow: hidden;
+}
+
+.ui-datepicker-calendar {
+    border-collapse: collapse;
+    text-align: right;
+}
+
+.ui-datepicker-calendar td {
+    width: 20px;
+}
+
+.ui-datepicker-week-end {
+    background-color: #eee;
+}
+
+.ui-datepicker-unselectable {
+    color: #777;
+}
+
 /* vim: set et ts=4 sts=4 sw=4: */
index 4ae8637..bdf3fb8 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -212,6 +212,18 @@ table.tinybicol td, table.bicol td {
     background: inherit;
 }
 
+table.tinybicol td.error, table.bicol td.error {
+    background: #faa;
+}
+
+table.tinybicol td.warning, table.bicol td.warning {
+    background: #fda;
+}
+
+table.tinybicol td.valid, table.bicol td.valid {
+    background: #afa;
+}
+
 table.tinybicol td, table.bicol td, table.tinybicol tr, table.bicol tr { padding: 4px; }
 
 td.half { width: 50%; padding: 4px; }
index 42a34a3..6ecc552 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index a8b5e3b..a5a2474 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 4c5364e..8f3688c 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 7372142..73894fd 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -231,6 +231,18 @@ table.tinybicol td, table.bicol td {
     background: inherit;
 }
 
+table.tinybicol td.error, table.bicol td.error {
+    background: #faa;
+}
+
+table.tinybicol td.warning, table.bicol td.warning {
+    background: #fda;
+}
+
+table.tinybicol td.valid, table.bicol td.valid {
+    background: #afa;
+}
+
 table.tinybicol td, table.bicol td, table.tinybicol tr, table.bicol tr { padding: 4px; }
 
 td.half { width: 50%; padding: 4px; }
index 65e5b87..c29104d 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index c881c26..9fa7a31 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 9142891..086ea6e 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 8ed5f96..cd0dcc3 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 5a2566e..62620b0 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index bf6f342..0d2d7d5 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 83634d8..0682da6 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -201,6 +201,18 @@ table.tinybicol td, table.bicol td {
     padding: 0px 4px;
 }
 
+table.tinybicol td.error, table.bicol td.error {
+    background: #faa;
+}
+
+table.tinybicol td.warning, table.bicol td.warning {
+    background: #fda;
+}
+
+table.tinybicol td.valid, table.bicol td.valid {
+    background: #afa;
+}
+
 td.half { width: 50%; padding: 4px; }
 
 td.titre {
index c7343a7..029fb18 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 2ac5b06..1cad87e 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 0de11c8..f077866 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index ddd07d3..2b2ad7a 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index fe7a6a6..85fe6a4 100644 (file)
@@ -1,9 +1,7 @@
 # Versioning links
-/0.10.*
-/0.f.*
 /1.*
 
 # jQuery and its plugins are downloaded by the Makefile
 /jquery*.*js
-/ui.*js
+/core.js
 !/jquery.autocomplete.js
diff --git a/htdocs/javascript/ajax.js b/htdocs/javascript/ajax.js
deleted file mode 100644 (file)
index 95ee31f..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-/***************************************************************************
- *  Copyright (C) 2003-2010 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 AjaxEngine()
-{
-    this.update_html = function(obj, src, func)
-    {
-        $.get(src,
-            function(data, textStatus) {
-                if (textStatus == "success") {
-                    if (obj) {
-                        $('#' + obj).html(data);
-                    }
-                    if (func) {
-                        func(data);
-                    }
-                } else if (textStatus == "error") {
-                    alert("Une erreur s'est produite lors du traitement de la requête.\n"
-                         +"Ta session a peut-être expirée.");
-                }
-            }, 'text');
-        return false;
-    }
-}
-
-var Ajax = new AjaxEngine();
-
-var currentTempMessage = 0;
-function setOpacity(obj, opacity)
-{
-  opacity = (opacity == 100)?99:opacity;
-  // IE
-  obj.style.filter = "alpha(opacity:"+opacity+")";
-  // Safari < 1.2, Konqueror
-  obj.style.KHTMLOpacity = opacity/100;
-  // Old Mozilla
-  obj.style.MozOpacity = opacity/100;
-  // Safari >= 1.2, Firefox and Mozilla, CSS3
-  obj.style.opacity = opacity/100
-}
-
-function _showTempMessage(id, state, back)
-{
-    var obj = document.getElementById(id);
-    if (currentTempMessage != state) {
-        return;
-    }
-    setOpacity(obj, back * 4);
-    if (back > 0) {
-        setTimeout("_showTempMessage('" + id + "', " + currentTempMessage + "," + (back-1) + ")", 125);
-    } else {
-        obj.innerHTML = "";
-    }
-}
-
-function showTempMessage(id, message, success)
-{
-    var obj = document.getElementById(id);
-    obj.innerHTML = (success ? "<img src='images/icons/wand.gif' alt='' /> "
-                             : "<img src='images/icons/error.gif' alt='' /> ") + message;
-    obj.style.fontWeight = "bold";
-    obj.style.color = (success ? "green" : "red");;
-    currentTempMessage++;
-    setOpacity(obj, 100);
-    setTimeout("_showTempMessage('" + id + "', " + currentTempMessage + ", 25)", 1000);
-}
-
-function previewWiki(idFrom, idTo, withTitle, idShow)
-{
-    var text = document.getElementById(idFrom).value;
-    if (text == "") {
-        return false;
-    }
-    var url  = "wiki_preview";
-    if (!withTitle) {
-        url += "/notitle";
-    }
-    $.post(url, { text: text },
-        function(data) {
-            $("#" + idTo).html(data);
-        },
-        'text');
-    if (idShow != null) {
-        document.getElementById(idShow).style.display = "";
-    }
-}
-
-function sendTestEmail(token, hruid)
-{
-    Ajax.update_html(null, 'emails/test' + (hruid == null ? '' : '/' + hruid) + '?token=' + token,
-                     function() {
-                        showTempMessage('mail_sent', "Un email a été envoyé avec succès"
-                                        + (hruid == null ? " sur ton adresse." : " sur l'adresse de " + hruid),
-                                        true); });
-    return false;
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
index 102ec18..43d551e 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 061d5c8..29fc83c 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index b59adc1..af06b51 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -30,7 +30,7 @@ function markEventAsRead(event_id)
     _toggle(_gel("mark-read-" + event_id));
     _gel("evt-" + event_id).setAttribute("class", "read");
     _gel("link-" + event_id).setAttribute("href", "events/unread/" + event_id);
-    Ajax.update_html(null, "events/read/" + event_id);
+    $.xget("events/read/" + event_id);
     return false;
 }
 
index d9b438d..936f430 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 578e345..af708a8 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index a173e4b..ff6c312 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -77,10 +77,12 @@ function addSearchName(isFemale)
     while ($('#search_name_' + i).length != 0) {
         i++;
     }
-    Ajax.update_html('search_name_' + i, 'profile/ajax/searchname/' + i + '/' + isFemale, function(data){
-        $('#searchname').before(data);
-        changeNameFlag(i);
-    });
+    $('#search_name_' + i)
+        .updateHtml('profile/ajax/searchname/' + i + '/' + isFemale,
+                    function(data) {
+                        $('#searchname').before(data);
+                        changeNameFlag(i);
+                    });
 }
 
 function removeSearchName(i, isFemale)
@@ -117,11 +119,12 @@ function updateNameDisplay(isFemale)
             searchnames += $('#search_name_' + i).find(':text').val() + ';;';
         }
     }
-    Ajax.update_html(null, 'profile/ajax/buildnames/' + searchnames + '/' + isFemale, function(data){
-        var name = data.split(';');
-        $('#public_name').html(name[0]);
-        $('#private_name').html(name[0] + name[1]);
-    });
+    $.xget('profile/ajax/buildnames/' + searchnames + '/' + isFemale,
+           function(data){
+               var name = data.split(';');
+               $('#public_name').html(name[0]);
+               $('#private_name').html(name[0] + name[1]);
+           });
 }
 
 function toggleParticle(id)
@@ -321,7 +324,8 @@ function addAddress()
         i++;
     }
     $('#add_address').before('<div id="addresses_' + i + '_cont"></div>');
-    Ajax.update_html('addresses_' + i + '_cont', 'profile/ajax/address/' + i, checkCurrentAddress());
+    $('#addresses_' + i + '_cont').updateHtml('profile/ajax/address/' + i,
+                                              checkCurrentAddress());
 }
 
 function addressChanged(prefid)
@@ -353,7 +357,7 @@ function addTel(prefid, prefname, subField, mainField, mainId)
         i++;
     }
     $('#' + prefix + 'add').before('<div id="' + prefix + i + '" style="clear: both; padding-top: 4px; padding-bottom: 4px"></div>');
-    Ajax.update_html(prefix + i, 'profile/ajax/tel/' + prefid + '/' + prefname + '/' + i + '/' + subField + '/' + mainField + '/' + mainId);
+    $('#' + prefix + i).updateHtml('profile/ajax/tel/' + prefid + '/' + prefname + '/' + i + '/' + subField + '/' + mainField + '/' + mainId);
 }
 
 function removeTel(prefname, prefid, id)
@@ -634,6 +638,8 @@ function selectJobTerm(li)
  */
 function toggleJobTermsTree(jobid, textfilter)
 {
+    $('#term_tree_comment').toggle();
+
     var treepath;
     if (jobid < 0) {
         treepath = '';
index 71c6fbf..56ece48 100644 (file)
-/***************************************************************************\r
- *  Copyright (C) 2003-2010 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
-function hash_encrypt(a) {\r
-    return hex_sha1(a);\r
-}\r
-\r
-var hexa_h = "0123456789abcdef";\r
-\r
-function dechex(a) {\r
-    return hexa_h.charAt(a);\r
-}\r
-\r
-function hexdec(a) {\r
-    return hexa_h.indexOf(a);\r
-}\r
-\r
-function hash_xor(a, b) {\r
-    var c,i,j,k;\r
-    c = "";\r
-    i = a.length;\r
-    j = b.length;\r
-    if (i < j) {\r
-        var d;\r
-        d = a; a = b; b = d;\r
-        k = i; i = j; j = k;\r
-    }\r
-    for (k = 0; k < j; k++)\r
-        c += dechex(hexdec(a.charAt(k)) ^ hexdec(b.charAt(k)));\r
-    for (; k < i; k++)\r
-        c += a.charAt(k);\r
-    return c;\r
-}\r
+/***************************************************************************
+ *  Copyright (C) 2003-2011 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                *
+ ***************************************************************************/
+
+/* {{{ SHA1 Implementation */
+
+/*
+ * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
+ * in FIPS PUB 180-1
+ * Version 2.1a Copyright Paul Johnston 2000 - 2002.
+ * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
+ * Distributed under the BSD License
+ * See http://pajhome.org.uk/crypt/md5 for details.
+ */
+
+/*
+ * Configurable variables. You may need to tweak these to be compatible with
+ * the server-side, but the defaults work in most cases.
+ */
+var hexcase = 0;  /* hex output format. 0 - lowercase; 1 - uppercase        */
+var b64pad  = ""; /* base-64 pad character. "=" for strict RFC compliance   */
+var chrsz   = 8;  /* bits per input character. 8 - ASCII; 16 - Unicode      */
+
+/*
+ * These are the functions you'll usually want to call
+ * They take string arguments and return either hex or base-64 encoded strings
+ */
+function hex_sha1(s){return binb2hex(core_sha1(str2binb(s),s.length * chrsz));}
+function b64_sha1(s){return binb2b64(core_sha1(str2binb(s),s.length * chrsz));}
+function str_sha1(s){return binb2str(core_sha1(str2binb(s),s.length * chrsz));}
+function hex_hmac_sha1(key, data){ return binb2hex(core_hmac_sha1(key, data));}
+function b64_hmac_sha1(key, data){ return binb2b64(core_hmac_sha1(key, data));}
+function str_hmac_sha1(key, data){ return binb2str(core_hmac_sha1(key, data));}
+
+/*
+ * Perform a simple self-test to see if the VM is working
+ */
+function sha1_vm_test()
+{
+  return hex_sha1("abc") == "a9993e364706816aba3e25717850c26c9cd0d89d";
+}
+
+/*
+ * Calculate the SHA-1 of an array of big-endian words, and a bit length
+ */
+function core_sha1(x, len)
+{
+  /* append padding */
+  x[len >> 5] |= 0x80 << (24 - len % 32);
+  x[((len + 64 >> 9) << 4) + 15] = len;
+
+  var w = Array(80);
+  var a =  1732584193;
+  var b = -271733879;
+  var c = -1732584194;
+  var d =  271733878;
+  var e = -1009589776;
+
+  for(var i = 0; i < x.length; i += 16)
+  {
+    var olda = a;
+    var oldb = b;
+    var oldc = c;
+    var oldd = d;
+    var olde = e;
+
+    for(var j = 0; j < 80; j++)
+    {
+      if(j < 16) w[j] = x[i + j];
+      else w[j] = rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1);
+      var t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)),
+                       safe_add(safe_add(e, w[j]), sha1_kt(j)));
+      e = d;
+      d = c;
+      c = rol(b, 30);
+      b = a;
+      a = t;
+    }
+
+    a = safe_add(a, olda);
+    b = safe_add(b, oldb);
+    c = safe_add(c, oldc);
+    d = safe_add(d, oldd);
+    e = safe_add(e, olde);
+  }
+  return Array(a, b, c, d, e);
+
+}
+
+/*
+ * Perform the appropriate triplet combination function for the current
+ * iteration
+ */
+function sha1_ft(t, b, c, d)
+{
+  if(t < 20) return (b & c) | ((~b) & d);
+  if(t < 40) return b ^ c ^ d;
+  if(t < 60) return (b & c) | (b & d) | (c & d);
+  return b ^ c ^ d;
+}
+
+/*
+ * Determine the appropriate additive constant for the current iteration
+ */
+function sha1_kt(t)
+{
+  return (t < 20) ?  1518500249 : (t < 40) ?  1859775393 :
+         (t < 60) ? -1894007588 : -899497514;
+}
+
+/*
+ * Calculate the HMAC-SHA1 of a key and some data
+ */
+function core_hmac_sha1(key, data)
+{
+  var bkey = str2binb(key);
+  if(bkey.length > 16) bkey = core_sha1(bkey, key.length * chrsz);
+
+  var ipad = Array(16), opad = Array(16);
+  for(var i = 0; i < 16; i++)
+  {
+    ipad[i] = bkey[i] ^ 0x36363636;
+    opad[i] = bkey[i] ^ 0x5C5C5C5C;
+  }
+
+  var hash = core_sha1(ipad.concat(str2binb(data)), 512 + data.length * chrsz);
+  return core_sha1(opad.concat(hash), 512 + 160);
+}
+
+/*
+ * Add integers, wrapping at 2^32. This uses 16-bit operations internally
+ * to work around bugs in some JS interpreters.
+ */
+function safe_add(x, y)
+{
+  var lsw = (x & 0xFFFF) + (y & 0xFFFF);
+  var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
+  return (msw << 16) | (lsw & 0xFFFF);
+}
+
+/*
+ * Bitwise rotate a 32-bit number to the left.
+ */
+function rol(num, cnt)
+{
+  return (num << cnt) | (num >>> (32 - cnt));
+}
+
+/*
+ * Convert an 8-bit or 16-bit string to an array of big-endian words
+ * In 8-bit function, characters >255 have their hi-byte silently ignored.
+ */
+function str2binb(str)
+{
+  var bin = Array();
+  var mask = (1 << chrsz) - 1;
+  for(var i = 0; i < str.length * chrsz; i += chrsz)
+    bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (32 - chrsz - i%32);
+  return bin;
+}
+
+/*
+ * Convert an array of big-endian words to a string
+ */
+function binb2str(bin)
+{
+  var str = "";
+  var mask = (1 << chrsz) - 1;
+  for(var i = 0; i < bin.length * 32; i += chrsz)
+    str += String.fromCharCode((bin[i>>5] >>> (32 - chrsz - i%32)) & mask);
+  return str;
+}
+
+/*
+ * Convert an array of big-endian words to a hex string.
+ */
+function binb2hex(binarray)
+{
+  var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
+  var str = "";
+  for(var i = 0; i < binarray.length * 4; i++)
+  {
+    str += hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) +
+           hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8  )) & 0xF);
+  }
+  return str;
+}
+
+/*
+ * Convert an array of big-endian words to a base-64 string
+ */
+function binb2b64(binarray)
+{
+  var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+  var str = "";
+  for(var i = 0; i < binarray.length * 4; i += 3)
+  {
+    var triplet = (((binarray[i   >> 2] >> 8 * (3 -  i   %4)) & 0xFF) << 16)
+                | (((binarray[i+1 >> 2] >> 8 * (3 - (i+1)%4)) & 0xFF) << 8 )
+                |  ((binarray[i+2 >> 2] >> 8 * (3 - (i+2)%4)) & 0xFF);
+    for(var j = 0; j < 4; j++)
+    {
+      if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
+      else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
+    }
+  }
+  return str;
+}
+
+/* }}} */
+
+function hash_encrypt(a) {
+    return hex_sha1(a);
+}
+
+var hexa_h = "0123456789abcdef";
+
+function dechex(a) {
+    return hexa_h.charAt(a);
+}
+
+function hexdec(a) {
+    return hexa_h.indexOf(a);
+}
+
+function hash_xor(a, b) {
+    var c,i,j,k;
+    c = "";
+    i = a.length;
+    j = b.length;
+    if (i < j) {
+        var d;
+        d = a; a = b; b = d;
+        k = i; i = j; j = k;
+    }
+    for (k = 0; k < j; k++)
+        c += dechex(hexdec(a.charAt(k)) ^ hexdec(b.charAt(k)));
+    for (; k < i; k++)
+        c += a.charAt(k);
+    return c;
+}
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
diff --git a/htdocs/javascript/sha1.js b/htdocs/javascript/sha1.js
deleted file mode 100644 (file)
index a546ee3..0000000
+++ /dev/null
@@ -1,203 +0,0 @@
-/*\r
- * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined\r
- * in FIPS PUB 180-1\r
- * Version 2.1a Copyright Paul Johnston 2000 - 2002.\r
- * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet\r
- * Distributed under the BSD License\r
- * See http://pajhome.org.uk/crypt/md5 for details.\r
- */\r
-\r
-/*\r
- * Configurable variables. You may need to tweak these to be compatible with\r
- * the server-side, but the defaults work in most cases.\r
- */\r
-var hexcase = 0;  /* hex output format. 0 - lowercase; 1 - uppercase        */\r
-var b64pad  = ""; /* base-64 pad character. "=" for strict RFC compliance   */\r
-var chrsz   = 8;  /* bits per input character. 8 - ASCII; 16 - Unicode      */\r
-\r
-/*\r
- * These are the functions you'll usually want to call\r
- * They take string arguments and return either hex or base-64 encoded strings\r
- */\r
-function hex_sha1(s){return binb2hex(core_sha1(str2binb(s),s.length * chrsz));}\r
-function b64_sha1(s){return binb2b64(core_sha1(str2binb(s),s.length * chrsz));}\r
-function str_sha1(s){return binb2str(core_sha1(str2binb(s),s.length * chrsz));}\r
-function hex_hmac_sha1(key, data){ return binb2hex(core_hmac_sha1(key, data));}\r
-function b64_hmac_sha1(key, data){ return binb2b64(core_hmac_sha1(key, data));}\r
-function str_hmac_sha1(key, data){ return binb2str(core_hmac_sha1(key, data));}\r
-\r
-/*\r
- * Perform a simple self-test to see if the VM is working\r
- */\r
-function sha1_vm_test()\r
-{\r
-  return hex_sha1("abc") == "a9993e364706816aba3e25717850c26c9cd0d89d";\r
-}\r
-\r
-/*\r
- * Calculate the SHA-1 of an array of big-endian words, and a bit length\r
- */\r
-function core_sha1(x, len)\r
-{\r
-  /* append padding */\r
-  x[len >> 5] |= 0x80 << (24 - len % 32);\r
-  x[((len + 64 >> 9) << 4) + 15] = len;\r
-\r
-  var w = Array(80);\r
-  var a =  1732584193;\r
-  var b = -271733879;\r
-  var c = -1732584194;\r
-  var d =  271733878;\r
-  var e = -1009589776;\r
-\r
-  for(var i = 0; i < x.length; i += 16)\r
-  {\r
-    var olda = a;\r
-    var oldb = b;\r
-    var oldc = c;\r
-    var oldd = d;\r
-    var olde = e;\r
-\r
-    for(var j = 0; j < 80; j++)\r
-    {\r
-      if(j < 16) w[j] = x[i + j];\r
-      else w[j] = rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1);\r
-      var t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)),\r
-                       safe_add(safe_add(e, w[j]), sha1_kt(j)));\r
-      e = d;\r
-      d = c;\r
-      c = rol(b, 30);\r
-      b = a;\r
-      a = t;\r
-    }\r
-\r
-    a = safe_add(a, olda);\r
-    b = safe_add(b, oldb);\r
-    c = safe_add(c, oldc);\r
-    d = safe_add(d, oldd);\r
-    e = safe_add(e, olde);\r
-  }\r
-  return Array(a, b, c, d, e);\r
-\r
-}\r
-\r
-/*\r
- * Perform the appropriate triplet combination function for the current\r
- * iteration\r
- */\r
-function sha1_ft(t, b, c, d)\r
-{\r
-  if(t < 20) return (b & c) | ((~b) & d);\r
-  if(t < 40) return b ^ c ^ d;\r
-  if(t < 60) return (b & c) | (b & d) | (c & d);\r
-  return b ^ c ^ d;\r
-}\r
-\r
-/*\r
- * Determine the appropriate additive constant for the current iteration\r
- */\r
-function sha1_kt(t)\r
-{\r
-  return (t < 20) ?  1518500249 : (t < 40) ?  1859775393 :\r
-         (t < 60) ? -1894007588 : -899497514;\r
-}\r
-\r
-/*\r
- * Calculate the HMAC-SHA1 of a key and some data\r
- */\r
-function core_hmac_sha1(key, data)\r
-{\r
-  var bkey = str2binb(key);\r
-  if(bkey.length > 16) bkey = core_sha1(bkey, key.length * chrsz);\r
-\r
-  var ipad = Array(16), opad = Array(16);\r
-  for(var i = 0; i < 16; i++)\r
-  {\r
-    ipad[i] = bkey[i] ^ 0x36363636;\r
-    opad[i] = bkey[i] ^ 0x5C5C5C5C;\r
-  }\r
-\r
-  var hash = core_sha1(ipad.concat(str2binb(data)), 512 + data.length * chrsz);\r
-  return core_sha1(opad.concat(hash), 512 + 160);\r
-}\r
-\r
-/*\r
- * Add integers, wrapping at 2^32. This uses 16-bit operations internally\r
- * to work around bugs in some JS interpreters.\r
- */\r
-function safe_add(x, y)\r
-{\r
-  var lsw = (x & 0xFFFF) + (y & 0xFFFF);\r
-  var msw = (x >> 16) + (y >> 16) + (lsw >> 16);\r
-  return (msw << 16) | (lsw & 0xFFFF);\r
-}\r
-\r
-/*\r
- * Bitwise rotate a 32-bit number to the left.\r
- */\r
-function rol(num, cnt)\r
-{\r
-  return (num << cnt) | (num >>> (32 - cnt));\r
-}\r
-\r
-/*\r
- * Convert an 8-bit or 16-bit string to an array of big-endian words\r
- * In 8-bit function, characters >255 have their hi-byte silently ignored.\r
- */\r
-function str2binb(str)\r
-{\r
-  var bin = Array();\r
-  var mask = (1 << chrsz) - 1;\r
-  for(var i = 0; i < str.length * chrsz; i += chrsz)\r
-    bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (32 - chrsz - i%32);\r
-  return bin;\r
-}\r
-\r
-/*\r
- * Convert an array of big-endian words to a string\r
- */\r
-function binb2str(bin)\r
-{\r
-  var str = "";\r
-  var mask = (1 << chrsz) - 1;\r
-  for(var i = 0; i < bin.length * 32; i += chrsz)\r
-    str += String.fromCharCode((bin[i>>5] >>> (32 - chrsz - i%32)) & mask);\r
-  return str;\r
-}\r
-\r
-/*\r
- * Convert an array of big-endian words to a hex string.\r
- */\r
-function binb2hex(binarray)\r
-{\r
-  var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";\r
-  var str = "";\r
-  for(var i = 0; i < binarray.length * 4; i++)\r
-  {\r
-    str += hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) +\r
-           hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8  )) & 0xF);\r
-  }\r
-  return str;\r
-}\r
-\r
-/*\r
- * Convert an array of big-endian words to a base-64 string\r
- */\r
-function binb2b64(binarray)\r
-{\r
-  var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";\r
-  var str = "";\r
-  for(var i = 0; i < binarray.length * 4; i += 3)\r
-  {\r
-    var triplet = (((binarray[i   >> 2] >> 8 * (3 -  i   %4)) & 0xFF) << 16)\r
-                | (((binarray[i+1 >> 2] >> 8 * (3 - (i+1)%4)) & 0xFF) << 8 )\r
-                |  ((binarray[i+2 >> 2] >> 8 * (3 - (i+2)%4)) & 0xFF);\r
-    for(var j = 0; j < 4; j++)\r
-    {\r
-      if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;\r
-      else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);\r
-    }\r
-  }\r
-  return str;\r
-}\r
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
diff --git a/htdocs/javascript/survey.js b/htdocs/javascript/survey.js
new file mode 100644 (file)
index 0000000..a0ef4e2
--- /dev/null
@@ -0,0 +1,193 @@
+/***************************************************************************
+ *  Copyright (C) 2003-2011 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($) {
+    $.extend({
+        questions: function() {
+            return $('.q_edit:not(#questions)');
+        },
+
+        lastQuestion: function() {
+            return $.questions().last();
+        },
+
+        renumberQuestions: function() {
+            var q = $.questions();
+            q.each(function(idx) {
+                var elt = $(this);
+                var old_id = elt.attr('id');
+                var new_id = 'q_edit[' + idx + ']';
+                if (old_id == new_id) {
+                    return;
+                }
+
+                var children = elt.children(':not(.q_edit)');
+                while (children.length > 0) {
+                    children.filter('.q_edit_label').text('Question ' + (idx + 1));
+                    children.children('[name*="' + old_id + '"]').each(function() {
+                        function replace(attr) {
+                            var cid = $(this).attr(attr);
+                            if (cid.substr(0, id.length) == old_id) {
+                               $(this).attr(attr, new_id + cid.substring(old_id.length, cid.length));
+                            }
+                        }
+                        replace('id');
+                        replace('name');
+                    });
+                    children = children.children(':not(.q_edit)');
+                }
+                elt.attr('id', new_id);
+            });
+        },
+
+        debugPrintQuestions: function() {
+            var q = $.questions();
+            var str = '';
+            q.each(function() {
+                str += $(this).attr('id') + '\n';
+            });
+            alert(str);
+        }
+    });
+
+    $.fn.extend({
+        showQuestions: function(questions) {
+            var data = $('#question_base').tmpl(questions);
+            this.empty();
+            data.appendTo(this);
+            return this;
+        },
+
+        /* Edition form */
+        prepareQuestions: function(questions) {
+            var data = $('#q_edit_new').tmpl(questions);
+            data.prependTo(this);
+            return this;
+        },
+
+        isQuestion: function() {
+            return this.hasClass('q_edit');
+        },
+
+        isRootSection: function() {
+            return this.attr('id') == 'questions';
+        },
+
+        question: function() {
+            return this.isQuestion() ? this : this.parentQuestion();
+        },
+
+        qid: function() {
+            var question = this.question();
+            if (question.get(0) == undefined) {
+                return undefined;
+            }
+            var id = question.attr('id');
+            if (id.substr(0, 7) != 'q_edit[') {
+                return undefined;
+            }
+            if (id.charAt(id.length - 1) != ']') {
+                return undefined;
+            }
+            id = id.substr(7, id.length - 8);
+            return parseInt(id);
+        },
+
+        parentQuestion: function() {
+            return this.parent().closest('.q_edit');
+        },
+
+        childrenContainer: function() {
+            var question = this.question();
+            return question.isRootSection() ? question : question.children('.q_edit_form').children();
+        },
+
+        childrenQuestion: function() {
+            return this.childrenContainer().children('.q_edit');
+        },
+
+        addQuestion: function() {
+            var id = $.lastQuestion().qid();
+            if (id == undefined) {
+                id = 0;
+            } else {
+                id++;
+            }
+            var question = $("#q_edit_new").tmpl([{ qid: id } ]);
+            question
+                .children('select')
+                .change(function () {
+                    var type = $(this).val();
+                    var form = question.children('.q_edit_form');
+                    form.empty();
+                    $("#q_edit_base").tmpl([ { qid: id, type: type } ]).appendTo(form);
+                    return true;
+                });
+            var dest = this.question();
+            var res = this.childrenContainer().children('.add_question').before(question);
+            $.renumberQuestions();
+            return res;
+        },
+
+        removeQuestion: function(force) {
+            var question = this.parentQuestion();
+            if (!force && question.children('.q_edit_form').children().children('.q_edit').length > 0) {
+                if (!alert('Vous avez demander la suppression d\'une section contenant des questions. '
+                         + 'Ces questions seront supprimées. Etes-vous sur de vouloir continuer ?')) {
+                    return this;
+                }
+            }
+            var res;
+            if (question.isRootSection()) {
+                res = question.empty();
+            } else {
+                res = question.remove();
+            }
+            $.renumberQuestions();
+            return res;
+        },
+
+        buildParentsQuestions: function() {
+            var $this = $(this);
+            $.questions().each(function() {
+                var parent = $(this).parentQuestion();
+                if (!parent.isRootSection()) {
+                    $('<input>', {
+                        type: 'hidden',
+                        name: 'q_edit[' + $(this).qid() + '][parent]',
+                        value: parent.qid()
+                    }).appendTo($this);
+                }
+            });
+            return $this;
+        }
+    });
+})(jQuery);
+
+
+$(function() {
+    $(".datepicker").datepicker({
+        hideIfNoPrevNext: true,
+        minDate: new Date()
+    });
+});
+
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
index ccc9c0b..ca59cfd 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
 var is_IE       = $.browser.msie;
 
 // {{{ function getNow()
+var days   = ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'];
+var months = ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet',
+              'août', 'septembre', 'octobre', 'novembre', 'décembre']
 
 function getNow() {
-    dt = new Date();
-    dy = dt.getDay();
-    mh = dt.getMonth();
-    wd = dt.getDate();
-    yr = dt.getYear();
+    var dt = new Date();
+    var dy = dt.getDay();
+    var mh = dt.getMonth();
+    var wd = dt.getDate();
+    var yr = dt.getYear();
     if (yr<1000) yr += 1900;
-    hr = dt.getHours();
-    mi = dt.getMinutes();
-
-    time   = (mi < 10) ? hr +':0'+mi : hr+':'+mi;
-    days   = ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'];
-    months = ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet',
-           'août', 'septembre', 'octobre', 'novembre', 'décembre']
+    var hr = dt.getHours();
+    var mi = dt.getMinutes();
+    if (mi < 10) {
+        mi = '0' + mi;
+    }
+    var se = dt.getSeconds();
+    if (se < 10) {
+        se = '0' + se;
+    }
 
-    return days[dy]+' '+wd+' '+months[mh]+' '+yr+'<br />'+time;
+    $(".date-heure").html(days[dy] + ' ' + wd + ' ' + months[mh] + ' ' + yr + '<br />'
+                        + hr + ':' + mi + ':' + se);
 }
 
 // }}}
@@ -71,67 +77,11 @@ function addSearchEngine()
 }
 
 // }}}
-// {{{ dynpost()
-
-function dynpost(action, values)
-{
-    var form = document.createElement('form');
-    form.action = action;
-    form.method = 'post';
-
-    $('body').get(0).appendChild(form);
-
-    for (var k in values) {
-        var input = document.createElement('input');
-        input.type = 'hidden';
-        input.name = k;
-        input.value = values[k];
-        form.appendChild(input);
-    }
-
-    form.submit();
-}
-
-
-function dynpostkv(action, k, v)
-{
-    var dict = {};
-    dict[k] = v;
-    dynpost(action, dict);
-}
-
-// }}}
-// {{{ function RegExp.escape()
-
-RegExp.escape = function(text) {
-  if (!arguments.callee.sRE) {
-    var specials = [
-      '/', '.', '*', '+', '?', '|',
-      '(', ')', '[', ']', '{', '}',
-      '\\', '^' , '$'
-    ];
-    arguments.callee.sRE = new RegExp(
-      '(\\' + specials.join('|\\') + ')', 'g'
-    );
-  }
-  return text.replace(arguments.callee.sRE, '\\$1');
-}
-
-// }}}
 
 /***************************************************************************
  * POPUP THINGS
  */
 
-// {{{ function popWin()
-
-function popWin(theNode, w, h) {
-    window.open(theNode.href, '_blank',
-        'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width='+w+',height='+h);
-    return false;
-}
-
-// }}}
 // {{{ function goodiesPopup()
 
 var __goodies_active = true;
@@ -205,54 +155,54 @@ function goodiesPopup(node, goodies) {
 // {{{ function auto_links()
 
 function auto_links() {
-    url  = document.URL;
-    fqdn = url.replace(/^https?:\/\/([^\/]*)\/.*$/,'$1');
-    light = (url.indexOf('display=light') > url.indexOf('?'));
-    resource_page = (url.indexOf('rss') > -1 || url.indexOf('ical') > -1);
-
-    $("a,link").each(
-        function(i) {
-            node = $(this);
-            href =  this.href;
-            if(!href || node.hasClass('xdx')
-               || href.indexOf('mailto:') > -1 || href.indexOf('javascript:') > -1) {
-                return;
-            }
-            if ((href.indexOf(fqdn) < 0 && this.className.indexOf('popup') < 0) || node.hasClass('popup')) {
-                node.click(function () { window.open(this.href); return false; });
-            }
-            if (href.indexOf(fqdn) > -1 && light) {
-                href = href.replace(/([^\#\?]*)\??([^\#]*)(\#.*)?/, "$1?display=light&$2$3");
-                this.href = href;
-            }
-            rss  = href.indexOf('rss') > -1;
-            ical = href.indexOf('ical') > -1;
-            if (rss || ical) {
-                if (href.indexOf('http') < 0) {
-                    href = 'http://' + fqdn + '/' + href;
-                }
-            }
-            if (this.nodeName.toLowerCase() == 'a' && !resource_page) {
-                if (rss && href.indexOf('prefs/rss') < 0 &&  (href.indexOf('xml') > -1 || href.indexOf('hash'))) {
-                    goodiesPopup(this, __goodies_rss);
-                } else if (ical) {
-                    goodiesPopup(this, __goodies_ical);
-                }
+    var url  = document.URL;
+    var fqdn = url.replace(/^https?:\/\/([^\/]*)\/.*$/,'$1');
+    var light = (url.indexOf('display=light') > url.indexOf('?'));
+    var resource_page = (url.indexOf('rss') > -1 || url.indexOf('ical') > -1);
+
+    $("a,link").each(function(i) {
+        var node = $(this);
+        var href = this.href;
+        if(!href || node.hasClass('xdx')
+           || href.indexOf('mailto:') > -1 || href.indexOf('javascript:') > -1) {
+            return;
+        }
+        if ((href.indexOf(fqdn) < 0 && this.className.indexOf('popup') < 0) || node.hasClass('popup')) {
+            node.click(function () {
+                window.open(href);
+                return false;
+            });
+        }
+        if (href.indexOf(fqdn) > -1 && light) {
+            href = href.replace(/([^\#\?]*)\??([^\#]*)(\#.*)?/, "$1?display=light&$2$3");
+            this.href = href;
+        }
+        var rss  = href.indexOf('rss') > -1;
+        var ical = href.indexOf('ical') > -1;
+        if (rss || ical) {
+            if (href.indexOf('http') < 0) {
+                href = 'http://' + fqdn + '/' + href;
             }
-            if(matches = (/^popup_([0-9]*)x([0-9]*)$/).exec(this.className)) {
-                var w = matches[1], h = matches[2];
-                node.click(function() { return popWin(this, w, h); });
+        }
+        if (this.nodeName.toLowerCase() == 'a' && !resource_page) {
+            if (rss && href.indexOf('prefs/rss') < 0 &&  (href.indexOf('xml') > -1 || href.indexOf('hash'))) {
+                goodiesPopup(this, __goodies_rss);
+            } else if (ical) {
+                goodiesPopup(this, __goodies_ical);
             }
         }
-    );
-    $('.popup2').click(function() { return popWin(this, 840, 600); });
-    $('.popup3').click(function() { return popWin(this, 640, 800); });
+        if(matches = (/^popup_([0-9]*)x([0-9]*)$/).exec(this.className)) {
+            var w = matches[1], h = matches[2];
+            node.popWin(w, h);
+        }
+    });
+    $('.popup2').popWin(840, 600);
+    $('.popup3').popWin(640, 800);
 }
 
 
 // }}}
 
-
 /***************************************************************************
  * Password check
  */
@@ -353,12 +303,50 @@ function checkPassword(box, okLabel) {
 }
 
 // }}}
+// {{{ send test email
+
+function sendTestEmail(token, hruid)
+{
+    var url = 'emails/test';
+    var msg = "Un email a été envoyé avec succès";
+    if (hruid != null) {
+        url += '/' + hruid;
+        msg += " sur l'adresse de " + hruid + ".";
+    } else {
+        msg += " sur ton addresse.";
+    }
+    $('#mail_sent').successMessage($url + '?token=' + token, msg);
+    return false;
+}
+
+// }}}
 
 
 /***************************************************************************
  * The real OnLoad
  */
 
-$(document).ready(auto_links);
+$(function() {
+    auto_links();
+    getNow();
+    setInterval(getNow, 1000);
+    $("#quick")
+        .focus(function() {
+            if ($(this).val() === 'Recherche dans l\'annuaire') {
+                $(this).val('');
+            }
+            $("#quick_button").show();
+        })
+        .blur(function() {
+            $("#quick_button").hide();
+        });
+    $("#quick_button").click(function() {
+        if ($("#quick").val() === 'Recherche dans l\'annuaire'
+            || $("#quick").val() === '') {
+            return false;
+        }
+        return true;
+    });
+});
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
index 8c08052..933c88a 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index befcdab..572042f 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 8b4e795..57f869b 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index c8e4fc6..a33d9a5 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index b721d64..e81fd2b 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -147,7 +147,7 @@ class ForumsBanana extends Banana
         } else {
             // Register custom Banana links and tabs
             if (!Banana::$profile['autoup']) {
-                Banana::$page->registerAction('<a href=\'javascript:dynpostkv("'
+                Banana::$page->registerAction('<a href=\'javascript:$.dynPost("'
                                     . $platal->path . '", "updateall", ' . time() . ')\'>'
                                     . 'Marquer tous les messages comme lus'
                                     . '</a>', array('forums', 'thread', 'message'));
index c08c983..8e90432 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 8995535..087cfda 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index b09d2f1..6979d41 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index bda3922..04535e1 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 51437db..9c7ab44 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 288aa66..db6979b 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index e29cf3e..bb7bf1a 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index f23403e..f4cc69c 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index b2e13f9..fea0499 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 0155eee..9943499 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 8c132a1..b38c961 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 7fd7623..7b56365 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index bccf89f..4e3aa7f 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index b114ae5..a47e27f 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index b39b8f9..f34e3b8 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -150,7 +150,7 @@ class Company
 
     public function setPhone(Phone &$phone)
     {
-        if ($phone->linkType() == Phone::LINK_COMPANY && $phone->linkId() == $this->id) {
+        if ($phone->link_type == Phone::LINK_COMPANY && $phone->link_id == $this->id) {
             $this->phone = $phone;
         }
     }
@@ -223,7 +223,7 @@ class Job
 
     public function addPhone(Phone &$phone)
     {
-        if ($phone->linkType() == Phone::LINK_JOB && $phone->linkId() == $this->id && $phone->pid() == $this->pid) {
+        if ($phone->link_type == Phone::LINK_JOB && $phone->link_id == $this->id && $phone->pid == $this->pid) {
             $this->phones[$phone->uniqueId()] = $phone;
         }
     }
@@ -544,10 +544,10 @@ class ProfileAddresses extends ProfileField
         $p = $phones->get(Profile::PHONE_LINK_ADDRESS | Profile::PHONE_TYPE_ANY);
         foreach ($p as $phone) {
             /* We must iterate on the addresses because id is not uniq thus,
-             * $this->addresse[$phone->linkId()] is invalid.
+             * $this->addresse[$phone->link_id] is invalid.
              */
             foreach ($this->addresses as $address) {
-                if ($address->type == Address::LINK_PROFILE && $address->id == $phone->linkId()) {
+                if ($address->type == Address::LINK_PROFILE && $address->id == $phone->link_id) {
                     $address->addPhone($phone);
                 }
             }
@@ -634,8 +634,8 @@ class ProfileJobs extends ProfileField
     {
         $p = $phones->get(Profile::PHONE_LINK_JOB | Profile::PHONE_TYPE_ANY);
         foreach ($p as $phone) {
-            if ($phone->linkType() == Phone::LINK_JOB && array_key_exists($phone->linkId(), $this->jobs)) {
-                $this->jobs[$phone->linkId()]->addPhone($phone);
+            if ($phone->link_type == Phone::LINK_JOB && array_key_exists($phone->link_id, $this->jobs)) {
+                $this->jobs[$phone->link_id]->addPhone($phone);
             }
         }
     }
@@ -756,7 +756,7 @@ class CompanyList
         if (count($newcompanies)) {
             $it = Phone::iterate(array(), array(Phone::LINK_COMPANY), $newcompanies);
             while ($phone = $it->next()) {
-                self::$companies[$phone->linkId()]->setPhone($phone);
+                self::$companies[$phone->link_id]->setPhone($phone);
             }
         }
 
index 9cf399d..e11711a 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 4ce9abb..228dc30 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 353e0ef..8c09a50 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 887f5a9..881a3e5 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 23fd7c4..e7f3ee7 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index c5ee810..0561e98 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 92c6be6..03b8ef2 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index b6211d4..7147edb 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 52400e9..f61ce9c 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index a49e4e7..8176320 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 2f77f82..cb3cba5 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 9d9b592..46844be 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index f189ca3..73997e9 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -193,7 +193,8 @@ class UFB_AdvancedSearch extends UserFilterBuilder
 
             new UFBF_Town('city', 'Ville / Code Postal'),
             new UFBF_Country('countryTxt', 'country', 'Pays'),
-            new UFBF_AdminArea('region', 'Région'),
+            new UFBF_AdminArea('administrativearea', 'Région'),
+            new UFBF_SubAdminArea('subadministrativearea', 'Département'),
 
             new UFBF_JobCompany('entreprise', 'Entreprise'),
             new UFBF_JobDescription('jobdescription', 'Fonction'),
@@ -861,6 +862,32 @@ class UFBF_AdminArea extends UFBF_Index
 }
 // }}}
 
+// {{{ class UFBF_SubAdminArea
+class UFBF_SubAdminArea extends UFBF_Index
+{
+    protected $direnum = DirEnum::SUBADMINAREAS;
+    protected $onlycurrentfield;
+
+    public function __construct($envfield, $formtext = '', $onlycurrentfield = 'only_current')
+    {
+        parent::__construct($envfield, $formtext);
+        $this->onlycurrentfield = $onlycurrentfield;
+    }
+
+
+    protected function buildUFC(UserFilterBuilder &$ufb)
+    {
+        if ($ufb->isOn($this->onlycurrentfield)) {
+            $flags = UFC_Address::FLAG_CURRENT;
+        } else {
+            $flags = UFC_Address::FLAG_ANY;
+        }
+
+        return new UFC_AddressField($this->val, UFC_AddressField::FIELD_SUBADMAREA, UFC_Address::TYPE_ANY, $flags);
+    }
+}
+// }}}
+
 // {{{ class UFBF_JobCompany
 class UFBF_JobCompany extends UFBF_Text
 {
index 11f49e4..f99faf2 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 1600a1b..ab91cc5 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index f5c05e2..eb0c2d7 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index c274761..2864547 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 671d93f..78ff349 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 4a7416f..13a506a 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 28cb310..3377bf9 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 420fd65..684ef29 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 087edd6..4be1f5e 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -82,17 +82,23 @@ class ListeReq extends Validate
         global $globals;
 
         if (Env::has('listname')) {
-            $this->liste = trim(Env::v('listname'));
+            $this->liste = Post::t('listname');
         }
         if (Env::has('domainname')) {
-            $this->domain = trim(Env::v('domainname'));
+            $this->domain = Post::t('domainname');
         }
         if (Env::has('assotype')) {
-            $this->asso = trim(Env::v('assotype'));
+            $this->asso = Post::t('assotype');
         }
         if (!$this->asso) {
             $this->domain = $globals->mail->domain;
         }
+        foreach ($this->owners as $key => &$email) {
+            $email = Post::t('owners_' . $key);
+        }
+        foreach ($this->members as $key => &$email) {
+            $email = Post::t('members_' . $key);
+        }
         return true;
     }
 
index c0d2707..9261174 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index dbfbb4b..9147806 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 5d9affe..f39f139 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 25067a4..ef07d35 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 068aff8..61883ed 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 406dfbf..aab352e 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 21a56b9..897a077 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 8eca5d6..b77c92e 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 778cd1f..758714e 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -90,16 +90,15 @@ class VCard extends PlVCard
                                 null, $adr->administrativeArea, null,
                                 $adr->hasFlag('current'), $adr->hasFlag('mail'), $adr->hasFlag('mail'));
             } else {
-                // TODO : find a way to fetch only the "street" part of the address
-                $group = $entry->addHome($adr->text, null, null, $adr->postalCode,
+                $group = $entry->addHome(trim(Geocoder::getFirstLines($adr->text, $adr->postalCode, 4)), null, null, $adr->postalCode,
                                 $adr->locality, $adr->administrativeArea, $adr->country,
                                 $adr->hasFlag('current'), $adr->hasFlag('mail'), $adr->hasFlag('mail'));
             }
             foreach ($adr->phones() as $phone) {
-                if ($phone->linkType() == Phone::TYPE_FIXED) {
+                if ($phone->link_type == Phone::TYPE_FIXED) {
                     $entry->addTel($group, $phone->display, false, true, true, false, false,
                                    $adr->hasFlag('current') && empty($pf->mobile));
-                } else if ($phone->linkType() == Phone::TYPE_FAX) {
+                } else if ($phone->link_type == Phone::TYPE_FAX) {
                     $entry->addTel($group, $phone->display, true, false, false, false, false, false);
                 }
             }
@@ -115,13 +114,13 @@ class VCard extends PlVCard
             } else {
                 // TODO : link address to company
                 $group = $entry->addWork(null, null, null, null,
-                                         $adr->text, null, null, $adr->postalCode,
+                                         trim(Geocoder::getFirstLines($adr->text, $adr->postalCode, 4)), null, null, $adr->postalCode,
                                          $adr->locality, $adr->administrativeArea, $adr->country);
             }
             foreach ($adr->phones() as $phone) {
-                if ($phone->linkType() == Phone::TYPE_FIXED) {
+                if ($phone->link_type == Phone::TYPE_FIXED) {
                     $entry->addTel($group, $phone->display);
-                } else if ($phone->linkType() == Phone::TYPE_FAX) {
+                } else if ($phone->link_type == Phone::TYPE_FAX) {
                     $entry->addTel($group, $phone->display, true);
                 }
             }
@@ -130,14 +129,14 @@ class VCard extends PlVCard
         // Melix
         if (!is_null($user)) {
             $alias = $user->emailAlias();
-            if (!is_null($alias) && $pf->alias_pub == 'pub') {
+            if (!is_null($alias) && $pf->alias_pub == 'public') {
                 $entry->addMail(null, $alias);
             }
         }
 
         // Custom fields
         if (!is_null($user)) {
-            $groups = $user->groups();
+            $groups = $user->groups(true, true);
             if (count($groups)) {
                 $gn = DirEnum::getOptions(DirEnum::GROUPESX);
                 $gns = array();
@@ -159,8 +158,7 @@ class VCard extends PlVCard
             $entry->set('X-BINETS', join(', ', $bns));
         }
         if (!empty($pf->section)) {
-            $sections = DirEnum::getOptions(DirEnum::SECTIONS);
-            $entry->set('X-SECTION', $sections[$pf->section]);
+            $entry->set('X-SECTION', $pf->section);
         }
 
         // Photo
index 08beb41..61a75b9 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 391162b..a57e421 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index cd6f6ff..b36d1cb 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 38d3f65..75ab39a 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -47,6 +47,7 @@ class AdminModule extends PLModule
             'admin/wiki'                   => $this->make_hook('wiki',                   AUTH_MDP, 'admin'),
             'admin/ipwatch'                => $this->make_hook('ipwatch',                AUTH_MDP, 'admin'),
             'admin/icons'                  => $this->make_hook('icons',                  AUTH_MDP, 'admin'),
+            'admin/geocoding'              => $this->make_hook('geocoding',              AUTH_MDP, 'admin'),
             'admin/accounts'               => $this->make_hook('accounts',               AUTH_MDP, 'admin'),
             'admin/account/watch'          => $this->make_hook('account_watch',          AUTH_MDP, 'admin'),
             'admin/account/types'          => $this->make_hook('account_types',          AUTH_MDP, 'admin'),
@@ -128,23 +129,6 @@ class AdminModule extends PLModule
         $page->assign_by_ref('mails', $sql);
     }
 
-    function handler_postfix_regexpsbounces(&$page, $new = null) {
-        $page->changeTpl('admin/emails_bounces_re.tpl');
-        $page->setTitle('Administration - Postfix : Regexps Bounces');
-        $page->assign('new', $new);
-
-        if (Post::has('submit')) {
-            foreach (Env::v('lvl') as $id=>$val) {
-                XDB::query(
-                        "REPLACE INTO emails_bounces_re (id,pos,lvl,re,text) VALUES ({?}, {?}, {?}, {?}, {?})",
-                        $id, $_POST['pos'][$id], $_POST['lvl'][$id], $_POST['re'][$id], $_POST['text'][$id]
-                );
-            }
-        }
-
-        $page->assign('bre', XDB::iterator("SELECT * FROM emails_bounces_re ORDER BY pos"));
-    }
-
     // {{{ logger view
 
     /** Retrieves the available days for a given year and month.
@@ -692,6 +676,7 @@ class AdminModule extends PLModule
 
 
         $page->addJsLink('jquery.ui.core.js');
+        $page->addJsLink('jquery.ui.widget.js');
         $page->addJsLink('jquery.ui.tabs.js');
         $page->addJsLink('password.js');
 
@@ -1075,7 +1060,6 @@ class AdminModule extends PLModule
         $page->changeTpl('admin/validation.tpl');
         $page->setTitle('Administration - Valider une demande');
         $page->addCssLink('nl.css');
-        $page->addJsLink('ajax.js');
 
         if ($action == 'edit' && !is_null($id)) {
             $page->assign('preview_id', $id);
@@ -1207,6 +1191,228 @@ class AdminModule extends PLModule
         $table_editor->apply($page, $action, $id);
     }
 
+    private static function isCountryIncomplete(array &$item)
+    {
+        $warning = false;
+        foreach (array('worldRegion', 'country', 'capital', 'phonePrefix', 'licensePlate', 'countryPlain') as $field) {
+            if ($item[$field] == '') {
+                $item[$field . '_warning'] = true;
+                $warning = true;
+            }
+        }
+        if (is_null($item['belongsTo'])) {
+            foreach (array('nationality', 'nationalityEn') as $field) {
+                if ($item[$field] == '') {
+                    $item[$field . '_warning'] = true;
+                    $warning = true;
+                }
+            }
+        }
+        return $warning;
+    }
+
+    private static function updateCountry(array $item)
+    {
+        XDB::execute('UPDATE  geoloc_countries
+                         SET  countryPlain = {?}
+                       WHERE  iso_3166_1_a2 = {?}',
+                     mb_strtoupper(replace_accent($item['country'])), $item['iso_3166_1_a2']);
+    }
+
+    private static function isLanguageIncomplete(array &$item)
+    {
+        if ($item['language'] == '') {
+            $item['language_warning'] = true;
+            return true;
+        }
+        return false;
+    }
+
+    private static function updateLanguage(array $item) {}
+
+    function handler_geocoding(&$page, $category = null, $action = null, $id = null)
+    {
+        // Warning, this handler requires the following packages:
+        //  * pkg-isocodes
+        //  * isoquery
+
+        static $properties = array(
+            'country'  => array(
+                'name'         => 'pays',
+                'isocode'      => '3166',
+                'table'        => 'geoloc_countries',
+                'id'           => 'iso_3166_1_a2',
+                'main_fields'  => array('iso_3166_1_a3', 'iso_3166_1_num', 'countryEn'),
+                'other_fields' => array('worldRegion', 'country', 'capital', 'nationality', 'nationalityEn',
+                                        'phonePrefix', 'phoneFormat', 'licensePlate', 'belongsTo')
+            ),
+            'language' => array(
+                'name'         => 'langages',
+                'isocode'      => '639',
+                'table'        => 'profile_langskill_enum',
+                'id'           => 'iso_639_2b',
+                'main_fields'  => array('iso_639_2t', 'iso_639_1', 'language_en'),
+                'other_fields' => array('language')
+
+            )
+        );
+
+        if (is_null($category) || !array_key_exists($category, $properties)) {
+            pl_redirect('admin');
+        }
+
+        $data = $properties[$category];
+
+        if ($action == 'edit' || $action == 'add') {
+            $main_fields = array_merge(array($data['id']), $data['main_fields']);
+            $all_fields = array_merge($main_fields, $data['other_fields']);
+
+            if (is_null($id)) {
+                if (Post::has('new_id')) {
+                    $id = Post::v('new_id');
+                } else {
+                    pl_redirect('admin/geocoding/' . $category);
+                }
+            }
+
+            $list = array();
+            exec('isoquery --iso=' . $data['isocode'] . ' ' . $id, $list);
+            if (count($list) == 1) {
+                $array = explode("\t", $list[0]);
+                foreach ($main_fields as $i => $field) {
+                    $iso[$field] = $array[$i];
+                }
+            } else {
+                $iso = array();
+            }
+
+            if ($action == 'add') {
+                if (Post::has('new_id')) {
+                    S::assert_xsrf_token();
+                }
+
+                if (count($iso)) {
+                    $item = $iso;
+                } else {
+                    $item = array($data['id'] => $id);
+                }
+                XDB::execute('INSERT INTO  ' . $data['table'] . '(' . implode(', ', array_keys($item)) . ')
+                                   VALUES  ' . XDB::formatArray($item));
+                $page->trigSuccess($id . ' a bien été ajouté à la base.');
+            } elseif ($action == 'edit') {
+                if (Post::has('edit')) {
+                    S::assert_xsrf_token();
+
+                    $item = array();
+                    $set  = array();
+                    foreach ($all_fields as $field) {
+                        $item[$field] = Post::t($field);
+                        $set[] = $field . XDB::format(' = {?}', ($item[$field] ? $item[$field] : null));
+                    }
+                    XDB::execute('UPDATE  ' . $data['table'] . '
+                                     SET  ' . implode(', ', $set) . '
+                                   WHERE  ' . $data['id'] . ' = {?}',
+                                 $id);
+                    call_user_func_array(array('self', 'update' . ucfirst($category)), array($item));
+                    $page->trigSuccess($id . ' a bien été mis à jour.');
+                } elseif (Post::has('del')) {
+                    S::assert_xsrf_token();
+
+                    XDB::execute('DELETE FROM  ' . $data['table'] . '
+                                        WHERE  ' . $data['id'] . ' = {?}',
+                                 $id);
+                    $page->trigSuccessRedirect($id . ' a bien été supprimé.', 'admin/geocoding/' . $category);
+                } else {
+                    $item = XDB::fetchOneAssoc('SELECT  *
+                                                  FROM  ' . $data['table'] . '
+                                                 WHERE  ' . $data['id'] . ' = {?}',
+                                               $id);
+                }
+            }
+
+            $page->changeTpl('admin/geocoding_edit.tpl');
+            $page->setTitle('Administration - ' . ucfirst($data['name']));
+            $page->assign('category', $category);
+            $page->assign('name', $data['name']);
+            $page->assign('all_fields', $all_fields);
+            $page->assign('id', $id);
+            $page->assign('iso', $iso);
+            $page->assign('item', $item);
+            return;
+        }
+
+        $page->changeTpl('admin/geocoding.tpl');
+        $page->setTitle('Administration - ' . ucfirst($data['name']));
+        $page->assign('category', $category);
+        $page->assign('name', $data['name']);
+        $page->assign('id', $data['id']);
+        $page->assign('main_fields', $data['main_fields']);
+        $page->assign('all_fields', array_merge($data['main_fields'], $data['other_fields']));
+
+        // First build the list provided by the iso codes.
+        $list = array();
+        exec('isoquery --iso=' . $data['isocode'], $list);
+
+        foreach ($list as $key => $item) {
+            $array = explode("\t", $item);
+            unset($list[$key]);
+            $list[$array[0]] = array();
+            foreach ($data['main_fields'] as $i => $field) {
+                $list[$array[0]][$field] = $array[$i + 1];
+            }
+        }
+        ksort($list);
+
+        // Retrieve all data from the database.
+        $db_list = XDB::rawFetchAllAssoc('SELECT  *
+                                            FROM  ' . $data['table'] . '
+                                        ORDER BY  ' . $data['id'],
+                                         $data['id']);
+
+        // Sort both iso and database data into 5 categories:
+        //  $missing: data from the iso list not in the database,
+        //  $non_existing: data from the database not in the iso list,
+        //  $erroneous: data that differ on main fields,
+        //  $incomplete: data with empty fields in the data base,
+        //  $remaining: remaining correct and complete data from the database.
+
+        $missing = $non_existing = $erroneous = $incomplete = $remaining = array();
+        foreach (array_keys($list) as $id) {
+            if (!array_key_exists($id, $db_list)) {
+                $missing[$id] = $list[$id];
+            }
+        }
+
+        foreach ($db_list as $id => $item) {
+            if (!array_key_exists($id, $list)) {
+                $non_existing[$id] = $item;
+            } else {
+                $error = false;
+                foreach ($data['main_fields'] as $field) {
+                    if ($item[$field] != $list[$id][$field]) {
+                        $item[$field . '_error'] = true;
+                        $error = true;
+                    }
+                }
+                if ($error == true) {
+                    $erroneous[$id] = $item;
+                } elseif (call_user_func_array(array('self', 'is' . ucfirst($category) . 'Incomplete'), array(&$item))) {
+                    $incomplete[$id] = $item;
+                } else {
+                    $remaining[$id] = $item;
+                }
+            }
+        }
+
+        $page->assign('lists', array(
+                'manquant'  => $missing,
+                'disparu'   => $non_existing,
+                'erroné'    => $erroneous,
+                'incomplet' => $incomplete,
+                'restant'   => $remaining
+        ));
+    }
+
     function handler_accounts(PlPage $page)
     {
         $page->changeTpl('admin/accounts.tpl');
index 0a60875..1a2ff45 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
diff --git a/modules/api.php b/modules/api.php
new file mode 100644 (file)
index 0000000..1fa485f
--- /dev/null
@@ -0,0 +1,54 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2011 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 ApiModule extends PlModule
+{
+    function handlers()
+    {
+        return array(
+            // TODO(vzanotti): Extend the plat/al engine to support placeholders
+            // in handler urls, for instance "api/1/user/%forlife/isRegistered".
+            'api/1/user' => $this->make_api_hook('user', AUTH_COOKIE, 'api_user_readonly'),
+        );
+    }
+
+    // This handler supports the following URL patterns:
+    //   /api/1/user/{forlife}/isRegistered
+    function handler_user(PlPage& $page, PlUser& $authUser, $payload, $user = null, $selector = null)
+    {
+        // Retrieve the PlUser referenced in the request. Note that this is the
+        // target user, not the authenticated user.
+        $user = PlUser::getSilent($user);
+        if (empty($user)) {
+            return PL_NOT_FOUND;
+        }
+
+        if ($selector == 'isRegistered') {
+            $page->jsonAssign('isRegistered', $user->isActive());
+            return PL_JSON;
+        } else {
+            return PL_NOT_FOUND;
+        }
+    }
+}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
index 2ca51c9..2c39af9 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 186506a..ab488d1 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index b0f654e..67bdf55 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 8c28586..1d1a52a 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 146580e..09d0ad6 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index ba5e1df..82d0609 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -24,18 +24,18 @@ class CarnetModule extends PLModule
     function handlers()
     {
         return array(
-            'carnet'                => $this->make_hook('index',    AUTH_COOKIE, 'directory_private'),
-            'carnet/panel'          => $this->make_hook('panel',    AUTH_COOKIE, 'directory_private'),
-            'carnet/notifs'         => $this->make_hook('notifs',   AUTH_COOKIE, 'directory_private'),
-
-            'carnet/contacts'       => $this->make_hook('contacts', AUTH_COOKIE, 'directory_private'),
-            'carnet/contacts/pdf'   => $this->make_hook('pdf',      AUTH_COOKIE, 'directory_private'),
-            'carnet/contacts/vcard' => $this->make_hook('vcard',    AUTH_COOKIE, 'directory_private'),
-            'carnet/contacts/ical'  => $this->make_hook('ical',     AUTH_PUBLIC, 'directory_private', NO_HTTPS),
-            'carnet/contacts/csv'   => $this->make_hook('csv',     AUTH_PUBLIC,  'directory_private', NO_HTTPS),
-            'carnet/contacts/csv/birthday'  => $this->make_hook('csv_birthday',     AUTH_PUBLIC, 'directory_private', NO_HTTPS),
-
-            'carnet/rss'            => $this->make_hook('rss',      AUTH_PUBLIC, 'directory_private', NO_HTTPS),
+            'carnet'                => $this->make_hook('index',      AUTH_COOKIE, 'directory_private'),
+            'carnet/panel'          => $this->make_hook('panel',      AUTH_COOKIE, 'directory_private'),
+            'carnet/notifs'         => $this->make_hook('notifs',     AUTH_COOKIE, 'directory_private'),
+
+            'carnet/contacts'       => $this->make_hook('contacts',   AUTH_COOKIE, 'directory_private'),
+            'carnet/contacts/pdf'   => $this->make_hook('pdf',        AUTH_COOKIE, 'directory_private'),
+            'carnet/contacts/vcard' => $this->make_hook('vcard',      AUTH_COOKIE, 'directory_private'),
+            'carnet/contacts/ical'  => $this->make_token_hook('ical', AUTH_COOKIE, 'directory_private'),
+            'carnet/contacts/csv'   => $this->make_token_hook('csv',  AUTH_COOKIE, 'directory_private'),
+            'carnet/contacts/csv/birthday' => $this->make_token_hook('csv_birthday', AUTH_COOKIE, 'directory_private'),
+
+            'carnet/rss'            => $this->make_token_hook('rss',  AUTH_COOKIE, 'directory_private'),
         );
     }
 
@@ -358,11 +358,11 @@ class CarnetModule extends PLModule
         exit;
     }
 
-    function handler_rss(&$page, $user = null, $hash = null)
+    function handler_rss(PlPage& $page, PlUser& $user)
     {
         $this->load('feed.inc.php');
         $feed = new CarnetFeed();
-        return $feed->run($page, $user, $hash);
+        return $feed->run($page, $user);
     }
 
     function buildBirthRef(Profile $profile)
@@ -378,17 +378,8 @@ class CarnetModule extends PLModule
         );
     }
 
-    function handler_csv_birthday(&$page, $alias = null, $hash = null)
+    function handler_csv_birthday(PlPage& $page, PlUser& $user)
     {
-        $user = Platal::session()->tokenAuth($alias, $hash);
-        if (is_null($user)) {
-            if (S::logged()) {
-                $user = S::user();
-            } else {
-                return PL_FORBIDDEN;
-            }
-        }
-
         $page->changeTpl('carnet/calendar.outlook.tpl', NO_SKIN);
         $filter = new UserFilter(new UFC_Contact($user));
         $profiles = $filter->iterProfiles();
@@ -411,17 +402,8 @@ class CarnetModule extends PLModule
         pl_content_headers("text/comma-separated-values;charset=".$encoding);
     }
 
-    function handler_ical(&$page, $alias = null, $hash = null)
+    function handler_ical(PlPage& $page, PlUser& $user)
     {
-        $user = Platal::session()->tokenAuth($alias, $hash);
-        if (is_null($user)) {
-            if (S::logged()) {
-                $user = S::user();
-            } else {
-                return PL_FORBIDDEN;
-            }
-        }
-
         require_once 'ical.inc.php';
         $page->changeTpl('carnet/calendar.tpl', NO_SKIN);
         $page->register_function('display_ical', 'display_ical');
@@ -441,17 +423,8 @@ class CarnetModule extends PLModule
         $vcard->show();
     }
 
-    function handler_csv(&$page, $alias = null, $hash = null)
+    function handler_csv(PlPage& $page, PlUser& $user)
     {
-        $user = Platal::session()->tokenAuth($alias, $hash);
-        if (is_null($user)) {
-            if (S::logged()) {
-                $user = S::user();
-            } else {
-                return PL_FORBIDDEN;
-            }
-        }
-
         $page->changeTpl('carnet/mescontacts.outlook.tpl', NO_SKIN);
         $pf = new ProfileFilter(new UFC_Contact($user));
         require_once 'carnet/outlook.inc.php';
index 3f35235..ed79ee9 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -265,23 +265,27 @@ class ContactsPDF extends FPDF
         if ($wp) {
             $photo = $profile->getPhoto(false, true);
             if ($photo) {
-                $old2  = clone $self;
-                $width = $photo->width() * 20 / $photo->height();
-                $_x = $self->getX();
-                $_y = $self->getY();
-                $self->Cell(0, 20, '', '', 0, '', 1);
-                error_reporting(0);
-                $self->Image($photo->path(), $_x, $_y, $width, 20, $photo->mimeType());
-                error_reporting($self->report);
-
-                if ($self->error) {
-                    $self = clone $old2;
-                } else {
-                    $self->setX($_x);
-                    $self->Cell($width, 20, '', "T");
-                    $h = 20 / $self->wordwrap($nom, 90 - $width);
-                    $self->MultiCell(0, $h, $nom, 'T', 'C');
-                    $ok = true;
+                list(, $type) = explode('/', $photo->mimeType());
+                $type = ($type == 'jpeg') ? 'jpg' : $type;
+                if (method_exists($self, '_parse' . $type)) {
+                    $old2  = clone $self;
+                    $width = $photo->width() * 20 / $photo->height();
+                    $_x = $self->getX();
+                    $_y = $self->getY();
+                    $self->Cell(0, 20, '', '', 0, '', 1);
+                    error_reporting(0);
+                    $self->Image($photo->path(), $_x, $_y, $width, 20, $type);
+                    error_reporting($self->report);
+
+                    if ($self->error) {
+                        $self = clone $old2;
+                    } else {
+                        $self->setX($_x);
+                        $self->Cell($width, 20, '', "T");
+                        $h = 20 / $self->wordwrap($nom, 90 - $width);
+                        $self->MultiCell(0, $h, $nom, 'T', 'C');
+                        $ok = true;
+                    }
                 }
             }
         }
index ea4f52c..96f45f9 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 03913a8..66520a9 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index b97b6c9..cf06908 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -370,7 +370,6 @@ class EmailModule extends PLModule
     function handler_send(&$page)
     {
         $page->changeTpl('emails/send.tpl');
-        $page->addJsLink('ajax.js');
 
         $page->setTitle('Envoyer un email');
 
index 9f434cb..b9cca56 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -25,11 +25,11 @@ class EventsModule extends PLModule
     {
         return array(
             'events'         => $this->make_hook('ev',           AUTH_COOKIE),
-            'rss'            => $this->make_hook('rss',          AUTH_PUBLIC, 'user', NO_HTTPS),
             'events/preview' => $this->make_hook('preview',      AUTH_PUBLIC, 'user', NO_AUTH),
             'events/photo'   => $this->make_hook('photo',        AUTH_PUBLIC),
             'events/submit'  => $this->make_hook('ev_submit',    AUTH_MDP),
             'admin/events'   => $this->make_hook('admin_events', AUTH_MDP,    'admin'),
+            'rss'            => $this->make_token_hook('rss',    AUTH_COOKIE),
 
             'ajax/tips'      => $this->make_hook('tips',         AUTH_COOKIE, 'user', NO_AUTH),
             'admin/tips'     => $this->make_hook('admin_tips',   AUTH_MDP,    'admin'),
@@ -103,7 +103,6 @@ class EventsModule extends PLModule
     function handler_ev(&$page, $action = 'list', $eid = null, $pound = null)
     {
         $page->changeTpl('events/index.tpl');
-        $page->addJsLink('ajax.js');
 
         $user = S::user();
 
@@ -229,11 +228,11 @@ class EventsModule extends PLModule
         exit;
     }
 
-    function handler_rss(&$page, $user = null, $hash = null)
+    function handler_rss(PlPage& $page, PlPage& $user)
     {
         $this->load('feed.inc.php');
         $feed = new EventFeed();
-        return $feed->run($page, $user, $hash);
+        return $feed->run($page, $user);
     }
 
     function handler_preview(&$page)
@@ -255,7 +254,6 @@ class EventsModule extends PLModule
     function handler_ev_submit(&$page)
     {
         $page->changeTpl('events/submit.tpl');
-        $page->addJsLink('ajax.js');
 
         $wp = new PlWikiPage('Xorg.Annonce');
         $wp->buildCache();
@@ -333,7 +331,6 @@ class EventsModule extends PLModule
     function handler_admin_events(&$page, $action = 'list', $eid = null)
     {
         $page->changeTpl('events/admin.tpl');
-        $page->addJsLink('ajax.js');
         $page->setTitle('Administration - Evenements');
         $page->register_modifier('hde', 'html_entity_decode');
 
index 9e1298c..bc93fde 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 577791b..1dfbd18 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 1b07698..ecd1eec 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index d3bbe8b..5ed8d00 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index bdfff0c..cb3da7e 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index cbbbb11..6964887 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 2ed4836..55fe39b 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -91,7 +91,6 @@ class ListsModule extends PLModule
         $domain = $this->prepare_client($page);
 
         $page->changeTpl('lists/index.tpl');
-        $page->addJsLink('ajax.js');
         $page->setTitle('Listes de diffusion');
 
 
index 5f8c2f4..94eb931 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 96b2cf2..2840f78 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index ec52264..051b4ed 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 619e0c1..e010c82 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 0e0caa1..f0137a5 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 543eba1..6f8896d 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -55,23 +55,23 @@ function paypal_erreur($text, $send=true)
 function luhn($nombre) {
     $s = strrev($nombre);
     $sum = 0;
-    for ($i = 0; $i < strlen($s); $i++) {
+    for ($i = 0; $i < strlen($s); ++$i) {
     $dgt = $s{$i};
-        $sum += ($i % 2) ? (2*$dgt) % 9 : $dgt;
+        $sum += ($i % 2) ? (2 * $dgt) % 9 : $dgt;
     }
     return $sum % 10;
 }
 
 /* calcule la clé d'acceptation a partir de 5 champs */
-function cle_accept($d1,$d2,$d3,$d4,$d5)
+function cle_accept($d1, $d2, $d3, $d4, $d5)
 {
-    $m1 = luhn($d1.$d5);
-    $m2 = luhn($d2.$d5);
-    $m3 = luhn($d3.$d5);
-    $m4 = luhn($d4.$d5);
+    $m1 = luhn($d1 . $d5);
+    $m2 = luhn($d2 . $d5);
+    $m3 = luhn($d3 . $d5);
+    $m4 = luhn($d4 . $d5);
     $n = $m1 + $m2 + $m3 + $m4;
-    $alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
-    return $alpha{$n-1}.$m1.$m2.$m3.$m4;
+    $alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
+    return $alpha{$n-1} . $m1 . $m2 . $m3 . $m4;
 }
 
 /* decode the comment */
@@ -88,16 +88,16 @@ function comment_decode($comment) {
 function check_rib($rib)
 {
     if(strlen($rib) != 23) return false;
-    
+
     // extract fields
     $rib = strtr(strtoupper($rib),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','12345678912345678923456789');
     $bank    = substr($rib,0,5);
     $counter = substr($rib,5,5);
     $account = substr($rib,10,11);
     $key     = substr($rib,21,2);
-    
+
     // check
-    return 0 == fmod(89 * $bank + 15 * $counter + 3 * $account + $key, 97);
+    return (0 == fmod(89 * $bank + 15 * $counter + 3 * $account + $key, 97));
 }
 
 class PaymentModule extends PLModule
@@ -105,22 +105,22 @@ class PaymentModule extends PLModule
     function handlers()
     {
         return array(
-            'payment'                    => $this->make_hook('payment',       AUTH_MDP,    'payment'),
-            'payment/cyber_return'       => $this->make_hook('cyber_return',  AUTH_PUBLIC, 'user', NO_HTTPS),
-            'payment/cyber2_return'      => $this->make_hook('cyber2_return', AUTH_PUBLIC, 'user', NO_HTTPS),
-            'payment/paypal_return'      => $this->make_hook('paypal_return', AUTH_PUBLIC, 'user', NO_HTTPS),
-            '%grp/paiement'              => $this->make_hook('xnet_payment',  AUTH_MDP),
-            '%grp/payment'               => $this->make_hook('xnet_payment',  AUTH_MDP),
-            '%grp/payment/cyber_return'  => $this->make_hook('cyber_return',  AUTH_PUBLIC, 'user', NO_HTTPS),
-            '%grp/payment/cyber2_return' => $this->make_hook('cyber2_return', AUTH_PUBLIC, 'user', NO_HTTPS),
-            '%grp/payment/paypal_return' => $this->make_hook('paypal_return', AUTH_PUBLIC, 'user', NO_HTTPS),
-            'admin/payments'             => $this->make_hook('admin',         AUTH_MDP,    'admin'),
-            'admin/payments/methods'     => $this->make_hook('adm_methods',   AUTH_MDP,    'admin'),
-            'admin/payments/transactions'=> $this->make_hook('adm_transactions', AUTH_MDP, 'admin'),
-            'admin/reconcile'            => $this->make_hook('adm_reconcile', AUTH_MDP,    'admin'),
-            'admin/reconcile/importlogs' => $this->make_hook('adm_importlogs', AUTH_MDP,    'admin'),
-            'admin/reconcile/transfers'  => $this->make_hook('adm_transfers', AUTH_MDP,    'admin'),
-            'admin/reconcile/bankaccounts'=> $this->make_hook('adm_bankaccounts', AUTH_MDP, 'admin'),
+            'payment'                      => $this->make_hook('payment',          AUTH_MDP,    'payment'),
+            'payment/cyber_return'         => $this->make_hook('cyber_return',     AUTH_PUBLIC, 'user', NO_HTTPS),
+            'payment/cyber2_return'        => $this->make_hook('cyber2_return',    AUTH_PUBLIC, 'user', NO_HTTPS),
+            'payment/paypal_return'        => $this->make_hook('paypal_return',    AUTH_PUBLIC, 'user', NO_HTTPS),
+            '%grp/paiement'                => $this->make_hook('xnet_payment',     AUTH_MDP),
+            '%grp/payment'                 => $this->make_hook('xnet_payment',     AUTH_MDP),
+            '%grp/payment/cyber_return'    => $this->make_hook('cyber_return',     AUTH_PUBLIC, 'user', NO_HTTPS),
+            '%grp/payment/cyber2_return'   => $this->make_hook('cyber2_return',    AUTH_PUBLIC, 'user', NO_HTTPS),
+            '%grp/payment/paypal_return'   => $this->make_hook('paypal_return',    AUTH_PUBLIC, 'user', NO_HTTPS),
+            'admin/payments'               => $this->make_hook('admin',            AUTH_MDP,    'admin'),
+            'admin/payments/methods'       => $this->make_hook('adm_methods',      AUTH_MDP,    'admin'),
+            'admin/payments/transactions'  => $this->make_hook('adm_transactions', AUTH_MDP,    'admin'),
+            'admin/reconcile'              => $this->make_hook('adm_reconcile',    AUTH_MDP,    'admin'),
+            'admin/reconcile/importlogs'   => $this->make_hook('adm_importlogs',   AUTH_MDP,    'admin'),
+            'admin/reconcile/transfers'    => $this->make_hook('adm_transfers',    AUTH_MDP,    'admin'),
+            'admin/reconcile/bankaccounts' => $this->make_hook('adm_bankaccounts', AUTH_MDP,    'admin'),
         );
     }
 
@@ -134,9 +134,9 @@ class PaymentModule extends PLModule
             if (!$globals->asso('id')) {
                 return PL_NOT_FOUND;
             }
-            $res = XDB::query("SELECT asso_id
-                                 FROM payments
-                                WHERE asso_id = {?} AND id = {?}",
+            $res = XDB::query('SELECT  asso_id
+                                 FROM  payments
+                                WHERE  asso_id = {?} AND id = {?}',
                               $globals->asso('id'), $ref);
             if (!$res->numRows()) {
                 return PL_FORBIDDEN;
@@ -160,25 +160,27 @@ class PaymentModule extends PLModule
             $page->trigError($e);
         }
 
-        if ($op=='submit') {
+        if ($op == 'submit') {
             $pay->init($val, $meth);
             $pay->prepareform($pay);
         } else {
-            $res = XDB::iterator("SELECT  timestamp, amount
+            $res = XDB::iterator('SELECT  timestamp, amount
                                     FROM  payment_transactions
                                    WHERE  uid = {?} AND ref = {?}
-                                ORDER BY  timestamp DESC",
+                                ORDER BY  timestamp DESC',
                                  S::v('uid', -1), $ref);
 
-            if ($res->total()) $page->assign('transactions', $res);
+            if ($res->total()) {
+                $page->assign('transactions', $res);
+            }
         }
 
-        $val = floor($val).".".substr(floor(($val - floor($val))*100+100),1);
-        $page->assign('montant',$val);
-        $page->assign('comment',Env::v('comment'));
+        $val = floor($val) . '.' . substr(floor(($val - floor($val)) * 100 + 100), 1);
+        $page->assign('montant', $val);
+        $page->assign('comment', Env::v('comment'));
 
         $page->assign('meth', $meth);
-        $page->assign('pay',  $pay);
+        $page->assign('pay', $pay);
         $page->assign('evtlink', $pay->event());
         $page->assign('sex', S::user()->isFemale());
     }
@@ -214,9 +216,9 @@ class PaymentModule extends PLModule
         }
 
         echo ($ref = $matches[1]);
-        $res = XDB::query("SELECT  mail, text, confirmation
+        $res = XDB::query('SELECT  mail, text, confirmation
                              FROM  payments
-                            WHERE  id={?}", $ref);
+                            WHERE  id = {?}', $ref);
         if (!list($conf_mail, $conf_title, $conf_text) = $res->fetchOneRow()) {
             cb_erreur("référence de commande inconnue");
         }
@@ -235,8 +237,8 @@ class PaymentModule extends PLModule
         }
 
         /* on fait l'insertion en base de donnees */
-        XDB::execute("INSERT INTO  payment_transactions (id, uid, ref, fullref, amount, pkey, comment)
-                           VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, {?})",
+        XDB::execute('INSERT INTO  payment_transactions (id, uid, ref, fullref, amount, pkey, comment)
+                           VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, {?})',
                      $champ901, $user->id(), $ref, $champ200, $montant, $champ905, Env::v('comment'));
 
         // We check if it is an Xnet payment and then update the related ML.
@@ -288,10 +290,11 @@ class PaymentModule extends PLModule
         /* on vérifie la signature */
         $vads_params = array();
         foreach($_REQUEST as $key => $value)
-            if(substr($key,0,5) == "vads_")
+            if(substr($key,0,5) == 'vads_') {
                 $vads_params[$key] = $value;
+            }
         ksort($vads_params);
-        $signature = sha1(join('+',$vads_params).'+'.$globals->money->cyperplus_key);
+        $signature = sha1(join('+', $vads_params) . '+' . $globals->money->cyperplus_key);
         //if($signature != Env::v('signature')) {
         //    cb_erreur("signature invalide");
         //}
@@ -308,30 +311,30 @@ class PaymentModule extends PLModule
         }
 
         $ref = $matches[1];
-        $res = XDB::query("SELECT  mail, text, confirmation
+        $res = XDB::query('SELECT  mail, text, confirmation
                              FROM  payments
-                            WHERE  id={?}", $ref);
+                            WHERE  id={?}', $ref);
         if ($res->numRows() != 1) {
             cb_erreur("référence de commande inconnue");
         }
         list($conf_mail, $conf_title, $conf_text) = $res->fetchOneRow();
 
         /* on extrait le montant */
-        if (Env::v('vads_currency') != "978") {
+        if (Env::v('vads_currency') != '978') {
             cb_erreur("monnaie autre que l'euro");
         }
         $amount = ((float)Env::i('vads_amount')) / 100;
         $montant = sprintf("%.02f EUR", $amount);
 
         /* on extrait le code de retour */
-        if (Env::v('vads_result') != "00") {
-            cb_erreur("erreur lors du paiement : ?? (".Env::v('vads_result').")");
+        if (Env::v('vads_result') != '00') {
+            cb_erreur('erreur lors du paiement : ?? (' . Env::v('vads_result') . ')');
         }
 
         /* on fait l'insertion en base de donnees */
-        XDB::execute("INSERT INTO  payment_transactions (id, uid, ref, fullref, amount, pkey, comment)
-                           VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, {?})",
-                     Env::v('vads_trans_date'), $user->id(), $ref, Env::v('vads_order_id'), $montant, "", Env::v('vads_order_info'));
+        XDB::execute('INSERT INTO  payment_transactions (id, uid, ref, fullref, amount, pkey, comment)
+                           VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, {?})',
+                     Env::v('vads_trans_date'), $user->id(), $ref, Env::v('vads_order_id'), $montant, '', Env::v('vads_order_info'));
         echo "Paiement stored.\n";
 
         // We check if it is an Xnet payment and then update the related ML.
@@ -389,7 +392,7 @@ class PaymentModule extends PLModule
         /* code retour */
         $status = Env::s('st');
         /* raison */
-        $reason = ($status == 'Pending')? Env::s('pending_reason'): Env::s('reason_code');
+        $reason = ($status == 'Pending') ? Env::s('pending_reason') : Env::s('reason_code');
         /* reference complete de la commande */
         $fullref = Env::s('cm');
         /* montant de la transaction */
@@ -400,10 +403,11 @@ class PaymentModule extends PLModule
 
         /* on extrait le code de retour */
         if ($status != "Completed") {
-            if ($status)
+            if ($status) {
                 paypal_erreur("erreur lors du paiement : $status - $reason");
-            else
+            } else {
                 paypal_erreur("Paiement annulé", false);
+            }
         }
 
         /* on extrait les informations sur l'utilisateur */
@@ -418,11 +422,11 @@ class PaymentModule extends PLModule
         }
 
         $ref = $matches[1];
-        $res = XDB::query("SELECT  mail, text, confirmation
+        $res = XDB::query('SELECT  mail, text, confirmation
                              FROM  payments
-                            WHERE  id = {?}", $ref);
-        if (!list($conf_mail,$conf_title,$conf_text) = $res->fetchOneRow()) {
-            paypal_erreur("référence de commande inconnue");
+                            WHERE  id = {?}', $ref);
+        if (!list($conf_mail, $conf_title, $conf_text) = $res->fetchOneRow()) {
+            paypal_erreur('référence de commande inconnue');
         }
 
         /* on fait l'insertion en base de donnees */
@@ -503,33 +507,60 @@ class PaymentModule extends PLModule
                   WHERE  asso_id = {?} AND NOT FIND_IN_SET('old', flags)
                ORDER BY  id DESC", $globals->asso('id'));
         $tit = $res->fetchAllAssoc();
-        $page->assign('titres', $tit);
-
+        $page->assign('titles', $tit);
 
-        // TODO: replug sort.
         $trans = array();
         $event = array();
+        if (may_update()) {
+            static $orders = array('timestamp' => 'p', 'directory_name' => 'a', 'promo' => 'pd', 'comment' => 'p', 'amount' => 'p');
+
+            if (Get::has('order_id') && Get::has('order') && array_key_exists(Get::v('order'), $orders)) {
+                $order_id = Get::i('order_id');
+                $order = Get::v('order');
+                $ordering = ' ORDER BY ' . $orders[$order] . '.' . $order;
+                if (Get::has('order_inv') && Get::i('order_inv') == 1) {
+                    $ordering .= ' DESC';
+                    $page->assign('order_inv', 0);
+                } else {
+                    $page->assign('order_inv', 1);
+                }
+                $page->assign('order_id', $order_id);
+                $page->assign('order', $order);
+                $page->assign('anchor', 'legend_' . $order_id);
+            } else {
+                $order_id = false;
+                $ordering = '';
+                $page->assign('order', false);
+            }
+        } else {
+            $ordering = '';
+            $page->assign('order', false);
+        }
         foreach($tit as $foo) {
             $pid = $foo['id'];
             if (may_update()) {
-                $res = XDB::query('SELECT  t.uid, timestamp AS `date`, t.comment, amount
-                                     FROM  payment_transactions AS t
-                                    WHERE  t.ref = {?}', $pid);
+                $res = XDB::query('SELECT  p.uid, IF(p.timestamp = \'0000-00-00\', 0, p.timestamp) AS date, p.comment, p.amount
+                                     FROM  payment_transactions AS p
+                               INNER JOIN  accounts             AS a  ON (a.uid = p.uid)
+                                LEFT JOIN  account_profiles     AS ap ON (ap.uid = p.uid AND FIND_IN_SET(\'owner\', ap.perms))
+                                LEFT JOIN  profile_display      AS pd ON (ap.pid = pd.pid)
+                                    WHERE  p.ref = {?}' . (($order_id == $pid) ? $ordering : ''),
+                                  $pid);
                 $trans[$pid] = User::getBulkUsersWithUIDs($res->fetchAllAssoc(), 'uid', 'user');
                 $sum = 0;
                 foreach ($trans[$pid] as $i => $t) {
                     $sum += strtr(substr($t['amount'], 0, strpos($t['amount'], 'EUR')), ',', '.');
                     $trans[$pid][$i]['amount'] = str_replace('EUR', '€', $t['amount']);
                 }
-                $trans[$pid][] = array('nom' => 'somme totale',
-                                       'amount' => strtr($sum, '.', ',').' €');
+                $trans[$pid][] = array('limit'  =>  true,
+                                       'amount' => strtr($sum, '.', ',') . ' €');
             }
-            $res = XDB::iterRow("SELECT e.eid, e.short_name, e.intitule, ep.nb, ei.montant, ep.paid
-                                   FROM group_events AS e
-                              LEFT JOIN group_event_participants AS ep ON (ep.eid = e.eid AND ep.uid = {?})
-                             INNER JOIN group_event_items AS ei ON (ep.eid = ei.eid AND ep.item_id = ei.item_id)
-                                  WHERE e.paiement_id = {?}",
-                                 S::v('uid'), $pid);
+            $res = XDB::iterRow("SELECT  e.eid, e.short_name, e.intitule, ep.nb, ei.montant, ep.paid
+                                   FROM  group_events             AS e
+                              LEFT JOIN  group_event_participants AS ep ON (ep.eid = e.eid AND ep.uid = {?})
+                             INNER JOIN  group_event_items        AS ei ON (ep.eid = ei.eid AND ep.item_id = ei.item_id)
+                                  WHERE  e.paiement_id = {?}",
+                                S::v('uid'), $pid);
             $event[$pid] = array();
             $event[$pid]['paid'] = 0;
             if ($res->total()) {
@@ -543,9 +574,9 @@ class PaymentModule extends PLModule
                     $event[$pid]['paid']      = $paid;
                 }
             }
-            $res = XDB::query("SELECT amount
-                                 FROM payment_transactions AS t
-                                WHERE ref = {?} AND uid = {?}", $pid, S::v('uid'));
+            $res = XDB::query('SELECT  amount
+                                 FROM  payment_transactions
+                                WHERE  id = {?} AND uid = {?}', $pid, S::v('uid'));
             $montants = $res->fetchColumn();
 
             foreach ($montants as $m) {
@@ -566,61 +597,61 @@ class PaymentModule extends PLModule
         $table_editor->add_sort_field('flags');
         $table_editor->add_sort_field('id', true, true);
         $table_editor->on_delete("UPDATE payments SET flags = 'old' WHERE id = {?}", "Le paiement a été archivé");
-        $table_editor->describe('text','intitulé',true);
-        $table_editor->describe('url','site web',false);
-        $table_editor->describe('amount_def','montant par défaut',false);
-        $table_editor->describe('amount_min','montant minimum',false);
-        $table_editor->describe('amount_max','montant maximum',false);
-        $table_editor->describe('mail','email contact',true);
-        $table_editor->describe('confirmation','message confirmation',false);
+        $table_editor->describe('text', 'intitulé', true);
+        $table_editor->describe('url', 'site web', false);
+        $table_editor->describe('amount_def', 'montant par défaut', false);
+        $table_editor->describe('amount_min', 'montant minimum', false);
+        $table_editor->describe('amount_max', 'montant maximum', false);
+        $table_editor->describe('mail', 'email contact', true);
+        $table_editor->describe('confirmation', 'message confirmation', false);
 
         // adds a column with the start date of the linked event if there is one
-        $table_editor->add_option_table('group_events','group_events.paiement_id = t.id');
+        $table_editor->add_option_table('group_events', 'group_events.paiement_id = t.id');
         $table_editor->add_option_field('group_events.debut', 'related_event', 'évènement', 'timestamp');
 
         $table_editor->apply($page, $action, $id);
     }
-    
+
     function handler_adm_transactions(&$page, $payment_id = null, $action = "list", $id = null) {
         // show transactions. FIXME: should not be modifiable
         $page->setTitle('Administration - Paiements - Transactions');
         $page->assign('title', "Liste des transactions pour le paiement {$payment_id}");
-        
+
         if ($payment_id == null)
             $page->trigError("Aucun ID de paiement fourni.");
-        
+
         $table_editor = new PLTableEditor("admin/transactions/{$payment_id}",'payment_transactions','id');
         $table_editor->set_where_clause(XDB::format('ref = {?}', $payment_id));
         $table_editor->apply($page, 'list', $id); // only the 'list' action is allowed
-        $page->assign("readonly","readonly");     // don't show modification features
+        $page->assign('readonly', 'readonly');     // don't show modification features
     }
-    
-    function handler_adm_bankaccounts(&$page, $action = "list", $id = null) {
+
+    function handler_adm_bankaccounts(&$page, $action = 'list', $id = null) {
         // managment of bank account used for money transfert
         $page->setTitle('Administration - Paiements - RIBs');
         $page->assign('title', "Liste des RIBs");
-        
-        $table_editor = new PLTableEditor("admin/payments/bankaccounts",'payment_bankaccounts','id');
-        $table_editor->describe('asso_id','ID du groupe',false);
-        $table_editor->describe('owner','titulaire',true);
-        $table_editor->add_option_table('groups','groups.id = t.asso_id');
+
+        $table_editor = new PLTableEditor('admin/payments/bankaccounts', 'payment_bankaccounts', 'id');
+        $table_editor->describe('asso_id', 'ID du groupe', false);
+        $table_editor->describe('owner', 'titulaire', true);
+        $table_editor->add_option_table('groups', 'groups.id = t.asso_id');
         $table_editor->add_option_field('groups.diminutif', 'group_name', 'groupe', 'varchar','account');
-        
+
         // check RIB key
-        if ($action == "update" && Post::has("account") && !check_rib(Post::v("account"))) {
+        if ($action == 'update' && Post::has('account') && !check_rib(Post::v('account'))) {
             $page->trigError("Le RIB n'est pas valide");
-            $table_editor->apply($page, "edit", $id);
+            $table_editor->apply($page, 'edit', $id);
             return;
         }
-        
+
         $table_editor->apply($page, $action, $id);
     }
-    
-    function handler_adm_methods(&$page, $action = "list", $id = null) {
+
+    function handler_adm_methods(&$page, $action = 'list', $id = null) {
         // show and edit payment methods
         $page->setTitle('Administration - Paiements - Méthodes');
-        $page->assign('title', "Méthodes de paiement");
-        $table_editor = new PLTableEditor("admin/payments/methods",'payment_methods','id');
+        $page->assign('title', 'Méthodes de paiement');
+        $table_editor = new PLTableEditor('admin/payments/methods', 'payment_methods', 'id');
         $table_editor->apply($page, $action, $id);
     }
 
@@ -631,40 +662,40 @@ class PaymentModule extends PLModule
         $page->changeTpl('payment/reconcile.tpl');
         $page->assign('step', $step);
         $list = true;
-        
+
         // actions
         if ($step == 'delete' && $param != null) {
             S::assert_xsrf_token();
-            XDB::execute("DELETE FROM payment_reconcilations WHERE id={?}", $param);
+            XDB::execute('DELETE FROM payment_reconcilations WHERE id = {?}', $param);
             // FIXME: hardcoding !!!
-            XDB::execute("UPDATE payment_transactions SET recon_id=NULL,commission=NULL WHERE recon_id={?} AND method_id=2", $param);
-            XDB::execute("UPDATE payment_transactions SET recon_id=NULL WHERE recon_id={?} AND method_id=1", $param);
-            $page->trigSuccess("L'entrée ".$param." a été supprimée.");
-        
+            XDB::execute('UPDATE payment_transactions SET recon_id = NULL,commission = NULL WHERE recon_id = {?} AND method_id = 2', $param);
+            XDB::execute('UPDATE payment_transactions SET recon_id = NULL WHERE recon_id = {?} AND method_id = 1', $param);
+            $page->trigSuccess("L'entrée " . $param . ' a été supprimée.');
+
         } elseif ($step == 'edit') {
             $page->trigError("L'édition n'est pas implémentée.");
-            
+
         } elseif ($step == 'step5') {
             $page->trigSuccess("La réconciliation est terminée. Il est maintenant nécessaire de générer les virements.");
-        
+
         }
-        
+
         if($list) {
             // show list of reconciliations, with a "add" button
-            $page->assign('title', "Réconciliation - Liste");
+            $page->assign('title', 'Réconciliation - Liste');
             $page->assign('step', 'list');
-            
+
             $recongps = array();
-    
+
             $res = XDB::query("SELECT  r.id, short_name AS method, period_start, period_end, status,
                                        payment_count, sum_amounts, sum_commissions
                                  FROM  payment_reconcilations AS r
-                            LEFT JOIN  payment_methods AS m ON r.method_id=m.id
+                            LEFT JOIN  payment_methods        AS m ON (r.method_id = m.id)
                                 WHERE  recongroup_id IS NULL
                              ORDER BY  period_end DESC, period_start DESC");
             foreach ($res->fetchAllAssoc() as $recon)
                 $recongps[] = array('recons' => array($recon), 'transfers' => array());
-            
+
             $res = XDB::query("SELECT  recongroup_id AS id
                                  FROM  payment_reconcilations
                              GROUP BY  recongroup_id
@@ -673,114 +704,114 @@ class PaymentModule extends PLModule
                 $res = XDB::query("SELECT  r.id, short_name AS method, period_start, period_end, status,
                                            payment_count, sum_amounts, sum_commissions
                                      FROM  payment_reconcilations AS r
-                                LEFT JOIN  payment_methods AS m ON r.method_id=m.id
-                                    WHERE  recongroup_id={?}
+                                LEFT JOIN  payment_methods        AS m ON (r.method_id = m.id)
+                                    WHERE  recongroup_id = {?}
                                  ORDER BY  period_end DESC, period_start DESC",
                                   $recongp['id']);
                 $recongp['recons'] = $res->fetchAllAssoc();
 
-                $res = XDB::query("SELECT  id, payment_id, amount, account_id, message, date
+                $res = XDB::query('SELECT  id, payment_id, amount, account_id, message, date
                                      FROM  payment_transfers
-                                    WHERE  recongroup_id={?}",
+                                    WHERE  recongroup_id = {?}',
                                   $recongp['id']);
                 $recongp['transfers'] = $res->fetchAllAssoc();
-                        
+
                 $recongps[] = $recongp;
             }
             $page->assign_by_ref('recongps', $recongps);
         }
     }
-    
+
     function handler_adm_importlogs(&$page, $step, $param = null) {
         $page->setTitle('Administration - Paiements - Réconciliations');
         $page->changeTpl('payment/reconcile.tpl');
         $page->assign('step', $step);
-        
+
         if (isset($_SESSION['paymentrecon_data'])) {
             // create temporary table with imported data
-            XDB::execute("CREATE TEMPORARY TABLE payment_tmp (
+            XDB::execute('CREATE TEMPORARY TABLE payment_tmp (
                             reference VARCHAR(255) PRIMARY KEY,
                             date DATE,
                             amount DECIMAL(9,2),
                             commission DECIMAL(9,2)
-                          )");
+                          )');
             foreach ($_SESSION['paymentrecon_data'] as $i)
-                XDB::execute("INSERT INTO payment_tmp VALUES ({?},{?},{?},{?})",
+                XDB::execute('INSERT INTO payment_tmp VALUES ({?}, {?}, {?}, {?})',
                               $i['reference'], $i['date'], $i['amount'], $i['commission']);
         }
-        
+
         if ($step == 'step1') {
-            $page->assign('title', "Étape 1");
+            $page->assign('title', 'Étape 1');
             unset($_SESSION['paymentrecon_method']);
             unset($_SESSION['paymentrecon_data']);
             unset($_SESSION['paymentrecon_id']);
-                
+
             // was a payment method choosen ?
             if ($param != null) {
                 $_SESSION['paymentrecon_method'] = (int)$param;
-                pl_redirect("admin/reconcile/importlogs/step2");
+                pl_redirect('admin/reconcile/importlogs/step2');
 
             } else {
             // ask to choose a payment method
-                $res = XDB::query("SELECT id, text FROM payment_methods");
+                $res = XDB::query('SELECT id, text FROM payment_methods');
                 $page->assign('methods', $res->fetchAllAssoc());
             }
 
         } elseif ( $step == 'step2' ) {
-            $page->assign('title', "Étape 2");
-            
+            $page->assign('title', 'Étape 2');
+
             // import logs formated in CVS
-            $fields = array('date','reference','amount','commission');
+            $fields = array('date', 'reference', 'amount', 'commission');
             $importer = new PaymentLogsImporter();
             $importer->apply($page, 'admin/reconcile/importlogs/step2', $fields);
-            
+
             // if import is finished
             $result = $importer->get_result();
             if($result != null) {
                 $_SESSION['paymentrecon_data'] = $result;
-                pl_redirect("admin/reconcile/importlogs/step3");
+                pl_redirect('admin/reconcile/importlogs/step3');
             }
-            
+
         } elseif ($step == 'step3' ) {
-            $page->assign('title', "Étape 3");
-            
+            $page->assign('title', 'Étape 3');
+
             // compute reconcilation summary data
-            $res = XDB::query("SELECT  MIN(date) AS period_start, MAX(date) AS period_end,
+            $res = XDB::query('SELECT  MIN(date) AS period_start, MAX(date) AS period_end,
                                        count(*) AS payment_count, SUM(amount) AS sum_amounts,
                                        SUM(commission) AS sum_commissions
-                                 FROM  payment_tmp");
+                                 FROM  payment_tmp');
             $recon = $res->fetchOneAssoc();
             $recon['method_id'] = $_SESSION['paymentrecon_method'];
-            
+
             // create reconciliation item in database
             if(Post::has('next')) {
                 S::assert_xsrf_token();
-                
+
                 // get parameters
-                $recon['period_start'] = preg_replace('/([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})/','\3-\2-\1',Post::v('period_start'));
-                $recon['period_end']   = preg_replace('/([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})/','\3-\2-\1',Post::v('period_end'));
+                $recon['period_start'] = preg_replace('/([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})/', '\3-\2-\1', Post::v('period_start'));
+                $recon['period_end']   = preg_replace('/([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})/', '\3-\2-\1', Post::v('period_end'));
                     // FIXME: save checks to be done at next step
-                
+
                 // Create reconcilation item in database
                     // FIXME: check if period doesn't overlap with others for the same method_id
-                XDB::execute("INSERT INTO  payment_reconcilations (method_id, period_start, period_end,
+                XDB::execute('INSERT INTO  payment_reconcilations (method_id, period_start, period_end,
                                                                    payment_count, sum_amounts, sum_commissions)
-                                   VALUES  ({?}, {?}, {?}, {?}, {?}, {?})",
+                                   VALUES  ({?}, {?}, {?}, {?}, {?}, {?})',
                              $recon['method_id'], $recon['period_start'], $recon['period_end'],
                              $recon['payment_count'], $recon['sum_amounts'], $recon['sum_commissions']);
                 $_SESSION['paymentrecon_id'] = XDB::insertId();
-                
+
                 // reconcile simple cases (trans.commission n'est modifié que s'il vaut NULL)
                 XDB::execute("UPDATE  payment_transactions AS trans, payment_tmp AS tmp
-                                 SET  trans.recon_id={?}, trans.commission=tmp.commission
-                               WHERE  trans.fullref=tmp.reference
-                                      AND trans.amount=tmp.amount AND DATE(trans.ts_confirmed)=tmp.date
-                                      AND (trans.commission IS NULL OR trans.commission=tmp.commission)
-                                      AND method_id={?} AND recon_id IS NULL AND status='confirmed'",
+                                 SET  trans.recon_id = {?}, trans.commission=tmp.commission
+                               WHERE  trans.fullref = tmp.reference
+                                      AND trans.amount = tmp.amount AND DATE(trans.ts_confirmed) = tmp.date
+                                      AND (trans.commission IS NULL OR trans.commission = tmp.commission)
+                                      AND method_id = {?} AND recon_id IS NULL AND status = 'confirmed'",
                              $_SESSION['paymentrecon_id'], $recon['method_id']);
-                
-                pl_redirect("admin/reconcile/importlogs/step4");                
-                
+
+                pl_redirect("admin/reconcile/importlogs/step4");
+
             // show summary of the imported data + ask form start/end of reconcilation period
             } else {
                 $recon['period_start'] = preg_replace('/([0-9]{4})-([0-9]{2})-([0-9]{2})/', '\3/\2/\1', $recon['period_start']);
@@ -789,179 +820,194 @@ class PaymentModule extends PLModule
             }
 
         } elseif ($step == 'step4' ) {
-            $page->assign('title', "Étape 4");
-            
+            $page->assign('title', 'Étape 4');
+
             // get reconcilation summary informations
-            $res = XDB::query("SELECT * FROM payment_reconcilations WHERE id={?}", $_SESSION['paymentrecon_id']);
+            $res = XDB::query('SELECT * FROM payment_reconcilations WHERE id = {?}', $_SESSION['paymentrecon_id']);
             $recon = $res->fetchOneAssoc();
             $page->assign('recon', $recon);
 
             if (Post::has('force')) {
                 S::assert_xsrf_token();
                 foreach (Post::v('force') as $id => $value) {
-                    XDB::execute("UPDATE  payment_transactions AS trans, payment_tmp AS tmp
-                                     SET  trans.recon_id={?}, trans.commission=tmp.commission
-                                   WHERE  trans.id={?} AND trans.fullref=tmp.reference",
+                    XDB::execute('UPDATE  payment_transactions AS trans, payment_tmp AS tmp
+                                     SET  trans.recon_id = {?}, trans.commission = tmp.commission
+                                   WHERE  trans.id = {?} AND trans.fullref = tmp.reference',
                                  $_SESSION['paymentrecon_id'], $id);
                 }
-                $page->trigSuccess('La réconciliation a été forcée pour '.count(Post::v('force')).' transaction(s).');
-                
+                $page->trigSuccess('La réconciliation a été forcée pour ' . count(Post::v('force')) . ' transaction(s).');
+
             } elseif (Post::has('next')) {
-                if (strlen($recon['comments'])<3) {
-                    $page->trigError("Le commentaire doit contenir au moins 3 caractères.");
+                if (strlen($recon['comments'])< 3 ) {
+                    $page->trigError('Le commentaire doit contenir au moins 3 caractères.');
                 } else {
-                    XDB::execute("UPDATE payment_reconcilations SET status='transfering' WHERE id={?}", $_SESSION['paymentrecon_id']);
+                    XDB::execute("UPDATE payment_reconcilations SET status = 'transfering' WHERE id = {?}", $_SESSION['paymentrecon_id']);
                     pl_redirect('admin/reconcile/step5');
                 }
-                
+
             } elseif (Post::has('savecomments')) {
                 S::assert_xsrf_token();
                 $recon['comments'] = Post::v('comments');
                 $page->assign('recon', $recon);
-                XDB::execute("UPDATE payment_reconcilations SET comments={?} WHERE id={?}", $recon['comments'], $_SESSION['paymentrecon_id']);
+                XDB::execute('UPDATE payment_reconcilations SET comments = {?} WHERE id = {?}', $recon['comments'], $_SESSION['paymentrecon_id']);
                 $page->trigSuccess('Les commentaires ont été enregistrés.');
             }
-            
+
             // reconcilation results - ok
-            $res = XDB::query("SELECT  count(*),SUM(amount),SUM(commission)
-                                 FROM  payment_transactions WHERE recon_id={?}",
+            $res = XDB::query('SELECT  count(*), SUM(amount), SUM(commission)
+                                 FROM  payment_transactions
+                                WHERE recon_id = {?}',
                               $recon['id']);
-            list($ok_count,$ok_sum_amounts,$ok_sum_coms) = $res->fetchOneRow();
+            list($ok_count, $ok_sum_amounts, $ok_sum_coms) = $res->fetchOneRow();
             $page->assign('ok_count', $ok_count);
-            
+
             // reconcilation results - ref exists, but some data differs
-            $res = XDB::query("SELECT  id, fullref, method_id, ts_confirmed, trans.amount, trans.commission, status, recon_id,
+            $res = XDB::query('SELECT  id, fullref, method_id, ts_confirmed, trans.amount, trans.commission, status, recon_id,
                                        reference, date, tmp.amount as amount2, tmp.commission as commission2
                                  FROM  payment_transactions AS trans
-                           INNER JOIN  payment_tmp AS tmp ON trans.fullref=tmp.reference
-                                WHERE  trans.recon_id IS NULL OR trans.recon_id != {?}",
+                           INNER JOIN  payment_tmp          AS tmp ON (trans.fullref = tmp.reference)
+                                WHERE  trans.recon_id IS NULL OR trans.recon_id != {?}',
                               $recon['id']);
             $differs = $res->fetchAllAssoc();
             $page->assign_by_ref('differs', $differs);
             $page->assign('differ_count', count($differs));
-            
+
             // reconcilation results - ref doesn't exists in database
-            $res = XDB::query("SELECT  tmp.*
-                                 FROM  payment_tmp AS tmp
-                            LEFT JOIN  payment_transactions AS trans ON trans.fullref=tmp.reference
-                                WHERE  trans.fullref IS NULL");
+            $res = XDB::query('SELECT  tmp.*
+                                 FROM  payment_tmp          AS tmp
+                            LEFT JOIN  payment_transactions AS trans ON (trans.fullref = tmp.reference)
+                                WHERE  trans.fullref IS NULL');
             $only_import = $res->fetchAllAssoc();
             $page->assign_by_ref('only_import', $only_import);
             $page->assign('onlyim_count', count($only_import));
-            
+
             // reconcilation results - exists in database but not in import
-            $res = XDB::query("SELECT  trans.*
+            $res = XDB::query('SELECT  trans.*
                                  FROM  payment_transactions AS trans
-                            LEFT JOIN  payment_tmp AS tmp ON trans.fullref=tmp.reference
-                                WHERE  {?}<=DATE(trans.ts_confirmed) AND DATE(trans.ts_confirmed)<={?}
-                                       AND tmp.reference IS NULL AND method_id={?}",
+                            LEFT JOIN  payment_tmp          AS tmp ON (trans.fullref = tmp.reference)
+                                WHERE  {?} <= DATE(trans.ts_confirmed) AND DATE(trans.ts_confirmed) <= {?}
+                                       AND tmp.reference IS NULL AND method_id = {?}',
                               $recon['period_start'], $recon['period_end'], $recon['method_id']);
             $only_database = $res->fetchAllAssoc();
             $page->assign_by_ref('only_database', $only_database);
             $page->assign('onlydb_count', count($only_database));
         }
     }
-    
+
     function handler_adm_transfers(&$page, $action = null, $id = null) {
         // list/log all bank transfers and link them to individual transactions
-        
+
         if (Post::has('generate')) {
             $recon_ids = array_keys(Post::v('recon_id'));
-            
+
             // generate a new reconcilation group ID
             $res = XDB::query("SELECT MAX(recongroup_id)+1 FROM payment_reconcilations");
             $recongp_id = $res->fetchOneCell();
             if ($recongp_id == null) $recongp_id = 1;
-            
+
             // add reconcilations to group
                 // FIXME: should check if reconcilations are in good status
-            XDB::execute("UPDATE payment_reconcilations SET recongroup_id={?}, status='closed'
-                          WHERE id IN {?}",
-                          $recongp_id, $recon_ids);
-            
+            XDB::execute("UPDATE  payment_reconcilations
+                             SET  recongroup_id = {?}, status = 'closed'
+                           WHERE  id IN {?}",
+                         $recongp_id, $recon_ids);
+
             // create transfers
-            XDB::execute("INSERT INTO  payment_transfers
+            XDB::execute('INSERT INTO  payment_transfers
                                SELECT  NULL, {?}, t.ref, SUM(t.amount+t.commission), NULL, p.text, NULL
                                  FROM  payment_transactions AS t
-                            LEFT JOIN  payments AS p ON t.ref = p.id
-                            LEFT JOIN  groups AS g ON p.asso_id = g.id
+                            LEFT JOIN  payments             AS p ON (t.ref = p.id)
+                            LEFT JOIN  groups               AS g ON (p.asso_id = g.id)
                                 WHERE  t.recon_id IN {?}
-                             GROUP BY  t.ref",
-                              $recongp_id, $recon_ids);
-            
+                             GROUP BY  t.ref',
+                         $recongp_id, $recon_ids);
+
             //$res = XDB::query("SELECT * FROM  payment_reconcilations WHERE id IN {?}", $recon_ids);
             //$recons = $res->fetchAllAssoc();
-            
-            $page->trigSuccess("Les virements ont été générés pour ".count($recon_ids)." réconciliations.");
+
+            $page->trigSuccess('Les virements ont été générés pour ' . count($recon_ids) . ' réconciliations.');
             $this->handler_adm_reconcile($page);
-            
-        } elseif ($action == "delgroup") {
+
+        } elseif ($action == 'delgroup') {
             S::assert_xsrf_token();
-            XDB::execute("UPDATE payment_reconcilations SET status='transfering', recongroup_id=NULL WHERE recongroup_id={?}", $id);
-            XDB::execute("DELETE FROM payment_transfers WHERE recongroup_id={?} AND date IS NULL", $id);
-            
+            XDB::execute("UPDATE  payment_reconcilations
+                             SET  status = 'transfering', recongroup_id = NULL
+                           WHERE  recongroup_id = {?}", $id);
+            XDB::execute("DELETE FROM  payment_transfers
+                                WHERE  recongroup_id = {?} AND date IS NULL", $id);
+
             $page->trigSuccess("Les virements non réalisés ont été supprimé du groupe ".$id.".");
             $this->handler_adm_reconcile($page);
-            
+
         } elseif ($action == "confirm") {
             S::assert_xsrf_token();
-            XDB::execute("UPDATE payment_transfers SET date=NOW() WHERE id={?}", $id);
-            
-            $page->trigSuccess("Virement ".$id." confirmé.");
+            XDB::execute('UPDATE  payment_transfers
+                             SET  date = NOW()
+                           WHERE  id = {?}', $id);
+
+            $page->trigSuccess('Virement ' . $id . ' confirmé.');
             $this->handler_adm_reconcile($page);
-            
+
         } else {
-            pl_redirect("admin/reconcile");
+            pl_redirect('admin/reconcile');
         }
     }
 }
 
 class PaymentLogsImporter extends CSVImporter {
     protected $result;
-    
+
     public function __construct() {
         parent::__construct('');
-        $this->registerFunction('systempay_commission', 'Compute BPLC commission', array($this,"compute_systempay_commission"));
-        $this->registerFunction('payment_id', 'Autocompute payment ID', array($this,"compute_payment_id"));
+        $this->registerFunction('systempay_commission', 'Compute BPLC commission', array($this, 'compute_systempay_commission'));
+        $this->registerFunction('payment_id', 'Autocompute payment ID', array($this, 'compute_payment_id'));
         //$this->forceValue('payment_id','func_payment_id');
     }
-    
+
     public function run($action = null, $insert_relation = null, $update_relation = null) {
         $this->result = array();
         foreach ($this->data as $line) {
             $a = $this->makeAssoc($line, $insert_relation);
-            $a['date'] = preg_replace('/([0-9]{2})\/([0-9]{2})\/([0-9]{4}).*/','\3-\2-\1', $a['date']);
-            $a['amount'] = str_replace(',','.',$a['amount']);
-            $a['commission'] = str_replace(',','.',$a['commission']);
+            $a['date'] = preg_replace('/([0-9]{2})\/([0-9]{2})\/([0-9]{4}).*/', '\3-\2-\1', $a['date']);
+            $a['amount'] = str_replace(',', '.', $a['amount']);
+            $a['commission'] = str_replace(',', '.', $a['commission']);
             $this->result[] = $a;
         }
     }
-    
+
     public function get_result() {
         return $this->result;
     }
-    
+
     static public function compute_systempay_commission($line, $key, $relation) {
-        static $EEE_countries = array('France','Allemagne','Autriche','Belgique','Bulgarie','Chypre',
-            'Danemark','Espagne','Estonie','Finlande','Grèce','Hongrie','Irlande','Islande','Italie',
-            'Lettonie','Liechtenstein','Lituanie','Luxembourg','Malte','Norvège','Pays-Bas','Pologne',
-            'Portugal','Roumanie','Royaume-Uni','Slovaquie','Slovénie','Suède','République Tchèque');
-        
-        if($key!='commission' || !array_key_exists('carte',$line)) return null;
+        static $EEE_countries = array(
+            'France', 'Allemagne', 'Autriche', 'Belgique', 'Bulgarie', 'Chypre',
+            'Danemark', 'Espagne', 'Estonie', 'Finlande', 'Grèce', 'Hongrie', 'Irlande', 'Islande', 'Italie',
+            'Lettonie', 'Liechtenstein', 'Lituanie', 'Luxembourg', 'Malte', 'Norvège', 'Pays-Bas', 'Pologne',
+            'Portugal', 'Roumanie', 'Royaume-Uni', 'Slovaquie', 'Slovénie', 'Suède', 'République Tchèque'
+        );
+
+        if($key!='commission' || !array_key_exists('carte', $line)) {
+            return null;
+        }
         $amount = self::getValue($line, 'amount', $relation['amount']);
-        if (in_array($line['pays carte'],$EEE_countries))
-            return -0.20 - round($amount*0.005, 2);
-        else
-            return -0.20 - round($amount*0.005, 2) - 0.76;
+        if (in_array($line['pays carte'], $EEE_countries)) {
+            return -0.20 - round($amount * 0.005, 2);
+        } else {
+            return -0.20 - round($amount * 0.005, 2) - 0.76;
+        }
     }
 
     static public function compute_payment_id($line, $key, $relation) {
-        if ($key != 'payment_id') return null;
+        if ($key != 'payment_id') {
+            return null;
+        }
         $reference = self::getValue($line, 'reference', $relation['reference']);
-        if (ereg('-([0-9]+)$', $reference, $matches))
+        if (ereg('-([0-9]+)$', $reference, $matches)) {
             return $matches[1];
-        else
+        } else {
             return null;
+        }
     }
 }
 
index e052385..93c69cb 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 3f40979..225c337 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-/*
-    Numéros de cartes de test :
-    Commerçant non enrôlé 3D-Secure
-    4970 1000 0000 0003 Paiement accepté (autorisation accordée)
-    Commerçant enrôlé 3D-Secure
-    4970 1000 0000 0000 Paiement accepté avec authentification internaute
-    4970 1000 0000 0001 Paiement accepté sans authentification internaute (Internaute non enrôlé 3D-Secure)
-    4970 1000 0000 0002 contacter l'émetteur de carte (Transaction à forcer). Authentification réalisée avec succès.
-    4970 1000 0000 0006 Problème technique lors du calcul de la garantie de paiement
-    4970 1000 0000 0007 Problème technique lors de l’authentification porteur
-    4970 1000 0000 0097 Paiement refusé pour cause d’authentification 3D-Secure échouée (l'internaute n'est pas parvenu à s'authentifier)
-    4970 1000 0000 0098 Paiement refusé (autorisation refusée pour cause de plafond dépassé)
-    4970 1000 0000 0099 Paiement refusé (autorisation refusée suite à erreur dans le cryptogramme visuel saisi)
+/** Card numbers for tests.
+ * Non 3D-Secure shop:
+ *  4970 1000 0000 0003 Payment accepted (authorized)
+ * 3D-Secure shop:
+ *  4970 1000 0000 0000 Payment accepted, with user authentication.
+ *  4970 1000 0000 0001 Payment accepted, without user authentication (non 3D-Secure user).
+ *  4970 1000 0000 0002 Must contact card issuer (which must force transaction). Succesful authentication.
+ *  4970 1000 0000 0006 Technical issue while computing payment warranty.
+ *  4970 1000 0000 0007 Technical issue during user authentication.
+ *  4970 1000 0000 0097 Payment refused due to 3D-Secure authentication failure (user failed to authenticate).
+ *  4970 1000 0000 0098 Payment refused (user credit limit overrun).
+ *  4970 1000 0000 0099 Payment refused (invalid credit card visual cryptogramm).
 */
 
 class BPLCCyberPlus
@@ -49,7 +48,7 @@ class BPLCCyberPlus
 
     function BPLCCyberPlus($val)
     {
-        // SVA : nombre de chiffres après la virgule dépendant de currency ?
+        // Improvement: number of digits after the coma might depend from the currency.
         $this->val = 100 * strtr(sprintf("%.02f", (float)$val), '.', ',');
     }
 
@@ -61,14 +60,14 @@ class BPLCCyberPlus
         global $globals, $platal;
         $log = S::v('log');
 
-        // on constuit la reference de la transaction
+        // Transaction's reference computation.
         $prefix = ($pay->flags->hasflag('unique')) ? str_pad("",15,"0") : rand_url_id();
         $fullref = substr("$prefix-{$pay->id}",-12); // FIXME : check for duplicates
         $ts = time();
         $trans_date = date("YmdHis", $ts);
         $trans_id = date("His", $ts); // FIXME : check for duplicates
 
-        // contenu du formulaire
+        // Form's content.
         $this->urlform = "https://systempay.cyberpluspaiement.com/vads-payment/";
         $this->infos['commercant'] = Array(
             'vads_site_id' => $globals->money->cyperplus_account,
@@ -92,7 +91,7 @@ class BPLCCyberPlus
             'vads_page_action' => 'PAYMENT',
             'vads_action_mode' => 'INTERACTIVE');
 
-        // calcul de la clé d'acceptation en entrée
+        // Entry key computation.
         $all_params = array_merge($this->infos['commercant'],$this->infos['client'],$this->infos['commande'],$this->infos['divers']);
         ksort($all_params);
         $this->infos['divers']['signature'] = sha1(join('+',$all_params).'+'.$globals->money->cyperplus_key);
index a394563..b7577d8 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index f0985b5..71de323 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -66,22 +66,26 @@ class PayPal
             'email'      => $user->bestEmail()
         );
 
-        $res = XDB::query("SELECT  pa.text, gl.name AS city, pa.postalCode AS zip, pa.countryId AS country,
-                                   IF(pp1.display_tel != '', pp1.display_tel, pp2.display_tel) AS night_phone_b
-                             FROM  profile_addresses AS pa
-                        LEFT JOIN  profile_phones    AS pp1 ON (pp1.pid = pa.pid AND pp1.link_type = 'address'
-                                                                AND pp1.link_id = pa.id)
-                        LEFT JOIN  profile_phones    AS pp2 ON (pp2.pid = pa.pid AND pp2.link_type = 'user'
-                                                                AND pp2.link_id = 0)
-                        LEFT JOIN  geoloc_localities AS gl  ON (gl.id = pa.localityId)
-                            WHERE  pa.pid = {?} AND FIND_IN_SET('current', pa.flags)
-                            LIMIT  1",
-                          $user->profile()->id());
-        $this->infos['client'] = array_map('replace_accent', array_merge($info_client, $res->fetchOneAssoc()));
-        list($this->infos['client']['address1'], $this->infos['client']['address2']) =
-            explode("\n", Geocoder::getFirstLines($this->infos['client']['text'],
-                                                  $this->infos['client']['zip'], 2));
-        unset($this->infos['client']['text']);
+        if ($user->hasProfile() {
+            $res = XDB::query("SELECT  pa.text, gl.name AS city, pa.postalCode AS zip, pa.countryId AS country,
+                                       IF(pp1.display_tel != '', pp1.display_tel, pp2.display_tel) AS night_phone_b
+                                 FROM  profile_addresses AS pa
+                            LEFT JOIN  profile_phones    AS pp1 ON (pp1.pid = pa.pid AND pp1.link_type = 'address'
+                                                                    AND pp1.link_id = pa.id)
+                            LEFT JOIN  profile_phones    AS pp2 ON (pp2.pid = pa.pid AND pp2.link_type = 'user'
+                                                                    AND pp2.link_id = 0)
+                            LEFT JOIN  geoloc_localities AS gl  ON (gl.id = pa.localityId)
+                                WHERE  pa.pid = {?} AND FIND_IN_SET('current', pa.flags)
+                                LIMIT  1",
+                              $user->profile()->id());
+            $this->infos['client'] = array_map('replace_accent', array_merge($info_client, $res->fetchOneAssoc()));
+            list($this->infos['client']['address1'], $this->infos['client']['address2']) =
+                explode("\n", Geocoder::getFirstLines($this->infos['client']['text'],
+                                                      $this->infos['client']['zip'], 2));
+            unset($this->infos['client']['text']);
+        } else {
+            $this->infos['client'] = replace_accent($info_client);
+        }
 
         // We build the transaction's reference
         $prefix = ($pay->flags->hasflag('unique')) ? str_pad("", 15, "0") : rand_url_id();
index cfa973f..03883d4 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index ac70fcd..e4627e8 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 552d596..30fe082 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 08cda88..d9dd56d 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index a6fc07f..98c94f3 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -293,7 +293,6 @@ class ProfileModule extends PLModule
         $page->assign('view', $view);
         $page->assign('logged', S::logged());
 
-        $page->addJsLink('close_on_esc.js');
         header('Last-Modified: ' . date('r', strtotime($profile->last_change)));
     }
 
@@ -330,7 +329,6 @@ class ProfileModule extends PLModule
         }
 
         // Build the page
-        $page->addJsLink('ajax.js');
         $page->addJsLink('education.js', false); /* dynamic content */
         $page->addJsLink('grades.js', false);    /* dynamic content */
         $page->addJsLink('profile.js');
@@ -525,8 +523,6 @@ class ProfileModule extends PLModule
               LEFT JOIN  geoloc_countries       AS gc ON (m.country = gc.iso_3166_1_a2)
                   WHERE  pid = {?}", $pf->id());
         $page->assign('pays', $res->fetchColumn());
-
-        $page->addJsLink('close_on_esc.js');
     }
 
     function handler_ref_country(&$page)
index 587e0b6..4c0d723 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 5c41316..1c914b5 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index ac797c6..4171fe4 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 26bfafd..2d7caaa 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 4726e94..8e2b35d 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -92,7 +92,7 @@ class ProfileSettingJob implements ProfileSetting
         }
         $it = Phone::iterate(array($page->pid()), array(Phone::LINK_JOB));
         while ($phone = $it->next()) {
-            $jobs[$phone->linkId()]['w_phone'][$phone->id()] = $phone->toFormArray();
+            $jobs[$phone->link_id]['w_phone'][$phone->id] = $phone->toFormArray();
         }
         $res = XDB::iterator("SELECT  e.jtid, e.full_name, j.jid
                                 FROM  profile_job_term_enum AS e
index 6ad2598..3a842c6 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index f23919f..9501b58 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 82c30c8..2ad367e 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
 class ProfileSettingSkill implements ProfileSetting
 {
     private $table;
+    private $id;
     private $skill_field;
     private $text_field;
 
-    public function __construct($table, $skill, $text)
+    public function __construct($table, $id, $skill, $text)
     {
         $this->table = $table;
+        $this->id = $id;
         $this->skill_field = $skill;
         $this->text_field = $text;
     }
@@ -36,9 +38,9 @@ class ProfileSettingSkill implements ProfileSetting
     {
         if (is_null($value)) {
             $value = array();
-            $res = XDB::iterRow("SELECT  s.id, s.{$this->text_field}, i.level
+            $res = XDB::iterRow("SELECT  s.{$this->id}, s.{$this->text_field}, i.level
                                    FROM  profile_{$this->table}_enum AS s
-                             INNER JOIN  profile_{$this->table}s AS i ON(s.id = i.{$this->skill_field})
+                             INNER JOIN  profile_{$this->table}s     AS i ON (s.{$this->id} = i.{$this->skill_field})
                                   WHERE  i.pid = {?}",
                                 $page->pid());
             while (list($sid, $text, $level) = $res->next()) {
@@ -52,7 +54,7 @@ class ProfileSettingSkill implements ProfileSetting
                 if (!isset($skill['text']) || empty($skill['text'])) {
                     $res = XDB::query("SELECT  {$this->text_field}
                                          FROM  profile_{$this->table}_enum
-                                        WHERE  id = {?}", $id);
+                                        WHERE  {$this->id} = {?}", $id);
                     $skill['text'] = $res->fetchOneCell();
                 }
             }
@@ -109,8 +111,8 @@ class ProfilePageSkills extends ProfilePage
     public function __construct(PlWizard &$wiz)
     {
         parent::__construct($wiz);
-        $this->settings['competences'] = new ProfileSettingSkill('skill', 'cid', 'text_fr');
-        $this->settings['langues'] = new ProfileSettingSkill('langskill', 'lid', 'langue_fr');
+        $this->settings['competences'] = new ProfileSettingSkill('skill', 'id', 'cid', 'text_fr');
+        $this->settings['langues'] = new ProfileSettingSkill('langskill', 'iso_639_2b', 'lid', 'language');
     }
 
     public function _prepare(PlPage &$page, $id)
@@ -120,9 +122,9 @@ class ProfilePageSkills extends ProfilePage
         $page->assign('comp_level', array('initié' => 'initié',
                                           'bonne connaissance' => 'bonne connaissance',
                                           'expert' => 'expert'));
-        $page->assign('lang_list', XDB::iterator("SELECT  id, langue_fr
+        $page->assign('lang_list', XDB::iterator('SELECT  iso_639_2b, language
                                                     FROM  profile_langskill_enum
-                                                ORDER BY  langue_fr"));
+                                                ORDER BY  language'));
         $page->assign('lang_level', array(1 => 'connaissance basique',
                                           2 => 'maîtrise des bases',
                                           3 => 'maîtrise limitée',
index 9c235f9..39e1034 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -52,7 +52,7 @@ class RegisterModule extends PLModule
             $nameTypes = DirEnum::getOptions(DirEnum::NAMETYPES);
             $nameTypes = array_flip($nameTypes);
             $res = XDB::query("SELECT  a.uid, pd.promo, pnl.name AS lastname, pnf.name AS firstname, p.xorg_id AS xorgid,
-                                       p.birthdate_ref AS birthdateRef, FIND_IN_SET('watch', a.flags) AS watch, m.hash, a.type as eduType
+                                       p.birthdate_ref AS birthdateRef, FIND_IN_SET('watch', a.flags) AS watch, m.hash
                                  FROM  register_marketing AS m
                            INNER JOIN  accounts           AS a   ON (m.uid = a.uid)
                            INNER JOIN  account_profiles   AS ap  ON (a.uid = ap.uid AND FIND_IN_SET('owner', ap.perms))
@@ -171,13 +171,8 @@ class RegisterModule extends PLModule
                     }
 
                     // Register the optional services requested by the user.
-                    if ($subState->v('eduType') == 'x') {
-                        $proposedServices = array('ax_letter', 'imap', 'ml_promo', 'nl');
-                    } else {
-                        $proposedServices = array('ax_letter', 'nl');
-                    }
                     $services = array();
-                    foreach ($proposedServices as $service) {
+                    foreach (array('ax_letter', 'imap', 'ml_promo', 'nl') as $service) {
                         if (Post::b($service)) {
                             $services[] = $service;
                         }
@@ -354,15 +349,8 @@ class RegisterModule extends PLModule
 
         // Add the registration email address as first and only redirection.
         require_once 'emails.inc.php';
-        $user = User::getSilentWithUID($uid);
-        if ($isX) {
-            $redirect = new Redirect($user);
-            $redirect->add_email($email);
-        } else {
-            XDB::execute('UPDATE  accounts
-                             SET  email = {?}
-                           WHERE  uid = {?}', $email, $uid);
-        }
+        $redirect = new Redirect($user);
+        $redirect->add_email($email);
 
         // Try to start a session (so the user don't have to log in); we will use
         // the password available in Post:: to authenticate the user.
@@ -410,11 +398,10 @@ class RegisterModule extends PLModule
 
         // Congratulate our newly registered user by email.
         $mymail = new PlMailer('register/success.mail.tpl');
+        $mymail->addTo("\"{$user->fullName()}\" <{$user->forlifeEmail()}>");
         if ($isX) {
-            $mymail->addTo("\"{$user->fullName()}\" <{$user->forlifeEmail()}>");
             $mymail->setSubject('Bienvenue parmi les X sur le web !');
         } else {
-            $mymail->addTo($email);
             $mymail->setSubject('Bienvenue sur Polytechnique.org !');
         }
         $mymail->assign('forlife', $forlife);
index bf186a1..e9bd95c 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 6829ed4..8c05b86 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 86ccc55..64adb5f 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -66,7 +66,6 @@ class SearchModule extends PLModule
                 $page->changeTpl('search/index.tpl');
                 $page->setTitle('Annuaire');
                 $page->assign('formulaire', 1);
-                $page->addJsLink('ajax.js');
                 return;
             }
 
@@ -140,7 +139,6 @@ class SearchModule extends PLModule
             }
         } else {
             $page->assign('formulaire',1);
-            $page->addJsLink('ajax.js');
         }
 
         $page->changeTpl('search/index.tpl');
@@ -201,7 +199,6 @@ class SearchModule extends PLModule
         }
 
         $page->changeTpl('search/index.tpl', $model == 'mini' ? SIMPLE : SKINNED);
-        $page->addJsLink('ajax.js');
         $page->assign('public_directory',0);
     }
 
@@ -316,12 +313,20 @@ class SearchModule extends PLModule
           case 'nationalite':
             $ids = DirEnum::getOptionsIter(DirEnum::NATIONALITIES);
             break;
-          case 'region':
+          case 'administrativearea':
             if (Env::has('country')) {
                 $ids = DirEnum::getOptionsIter(DirEnum::ADMINAREAS, Env::v('country'));
             } else {
                 $ids = DirEnum::getOptionsIter(DirEnum::ADMINAREAS);
             }
+            $page->assign('onchange', 'changeAdministrativeArea(this.value)');
+            break;
+          case 'subadministrativearea':
+            if (Env::has('administrativearea')) {
+                $ids = DirEnum::getOptionsIter(DirEnum::SUBADMINAREAS, Env::v('administrativearea'));
+            } else {
+                $ids = DirEnum::getOptionsIter(DirEnum::SUBADMINAREAS);
+            }
             break;
           case 'school':
             $ids = DirEnum::getOptionsIter(DirEnum::EDUSCHOOLS);
index d931031..40a8a2b 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index fa2b5bc..d1626a8 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
 
 class SurveyModule extends PLModule
 {
-    // {{{ function handlers() : registers the different handlers
     function handlers()
     {
         return array(
-            'survey'              => $this->make_hook('index',         AUTH_PUBLIC),
-            'survey/vote'         => $this->make_hook('vote',          AUTH_PUBLIC),
-            'survey/result'       => $this->make_hook('result',        AUTH_PUBLIC),
+            'survey'              => $this->make_hook('index',         AUTH_COOKIE),
+            'survey/vote'         => $this->make_hook('vote',          AUTH_COOKIE),
             'survey/edit'         => $this->make_hook('edit',          AUTH_COOKIE),
+            /*
+            'survey/result'       => $this->make_hook('result',        AUTH_COOKIE),
             'survey/ajax'         => $this->make_hook('ajax',          AUTH_COOKIE),
             'survey/admin'        => $this->make_hook('admin',         AUTH_MDP, 'admin'),
             'survey/admin/edit'   => $this->make_hook('adminEdit',     AUTH_MDP, 'admin'),
             'survey/admin/valid'  => $this->make_hook('adminValidate', AUTH_MDP, 'admin'),
             'survey/admin/del'    => $this->make_hook('adminDelete',   AUTH_MDP, 'admin'),
-        );
+      */  );
     }
-    // }}}
 
-    // {{{ function handler_index() : lists all available surveys
-    function handler_index(&$page, $action = null)
+    private function setup_page(PlPage $page)
     {
         $this->load('survey.inc.php');
-        $page->changeTpl('survey/index.tpl');
-        $page->assign('survey_current', Survey::retrieveList('c'));
-        $page->assign('survey_old', Survey::retrieveList('o'));
-        $page->assign('survey_modes', Survey::getModes(false));
-    }
-    // }}}
-
-    // {{{ function handler_vote() : handles the vote to a survey
-    function handler_vote(&$page, $id = -1)
-    {
-        if (Post::has('survey_cancel')) { // if the user cancels, returns to index
-            return $this->handler_index(&$page);
-        }
-        $id = intval($id);
-        if ($id == -1) {
-            return $this->show_error($page, "Un identifiant de sondage doit être précisé.", 'survey');
-        }
-        $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');
-        } elseif ($survey->isEnded()) {
-            return $this->show_error($page, "Le sondage ".$survey->getTitle()." est terminé.", 'survey');
-        }
-        if (!$this->check_surveyPerms($page, $survey)) {
-            return PL_DO_AUTH;
-        }
-        if (Post::has('survey_submit')) { // checks if the survey has already been filled in
-            // admins can see the survey but not vote
-            if (!$this->check_surveyPerms($page, $survey, false, false)) {
-                return PL_DO_AUTH;
-            }
-            $uid = 0;
-            if (!$survey->isMode(Survey::MODE_ALL)) { // if survey is restriced to alumni
-                $uid = S::v('uid');
-                if ($survey->hasVoted($uid)) { // checks whether the user has already voted
-                    return $this->show_error($page, "Tu as déjà voté à ce sondage.", 'survey');
-                }
-            }
-            $survey->vote($uid, Post::v('survey'.$id)); // performs vote
-            $this->show_success($page, "Ta réponse a bien été prise en compte. Merci d'avoir participé à ce sondage.", 'survey');
-        } else { // offers to fill in the survey
-            if ($survey->isMode(Survey::MODE_ALL) || !$survey->hasVoted(S::v('uid'))) {
-                $page->assign('survey_votemode', true);
-            } else {
-                $page->assign('survey_warning', "Tu as déjà voté à ce sondage.");
-            }
-            //$page->assign('survey_id', $id);
-            $this->show_survey($page, $survey);
-        }
+        $page->addJsLink('jquery.ui.core.js');
+        $page->addJsLink('jquery.ui.widget.js');
+        $page->addJsLink('jquery.ui.datepicker.js');
+        $page->addJsLink('jquery.ui.datepicker-fr.js');
+        $page->addJsLink('jquery.tmpl.js');
+        $page->addJsLink('survey.js');
     }
-    // }}}
 
-    // {{{ function handler_result() : show the results of the votes to a survey
-    function handler_result($page, $id = -1, $show = 'all')
+    function handler_index(&$page, $action = null)
     {
-        $id = intval($id);
-        if ($id == -1) {
-            return $this->show_error($page, "Un identifiant de sondage doit être précisé.", 'survey');
-        }
-        $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');
-        } elseif (!$survey->isEnded() && !$survey->canSeeEarlyResults(S::user())) {
-            return $this->show_error($page, "Le sondage ".$survey->getTitle()." n'est pas encore terminé.", 'survey');
-        }
-        if (!$survey->canSeeEarlyResults(S::user()) && !$this->check_surveyPerms($page, $survey)) {
-            return PL_DO_AUTH;
-        }
-        if ($show == 'csv') {
-            pl_content_headers("text/csv");
-            header('Content-Disposition: attachment; filename="'.addslashes($survey->getTitle()).'.csv"');
-            echo $survey->toCSV();
-            exit;
-        } else {
-            $page->assign('survey_resultmode', true);
-            $this->show_survey($page, $survey);
-        }
-    }
-    // }}}
+        $this->setup_page($page);
 
-    // {{{ function handler_admin() : index of admin mode
-    function handler_admin(&$page, $id = -1)
-    {
-        $this->load('survey.inc.php');
-        $this->clear_session();
-        if ($id == -1) {
-            $page->changeTpl('survey/admin.tpl');
-            $page->assign('survey_waiting', Survey::retrieveList('w'));
-            $page->assign('survey_current', Survey::retrieveList('c'));
-            $page->assign('survey_old', Survey::retrieveList('o'));
-            $page->assign('survey_modes', Survey::getModes(false));
-        } else {
-            $id = intval($id);
-            $survey = Survey::retrieveSurvey($id); // retrieves all survey object structure
-            if ($survey == null) {
-                $this->show_error($page, "Sondage ".$id." introuvable.", 'survey/admin');
-            }
-            $page->assign('survey_adminmode', true);
-            $this->show_survey($page, $survey);
-        }
+        $page->changeTpl('survey/index.tpl');
+        $page->assign('active', Survey::iterActive());
     }
-    // }}}
 
-    // {{{ function handler_adminEdit() : edits a survey in admin mode
-    function handler_adminEdit(&$page, $id = -1, $req = -1)
+    function handler_vote(PlPage $page, $name)
     {
-        if ($id == -1 || ($id == 'req' && $req == -1)) {
-            return $this->show_error($page, "Un identifiant de sondage doit être précisé.", 'survey/admin');
-        }
-        $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);
-            if ($survey == null) {
-                return $this->show_error($page, "Sondage introuvable.", 'survey/admin');
-            }
-            $this->store_session($survey, $req, true);
-        } else {
-            $id = intval($id);
-            $survey = Survey::retrieveSurvey($id); // retrieves the survey in database
-            if ($survey == null) {
-                return $this->show_error($page, "Sondage ".$id." introuvable.", 'survey/admin');
-            }
-            $this->store_session($survey, $id);
-        }
-        $this->handler_edit($page, 'show'); // calls handler_edit, but in admin mode since 'survey_id' is in session
-    }
-    // }}}
+        $this->setup_page($page);
+        $page->changeTpl('survey/vote.tpl');
 
-    // {{{ function handler_adminValidate() : validates a survey (admin mode)
-    function handler_adminValidate(&$page, $id = -1)
-    {
-        $id = Post::i('survey_id', $id);
-        if (Post::has('survey_cancel')) { // if the admin cancels the validation, returns to the admin index
-            $this->clear_session();
-            return $this->handler_admin(&$page, $id);
+        $survey = Survey::get($name);
+        if (is_null($survey)) {
+            return PL_NOT_FOUND;
         }
-        if ($id == -1) {
-            return $this->show_error($page, "Un identifiant de sondage doit être précisé.", 'survey/admin');
+        if (!$survey->canSee(S::user())) {
+            return PL_FORBIDDEN;
         }
-        $id = intval($id);
-        $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');
-        }
-        if (Post::has('survey_submit')) { // needs a confirmation before validation
-            if (Survey::validateSurvey($id)) { // validates the survey (in the database)
-                $this->show_success($page, "Le sondage \"".$surveyInfo['title']."\" a bien été validé, les votes sont maintenant ouverts.", 'survey/admin');
+        if (Post::has('vote')) {
+            $answers = Post::v('qid');
+            $vote = $survey->vote(S::user(), $answers);
+            if (is_null($vote)) {
+                $page->kill("Tu n'as pas le droit de voter à ce sondage.");
+            } else if ($vote->inError()) {
+                $page->trigError("Certaines réponses sont invalides et doivent être corrigées");
             } else {
-                $this->show_error($page, '', 'survey/admin');
+                $vote->insert(true);
+                $page->trigSuccess("Ton vote a été enregistré");
             }
-        } else { // asks for a confirmation
-            $this->show_confirm($page, "Êtes-vous certain de vouloir valider le sondage \"".$surveyInfo['title']."\" ? "
-                                      ."Les votes seront immédiatement ouverts.", 'admin/valid', array('id' => $id));
         }
+        $page->assign('survey', $survey);
     }
-    // }}}
 
-    // {{{ function handler_adminDelete() : deletes a survey (admin mode)
-    function handler_adminDelete(&$page, $id = -1)
+    function handler_edit(PlPage $page, $name = null)
     {
-        $id = Post::i('survey_id', $id);
-        if (Post::has('survey_cancel')) { // if the admin cancels the suppression, returns to the admin index
-            return $this->handler_admin(&$page, $id);
-        }
-        if ($id == -1) {
-            return $this->show_error($page, "Un identifiant de sondage doit être précisé.", 'survey/admin');
-        }
-        $id = intval($id);
-        $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');
-        }
-        if (Post::has('survey_submit')) { // needs a confirmation before suppression
-            if (Survey::deleteSurvey($id)) { // deletes survey in database
-                $this->show_success($page, "Le sondage \"".$surveyInfo['title']."\" a bien été supprimé, ainsi que tous les votes le concernant.", 'survey/admin');
-            } else {
-                $this->show_error($page, '', 'survey/admin');
-            }
-        } else { // asks for a confirmation
-            $this->show_confirm($page, "Êtes-vous certain de vouloir supprimer le sondage \"".$surveyInfo['title']."\" ?", 'admin/del', array('id' => $id));
-        }
-    }
-    // }}}
+        $this->setup_page($page);
+        $page->changeTpl('survey/edit.tpl');
 
-    // {{{ function handler_edit() : edits a survey (in normal mode unless called by handler_adminEdit() )
-    function handler_edit(&$page, $action = 'show', $qid = 'root')
-    {
-        $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
-            if (S::has('survey')) {
-                $action = 'show';
-            } else {                      // unless no editing has been done at all (shows to the surveys index page)
-                return $this->handler_index($page);
-            }
-        }
-        $page->assign('survey_editmode', true);
-        if (S::has('survey_id')) { // if 'survey_id' is in session, it means we are modifying a survey in admin mode
-            $page->assign('survey_updatemode', true);
-        }
-        if ($action == 'show' && !S::has('survey')) {
-            $action = 'new';
-        }
-        if ($action == 'question') { // {{{ modifies an existing question
-            if (Post::has('survey_submit')) { // if the form has been submitted, makes the modifications
-                $survey = unserialize(S::v('survey'));
-                $args   = Post::v('survey_question');
-                if (!$survey->editQuestion($qid, $args)) { // update the survey object structure
-                    return $this->show_error($page, '', 'survey/edit');
-                }
-                $this->show_survey($page, $survey);
-                $this->store_session($survey);
-            } else { // if a form has not been submitted, shows modification form
-                $survey = unserialize(S::v('survey'));
-                $current = $survey->toArray($qid); // gets the current parameters of the question
-                if ($current == null) {
-                    return $this->show_error($page, '', 'survey/edit');
-                }
-                $this->show_form($page, $action, $qid, $current['type'], $current);
-            } // }}}
-        } elseif ($action == 'new') { // {{{ create a new survey : actually store the root question
-            if (Post::has('survey_submit')) { // if the form has been submitted, creates the survey
-                $this->clear_session();
-                $survey = new Survey(Post::v('survey_question')); // creates the object structure
-                $this->show_survey($page, $survey);
-                $this->store_session($survey);
-            } else {
-                $this->clear_session();
-                $this->show_form($page, $action, 'root', 'newsurvey');
-            } // }}}
-        } elseif ($action == 'add') { // {{{ adds a new question
-            if (Post::has('survey_submit')) { // if the form has been submitted, adds the question
-                $survey = unserialize(S::v('survey'));
-                if (!$survey->addQuestion($qid, $survey->factory(Post::v('survey_type'), Post::v('survey_question')))) {
-                    return $this->show_error($page, '', 'survey/edit');
-                }
-                $this->show_survey($page, $survey);
-                $this->store_session($survey);
-            } else {
-                $this->show_form($page, $action, $qid);
-            } // }}}
-        } elseif ($action == 'del') { // {{{ deletes a question
-            if (Post::has('survey_submit')) { // if a confirmation has been sent, deletes the question
-                $survey = unserialize(S::v('survey'));
-                if (!$survey->delQuestion(Post::v('survey_qid'))) { // deletes the node in the survey object structure
-                    return $this->show_error($page, '', 'survey/edit');
-                }
-                $this->show_survey($page, $survey);
-                $this->store_session($survey);
-            } else { // if user has not confirmed, shows a confirmation form
-                $survey = unserialize(S::v('survey'));
-                $current = $survey->toArray($qid); // needed to get the title of the question to delete (more user-friendly than an id)
-                if ($current == null) {
-                    return $this->show_error($page, '', 'survey/edit');
-                }
-                $this->show_confirm($page, 'Êtes-vous certain de vouloir supprimer la question intitulé "'.$current['question'].'" ? '
-                                          .'Attention, cela supprimera en même temps toutes les questions qui dépendent de celle-ci.',
-                                                'edit', array('action' => 'del', 'qid' => $qid));
-            } // }}}
-        } elseif ($action == 'show') { // {{{ simply shows the survey in its current state
-            $this->show_survey($page, unserialize(S::v('survey'))); // }}}
-        } elseif ($action == 'valid') { // {{{ validates the proposition, i.e stores the proposition in the database
-                                        // but an admin will still need to validate the survey before it is activated
-            if (Post::has('survey_submit')) { // needs a confirmation before storing the proposition
-                $survey = unserialize(S::v('survey'));
-                if (S::has('survey_id')) { // if 'survey_id' is in session, we are modifying an existing survey (in admin mode) instead of proposing a new one
-                    $link = (S::has('survey_validate'))? 'admin/validate' : 'survey/admin';
-                    if ($survey->updateSurvey()) { // updates the database according the new survey object structure
-                        $this->show_success($page, "Les modifications sur le sondage ont bien été enregistrées.", $link);
-                    } else {
-                        $this->show_error($page, '', $link);
-                    }
-                } else { // if no 'survey_id' is in session, we are indeed proposing a new survey
-                    if ($survey->proposeSurvey()) { // stores the survey object structure in database
-                        $this->show_success($page, "Votre proposition de sondage a bien été enregistrée,
-                                                    elle est en attente de validation par un administrateur du site.", 'survey');
-                    } else {
-                        $this->show_error($page, '', 'survey');
-                    }
-                }
-                $this->clear_session();
-            } else { // asks for a confirmation if it has not been sent
-                $survey = unserialize(S::v('survey'));
-                $errors = $survey->checkSyntax();
-                if (!is_null($errors)) {
-                    $this->show_error($page, "", 'survey/edit', $errors);
-                } else {
-                    if (S::has('survey_id')) {
-                        $this->show_confirm($page, "Veuillez confirmer l'enregistrement des modifications apportées à ce sondage.", 'edit', array('action' => 'valid'));
-                    } else {
-                        $this->show_confirm($page, "Veuillez confirmer l'envoi de cette proposition de sondage.", 'edit', array('action' => 'valid'));
-                    }
-                }
-            } // }}}
-        } elseif ($action == 'cancel') { // {{{ cancels the creation/modification of a survey
-            if (Post::has('survey_submit')) { // needs a confirmation
-                if (S::has('survey_id')) {  // only possible when modifying a survey in admin mode
-                    if (S::has('survey_validate')) { // if a link has been supplied, uses it
-                        $this->clear_session();
-                        return $this->show_success($page, "Les modifications effectuées ont été annulées", 'admin/validate');
-                    } else { // else shows the admin index
-                        $this->clear_session();
-                        return $this->handler_admin($page);
-                    }
+        if (!is_null($name)) {
+            $survey = Survey::get($name);
+        } else {
+            $survey = new Survey();
+            $survey->id = null;
+            $survey->uid = S::user()->id();
+        }
+        if (Post::has('valid')) {
+            $survey->title = Post::t('title');
+            $survey->shortname = Post::t('shortname');
+            $survey->description = Post::t('description');
+            $survey->begin     = Post::t('begin');
+            $survey->end       = Post::t('end');
+            $survey->flags     = 'validated';
+            $survey->flags->addFlag('anonymous', Post::b('anonymous'));
+
+            $q_edit = Post::v('q_edit');
+            $qs = array();
+            $survey->clearQuestions();
+            foreach ($q_edit as $qid => $q_desc) {
+                if (isset($q_desc['parent'])) {
+                    $parent = $qs[$q_desc['parent']];
                 } else {
-                    $this->clear_session();
-                    return $this->handler_index($page); // else shows the 'normal' index
+                    $parent = $survey;
                 }
-            } else { // asks for a confirmation if it has not been sent
-                $this->show_confirm(&$page, "Êtes-vous certain de vouloir annuler totalement l'édition de ce sondage ? Attention, "
-                                           ."toutes les données éditées jusque là seront définitivement perdues.",
-                                                'edit', array('action' => $action));
-            }
-        } // }}}
-    }
-    // }}}
-
-    // {{{ function handler_ajax() : some ajax in editing a new question (for now, there may be a little more later)
-    function handler_ajax(&$page, $type)
-    {
-        $this->load('survey.inc.php');
-        pl_content_headers("text/html");
-        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);
-            $page->assign('survey_types', Survey::getTypes());
-            $page->assign('survey_type', $type);
-        }
-    }
-    // }}}
-
-    // {{{ function clear_session() : clears the data stored in session
-    function clear_session()
-    {
-        S::kill('survey');
-        S::kill('survey_id');
-        S::kill('survey_validate');
-    }
-    // }}}
-
-    // {{{ function store_session() : serializes and stores survey (and survey_id) in session
-    function store_session($survey, $survey_id = -1, $survey_validate = false)
-    {
-        $_SESSION['survey'] = serialize($survey);
-        if ($survey_id != -1) {
-            $_SESSION['survey_id'] = $survey_id;
-        }
-        if ($survey_validate) {
-            $_SESSION['survey_validate'] = true;
-        }
-    }
-    // }}}
-
-    // {{{ function check_surveyPerms() : checks the particular surveys access permissions
-    function check_surveyPerms(&$page, $survey, $silent = false, $admin_allowed = true)
-    {
-        $this->load('survey.inc.php');
-        if ($survey->isMode(Survey::MODE_ALL)) { // if the survey is not reserved to alumni
-            return true;
-        }
-        if (!S::logged()) {
-            return false;
-        }
-        $profile = S::user()->profile();
-        if (!$profile) {
-            return false;
-        }
-        // checks promotion
-        $allowed = false;
-        foreach ($profile->yearspromo() as $p) {
-            if ($survey->checkPromo($p)) {
-                $allowed = true;
-                break;
-            }
-        }
-        if ($allowed) {
-            return true;
-        }
-        if (S::admin() && $admin_allowed) {
-            if (!$silent) {
-                $page->trigWarning('Tu as accès à ce sondage car tu es administrateur du site.');
+                $question = $parent->newQuestion($q_desc['type']);
+                $question->label = $q_desc['label'];
+                unset($q_desc['type']);
+                unset($q_desc['parent']);
+                unset($q_desc['label']);
+                $question->parameters = $q_desc;
+                $qs[$qid] = $question;
             }
-            return true;
+            $survey->insert('true');
         }
-        if (!$silent) {
-            $page->kill("Tu n'as pas accès à ce sondage car il est réservé à d'autres promotions.");
-        }
-        return false;
-    }
-    // }}}
-
-    // {{{ function show_survey() : calls the template to display a survey, for editing, voting, or consulting the results
-    function show_survey(&$page, $survey)
-    {
-        $page->changeTpl('survey/show_root.tpl');
-        $page->assign('survey', $survey->toArray());
-        $page->assign('survey_modes', Survey::getModes());
-    }
-    // }}}
-
-    // {{{ function show_form() : calls the template to display the editing form
-    function show_form(&$page, $action, $qid, $type = 'new', $current = null)
-    {
-        $page->changeTpl('survey/edit_survey.tpl');
-        $page->assign('survey_action', $action);
-        $page->assign('survey_qid', $qid);
-        $page->assign('survey_formaction', './survey/edit');
-        $page->assign('survey_type', $type);
-        if (!is_null($current) && is_array($current)) {
-            $page->assign('survey_current', $current);
-        } elseif ($type == 'new') {
-            $page->addJsLink('ajax.js');
-            $page->assign('survey_types', Survey::getTypes());
-        }
-        if ($type == 'root' || $type == 'newsurvey') {
-            $page->assign('survey_modes', Survey::getModes());
-        }
-    }
-    // }}}
-
-    // {{{ function show_confirm() : calls the template to display a confirm form
-    function show_confirm(&$page, $message, $formaction, $formhidden = null)
-    {
-        $page->changeTpl('survey/confirm.tpl');
-        $page->assign('survey_message', $message);
-        $page->assign('survey_formaction', './survey/'.$formaction);
-        $page->assign('survey_formhidden', $formhidden);
-    }
-    // }}}
-
-    // {{{ function show_error() : calls the template to display an error message
-    function show_error(&$page, $message, $link = "", $errArray = null)
-    {
-        $page->changeTpl('survey/error.tpl');
-        $page->assign('survey_message', $message);
-        $page->assign('survey_link', $link); // 'return' link to let the user leave the page
-        if (!is_null($errArray)) {
-            $page->assign('survey_errors', $errArray);
-        }
-
-    }
-    // }}}
-
-    // {{{ function show_success() : calls the template to display a success message
-    function show_success(&$page, $message = "", $link = "")
-    {
-        $page->changeTpl('survey/success.tpl');
-        $page->assign('survey_message', $message);
-        $page->assign('survey_link', $link); // 'return' link to let the user leave the page
+        $page->assign('survey', $survey);
     }
-    // }}}
 }
 
 // vim:set et sw=4 sts=4 ts=4 foldmethod=marker enc=utf-8:
diff --git a/modules/survey/answer.inc.php b/modules/survey/answer.inc.php
new file mode 100644 (file)
index 0000000..6b7d699
--- /dev/null
@@ -0,0 +1,163 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2011 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 SurveyVote extends PlDBTableEntry
+{
+    protected $survey;
+    protected $user;
+
+    private $answers = array();
+    private $fetchAnswers;
+
+    public function __construct(Survey $survey, User $user)
+    {
+        parent::__construct('survey_votes');
+        $this->survey = $survey;
+        $this->user = $user;
+        $this->sid = $survey->id;
+    }
+
+    protected function postSave()
+    {
+        Platal::assert(!is_null($this->vid), "Cannot process a vote without its identifier");
+        XDB::execute("REPLACE INTO  survey_voters (sid, uid, vid)
+                            VALUES  ({?}, {?}, {?})",
+                     $this->survey->id, $this->user->id(),
+                     $this->survey->flags->hasFlag('anonymous') ? null : $this->vid);
+
+        /* Save answers */
+        $selector = new SurveyAnswer($this);
+        $selector->delete();
+
+        $answers = array();
+        foreach ($this->answers as $key=>$answer) {
+            if (!is_null($answer)) {
+                $answer->vid = $this->vid;
+                $answers[] = $answer;
+            }
+        }
+        PlDBTableEntry::insertBatch($answers);
+        return true;
+    }
+
+    protected function postFetch()
+    {
+        $selector = new SurveyAnswer($this);
+        foreach ($selector as $answer) {
+            $question = $this->survey->questionForId($answer->qid);
+            $this->answers[$answer->qid] = $answer;
+        }
+        return true;
+    }
+
+    public function inError()
+    {
+        foreach ($this->answers as $answer) {
+            if ($answer->inError !== false) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public function getAnswer(SurveyQuestion $question)
+    {
+        if (!isset($this->answers[$question->qid])) {
+            $val = new SurveyAnswer($this);
+            $val->qid = $question->qid;
+            $this->answers[$question->qid] = $val;
+        }
+        return $this->answers[$question->qid];
+    }
+
+    public function export()
+    {
+        $export = array();
+        foreach ($this->answers as $qid=>$answer) {
+            $export[$qid] = $answer->export();
+        }
+        return $export;
+    }
+
+    public static function getVote(Survey $survey, User $user, $fetchAnswers = true)
+    {
+        $vid = XDB::query('SELECT  vid
+                             FROM  survey_voters
+                            WHERE  sid = {?} AND uid = {?}',
+                          $survey->id, $user->id());
+        if ($vid->numRows() == 0) {
+            $vote = new SurveyVote($survey, $user);
+            $vote->fetchAnswers = $fetchAnswers;
+            return $vote;
+        }
+        $vid = $vid->fetchOneCell();
+        if (is_null($vid)) {
+            /* User already vote, but survey is anonymous and the vote
+             * cannot be changed
+             */
+            return null;
+        }
+        $vote = new SurveyVote($survey, $user);
+        $vote->vid = $vid;
+        $vote->fetchAnswers = $fetchAnswers;
+        $vote->fetch();
+        return $vote;
+    }
+}
+
+class SurveyAnswer extends PlDBTableEntry
+{
+    public $inError = false;
+    public $vote;
+
+    public function __construct(SurveyVote $vote)
+    {
+        parent::__construct('survey_vote_answers');
+        $this->registerFieldFormatter('answer', 'JSonFieldFormatter');
+        $this->vote = $vote;
+        if (!is_null($vote->vid)) {
+            $this->vid = $vote->vid;
+        }
+    }
+
+    protected function preSave()
+    {
+        Platal::assert(!$this->inError, "Cannot save an invalid answer");
+        $this->sid = $this->vote->sid;
+        $this->vid = $this->vote->vid;
+        return true;
+    }
+
+    public function export()
+    {
+        $export = array();
+        if (!is_null($this->answer)) {
+            $export['value'] = $this->answer->export();
+        }
+        if ($this->inError !== false) {
+            $export['error'] = $this->inError;
+        }
+        return $export;
+    }
+}
+
+// vim:set et sw=4 sts=4 ts=4 foldmethod=marker enc=utf-8:
+?>
diff --git a/modules/survey/multiple.inc.php b/modules/survey/multiple.inc.php
new file mode 100644 (file)
index 0000000..e9ce0fb
--- /dev/null
@@ -0,0 +1,58 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2011 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 SurveyQuestionMultiple extends SurveyQuestion
+{
+    public function __construct(Survey $survey)
+    {
+        parent::__construct($survey);
+        $this->type = "multiple";
+    }
+
+    protected function buildAnswer(SurveyAnswer $answer, PlDict $data)
+    {
+        $content = $data->v($this->qid);
+        $value   = $content['answer'];
+        if (empty($value)) {
+            $answer->answer = null;
+            return true;
+        }
+        $id = to_integer($value);
+        if ($id === false) {
+            if ($value != 'other') {
+                $answer->answers = null;
+                return false;
+            }
+            if (@$this->parameters['allow_other']) {
+                $answer->answer = array('other' => $content['text']);
+            }
+        } else {
+            if ($id >= count($this->parameters['answers'])) {
+                $answer->answers = null;
+                return false;
+            }
+            $answer->answer = array('answer' => $id);
+        }
+        return true;
+    }
+}
+
+?>
diff --git a/modules/survey/question.inc.php b/modules/survey/question.inc.php
new file mode 100644 (file)
index 0000000..bd206ad
--- /dev/null
@@ -0,0 +1,182 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2011 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 SurveyQuestionContainer
+{
+    public function addQuestion(SurveyQuestion $question, $pos = null);
+    public function newQuestion($type, $pos = null);
+    public function reassignQuestionIds();
+}
+
+class SurveyQuestion extends PlDBTableEntry
+{
+    protected $survey;
+    protected $parentQuestion;
+
+    public function __construct(Survey $survey)
+    {
+        parent::__construct('survey_questions');
+        $this->registerFieldFormatter('parameters', 'JSonFieldFormatter');
+        $this->survey = $survey;
+    }
+
+    public function typedInstance()
+    {
+        $instance = self::instanceForType($this->survey, $this->type);
+        $instance->copy($this);
+        return $instance;
+    }
+
+    public static function instanceForType(Survey $survey, $type)
+    {
+        $file = dirname(__FILE__) . '/' . $type . '.inc.php';
+        if (!file_exists($file)) {
+            throw new Exception("Unknown question type \"$type\"");
+        }
+        require_once $file;
+        $class = 'SurveyQuestion' . $type;
+        return new $class($survey);
+    }
+
+    public function voteTemplate()
+    {
+        return 'survey/question.' . $this->type . '.tpl';
+    }
+
+    public function editTemplate()
+    {
+        return 'survey/edit.' . $this->type . '.tpl';
+    }
+
+    protected function buildAnswer(SurveyAnswer $answer, PlDict $answers)
+    {
+        Platal::assert(false, "This should not happen");
+    }
+
+    public function vote(SurveyVote $vote, PlDict $answers)
+    {
+        if ($this->flags->hasFlag('noanswer')) {
+            if ($answers->has($this->qid)) {
+                throw new Exception("Des réponses ont été données à une question n'en attendant pas");
+            }
+            return null;
+        }
+        $answer = $vote->getAnswer($this);
+        if (is_null($answer)) {
+            return null;
+        }
+        if (!$this->buildAnswer($answer, $answers)) {
+            return $answer;
+        }
+        if ($this->flags->hasFlag('mandatory') && is_null($answer->answer)) {
+            $answer->inError = 'Tu dois répondre à cette question';
+        }
+        return $answer;
+    }
+}
+
+class SurveyQuestionGroup extends SurveyQuestion implements SurveyQuestionContainer
+{
+    public $children = array();
+
+    public function __construct(Survey $survey)
+    {
+        parent::__construct($survey);
+    }
+
+    public function addQuestion(SurveyQuestion $question, $pos = null)
+    {
+        $question->parentQuestion = $this;
+        if (is_null($pos)) {
+            $this->children[] = $question;
+        } else {
+            array_splice($this->children, $pos, 0, $question);
+        }
+    }
+
+    public function newQuestion($type, $pos = null)
+    {
+        $question = SurveyQuestion::instanceForType($this->survey, $type);
+        $this->addQuestion($question, $pos);
+        return $question;
+    }
+
+    public function reassignQuestionIds()
+    {
+        $id = $this->qid + 1;
+        foreach ($this->children as $question) {
+            $question->qid = $id;
+            if ($question instanceof SurveyQuestionContainer) {
+                $id = $question->reassignQuestionIds();
+            } else {
+                $id++;
+            }
+        }
+        return $id;
+    }
+
+    protected function postSave()
+    {
+        foreach ($this->children as $question) {
+            $question->sid = $this->sid;
+            $question->parent = $this->qid;
+            $question->insert();
+        }
+    }
+
+    public function export()
+    {
+        $export = parent::export();
+        $export['children'] = array();
+        foreach ($this->children as $child) {
+            $export['children'][] = $child->export();
+        }
+        return $export;
+    }
+
+    public function vote(SurveyVote $vote, PlDict $answers)
+    {
+        $a = parent::vote($vote, $answers);
+        foreach ($this->children as $child) {
+            $child->vote($vote, $answers);
+        }
+        return $a;
+    }
+
+    public function child($qid)
+    {
+        $prev = null;
+        foreach ($this->children as $question) {
+            if ($qid == $question->qid) {
+                return $question;
+            } else if ($qid < $question->qid) {
+                Platal::assert($prev instanceof SurveyQuestionGroup);
+                return $prev->child($qid);
+            }
+            $prev = $question;
+        }
+        Platal::assert($prev instanceof SurveyQuestionGroup);
+        return $prev->child($qid);
+    }
+}
+
+// vim:set et sw=4 sts=4 ts=4 foldmethod=marker enc=utf-8:
+?>
similarity index 79%
rename from htdocs/javascript/close_on_esc.js
rename to modules/survey/section.inc.php
index 399ec37..5d2493c 100644 (file)
@@ -1,5 +1,6 @@
+<?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-$(window).keydown(
-    function(e)  {
-        if (e.keyCode == 27) {
-            window.close();
-        }
-    });
+class SurveyQuestionSection extends SurveyQuestionGroup
+{
+    public function __construct(Survey $survey)
+    {
+        parent::__construct($survey);
+        $this->type = "section";
+        $this->flags = 'noanswer';
+    }
+}
 
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+// vim:set et sw=4 sts=4 ts=4 foldmethod=marker enc=utf-8:
+?>
index cfc2812..7e715fd 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-// {{{ class Survey : root of any survey, contains all questions
-class Survey
-{
-    // {{{ static properties and functions, regarding survey modes and question types
-    const MODE_ALL    = 0;
-    const MODE_XANON  = 1;
-    const MODE_XIDENT = 2;
-    private static $longModes = array(self::MODE_ALL    => "sondage ouvert à tout le monde, anonyme",
-                                      self::MODE_XANON  => "sondage restreint aux polytechniciens, anonyme",
-                                      self::MODE_XIDENT => "sondage restreint aux polytechniciens, non anonyme");
-    private static $shortModes = array(self::MODE_ALL    => "tout le monde, anonyme",
-                                       self::MODE_XANON  => "polytechniciens, anonyme",
-                                       self::MODE_XIDENT => "polytechniciens, non anonyme");
-
-    public static function getModes($long = true) {
-        return ($long)? self::$longModes : self::$shortModes;
-    }
-
-    private static $types = array('text'          => 'Texte court',
-                                  'textarea'      => 'Texte long',
-                                  'num'           => 'Numérique',
-                                  'radio'         => 'Choix multiples (une réponse)',
-                                  'checkbox'      => 'Choix multiples (plusieurs réponses)',
-                                  'radiotable'    => 'Questions multiples à choix multiples (une réponse)',
-                                  'checkboxtable' => 'Questions multiples à choix mutliples (plusieurs réponses)');
-
-    public static function getTypes()
-    {
-        return self::$types;
-    }
+require_once dirname(__FILE__) . '/question.inc.php';
+require_once dirname(__FILE__) . '/answer.inc.php';
 
-    public static function isType($t)
-    {
-        return array_key_exists($t, self::$types);
-    }
-    // }}}
-
-    // {{{ properties, constructor and basic methods
-    private $id;
-    private $title;
-    private $description;
-    private $end;
-    private $mode;
-    private $promos;
-    private $valid;
-    private $questions;
-    private $creator;
+class Survey extends PlDBTableEntry implements SurveyQuestionContainer
+{
+    private $fetchQuestions = true;
+    public $questions = array();
+    public $viewerFilter = null;
+    public $voterFilter = null;
 
-    public function __construct($args, $id = -1, $valid = false, $questions = null)
+    public function __construct()
     {
-        $this->update($args);
-        $this->id = $id;
-        $this->valid = $valid;
-        $this->questions = ($questions == null)? array() : $questions;
+        parent::__construct('surveys');
+        $this->registerFieldValidator('shortname', 'ShortNameFieldValidator');
+        $this->registerFieldFormatter('voters', 'JSonFieldFormatter');
+        $this->registerFieldFormatter('viewers', 'JSonFieldFormatter');
     }
 
-    public function update($args)
+    protected function postFetch()
     {
-        $this->title       = $args['title'];
-        $this->description = $args['description'];
-        $this->end         = $args['end'];
-        $this->mode        = (isset($args['mode']))? $args['mode'] : self::MODE_ALL;
-        $this->creator     = $args['uid'];
-        if ($this->mode == self::MODE_ALL) {
-            $args['promos'] = '';
+        if (!is_null($this->voters)) {
+            $this->voterFilter = UserFilter::fromExportedConditions($this->voters);
+        } else {
+            $this->voterFilter = null;
         }
-        $args['promos'] = str_replace(' ', '', $args['promos']);
-        $this->promos  = ($args['promos'] == '' || preg_match('#^(\d{4}-?|(\d{4})?-\d{4})(,(\d{4}-?|(\d{4})?-\d{4}))*$#', $args['promos']))? $args['promos'] : '#';
-    }
-
-    public function canSeeEarlyResults(User $user)
-    {
-        return $user->id() == $this->creator || $user->checkPerms('admin');
-    }
-    // }}}
-
-    // {{{ functions to access general information
-    public function isMode($mode)
-    {
-        return ($this->mode == $mode);
-    }
-
-    public function checkPromo($promo)
-    {
-        if ($this->promos == '') {
-            return true;
+        if (!is_null($this->viewers)) {
+            $this->viewerFilter = UserFilter::fromExportedConditions($this->viewers);
+        } else {
+            $this->viewerFilter = null;
         }
-        $promos = explode(',', $this->promos);
-        foreach ($promos as $p) {
-            if ((preg_match('#^\d{4}$#', $p) && $p == $promo) ||
-                (preg_match('#^\d{4}-$#', $p) && intval(substr($p, 0, 4)) <= $promo) ||
-                (preg_match('#^-\d{4}$#', $p) && intval(substr($p, 1)) >= $promo) ||
-                (preg_match('#^\d{4}-\d{4}$#', $p) &&
-                    (intval(substr($p, 0, 4)) <= $promo && intval(substr($p, 5)) >= $promo ||
-                     intval(substr($p, 0, 4)) >= $promo && intval(substr($p, 5)) <= $promo ))) {
-                    return true;
-            }
+        if (!$this->fetchQuestions) {
+            return true;
         }
-        return false;
-    }
-
-    public function isValid()
-    {
-        return $this->valid;
-    }
-
-    public function isEnded()
-    {
-        return (strtotime($this->end) - time() <= 0);
-    }
-
-    public function getTitle()
-    {
-        return $this->title;
-    }
-    // }}}
-
-    // {{{ function toArray() : converts a question (or the whole survey) to array, with results if the survey is ended
-    public function toArray($i = 'all')
-    {
-        if ($i != 'all' && $i != 'root') { // if a specific question is requested, then just returns this question converted to array
-            $i = intval($i);
-            if (array_key_exists($i, $this->questions)) {
-                return $this->questions[$i]->toArray();
+        $selector = new SurveyQuestion($this);
+        $selector->sid = $this->id;
+
+        $stack = array();
+        foreach ($selector as $question) {
+            $question = $question->typedInstance();
+            if (is_null($question->parent)) {
+                $this->addQuestion($question);
             } else {
-                return null;
-            }
-        } else { // else returns the root converted to array in any case
-            $a = array('title'       => $this->title,
-                       'description' => $this->description,
-                       'end'         => $this->end,
-                       'mode'        => $this->mode,
-                       'promos'      => $this->promos,
-                       'valid'       => $this->valid,
-                       'type'        => 'root');
-            if ($this->id != -1) {
-                $a['id'] = $this->id;
-            }
-            if ($this->isEnded()) { // if the survey is ended, then adds here the number of votes
-                $sql = 'SELECT COUNT(id)
-                          FROM survey_votes
-                         WHERE survey_id={?};';
-                $tot = XDB::query($sql, $this->id);
-                $a['votes'] = $tot->fetchOneCell();
-            }
-            if ($i == 'all' && count($this->questions) > 0) { // if the whole survey is requested, then returns all the questions converted to array
-                $qArr = array();
-                for ($k = 0; $k < count($this->questions); $k++) {
-                    $q = $this->questions[$k]->toArray();
-                    $q['id'] = $k;
-                    if ($this->isEnded()) { // if the survey is ended, then adds here the results of this question
-                        $q['result'] = $this->questions[$k]->getResultArray($this->id, $k);
-                    }
-                    $qArr[$k] = $q;
+                $pos = count($stack) - 1;
+                while ($stack[$pos]->qid != $question->parent) {
+                    --$pos;
+                    array_pop($stack);
                 }
-                $a['questions'] = $qArr;
+                Platal::assert(count($stack) > 0, "Invalid question structure");
+                Platal::assert($stack[$pos] instanceof SurveyQuestionContainer, "Invalid question type");
+                $stack[$pos]->addQuestion($question);
             }
-            return $a;
-        }
-    }
-    // }}}
-
-    // {{{ function toCSV() : builds a CSV file containing all the results of the survey
-    public function toCSV($sep = ',', $enc = '"', $asep='|')
-    {
-        $nbq = count($this->questions);
-        //require_once dirname(__FILE__) . '/../../classes/varstream.php';
-        VarStream::init();
-        global $csv_output;
-        $csv_output = '';
-        $csv = fopen('var://csv_output', 'w');
-        $line = ($this->isMode(self::MODE_XIDENT))? array('id', 'Nom', 'Prenom', 'Promo') : array('id');
-        $qids = array();
-        for ($qid = 0; $qid < $nbq; $qid++) {
-            $qids[$qid] = count($line); // stores the first id of a question (in case of questions with subquestions)
-            array_splice($line, count($line), 0, $this->questions[$qid]->getCSVColumns()); // the first line contains the questions
-        }
-        $nbf = count($line);
-        $users = array();
-        if ($this->isMode(self::MODE_XIDENT)) { // if the mode is non anonymous
-            $users = User::getBulkUsersWithUIDs(XDB::fetchAllAssoc('vid', 'SELECT  v.id AS vid, v.uid
-                                                                             FROM  survey_votes AS v
-                                                                            WHERE  v.survey_id = {?}
-                                                                         ORDER BY  vid ASC',
-                                                                    $this->id));
-        }
-        $sql = 'SELECT v.id AS vid, a.question_id AS qid, a.answer AS answer
-                  FROM survey_votes AS v
-            INNER JOIN survey_answers AS a ON a.vote_id=v.id
-                 WHERE v.survey_id={?}
-              ORDER BY vid ASC, qid ASC, answer ASC';
-        $res = XDB::iterator($sql, $this->id); // retrieves all answers from database
-        $vid = -1;
-        $vid_ = 0;
-        while (($cur = $res->next()) != null) {
-            if ($vid != $cur['vid']) { // if the vote id changes, then starts a new line
-                fputcsv($csv, $line, $sep, $enc); // stores the former line into $csv_output
-                $vid = $cur['vid'];
-                $line = array_fill(0, $nbf, ''); // creates an array full of empty string
-                $line[0] = $vid_; // the first field is a 'clean' vote id (not the one stored in database)
-                if ($this->isMode(self::MODE_XIDENT)) { // if the mode is non anonymous
-                    if (array_key_exists($vid, $users)) { // and if the user data can be found
-                        $line[1] = $users[$vid]->lastName(); // adds the user data (in the first fields of the line)
-                        $line[2] = $users[$vid]->firstName();;
-                        $line[3] = $users[$vid]->promo();
-                    }
-                }
-                $vid_++;
-            }
-            $ans = $this->questions[$cur['qid']]->formatAnswer($cur['answer']); // formats the current answer
-            if (!is_null($ans)) {
-                if (is_array($ans)) {
-                    $fid = $qids[$cur['qid']] + $ans['id']; // computes the field id
-                    $a = $ans['answer'];
-                } else {
-                    $fid = $qids[$cur['qid']];
-                    $a = $ans;
-                }
-                if ($line[$fid] != '') {  // if this field already contains something
-                    $line[$fid] .= $asep; // then adds a separator before adding the new answer
-                }
-                $line[$fid] .= $a; // adds the current answer to the correct field
-            }
-        }
-        fputcsv($csv, $line, $sep, $enc); // stores the last line into $csv_output
-        return $csv_output;
-    }
-    // }}}
-
-    // {{{ function factory($type, $args) : builds a question according to the given type
-    public function factory($t, $args)
-    {
-        switch ($t) {
-        case 'text':
-            return new SurveyText($args);
-        case 'textarea':
-            return new SurveyTextarea($args);
-        case 'num':
-            return new SurveyNum($args);
-        case 'radio':
-            return new SurveyRadio($args);
-        case 'checkbox':
-            return new SurveyCheckbox($args);
-        case 'radiotable':
-            return new SurveyRadioTable($args);
-        case 'checkboxtable':
-            return new SurveyCheckboxTable($args);
-        default:
-            return null;
-        }
-    }
-    // }}}
-
-    // {{{ questions manipulation functions
-    public function addQuestion($i, $c)
-    {
-        $i = intval($i);
-        if ($this->valid || $i > count($this->questions)) {
-            return false;
-        } else {
-            array_splice($this->questions, $i, 0, array($c));
-            return true;
+            array_push($stack, $question);
         }
+        return true;
     }
 
-    public function delQuestion($i)
+    protected function preSave()
     {
-        $i = intval($i);
-        if ($this->valid || !array_key_exists($i, $this->questions)) {
-            return false;
+        if (!is_null($this->voterFilter)) {
+            $this->voters = $this->voterFilter->exportConditions();
         } else {
-            array_splice($this->questions, $i, 1);
-            return true;
+            $this->voters = null;
         }
-    }
-
-    public function editQuestion($i, $a)
-    {
-        if ($i == 'root') {
-            $this->update($a);
+        if (!is_null($this->viewerFilter)) {
+            $this->viewers = $this->viewerFilter->exportConditions();
         } else {
-            $i = intval($i);
-            if ($this->valid ||!array_key_exists($i, $this->questions)) {
-                return false;
-            } else {
-                $this->questions[$i]->update($a);
-            }
+            $this->viewers = null;
         }
         return true;
     }
-    // }}}
 
-    // {{{ function checkSyntax() : checks syntax of the questions (currently the root only) before storing the survey in database
-    private static $errorMessages = array(
-        "datepassed"  => "la date de fin de sondage est déjà dépassée : vous devez préciser une date future",
-        "promoformat" => "les restrictions à certaines promotions sont mal formattées"
-    );
-
-    public function checkSyntax()
+    protected function postSave()
     {
-        $rArr = array();
-        // checks that the end date given is not already passed
-        // (unless the survey has already been validated : an admin can have a validated survey expired)
-        if (!$this->valid && $this->isEnded()) {
-            $rArr[] = array('question' => 'root', 'error' => self::$errorMessages["datepassed"]);
-        }
-        if ($this->promos != '' && !preg_match('#^(\d{4}-?|(\d{4})?-\d{4})(,(\d{4}-?|(\d{4})?-\d{4}))*$#', $this->promos)) {
-            $rArr[] = array('question' => 'root', 'error' => self::$errorMessages["promoformat"]);
-        }
-        return (empty($rArr))? null : $rArr;
-    }
-    // }}}
-
-    // {{{ functions that manipulate surveys in database
-    // {{{ static function retrieveList() : gets the list of available survey (current, old and not validated surveys)
-    public static function retrieveList($type, $tpl = true)
-    {
-        switch ($type) {
-        case 'c':
-        case 'current':
-            $where = 'end > NOW()';
-            break;
-        case 'o':
-        case 'old':
-            $where = 'end <= NOW()';
-            break;
-        default:
-            return null;
-        }
-        $sql = 'SELECT id, title, end, mode
-                  FROM surveys
-                 WHERE '.$where.'
-              ORDER BY end DESC;';
-        if ($tpl) {
-            return XDB::iterator($sql);
-        } else {
-            return XDB::iterRow($sql);
-        }
-    }
-    // }}}
+        $questions = array();
+        $selector = new SurveyQuestion($this);
+        $selector->sid = $this->id;
+        $selector->delete();
 
-    // {{{ static function retrieveSurvey() : gets a survey in database (and unserialize the survey object structure)
-    public static function retrieveSurvey($sid)
-    {
-        $sql = 'SELECT questions, title, description, end, mode, promos, uid
-                  FROM surveys
-                 WHERE id={?}';
-        $res = XDB::query($sql, $sid);
-        $data = $res->fetchOneAssoc();
-        if (is_null($data) || !is_array($data)) {
-            return null;
+        $this->reassignQuestionIds();
+        foreach ($this->questions as $question) {
+            $question->sid = $this->id;
+            $question->insert();
         }
-        $survey = new Survey($data, $sid, true, unserialize($data['questions']));
-        return $survey;
     }
-    // }}}
 
-    // {{{ static function retrieveSurveyInfo() : gets information about a survey (title, description, end date, restrictions) but does not unserialize the survey object structure
-    public static function retrieveSurveyInfo($sid)
+    public function clearQuestions()
     {
-        $sql = 'SELECT title, description, end, mode, promos
-                  FROM surveys
-                 WHERE id={?}';
-        $res = XDB::query($sql, $sid);
-        return $res->fetchOneAssoc();
+        $this->fetchQuestions = true;
+        $this->questions = array();
     }
-    // }}}
 
-    // {{{ static function retrieveSurveyReq() : gets a survey request to validate
-    public static function retrieveSurveyReq($id)
+    public function addQuestion(SurveyQuestion $question, $pos = null)
     {
-        $surveyreq = Validate::get_request_by_id($id);
-        if ($surveyreq == null) {
-            return null;
+        $question->parent = null;
+        if (is_null($pos)) {
+            $this->questions[] = $question;
+        } else {
+            array_splice($this->questions, $pos, 0, $question);
         }
-        $data = array('title'       => $surveyreq->title,
-                      'description' => $surveyreq->description,
-                      'end'         => $surveyreq->end,
-                      'mode'        => $surveyreq->mode,
-                      'promos'      => $surveyreq->promos);
-        $survey = new Survey($data, $id, false, $surveyreq->questions);
-        return $survey;
     }
-    // }}}
 
-    // {{{ function proposeSurvey() : stores a proposition of survey in database (before validation)
-    public function proposeSurvey()
+    public function newQuestion($type, $pos = null)
     {
-        $surveyreq = new SurveyReq($this->title, $this->description, $this->end, $this->mode, $this->promos, $this->questions, S::user());
-        return $surveyreq->submit();
+        $question = SurveyQuestion::instanceForType($this, $type);
+        $this->addQuestion($question, $pos);
+        return $question;
     }
-    // }}}
 
-    // {{{ function updateSurvey() : updates a survey in database (before validation)
-    public function updateSurvey()
+    public function questionForId($qid)
     {
-        if ($this->valid) {
-            $sql = 'UPDATE surveys
-                       SET questions={?},
-                           title={?},
-                           description={?},
-                           end={?},
-                           mode={?},
-                           promos={?}
-                     WHERE id={?};';
-            return XDB::execute($sql, serialize($this->questions), $this->title, $this->description, $this->end, $this->mode, $this->promos, $this->id);
-        } else {
-            $surveyreq = Validate::get_request_by_id($this->id);
-            if ($surveyreq == null) {
-                return false;
+        $prev = null;
+        foreach ($this->questions as $question) {
+            if ($qid == $question->qid) {
+                return $question;
+            } else if ($qid < $question->qid) {
+                Platal::assert($prev instanceof SurveyQuestionGroup,
+                               "Id gap must be caused by question groups");
+                return $prev->child($qid);
             }
-            return $surveyreq->updateReq($this->title, $this->description, $this->end, $this->mode, $this->promos, $this->questions);
+            $prev = $question;
         }
+        Platal::assert($prev instanceof SurveyQuestionGroup,
+                       "Id gap must be caused by question groups");
+        return $prev->child($qid);
     }
-    // }}}
 
-    // {{{ functions vote() and hasVoted() : handles vote to a survey
-    public function vote($uid, $args)
+    public function reassignQuestionIds()
     {
-        XDB::execute('INSERT INTO  survey_votes
-                              SET  survey_id = {?}, uid = {?}',
-                     $this->id, ($uid == 0) ? null : $uid); // notes the user as having voted
-        $vid = XDB::insertId();
-        for ($i = 0; $i < count($this->questions); $i++) {
-            $ans = $this->questions[$i]->checkAnswer($args[$i]);
-            if (!is_null($ans) && is_array($ans)) {
-                foreach ($ans as $a) {
-                    XDB::execute('INSERT INTO survey_answers
-                                          SET vote_id     = {?},
-                                              question_id = {?},
-                                              answer      = {?}', $vid, $i, $a);
-                }
+        $id = 0;
+        foreach ($this->questions as $question) {
+            $question->qid = $id;
+            if ($question instanceof SurveyQuestionContainer) {
+                $id = $question->reassignQuestionIds();
+            } else {
+                $id++;
             }
         }
+        return $id;
     }
 
-    public function hasVoted($uid)
-    {
-        $res = XDB::query('SELECT  id
-                             FROM  survey_votes
-                            WHERE  survey_id = {?} AND uid = {?};', $this->id, $uid); // checks whether the user has already voted
-        return ($res->numRows() != 0);
-    }
-    // }}}
-
-    // {{{ static function deleteSurvey() : deletes a survey (and all its votes)
-    public static function deleteSurvey($sid)
-    {
-        $sql = 'DELETE s.*, v.*, a.*
-                  FROM surveys AS s
-             LEFT JOIN survey_votes AS v
-                    ON v.survey_id=s.id
-             LEFT JOIN survey_answers AS a
-                    ON a.vote_id=v.id
-                 WHERE s.id={?};';
-        return XDB::execute($sql, $sid);
-    }
-    // }}}
-
-    // {{{ static function purgeVotes() : clears all votes concerning a survey (I'm not sure whether it's really useful)
-    public static function purgeVotes($sid)
-    {
-        $sql = 'DELETE v.*, a.*
-                  FROM survey_votes AS v
-             LEFT JOIN survey_answers AS a
-                    ON a.vote_id=v.id
-                 WHERE v.survey_id={?};';
-        return XDB::execute($sql, $sid);
-    }
-    // }}}
-
-    // }}}
-}
-// }}}
-
-// {{{ abstract class SurveyQuestion
-abstract class SurveyQuestion
-{
-    // {{{ common properties, constructor, and basic methods
-    private $question;
-    private $comment;
-
-    public function __construct($args)
-    {
-        $this->update($args);
-    }
-
-    public function update($a)
-    {
-        $this->question = $a['question'];
-        $this->comment  = $a['comment'];
-    }
-
-    abstract protected function getQuestionType();
-    // }}}
-
-    // {{{ function toArray() : converts to array
-    public function toArray()
-    {
-        return array('type' => $this->getQuestionType(), 'question' => $this->question, 'comment' => $this->comment);
-    }
-    // }}}
-
-    // {{{ function checkSyntax() : checks question elements (before storing into database), not currently needed (with new structure)
-    protected function checkSyntax()
+    public function export()
     {
-        return null;
+        $export = parent::export();
+        $export['questions'] = $this->exportQuestions();
+        return $export;
     }
-    // }}}
 
-    // {{{ function checkAnswer : returns a correct answer (or a null value if error)
-    public function checkAnswer($ans)
+    public function exportQuestions()
     {
-        return null;
-    }
-    // }}}
-
-    // {{{ functions regarding the results of a survey
-    abstract public function getResultArray($sid, $qid);
-
-    public function formatAnswer($ans)
-    {
-        return $ans;
-    }
-
-    public function getCSVColumns()
-    {
-        return $this->question;
-    }
-    // }}}
-}
-// }}}
-
-// {{{ abstract class SurveySimple and its derived classes : "open" questions
-// {{{ abstract class SurveySimple extends SurveyQuestion
-abstract class SurveySimple extends SurveyQuestion
-{
-    public function checkAnswer($ans)
-    {
-        return array($ans);
-    }
-
-    public function getResultArray($sid, $qid)
-    {
-        $sql = 'SELECT answer
-                  FROM survey_answers
-                 WHERE vote_id IN (SELECT id FROM survey_votes WHERE survey_id={?})
-                   AND question_id={?}
-              ORDER BY RAND()
-                 LIMIT 5;';
-        $res = XDB::query($sql, $sid, $qid);
-        return $res->fetchAllAssoc();
-    }
-}
-// }}}
-
-// {{{ class SurveyText extends SurveySimple : simple text field, allowing a few words
-class SurveyText extends SurveySimple
-{
-    public function getQuestionType()
-    {
-        return "text";
-    }
-}
-// }}}
-
-// {{{ class SurveyTextarea extends SurveySimple : textarea field, allowing longer comments
-class SurveyTextarea extends SurveySimple
-{
-    public function getQuestionType()
-    {
-        return "textarea";
-    }
-}
-// }}}
-
-// {{{ class SurveyNum extends SurveySimple : allows numerical answers
-class SurveyNum extends SurveySimple
-{
-    public function checkAnswer($ans)
-    {
-        return array(intval($ans));
-    }
-
-    protected function getQuestionType()
-    {
-        return "num";
-    }
-}
-// }}}
-// }}}
-
-// {{{ abstract class SurveyList and its derived classes : restricted questions that allows only a list of possible answers
-// {{{ abstract class SurveyList extends SurveyQuestion
-abstract class SurveyList extends SurveyQuestion
-{
-    protected $choices;
-
-    public function update($args)
-    {
-        parent::update($args);
-        $this->choices = array();
-        foreach ($args['choices'] as $val) {
-            if (trim($val) || trim($val) == '0') {
-                $this->choices[] = $val;
-            }
+        $export = array();
+        foreach ($this->questions as $question) {
+            $export[] = $question->export();
         }
+        return $export;
     }
 
-    public function toArray()
-    {
-        $rArr = parent::toArray();
-        $rArr['choices'] = $this->choices;
-        return $rArr;
-    }
-
-    public function getResultArray($sid, $qid)
+    public function exportQuestionsToJSON()
     {
-        $sql = 'SELECT answer, COUNT(id) AS count
-                  FROM survey_answers
-                 WHERE vote_id IN (SELECT id FROM survey_votes WHERE survey_id={?})
-                   AND question_id={?}
-              GROUP BY answer ASC';
-        $res = XDB::query($sql, $sid, $qid);
-        return $res->fetchAllAssoc();
+        return json_encode($this->exportQuestions());
     }
 
-    public function formatAnswer($ans)
+    /* Return an indicator of the progression of the survey:
+     *  negative values means 'the survey is not started'
+     *  0 means 'the survey is in progress'
+     *  positive values means 'the survey expired'
+     */
+    public function progression()
     {
-        if (array_key_exists($ans, $this->choices)) {
-            return $this->choices[$ans];
-        } else {
-            return null;
+        if (!$this->flags->hasFlag('validated')) {
+            return -2;
         }
-    }
-}
-// }}}
-
-// {{{ class SurveyRadio extends SurveyList : radio question, allows one answer among the list offered
-class SurveyRadio extends SurveyList
-{
-    public function checkAnswer($ans)
-    {
-        $a = intval($ans);
-        return (array_key_exists($a, $this->choices))? array($a) : null;
-    }
-
-    protected function getQuestionType()
-    {
-        return "radio";
-    }
-}
-// }}}
-
-// {{{ class SurveyCheckbox extends SurveyList : checkbox question, allows any number of answers among the list offered
-class SurveyCheckbox extends SurveyList
-{
-    public function checkAnswer($ans)
-    {
-        $rep = array();
-        foreach ($ans as $a) {
-            $a = intval($a);
-            if (array_key_exists($a, $this->choices)) {
-                $rep[] = $a;
-            }
+        $now = time();
+        if ($this->begin->format('U') > $now) {
+            return -1;
         }
-        return (count($rep) == 0)? null : $rep;
-    }
-
-    protected function getQuestionType()
-    {
-        return "checkbox";
-    }
-}
-// }}}
-// }}}
-
-// {{{ abstract class SurveyTable and its derived classes : table question, each column represents a choice, each line represents a question
-// {{{ abstract class SurveyTable extends SurveyList
-abstract class SurveyTable extends SurveyList
-{
-    protected $subquestions;
-
-    public function update($args)
-    {
-        parent::update($args);
-        $this->subquestions = array();
-        foreach ($args['subquestions'] as $val) {
-            if (trim($val) || trim($val) == '0') {
-                $this->subquestions[] = $val;
-            }
+        if ($this->end->format('U') <= $now) {
+            return 1;
         }
+        return 0;
     }
 
-    public function toArray()
+    public function canSee(User $user)
     {
-        $rArr = parent::toArray();
-        $rArr['subquestions'] = $this->subquestions;
-        return $rArr;
+        if ($this->canSeeResults($user) || $this->canVote($user)) {
+            return true;
+        }
+        return false;
     }
 
-    public function getResultArray($sid, $qid)
+    public function canSeeResults(User $user)
     {
-        $sql = 'SELECT answer, COUNT(id) AS count
-                  FROM survey_answers
-                 WHERE vote_id IN (SELECT id FROM survey_votes WHERE survey_id={?})
-                   AND question_id={?}
-              GROUP BY answer ASC';
-        $res = XDB::iterator($sql, $sid, $qid);
-        $result = array();
-        for ($i = 0; $i < count($this->subquestions); $i++) {
-            $result[$i] = array_fill(0, count($this->choices), 0);
+        if ($user->id() == $this->uid || $user->hasFlag('admin')) {
+            return true;
         }
-        while ($r = $res->next()) {
-            list($i, $j) = explode(':', $r['answer']);
-            $result[$i][$j] = $r['count'];
+        if (is_null($this->viewerFilter)) {
+            return $this->viewerFilter->checkUser($user);
         }
-        return $result;
+        return false;
     }
 
-    public function formatAnswer($ans)
+    public function canVote(User $user)
     {
-        list($q, $c) = explode(':', $ans);
-        if (array_key_exists($q, $this->subquestions) && array_key_exists($c, $this->choices)) {
-            return array('id' => $q, 'answer' => $this->choices[$c]);
-        } else {
-            return null;
+        $status = $this->progression();
+        if ($status < 0) {
+            return "Ce sondage n'est pas encore commencé";
+        } else if ($status > 0) {
+            return "Ce sondage est terminé";
+        }
+        if (!is_null($this->voterFilter) && !$this->voterFilter->checkUser($user)) {
+            return "Ce sondage ne s'adresse pas à toi";
+        }
+        $vote = SurveyVote::getVote($this, $user, false);
+        if (is_null($vote)) {
+            return "Tu as déjà voté à ce sondage.";
         }
+        return true;
     }
 
-    public function getCSVColumns()
+    public function vote(User $user, array $answers)
     {
-        $q = parent::getCSVColumns();
-        if (empty($this->subquestions)) {
-            return $q;
+        if (!$this->canVote($user)) {
+            return array('survey' => "Tu n'es pas autorisé à voter à ce sondage.");
+        }
+        $vote = SurveyVote::getVote($this, $user);
+        if (is_null($vote)) {
+            return $vote;
         }
-        $a = array();
-        for ($k = 0; $k < count($this->subquestions); $k++) {
-            $a[$k] = $q.' : '.$this->subquestions[$k];
+        $answers = new PlDict($answers);
+        foreach ($this->questions as $question) {
+            $question->vote($vote, $answers);
         }
-        return $a;
+        return $vote;
     }
-}
-// }}}
 
-// {{{ class SurveyRadioTable extends SurveyTable : SurveyTable with radio type choices
-class SurveyRadioTable extends SurveyTable
-{
-    public function checkAnswer($ans)
+    public static function get($name, $fetchQuestions = true)
     {
-        $rep = array();
-        foreach ($ans as $k => $a) {
-            if (!array_key_exists($k, $this->subquestions)) {
-                continue;
-            }
-            $a = intval($a);
-            if (array_key_exists($a, $this->choices)) {
-                $rep[] = $k . ':' . $a;
-            }
+        if (is_array($name)) {
+            $name = $name[0];
         }
-        return (count($rep) == 0)? null : $rep;
+        $survey = new Survey();
+        $survey->fetchQuestions = $fetchQuestions;
+        if (can_convert_to_integer($name)) {
+            $survey->id = $name;
+        } else {
+            $survey->shortname = $name;
+        }
+        if (!$survey->fetch()) {
+            return null;
+        }
+        return $survey;
     }
 
-    protected function getQuestionType()
+    public static function iterActive()
     {
-        return "radiotable";
+        $survey = new Survey();
+        $survey->fetchQuestions = false;
+        return $survey->iterateOnCondition('begin <= CURDATE() AND end >= CURDATE()
+                                            AND FIND_IN_SET(\'validated\', flags)');
     }
-
 }
-// }}}
 
-// {{{ class SurveyCheckboxTable extends SurveyTable : SurveyTable with checkbox type choices
-class SurveyCheckboxTable extends SurveyTable
+class ShortNameFieldValidator implements PlDBTableFieldValidator
 {
-    public function checkAnswer($ans)
+    public function __construct(PlDBTableField $field, $value)
     {
-        $rep = array();
-        foreach ($ans as $k => $aa) {
-            if (!array_key_exists($k, $this->subquestions)) {
-                continue;
-            }
-            foreach ($aa as $a) {
-                $a = intval($a);
-                if (array_key_exists($a, $this->choices)) {
-                    $rep[] = $k . ':' . $a;
-                }
-            }
+        if (can_convert_to_integer($value) || !preg_match('/^[a-z0-9]+[-_\.a-z0-9]*[a-z0-9]+$/i', $value)) {
+            throw new PlDBBadValueException($value, $field,
+                                            'The shortname can only contain alphanumerical caracters, dashes, underscores and dots');
         }
-        return (count($rep) == 0)? null : $rep;
-    }
-
-    protected function getQuestionType()
-    {
-        return "checkboxtable";
     }
-
 }
-// }}}
-// }}}
 
 // vim:set et sw=4 sts=4 ts=4 foldmethod=marker enc=utf-8:
 ?>
similarity index 61%
rename from htdocs/javascript/wiki.js
rename to modules/survey/text.inc.php
index 4ba1ce8..0ca61b4 100644 (file)
@@ -1,5 +1,6 @@
+<?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
+class SurveyQuestionText extends SurveyQuestion
+{
+    public function __construct(Survey $survey)
+    {
+        parent::__construct($survey);
+        $this->type = "text";
+    }
 
-Nix = {
-  map: null,
-  convert: function(a) {
-      Nix.init();
-      var s = '';
-      for (i = 0; i < a.length ; i++) {
-          var b = a.charAt(i);
-          s += ((b >= 'A' && b <= 'Z') || (b >= 'a' && b <= 'z') ? Nix.map[b] : b);
-      }
-      return s;
-  },
-  init: function() {
-            if (Nix.map != null)
-                return;
-            var map = new Array();
-            var s='abcdefghijklmnopqrstuvwxyz';
-            for (i = 0; i < s.length; i++)
-                map[s.charAt(i)] = s.charAt((i+13)%26);
-            for (i=0; i<s.length; i++)map[s.charAt(i).toUpperCase()] = s.charAt((i+13)%26).toUpperCase();
-            Nix.map = map;
-        },
-  decode: function(a) {
-              document.write(Nix.convert(a));
-          }
+    protected function buildAnswer(SurveyAnswer $answer, PlDict $data)
+    {
+        $value = $data->t($this->qid);
+        if (!empty($value)) {
+            $answer->answer = array('text' => $value);
+        } else {
+            $answer->answer = null;
+        }
+        return true;
+    }
 }
 
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+// vim:set et sw=4 sts=4 ts=4 foldmethod=marker enc=utf-8:
+?>
index dbaa8a3..6dc536d 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 4b2f7d3..96f563d 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -267,6 +267,25 @@ class XnetEventsModule extends PLModule
         if ($updated !== false) {
             $page->trigSuccess('Ton inscription à l\'événement a été mise à jour avec succès.');
             subscribe_lists_event(S::i('uid'), $evt, ($total > 0 ? 1 : 0), 0);
+
+            if ($evt['subscription_notification'] != 'nobody') {
+                $mailer = new PlMailer('xnetevents/subscription-notif.mail.tpl');
+                if ($evt['subscription_notification'] != 'creator') {
+                    $admins = $globals->asso()->iterAdmins();
+                    while ($admin = $admins->next()) {
+                        $mailer->addTo($admin);
+                    }
+                }
+                if ($evt['subscription_notification'] != 'animator') {
+                    $mailer->addTo($evt['organizer']);
+                }
+                $mailer->assign('group', $globals->asso('nom'));
+                $mailer->assign('event', $evt['intitule']);
+                $mailer->assign('subs', $subs);
+                $mailer->assign('moments', $evt['moments']);
+                $mailer->assign('name', S::user()->fullName('promo'));
+                $mailer->send();
+            }
         }
         $page->assign('event', get_event_detail($eid));
     }
@@ -390,7 +409,7 @@ class XnetEventsModule extends PLModule
                 'short_name'       => $short_name,
             );
 
-            $trivial = array('intitule', 'descriptif', 'noinvite',
+            $trivial = array('intitule', 'descriptif', 'noinvite', 'subscription_notification',
                              'show_participants', 'accept_nonmembre', 'uid');
             foreach ($trivial as $k) {
                 $evt[$k] = Post::v($k);
@@ -411,18 +430,18 @@ class XnetEventsModule extends PLModule
             XDB::execute('INSERT INTO  group_events (eid, asso_id, uid, intitule, paiement_id,
                                                      descriptif, debut, fin, show_participants,
                                                      short_name, deadline_inscription, noinvite,
-                                                     accept_nonmembre)
-                               VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})
+                                                     accept_nonmembre, subscription_notification)
+                               VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})
               ON DUPLICATE KEY UPDATE  asso_id = VALUES(asso_id), uid = VALUES(uid), intitule = VALUES(intitule),
                                        paiement_id = VALUES(paiement_id), descriptif = VALUES(descriptif), debut = VALUES(debut),
                                        fin = VALUES(fin), show_participants = VALUES(show_participants), short_name = VALUES(short_name),
                                        deadline_inscription = VALUES(deadline_inscription), noinvite = VALUES(noinvite),
-                                       accept_nonmembre = VALUES(accept_nonmembre)',
+                                       accept_nonmembre = VALUES(accept_nonmembre), subscription_notification = VALUES(subscription_notification)',
                          $evt['eid'], $evt['asso_id'], $evt['uid'],
                          $evt['intitule'], $evt['paiement_id'], $evt['descriptif'],
                          $evt['debut'], $evt['fin'], $evt['show_participants'],
                          $evt['short_name'], $evt['deadline_inscription'],
-                         $evt['noinvite'], $evt['accept_nonmembre']);
+                         $evt['noinvite'], $evt['accept_nonmembre'], $evt['subscription_notification']);
 
             // if new event, get its id
             if (!$eid) {
@@ -485,7 +504,7 @@ class XnetEventsModule extends PLModule
             $res = XDB::query(
                     "SELECT  eid, intitule, descriptif, debut, fin, uid,
                              show_participants, paiement_id, short_name,
-                             deadline_inscription, noinvite, accept_nonmembre
+                             deadline_inscription, noinvite, accept_nonmembre, subscription_notification
                        FROM  group_events
                       WHERE eid = {?}", $eid);
             $evt = $res->fetchOneAssoc();
index a4ba097..1380295 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -34,7 +34,8 @@ function get_event_detail($eid, $item_id = false, $asso_id = null)
                                LEFT(10, e.debut) AS start_day, LEFT(10, e.fin) AS last_day,
                                LEFT(NOW(), 10) AS now,
                                ei.titre, al.vid AS absent_list, pl.vid AS participant_list,
-                               pyl.vid AS payed_list, bl.vid AS booked_unpayed_list
+                               pyl.vid AS payed_list, bl.vid AS booked_unpayed_list,
+                               e.subscription_notification
                          FROM  group_events              AS e
                    INNER JOIN  group_event_items        AS ei ON (e.eid = ei.eid)
                     LEFT JOIN  group_event_participants AS ep ON(e.eid = ep.eid AND ei.item_id = ep.item_id)
index 48e0ce8..68e0d3d 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -48,7 +48,7 @@ class XnetGrpModule extends PLModule
             '%grp/member/new/ajax' => $this->make_hook('admin_member_new_ajax', AUTH_MDP,    'user', NO_AUTH),
             '%grp/member/del'      => $this->make_hook('admin_member_del',      AUTH_MDP,    'groupadmin'),
 
-            '%grp/rss'             => $this->make_hook('rss',                   AUTH_PUBLIC, 'user', NO_HTTPS),
+            '%grp/rss'             => $this->make_token_hook('rss',             AUTH_PUBLIC),
             '%grp/announce/new'    => $this->make_hook('edit_announce',         AUTH_MDP,    'groupadmin'),
             '%grp/announce/edit'   => $this->make_hook('edit_announce',         AUTH_MDP,    'groupadmin'),
             '%grp/announce/photo'  => $this->make_hook('photo_announce',        AUTH_PUBLIC),
@@ -184,22 +184,29 @@ class XnetGrpModule extends PLModule
                     $page->trigError('Ni le nom ni le diminutif du groupe ne peuvent être vide.');
                     return;
                 }
+                $axDate = make_datetime(Post::v('axDate'));
+                if (Post::t('axDate') != '') {
+                    $axDate = make_datetime(Post::v('axDate'))->format('Y-m-d');
+                } else {
+                    $axDate = null;
+                }
                 XDB::execute(
                     "UPDATE  groups
                         SET  nom={?}, diminutif={?}, cat={?}, dom={?},
                              descr={?}, site={?}, mail={?}, resp={?},
-                             forum={?}, mail_domain={?}, ax={?}, pub={?},
+                             forum={?}, mail_domain={?}, ax={?}, axDate = {?}, pub={?},
                              sub_url={?}, inscriptible={?}, unsub_url={?},
-                             flags={?}
+                             flags = {?}, welcome_msg = {?}
                       WHERE  id={?}",
                       Post::v('nom'), Post::v('diminutif'),
                       Post::v('cat'), (Post::i('dom') == 0) ? null : Post::i('dom'),
                       Post::v('descr'), $site,
                       Post::v('mail'), Post::v('resp'),
                       Post::v('forum'), Post::v('mail_domain'),
-                      Post::has('ax'), Post::v('pub'),
+                      Post::has('ax'), $axDate, Post::v('pub'),
                       Post::v('sub_url'), Post::v('inscriptible'),
-                      Post::v('unsub_url'), $flags, $globals->asso('id'));
+                      Post::v('unsub_url'), $flags, Post::t('welcome_msg'),
+                      $globals->asso('id'));
                 if (Post::v('mail_domain')) {
                     XDB::execute('INSERT IGNORE INTO virtual_domains (domain) VALUES({?})',
                                            Post::v('mail_domain'));
@@ -209,13 +216,14 @@ class XnetGrpModule extends PLModule
                     "UPDATE  groups
                         SET  descr={?}, site={?}, mail={?}, resp={?},
                              forum={?}, pub= {?}, sub_url={?},
-                             unsub_url={?},flags={?}
+                             unsub_url = {?}, flags = {?}, welcome_msg = {?}
                       WHERE  id={?}",
                       Post::v('descr'), $site,
                       Post::v('mail'), Post::v('resp'),
                       Post::v('forum'), Post::v('pub'),
                       Post::v('sub_url'), Post::v('unsub_url'),
-                      $flags, $globals->asso('id'));
+                      $flags, Post::t('welcome_msg'),
+                      $globals->asso('id'));
             }
 
 
@@ -252,7 +260,6 @@ class XnetGrpModule extends PLModule
         $mmlist = new MMList(S::user(), $globals->asso('mail_domain'));
         $page->assign('listes', $mmlist->get_lists());
         $page->assign('user', S::user());
-        $page->addJsLink('ajax.js');
 
         if (Post::has('send')) {
             S::assert_xsrf_token();
@@ -402,6 +409,7 @@ class XnetGrpModule extends PLModule
                      . "\n"
                      . "  Suite à ta demande d'adhésion à " . $globals->asso('nom')
                      . ", j'ai le plaisir de t'annoncer que ton inscription a été validée !\n"
+                     . (is_null($globals->asso('welcome_msg')) ? '' : "\n" . $globals->asso('welcome_msg') . "\n")
                      . "\n"
                      . "Bien cordialement,\n"
                      . "-- \n"
@@ -627,7 +635,6 @@ class XnetGrpModule extends PLModule
         global $globals;
 
         $page->changeTpl('xnetgrp/membres-add.tpl');
-        $page->addJsLink('ajax.js');
 
         if (is_null($email)) {
             return;
@@ -915,11 +922,12 @@ class XnetGrpModule extends PLModule
             // Update group params for user
             $perms = Post::v('group_perms');
             $comm  = Post::t('comm');
-            if ($user->group_perms != $perms || $user->group_comm != $comm) {
+            $position = (Post::t('group_position') == '') ? null : Post::v('group_position');
+            if ($user->group_perms != $perms || $user->group_comm != $comm || $user->group_position != $position) {
                 XDB::query('UPDATE  group_members
-                               SET  perms = {?}, comm = {?}
+                               SET  perms = {?}, comm = {?}, position = {?}
                              WHERE  uid = {?} AND asso_id = {?}',
-                            ($perms == 'admin') ? 'admin' : 'membre', $comm,
+                            ($perms == 'admin') ? 'admin' : 'membre', $comm, $position,
                             $user->id(), $globals->asso('id'));
                 if (XDB::affectedRows()) {
                     if ($perms != $user->group_perms) {
@@ -928,6 +936,9 @@ class XnetGrpModule extends PLModule
                     if ($comm != $user->group_comm) {
                         $page->trigSuccess('Commentaire mis à jour.');
                     }
+                    if ($position != $user->group_position) {
+                        $page->trigSuccess('Poste mis à jour.');
+                    }
                 }
             }
 
@@ -988,19 +999,23 @@ class XnetGrpModule extends PLModule
             }
         }
 
+        $res = XDB::rawFetchAllAssoc('SHOW COLUMNS FROM group_members LIKE \'position\'');
+        $positions = str_replace(array('enum(', ')', '\''), '', $res[0]['Type']);
+
         $page->assign('user', $user);
         $page->assign('listes', $mmlist->get_lists($user->forlifeEmail()));
         $page->assign('alias', $user->emailAliases($globals->asso('mail_domain'), 'user', true));
+        $page->assign('positions', explode(',', $positions));
     }
 
-    function handler_rss(&$page, $user = null, $hash = null)
+    function handler_rss(PlPage& $page, PlUser& $user)
     {
         global $globals;
         $page->assign('asso', $globals->asso());
 
         $this->load('feed.inc.php');
         $feed = new XnetGrpEventFeed();
-        return $feed->run($page, $user, $hash, false);
+        return $feed->run($page, $user, false);
     }
 
     private function upload_image(PlPage &$page, PlUpload &$upload)
index 95b421c..55cb0a7 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 0002242..948ccd9 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 43f4006..5af8e1e 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 85a9210..3278f6e 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 4e7db2a..8b9fdf7 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 39728ed..1ac822b 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index b76bbde..6e2c4aa 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 3a05b61..98448ee 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 551e0e6..6b66f80 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 745a484..0076536 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 7d69ee9..494e78e 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index a696a16..9639c68 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index d7b1dd9..fece962 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
@@ -66,7 +66,7 @@ function add_user_to_url(f) {
 
   <ul>
     <li><a href="admin/add_accounts">Ajout d'un ensemble d'utilisateurs</a></li>
-    <li>Ajouter une secrétaire de l'AX:</li>
+    <li>Ajouter un compte manuel :</li>
   </ul>
   <p>
     <form action="admin/accounts" method="post">
@@ -80,6 +80,7 @@ function add_user_to_url(f) {
               <option value="fx">Personnel de la FX</option>
               <option value="school">Personnel de l'Ecole</option>
             </select>
+            <a href="admin/account/types">Détail des permissions associées</a>
           </td>
         </tr>
         <tr>
index b52f3e6..83966f6 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index bd95d3d..4329ca1 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index d11cf46..afe0b82 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
diff --git a/templates/admin/emails_bounces_re.tpl b/templates/admin/emails_bounces_re.tpl
deleted file mode 100644 (file)
index 282cfd7..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-{**************************************************************************}
-{*                                                                        *}
-{*  Copyright (C) 2003-2010 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>Regexps pour les détections de bounces</h1>
-
-<p>
-Rappel sur les niveaux&nbsp;:
-</p>
-<ul>
-  <li>0: IGNORE == ignorer le bounce</li>
-  <li>1: NOTICE == forwarder le bounce (typiquement vacation)</li>
-  <li>2: ERREUR == erreur</li>
-</ul>
-
-
-<form action="admin/postfix/regexp_bounces" method="post">
-  <table class="bicol" cellpadding='0' cellspacing='0'>
-    <tr>
-      <th>Position/Niveau</th>
-      <th>Regexp/Raison</th>
-    </tr>
-    {if $new}
-    <tr class="impair">
-      <td>
-        <input type='text' name='pos[NULL]' value='' size='4' maxlength='4' />
-      </td>
-      <td>
-        <input type="text" size="82" name='re[NULL]'   value="{$re.re}" />
-      </td>
-    </tr>
-    <tr class="impair">
-      <td style="white-space: nowrap">
-        <input type='radio' name='lvl[NULL]' value='0' {if $re.lvl eq 0}checked="checked"{/if} />
-        <input type='radio' name='lvl[NULL]' value='1' {if $re.lvl eq 1}checked="checked"{/if} />
-        <input type='radio' name='lvl[NULL]' value='2' {if $re.lvl eq 2}checked="checked"{/if} />
-      </td>
-      <td>
-        <input type="text" size="32" name='text[NULL]' value="{$re.text}" />
-      </td>
-    </tr>
-    {else}
-    <tr class="impair">
-      <td colspan="2" class="right action">
-        <a href="admin/postfix/regexp_bounces/new">nouveau</a>
-      </td>
-    </tr>
-    {/if}
-    {iterate from=$bre item=re}
-    <tr class="{cycle values="pair,pair,impair,impair"}">
-      <td>
-        <input type='text' name='pos[{$re.id}]' value='{$re.pos}' size='4' maxlength='4' />
-      </td>
-      <td>
-        <input type="text" size="82" name='re[{$re.id}]'   value="{$re.re}" />
-      </td>
-    </tr>
-    <tr class="{cycle values="pair,pair,impair,impair"}">
-      <td style="white-space: nowrap">
-        <input type='radio' name='lvl[{$re.id}]' value='0' {if $re.lvl eq 0}checked="checked"{/if} />
-        <input type='radio' name='lvl[{$re.id}]' value='1' {if $re.lvl eq 1}checked="checked"{/if} />
-        <input type='radio' name='lvl[{$re.id}]' value='2' {if $re.lvl eq 2}checked="checked"{/if} />
-      </td>
-      <td>
-        <input type="text" size="32" name='text[{$re.id}]' value="{$re.text}" /><br />
-      </td>
-    </tr>
-    {/iterate}
-    <tr class="{cycle values="pair,impair"}">
-      <td colspan="2" class="center">
-        <input type="submit" value="valider" name="submit" />
-      </td>
-    </tr>
-  </table>
-</form>
-
-
-{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index 75bbdd5..180ba7d 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
similarity index 53%
rename from templates/survey/show_checkboxtable.tpl
rename to templates/admin/geocoding.tpl
index b58a0e9..89d88e8 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
 {*                                                                        *}
 {**************************************************************************}
 
+<h1>{$name|ucfirst}</h1>
+
+{foreach from=$lists item=list key=list_description}
+{if $list_description eq "manquant"}
+{assign var="fields" value=$main_fields}
+{assign var="action" value="add"}
+{else}
+{assign var="fields" value=$all_fields}
+{assign var="action" value="edit"}
+{/if}
+
+<h2>{$list|@count} {$name} {$list_description}{if $list|@count > 1}s{/if}.</h2>
+{if $list|@count}
 <table class="bicol">
-  <tr class="pair">
-    <td></td>
-    {foreach from=$squestion.choices item=schoice}
-      <td>{$schoice}</td>
+  <tr>
+    <th>{$id}</th>
+    {foreach from=$fields item=field}
+    <th>{$field}</th>
     {/foreach}
+    <th>{$action}</th>
   </tr>
-{foreach from=$squestion.subquestions item=ssubq key=ssqid}
-  <tr class="{cycle values="impair,pair"}">
-    <td>{$ssubq}</td>
-  {assign var=sid value=$survey.id}
-  {assign var=sqid value=$squestion.id}
-  {if $survey_resultmode}
-    {foreach from=$squestion.choices item=schoice key=value}
-    <td>
-      {$squestion.result.$ssqid.$value*100/$survey.votes|string_format:"%.1f"}% ({$squestion.result.$ssqid.$value} votes)
-    </td>
+{foreach from=$list item=item key=key}
+  <tr>
+    <td>{$key}</td>
+    {foreach from=$fields item=field}
+    {assign var="error" value=$field|cat:'_error'}
+    {assign var="warning" value=$field|cat:'_warning'}
+    <td{if t($item.$error)} class="error"{elseif t($item.$warning)} class="warning"{/if}>{$item.$field}</td>
     {/foreach}
-  {else}
-    {foreach from=$squestion.choices item=schoice key=value}
-    <td>
-      <label><input type="checkbox" name="survey{$sid}[{$sqid}][{$ssqid}][]" value="{$value}" {if !$survey_votemode}disabled="disabled" {/if}/></label>
-    </td>
-    {/foreach}
-  {/if}
+    <td><a href="admin/geocoding/{$category}/{$action}/{$key}">{icon name="page_edit"}</a></td>
   </tr>
 {/foreach}
+  <tr>
+    <th>{$id}</th>
+    {foreach from=$fields item=field}
+    <th>{$field}</th>
+    {/foreach}
+    <th>{$action}</th>
+  </tr>
 </table>
+{/if}
+{/foreach}
+
+<form method="post" action="admin/geocoding/{$category}/add">
+  {xsrf_token_field}
+  <p>
+    Ajouter un champ (n'indiquer que l'indentifiant principal)&nbsp;:
+    <input type="text" name="new_id" size="3" maxlength="3" />
+    <input type="submit" value="Ajouter" />
+  </p>
+</form>
 
-{* vim:set et sw=2 sts=2 ts=8 enc=utf-8: *}
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
similarity index 59%
rename from templates/survey/edit_radiotable.tpl
rename to templates/admin/geocoding_edit.tpl
index 0e034c3..72f598d 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
 {*                                                                        *}
 {**************************************************************************}
 
-{include file='survey/edit_radio.tpl'}
+<h1><a href="admin/geocoding/{$category}">{$name|ucfirst}&nbsp;: édition</a></h1>
+
+<form method="post" action="admin/geocoding/{$category}/edit/{$id}">
+  {xsrf_token_field}
+
+  {if $iso|@count eq 0}
+  <p class="error">Cet élément ne figure pas dans la liste ISO.</p>
+  {/if}
+  <table class="tinybicol">
     <tr>
-      <td class="titre">Sous-questions</td>
+      <th>Champs</th>
+      <th>Élément</th>
+      <th>Données ISO</th>
+    </tr>
+    {foreach from=$all_fields item=field}
+    <tr>
+      <th>{$field}</th>
       <td>
-        {foreach from=$survey_current.subquestions key=value item=subquestion}
-        <div id="subquestions_t{$value}">
-          <input type="text" name="survey_question[subquestions][t{$value}]" size="50" maxlength="200" value="{$subquestion}" />
-          <a href="javascript:removeField('subquestions','t{$value}')">{icon name=delete title="Supprimer"}</a>
-        </div>
-        {/foreach}
-        <div id="subquestions_last">
-          <a href="javascript:newField('subquestions','last')">{icon name=add}</a>
-        </div>
+        <input type="text" name="{$field}" value="{$item.$field}"
+               {if t($iso.$field)}{if !$item.$field} class="warning"{elseif $iso.$field neq $item.$field} class="error"{/if}{/if} />
       </td>
+      <td>{if t($iso.$field)}{$iso.$field}{/if}</td>
     </tr>
+    {/foreach}
+  </table>
+
+  <p class="center">
+    <input type="submit" name="edit" value="Éditer" />&nbsp;&nbsp;&nbsp;
+    <input type="submit" name="del" value="Supprimer" onclick="return confirm('Es-tu sûr de vouloir supprimer cet élément&nbsp;?')" />
+  </p>
+</form>
 
-{* vim:set et sw=2 sts=2 ts=8 enc=utf-8: *}
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index ab8d9fe..1567407 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 72f5902..309efba 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index d5360c7..17cd7eb 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
@@ -32,8 +32,6 @@
       <a href="admin/postfix/whitelist">Whitelist</a>
       &nbsp;&nbsp;|&nbsp;&nbsp;
       <a href="admin/postfix/delayed">Retardés</a>
-      &nbsp;&nbsp;|&nbsp;&nbsp;
-      <a href="admin/postfix/regexp_bounces">Regexps Bounces</a>
     </td>
   </tr>
   <tr class="pair">
 
   <tr><th colspan="2">{icon name=user_gray} Champs</th></tr>
   <tr class="impair">
+    <td class="titre">Pays / Langues</td>
+    <td>
+      <a href="admin/geocoding/country">Pays</a>
+      &nbsp;&nbsp;|&nbsp;&nbsp;
+      <a href="admin/geocoding/language">Langues</a>
+    </td>
+  </tr>
+  <tr class="impair">
     <td class="titre">Formation</td>
     <td>
       <a href="admin/education">Formations</a>
index da614ba..cc36b28 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 7ebb9c8..d8c9562 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 7dd7ff8..8505bce 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index b1dc2b7..9075d7c 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 03e73de..b72f421 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 3a20e9d..2f448ea 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
@@ -93,8 +93,8 @@ function ban_read()
     document.forms.bans.read_perm.value = "!xorg.*";
 }
 
-$(document).ready(function() {
-  $('#tabs > ul').tabs();
+$(function() {
+  $('#tabs').tabs();
   $('.ui-tabs-nav li').width('24%')
     .click(function() { $(this).children('a').click() });
 });
@@ -105,10 +105,10 @@ $(document).ready(function() {
 
 <div id="tabs">
   <ul style="margin-top: 0">
-    <li><a href="{$platal->pl_self()}#account"><span >Compte de {$user->login()}</span></a></li>
-    <li><a href="{$platal->pl_self()}#emails"><span>Emails</span></a></li>
-    <li><a href="{$platal->pl_self()}#authext"><span>OpenID</span></a></li>
-    <li><a href="{$platal->pl_self()}#forums"><span>Forums</span></a></li>
+    <li><a href="#account"><span>Compte de {$user->login()}</span></a></li>
+    <li><a href="#emails"><span>Emails</span></a></li>
+    <li><a href="#authext"><span>OpenID</span></a></li>
+    <li><a href="#forums"><span>Forums</span></a></li>
   </ul>
 </div>
 
@@ -464,7 +464,6 @@ $(document).ready(function() {
   </table>
 </form>
 
-{javascript name="ajax"}
 {test_email hruid=$user->login()}
 
 <h1>Autres adresses de l'utilisateur</h1>
index ad35662..ac1dd74 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index b043382..c7c3b55 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 78459e8..302b6c5 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index aa15aa6..7f43373 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index cf893d3..1bb758b 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 81c600f..0260463 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 0aa9ac7..ff64695 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 16e37bd..bb159fb 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 3f60dd0..51e7042 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index cf0e603..67c3b81 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 815c6fb..077e935 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}\r
 {*                                                                        *}\r
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}\r
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}\r
 {*  http://opensource.polytechnique.org/                                  *}\r
 {*                                                                        *}\r
 {*  This program is free software; you can redistribute it and/or modify  *}\r
index 52df5e2..9fe21f5 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}\r
 {*                                                                        *}\r
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}\r
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}\r
 {*  http://opensource.polytechnique.org/                                  *}\r
 {*                                                                        *}\r
 {*  This program is free software; you can redistribute it and/or modify  *}\r
index b00d7fa..bccf4bd 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 06ffcad..299d591 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index b6cef09..df21a2d 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 7ee9e0b..9d13880 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index db12e22..5f2bbdf 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 35e8016..91cbd82 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 0e568e3..21fcfa3 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index f5b7bdc..207e9dd 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 28bffb6..2bbcee4 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index e4edd05..1304624 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 14e6cf6..d502146 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
   </h1>
 
 {if $actuel}
-  {javascript name=ajax}
   {if $user->hasProfile()}
   <table class="flags">
     <tr>
       <td class="orange">
         <input type="checkbox" {if $mail_public}checked="checked"{/if}
-            onclick="
-                Ajax.update_html(null,'{$globals->baseurl}/emails/alias/set/'+(this.checked?'public':'private')+'?token={xsrf_token}');
-                document.getElementById('mail_public').innerHTML = (this.checked?'public et apparaît donc sur ta fiche':'privé et n\'apparaît nulle part sur le site') + '.';
+            onclick="$.xget('{$globals->baseurl}/emails/alias/set/'+(this.checked?'public':'private')+'?token={xsrf_token}');
+                $('#mail_public').html((this.checked?'public et apparaît donc sur ta fiche':'privé et n\'apparaît nulle part sur le site') + '.');
             " />
       </td>
       <td>
index 12d1cdd..628cf37 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
 
 {include wiki=Xorg.Antispam part=1}
 
-{javascript name=ajax}
 <script type="text/javascript">//<![CDATA[
   {literal}
-  function bogoUpdated()
-  {
-    showTempMessage('bogo-msg', "Le changement de réglage de l'antispam a bien été effectué.", true);
-  }
+  $(function() {
+      var url = '{/literal}{$globals->baseurl}/emails/antispam/{literal}';
+      var msg = "Le changement de réglage de l'antispam a bien été effectué.";
+      $(':radio[name=statut_filtre]').change(function() {
+          $("#bogo-msg").successMessage(url + $(this).val(), msg);
+      });
+  });
   {/literal}
 //]]></script>
   <fieldset>
     <legend><strong>Choisis ton propre réglage&nbsp;:</strong></legend>
-    <input id='s0' type='radio' name='statut_filtre' value='0' {if $filtre eq 0}checked="checked"{/if} onclick="Ajax.update_html(null, '{$globals->baseurl}/emails/antispam/'+this.value, bogoUpdated)" />
+    <input id='s0' type='radio' name='statut_filtre' value='0' {if $filtre eq 0}checked="checked"{/if} />
     <label for='s0'>(1) le filtre anti-spam n'agit pas sur tes emails</label>
     <br />
-    <input id='s1' type='radio' name='statut_filtre' value='1' {if $filtre eq 1}checked="checked"{/if} onclick="Ajax.update_html(null, '{$globals->baseurl}/emails/antispam/'+this.value, bogoUpdated)" />
+    <input id='s1' type='radio' name='statut_filtre' value='1' {if $filtre eq 1}checked="checked"{/if} />
     <label for='s1'>(2) le filtre anti-spam marque les emails</label>
     <br />
-    <input id='s2' type='radio' name='statut_filtre' value='2' {if $filtre eq 2}checked="checked"{/if} onclick="Ajax.update_html(null, '{$globals->baseurl}/emails/antispam/'+this.value, bogoUpdated)" />
+    <input id='s2' type='radio' name='statut_filtre' value='2' {if $filtre eq 2}checked="checked"{/if} />
     <label for='s2'>(3) le filtre anti-spam marque les emails, et élimine les spams avec des notes les plus hautes</label>
     <br />
-    <input id='s3' type='radio' name='statut_filtre' value='3' {if $filtre eq 3}checked="checked"{/if} onclick="Ajax.update_html(null, '{$globals->baseurl}/emails/antispam/'+this.value, bogoUpdated)" />
+    <input id='s3' type='radio' name='statut_filtre' value='3' {if $filtre eq 3}checked="checked"{/if} />
     <label for='s3'>(4) le filtre anti-spam élimine les emails détectés comme spams</label>
   </fieldset>
 
index 0e078e6..353cdc7 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 231a60a..13e80f4 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 927f7ec..84e808f 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index e4af879..8434ee5 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index d728fec..87e7575 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index af8c048..5071b21 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 8146bfe..de94958 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
 
 <h1>Gestion de mes emails</h1>
 
-{javascript name=ajax}
 {literal}
 <script type="text/javascript">
-  function bestaliasUpdated() {
-    showTempMessage('bestalias-msg', "Le changement a bien été effectué.", true);
-  }
+  //<![CDATA[
+  $(function() {
+      var url = '{/literal}{$globals->baseurl}/emails/best/{literal}';
+      var tok = '{/literal}{xsrf_token}{literal}';
+      var msg = "Le changement a bien été effectué.";
+      $(':radio[name=best]').change(function() {
+          $("#bestalias-msg").successMessage(url + $(this).val() + '?token=' + tok, msg);
+      });
+  });
+  //]]>
 </script>
 {/literal}
 
@@ -38,7 +44,7 @@
     Tes adresses polytechniciennes sont&nbsp;:<br />
     <div>
       {iterate from=$aliases item=a}
-      <label><input type='radio' {if $a.best}checked="checked"{/if} name='best' value='{$a.alias}' onclick='Ajax.update_html(null,"{$globals->baseurl}/emails/best/{$a.alias}?token={xsrf_token}",bestaliasUpdated)' />
+      <label><input type='radio' {if $a.best}checked="checked"{/if} name='best' value='{$a.alias}' />
       {if $a.a_vie}(**){/if}{if $a.cent_ans}(*){/if} <strong>{$a.alias}</strong>@{#globals.mail.domain#} et
       @{#globals.mail.domain2#}</label>
       {if $a.expire}<span class='erreur'>(expire le {$a.expire|date_format})</span>{/if}
index c9bf0cf..c187b9e 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index a56e173..4fb801f 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
@@ -56,7 +56,6 @@
     <a href="Xorg/SMTPSecurise">service d'envoi d'email SMTP sécurisé</a>.
   </p>
 
-  {javascript name=ajax}
   <script type="text/javascript">//<![CDATA[
     {literal}
     function activeEnable()
@@ -73,7 +72,7 @@
 
     function redirectUpdate()
     {
-        showTempMessage('redirect-msg', "Tes redirections ont été mises à jour.", true);
+        $('#redirect-msg').tmpMessage("Tes redirections ont été mises à jour.", true);
         activeEnable();
     }
 
     function updateRedirect(checked, email)
     {
         activeEnable();
-        Ajax.update_html(null, 'emails/redirect/' + (checked ? '' : 'in') + 'active/' + email, redirectUpdate);
+        $.xget('emails/redirect/' + (checked ? '' : 'in') + 'active/' + email,
+               redirectUpdate);
     }
 
     function rewriteUpdate(mail, allow, box)
                  onchange="updateRedirect(this.checked, '{$e->email}')" /></td>
         <td style="text-align: left">
           {if $e->has_rewrite()}
-          <select onchange="Ajax.update_html(null,'emails/redirect/rewrite/{$e->email}/'+this.value, rewriteUpdate('{$e->email}', {$e->allow_rewrite|default:"0"}, this))">
+          <select onchange="$.get('emails/redirect/rewrite/{$e->email}/'+this.value, 'text',  rewriteUpdate('{$e->email}', {$e->allow_rewrite|default:"0"}, this)); return false">
             <option value=''>--- aucune ---</option>
             {assign var=dom1 value=#globals.mail.domain#}
             {assign var=dom2 value=#globals.mail.domain2#}
index 38be526..52c26cc 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index e300833..f6dfc50 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index a0d501a..24189b2 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
       saveMessage();
       return true;
     });
-  $(document).ready(
+  $(
     function() {
       // Remove empty options in select (they were added only for HTML
       // compatibility).
       $('#cc_contacts option[value=""]').remove();
     });
 
-    $(document).ready(function() {
+    $(function() {
       $("[name='to']").focus();
     });
   {/literal}
       {literal}
       function removeAttachments()
       {
-          Ajax.update_html(null, 'emails/send', null);
-          document.getElementById('att_already').style.display = 'none';
-          document.getElementById('att_form').style.display = '';
+          $.xget('email/send');
+          $('#att_already').hide();
+          $('#att_form').show();
       }
       {/literal}
     //]]></script>
index ec2b5cc..307bf91 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 0f7474f..edfa97b 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 90bc0c8..59eddd2 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 14b73d7..ece0653 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index a1e1dc5..b5e9bcb 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
@@ -62,7 +62,7 @@
       page = "{$globals->baseurl}/" + page;
       {literal}
     }
-    Ajax.update_html('preview', page, null);
+    $('#preview').updateHtml(page);
     return false;
   }
   {/literal}
index afb4ba9..563f0d0 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
@@ -118,7 +118,7 @@ Bienvenue {$smarty.session.user->displayName()}{if t($birthday)}
        if (link.childNodes[i].nodeName == 'STRONG') {
                link.replaceChild(link.childNodes[i].firstChild,link.childNodes[i]);
        }
-       Ajax.update_html(null, 'events/read/'+id);
+    $.xget('events/read/'+id);
        return false;
   }
   -->
index 76f520c..10f6538 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 37b8bd4..7f8944b 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index b214f06..8ce6d1b 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index f845cb9..62f928c 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index ce22a0c..be5abbd 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 9b3c609..50e5f69 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 9fad56d..ec72407 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 2e376ca..c2a27c9 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index a26788c..f103aec 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
@@ -66,7 +66,7 @@ trouver une correspondance entre les personnes renseignés dans ces annuaires.<b
 <script type="text/javascript">
 {literal}
 //<!--
-$(document).ready(function() {
+$(function() {
     $('#autolink a.fusion-action').click(function(a){
         $.get(a.currentTarget.href,{},function(){
             $(a.currentTarget).hide();
index 83aa8fc..03121e5 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index f3cd1ba..b135b72 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 68829ac..e428a8e 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 814bff5..deb7ec6 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
@@ -23,7 +23,7 @@
 <script type="text/javascript">
 {literal}
 //<!--
-    $(document).ready(function() {
+    $(function() {
         $('#fusionax_import input').click(function() {
             $('#fusionax input').hide();
             $('#fusionax').append('Lancement de l\'import.<br/>');
index b8aac7d..7b67ae0 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index fbb274b..e0c56f4 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 7737a1f..1359dd5 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index d9d1f4c..5f55170 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index ac27dcd..61e744a 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index c9d8fa8..b1d4cd8 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 79c5701..f034bfb 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index ff248a6..ff5b138 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 783e251..ca0b1e8 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 6141267..4e30a65 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index ee930bd..76da0cd 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index b88b872..a9efa71 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 502fb77..c48f59b 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index aef3e7d..66dc373 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index e5b8f3e..12cc8fe 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
@@ -26,7 +26,6 @@
     <link rel="stylesheet" type="text/css" href="css/igoogle.css" media="all"/>
     <script type="text/javascript">var platal_baseurl = "{$globals->baseurl}/";</script>
     {javascript name=jquery}
-    {javascript name=ajax}
     {javascript name=xorg}
     {javascript name=igoogle}
   </head>
index e21a395..4dc9286 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 544eed0..27c51b4 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 7bff358..efb0882 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index b221242..345eb7e 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index f97055a..65f5fb2 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 774a3a9..dc37e8e 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 643acf7..54d8391 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 8db9aa7..656c731 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 518bda8..b1a3f7e 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
   {if $name eq "email"}<td></td>{/if}
   <td>
     <span class="{$new}" style="display: none">
-      <input type="text" maxlength="60" {if $error}class="error" value="{$val}"{/if} name="{if (($name neq "email_directory")
+      <input type="text" maxlength="255" {if $error}class="error" value="{$val}"{/if} name="{if (($name neq "email_directory")
       && ($name neq "email"))}jobs[{$i}][{$prefix}email_new]{else}{$name}_new{/if}"/>
     </span>
     <script type="text/javascript">//<![CDATA[
index a322c8d..eef48ac 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 536985c..f80d96b 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 2757bff..4103328 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 6059b43..43ea1b4 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 05ba17e..c5c3c51 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 3f25227..a612960 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 2efe011..530ed5a 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index e39cc50..a8e0c20 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 1918347..5d73119 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
 <label><input type="radio" name="assotype" value="" {if !$valid->asso}checked="checked"{/if} />quelconque</label>
 <label><input type="radio" name="assotype" value="alias" {if $valid->asso eq "alias"}checked="checked"{/if} />alias</label>
 <label><input type="radio" name="assotype" value="groupex" {if $valid->asso eq "groupex"}checked="checked"{/if} />groupe X</label><br />
-<strong>Domaine&nbsp;:</strong> <input type="text" name="domainname" size="25" maxlength="200" value="{$valid->domain}" />
+<strong>Domaine&nbsp;:</strong> <input type="text" name="domainname" size="25" maxlength="200" value="{$valid->domain}" /><br />
+<strong>Gestionnaires&nbsp;:</strong>
+{foreach from=$valid->owners item=email key=i}
+<input type="text" name="owners_{$i}" size="40" value="{$email}" /><br />
+{/foreach}
+<strong>Membres&nbsp;:</strong>
+{foreach from=$valid->members item=email key=i}
+<input type="text" name="members_{$i}" size="40" value="{$email}" /><br />
+{/foreach}
 
 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index 5bb452f..f2b442e 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 8d92f73..b8de1e0 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index a0c52d2..fa71eb2 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 78d2c60..2273a71 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index a81b655..32a26b0 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index d3726b1..a8faed7 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index af4522e..9a5da91 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 6945ce8..8a99686 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index d12ee01..44b6ab3 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index fcf5db9..0d8f6fa 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 954910a..57383a7 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index e9f0351..2210a93 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 3419c3a..b346d63 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 40bd5d1..58f5663 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 6bbf8ec..4dcc9b7 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 2b7c5f2..59cea1a 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index dc0a758..c527e8a 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 9336ad1..b634f6e 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 683c5b7..9752602 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index acd256a..4f29aaa 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 7e128a9..f286df4 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 24e157d..c1ea80f 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 15d9db0..8db07cf 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index dc4cee0..a9e8e34 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index efcc665..c96b57e 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
@@ -40,7 +40,7 @@
   {/tidy}
   {if !t($nochange)}
   <div class="right">
-    <a href="events" onclick="Ajax.update_html('tod', 'ajax/tips/{$tips.id}'); return false" style="text-decoration: none">
+    <a href="events" onclick="$('#tod').updateHtml('ajax/tips/{$tips.id}'); return false" style="text-decoration: none">
       Astuce suivante {icon name=resultset_next title="Astuce suivante"}
     </a>
   </div>
index b6cde5b..067589a 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 24d8783..6bfc6e9 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index cc30bf1..5d92576 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index d3b8ae3..93326ef 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index dc40bd7..f3ced3b 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 1c81c27..6fb44fd 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index b5395cc..2eae636 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 93a7fbe..8c514b8 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 5b04544..17cf815 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 6c73b39..431b43e 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 6c7fddb..36bce05 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
 {*                                                                        *}
 {**************************************************************************}
 
+<script type="text/javascript">
+  //<![CDATA[
+  {literal}
+  function updateHtml(id, url)
+  {
+      if (is_IE) {
+          return true;
+      } else {
+          $('#' + id).updateHtml(url);
+          return false;
+      }
+  }
+  {/literal}
+  //]]>
+</script>
+
 <h1>
   Listes de diffusion de Polytechnique.org
 </h1>
index 575f8a6..e4954f5 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
@@ -38,7 +38,7 @@
   <strong>&bull; Demandes d'inscription</strong><br />
   {foreach from=$liste.subscriptions item=s}
     <a href='{$platal->ns}lists/moderate/{$liste.list}?sadd={$s.id}&amp;token={xsrf_token}'
-        onclick="return (is_IE || Ajax.update_html('list_{$liste.list}', '{$platal->ns}lists/ajax/{$liste.list}?sadd={$s.id}&amp;token={xsrf_token}'));">
+        onclick="return updateHtml('list_{$liste.list}', '{$platal->ns}lists/ajax/{$liste.list}?sadd={$s.id}&amp;token={xsrf_token}');">
       {icon name=add title="Accepter"}
     </a>
     <a href='{$platal->ns}lists/moderate/{$liste.list}?sid={$s.id}'>
   <span class="smaller">
   {foreach from=$liste.mails item=m}
     <a href='{$platal->ns}lists/moderate/{$liste.list}?mid={$m.id}&amp;mok=1&amp;token={xsrf_token}'
-        onclick="return (is_IE || Ajax.update_html('list_{$liste.list}', '{$platal->ns}lists/ajax/{$liste.list}?mid={$m.id}&amp;mok=1&amp;token={xsrf_token}'));">
+        onclick="return updateHtml('list_{$liste.list}', '{$platal->ns}lists/ajax/{$liste.list}?mid={$m.id}&amp;mok=1&amp;token={xsrf_token}');">
       {icon name=add title="Valider l'email"}
     </a>
     <a href='{$platal->ns}lists/moderate/{$liste.list}?mid={$m.id}&amp;mdel=1&amp;token={xsrf_token}'
-        onclick="return (is_IE || Ajax.update_html('list_{$liste.list}', '{$platal->ns}lists/ajax/{$liste.list}?mid={$m.id}&amp;mdel=1&amp;token={xsrf_token}'));">
+        onclick="return updateHtml('list_{$liste.list}', '{$platal->ns}lists/ajax/{$liste.list}?mid={$m.id}&amp;mdel=1&amp;token={xsrf_token}');">
       {icon name=delete title="Spam"}
     </a>
     De&nbsp;: {$m.sender}<br />
 <td class='right'>
   {if $liste.sub eq 2}
   <a href='{$platal->ns}lists?del={$liste.list}&amp;token={xsrf_token}'
-      onclick="return (is_IE || Ajax.update_html('list_{$liste.list}', '{$platal->ns}lists/ajax/{$liste.list}?unsubscribe=1&amp;token={xsrf_token}'));">
+      onclick="return updateHtml('list_{$liste.list}', '{$platal->ns}lists/ajax/{$liste.list}?unsubscribe=1&amp;token={xsrf_token}');">
     {icon name=cross title="me désinscrire"}
   </a>
   {elseif $liste.sub eq 1}
   {icon name=flag_orange title='inscription en attente de modération'}
   {else}
   <a href='{$platal->ns}lists?add={$liste.list}&amp;token={xsrf_token}'
-      onclick="return (is_IE || Ajax.update_html('list_{$liste.list}', '{$platal->ns}lists/ajax/{$liste.list}?subscribe=1&amp;token={xsrf_token}'));">
+      onclick="return updateHtml('list_{$liste.list}', '{$platal->ns}lists/ajax/{$liste.list}?subscribe=1&amp;token={xsrf_token}');">
     {icon name=add title="m'inscrire"}
   </a>
   {/if}
index a7cd1dd..f81bd71 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index f266b49..fc50c26 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 5607d4e..ffa59f9 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index d3bb82b..94ef8cf 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 64176c2..6b5136f 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 5ebf189..2a540e2 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index ce7c82b..9660164 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index f1bbc02..cff2452 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index c5d27aa..1bfbf79 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index e7fdb79..b83539f 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 52eb717..60111c1 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index f157b6c..f8bb491 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index e20cfb5..eef62ca 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index ee7233a..12313ce 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 29251da..048a7ee 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index b439377..efb2f1f 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 44bd393..1e8900b 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 04f4b6e..522403e 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 0e2d8b9..6912d5b 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 1fb8ae5..bda1f5f 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 708877b..1d1ea52 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 32d3454..b861e52 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index d22bd41..c5f68ff 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 58126d7..c1c8b97 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 0d7a42b..865cf72 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 79b0a69..b85ff83 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index aed89b3..f96dfb6 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 2007a77..dc40971 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 9608321..8770588 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 2dd17b2..3c6c39d 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 4c7f794..3dbe870 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
 {*                                                                        *}
 {**************************************************************************}
 
+{if t($anchor)}
+{literal}
+<script type="text/javascript">
+//<![CDATA[
+$(function() {
+{/literal}
+  location.hash = "#{$anchor}";
+{literal}
+});
+// ]]>
+</script>
+{/literal}
+{/if}
+
 <h1>{$asso->nom}&nbsp;: Gestion des télépaiements </h1>
 
 <p class="descr">
 Voici la liste des paiements en ligne possible pour le groupe {$asso->nom}&nbsp;:
 </p>
 
-{foreach from=$titres item=p}
+{foreach from=$titles item=p}
 
 <fieldset>
-<legend><a href="{$platal->ns}payment/{$p.id}">{icon name=money title="Télépaiement"}{$p.text}</a></legend>
+<legend id="legend_{$p.id}"><a href="{$platal->ns}payment/{$p.id}">{icon name=money title="Télépaiement"}{$p.text}</a></legend>
 
 {if $event[$p.id]}
 {assign var='ev' value=$event[$p.id]}
 <p>
-  {if $p.url}
+  {if t($p.url)}
   Plus d'informations sur ce télépaiement sont disponibles sur <a href="{$p.url}">cette page</a>.<br />
   {/if}
-  {if $ev.eid}
+  {if t($ev.eid)}
   Ce paiement est associé à l'événement <a href="{$platal->ns}events">{$ev.title}</a>.<br />
     {if $ev.ins}
     Tu es inscrit à cet événements.
@@ -68,51 +82,51 @@ Voici la liste des paiements en ligne possible pour le groupe {$asso->nom}&nbsp;
 <table cellpadding="0" cellspacing="0" id="list_{$p.id}" class='bicol'>
   <tr>
     <th>
-      {if $order eq 'timestamp'}
-        <a href='{$platal->ns}payment?order={$order}&order_inv={$order_inv}'>
+      {if $order eq 'timestamp' && $order_id eq $p.id}
+        <a href='{$platal->ns}payment?order={$order}&amp;order_inv={$order_inv}&amp;order_id={$p.id}'>
           <img src="{$platal->baseurl}images/{if !$order_inv}dn{else}up{/if}.png" alt="" title="Tri {if $order_inv}dé{/if}croissant" />
       {else}
-        <a href='{$platal->ns}payment?order=timestamp'>
+        <a href='{$platal->ns}payment?order=timestamp&amp;order_id={$p.id}'>
       {/if}Date</a>
     </th>
     <th colspan="2">
-      {if $order eq 'nom'}
-        <a href='{$platal->ns}payment?order={$order}&order_inv={$order_inv}'>
+      {if $order eq 'directory_name' && $order_id eq $p.id}
+        <a href='{$platal->ns}payment?order={$order}&amp;order_inv={$order_inv}&amp;order_id={$p.id}'>
           <img src="{$platal->baseurl}images/{if $order_inv}dn{else}up{/if}.png" alt="" title="Tri {if !$order_inv}dé{/if}croissant" />
       {else}
-        <a href='{$platal->ns}payment?order=nom'>{/if}
+        <a href='{$platal->ns}payment?order=directory_name&amp;order_id={$p.id}'>{/if}
       NOM Prénom</a>
     </th>
     <th>
-      {if $order eq 'promo'}
-        <a href='{$platal->ns}payment?order={$order}&order_inv={$order_inv}'>
+      {if $order eq 'promo' && $order_id eq $p.id}
+        <a href='{$platal->ns}payment?order={$order}&amp;order_inv={$order_inv}&amp;order_id={$p.id}'>
           <img src="{$platal->baseurl}images/{if $order_inv}dn{else}up{/if}.png" alt="" title="Tri {if !$order_inv}dé{/if}croissant" />
       {else}
-        <a href='{$platal->ns}payment?order=promo'>
+        <a href='{$platal->ns}payment?order=promo&amp;order_id={$p.id}'>
       {/if}Promo</a>
     </th>
     <th>
-      {if $order eq 't.comment'}
-        <a href='{$platal->ns}payment?order=comment&order_inv={$order_inv}'>
+      {if $order eq 'comment' && $order_id eq $p.id}
+        <a href='{$platal->ns}payment?order=comment&amp;order_inv={$order_inv}&amp;order_id={$p.id}'>
           <img src="{$platal->baseurl}images/{if $order_inv}dn{else}up{/if}.png" alt="" title="Tri {if !$order_inv}dé{/if}   siant" />
       {else}
-        <a href='{$platal->ns}payment?order=comment'>
+        <a href='{$platal->ns}payment?order=comment&amp;order_id={$p.id}'>
       {/if}Commentaire</a>
     </th>
     <th>
-      {if $order eq 'amount'}
-        <a href='{$platal->ns}payment?order={$order}&order_inv={$order_inv}'>
+      {if $order eq 'amount' && $order_id eq $p.id}
+        <a href='{$platal->ns}payment?order={$order}&amp;order_inv={$order_inv}&amp;order_id={$p.id}'>
           <img src="{$platal->baseurl}images/{if $order_inv}dn{else}up{/if}.png" alt="" title="Tri {if !$order_inv}dé{/if}croissant" />
       {else}
-        <a href='{$platal->ns}payment?order=montant'>
+        <a href='{$platal->ns}payment?order=amount&amp;order_id={$p.id}'>
       {/if}Montant</a>
     </th>
   </tr>
   {assign var="somme" value=0}
   {foreach from=$trans[$p.id] item=p name=people}
-  {if $p.nom neq "somme totale"}
+  {if !t($p.limit)}
   <tr>
-    <td class="center">{$p.date|date_format:"%d/%m/%y"}</td>
+    <td class="center">{if $p.date eq 0}-{else}{$p.date|date_format:"%d/%m/%y"}{/if}</td>
     <td>
       {profile user=$p.user promo=false}
     </td>
index e1a86be..8d6af94 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index df2fb77..a8813e3 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 5673e7d..e99136a 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 83d5d24..eeb21e1 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index a88b734..090c6cc 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 40913b5..c0e6951 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 07b01b2..d84d193 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index de70400..985ed11 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
@@ -27,7 +27,7 @@
 <script type="text/javascript">
 {literal}
 /* <![CDATA[ */
-$(document).ready(function() {
+$(function() {
   $("form input:radio").change(function() {
     $("#form").submit();
   });
index 9dc5cf2..255e798 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index d642ddb..b233c27 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index bdf34f4..e5bea8d 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
@@ -37,7 +37,7 @@ Pour toute information complémentaire, n'hésite pas à écrire à
   <tr>
     <td class="skigauche">
       <input type="radio" name="newskin" value="{$skin.id}" {if $skin_id eq $skin.id}checked="checked"{/if}
-        onclick="dynpostkv('prefs/skin', 'newskin', {$skin.id})" />
+        onclick="$.dynPost('prefs/skin', 'newskin', {$skin.id})" />
     </td>
     <td class="skimilieu">
       <strong>{$skin.name}</strong>
index e08f536..db17cfa 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index fcddb19..dbd8d94 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 1685807..c8659f4 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 34d5dcc..45a8d4d 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 69ebf09..e39d426 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 3905c2e..78cd3c2 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 53ba85e..cd11e40 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 3960e6a..daa58de 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index a5cf438..4c27f5f 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index e5df00c..f3a518f 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index a35e521..18313db 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
 {*                                                                        *}
 {**************************************************************************}
 
-{javascript name=ajax}
+<script type="text/javascript">
+  $($.closeOnEsc);
+</script>
+
 {assign var=terms value=$profile->getMentoringTerms()}
 {assign var=countries value=$profile->getMentoringCountries()}
 <div id="fiche">
index 5baed08..20c2e75 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index ccf59b0..9459d20 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 7636aee..74b4b8a 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 42157d3..7d96f08 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 5636c15..ede21f9 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 70deab5..f95dd33 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index ab575cb..2d6ef9a 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 77641e6..b4bace7 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 116f1f3..fdae749 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index a1836c8..a39bec9 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
       <td colspan="2" class="term_tree">
       </td>
     </tr>
+    <tr class="pair" id="term_tree_comment" style="display: none">
+      <td colspan="2" class="center"><small>La catégorie « Emplois » donne une liste de métiers, « Secteurs d'activité » décrit des secteurs.</small></td>
+    </tr>
     <tr class="pair" {if $hiddenjob}style="display: none"{/if}>
       <td class="titre">Description</td>
       <td>
index f496e24..67a8592 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index a24d2c1..5fc41e3 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index b2d41ca..c07aba1 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 83f6223..fa442d7 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 376b956..9169e3b 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 95667c1..da935a0 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
@@ -36,6 +36,9 @@ function chgMainWinLoc(strPage)
     document.location = strPage;
   }
 }
+
+$($.closeOnEsc);
+
 //]]></script>
 {/literal}
 
index 08e6757..45119fc 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 469bb15..7b423a8 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
@@ -76,7 +76,7 @@
       <select name="langues_sel" onchange="updateElement('langues')">
         <option value="">&nbsp;</option>
         {iterate from=$lang_list item=lang}
-        <option value="{$lang.id}">{$lang.langue_fr}</option>
+        <option value="{$lang.iso_639_2b}">{$lang.language}</option>
         {/iterate}
       </select>
       <span id="langues_add" style="display: none">
index 1d9ed15..395b8fb 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 8eba2fc..30ce31f 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 7435fdd..3ed8331 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 1824dd6..e8d938f 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index bd0d62a..bc1ebc6 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index fd8eb3a..4dde720 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 2dc0c2c..c61c9d5 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 5f0f545..6bac3be 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index dd44fc2..87251c5 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index ee2ce77..6ae6a64 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 11ae26c..ebfe16d 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
           <dd>
             de recevoir les informations importantes de l'AX.
           </dd>
-          {if $smarty.session.subState.eduType eq 'x'}
           <dt><label><input type="checkbox" checked="checked" name="ml_promo" /> ta promotion</label></dt>
           <dd>
             de recevoir les informations plus spécifiques de ta promotion pour pouvoir participer plus facilement aux événements
           <dd>
             d'avoir un accès de secours aux 30 derniers jours d'emails reçus sur ton adresse Polytechnique.org.
           </dd>
-          {/if}
         </dl>
       </td>
     </tr>
index e9b71a9..a4ef54b 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 6b0df7c..255bbec 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index a7a5277..6036871 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
         {$reminder->text()}
       </div>
       <div class="center">
-        <a href="reminder/yes" onclick="Ajax.update_html('reminder', '{$reminder->baseurl()}/yes'); return false" style="text-decoration: none">
+        <a href="reminder/yes" onclick="$('#reminder').updateHtml('{$reminder->baseurl()}/yes'); return false" style="text-decoration: none">
           {icon name=add} M'inscrire
         </a> -
-        <a href="reminder/no" onclick="Ajax.update_html('reminder', '{$reminder->baseurl()}/no'); return false" style="text-decoration: none">
+        <a href="reminder/no" onclick="$('#reminder').updateHtml('{$reminder->baseurl()}/no'); return false" style="text-decoration: none">
           {icon name=delete} Ne pas m'inscrire
         </a> -
-        <a href="reminder/later" onclick="Ajax.update_html('reminder', '{$reminder->baseurl()}/dismiss'); return false" style="text-decoration: none">
+        <a href="reminder/later" onclick="$('#reminder').updateHtml('{$reminder->baseurl()}/dismiss'); return false" style="text-decoration: none">
           {icon name=cross} Décider plus tard
         </a>
         {if $reminder->info()}
index 5a90b4f..182241c 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 7304234..14de0c0 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
   <a href="{$reminder->baseurl()}/yes" style="text-decoration: none">
     {icon name=add} M'inscrire
   </a> -
-  <a href="reminder/no" onclick="Ajax.update_html('reminder', '{$reminder->baseurl()}/no'); return false" style="text-decoration: none">
+  <a href="reminder/no" onclick="$('#reminder').updateHtml('{$reminder->baseurl()}/no'); return false" style="text-decoration: none">
     {icon name=delete} Ne pas m'inscrire
   </a> -
-  <a href="reminder/later" onclick="Ajax.update_html('reminder', '{$reminder->baseurl()}/dismiss'); return false" style="text-decoration: none">
+  <a href="reminder/later" onclick="$('#reminder').updateHtml('{$reminder->baseurl()}/dismiss'); return false" style="text-decoration: none">
     {icon name=cross} Décider plus tard
   </a> -
   <a class="popup2" style="text-decoration: none" href="Xorg/GoogleApps">{icon name=information} En savoir plus</a>
index e53b7d8..0ed0b74 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
 
   <div class="center">
     <input type="submit" value="M'inscrire aux listes" /> -
-    <a href="reminder/no" onclick="Ajax.update_html('reminder', '{$reminder->baseurl()}/no'); return false" style="text-decoration: none">
+    <a href="reminder/no" onclick="$('#reminder').updateHtml('{$reminder->baseurl()}/no'); return false" style="text-decoration: none">
       {icon name=delete} Ne pas m'inscrire
     </a> -
-    <a href="reminder/later" onclick="Ajax.update_html('reminder', '{$reminder->baseurl()}/dismiss'); return false" style="text-decoration: none">
+    <a href="reminder/later" onclick="$('#reminder').updateHtml('{$reminder->baseurl()}/dismiss'); return false" style="text-decoration: none">
       {icon name=cross} Décider plus tard
     </a>
   </div>
index 021095b..cfcdcf9 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 4f43969..200883d 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 55bf9db..09881c3 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
@@ -51,7 +51,7 @@
 {/if}
 
 <div class="right">
-  <a href="reminder/later" onclick="Ajax.update_html('reminder', '{$reminder->baseurl()}/dismiss'); return false" style="text-decoration: none">
+  <a href="reminder/later" onclick="$('#reminder').updateHtml('{$reminder->baseurl()}/dismiss'); return false" style="text-decoration: none">
     {icon name=cross} Mettre à jour plus tard
   </a>
 </div>
index b239e4e..d3bc2d8 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
       };
   }
 
-  // when changing country, open up region choice
+  // when changing country, open up administrativearea choice
   function changeCountry(a2) {
     $(".autocompleteTarget[name='country']").attr('value',a2);
 
     if (a2) {
       $(".autocomplete[name='countryTxt']").addClass('hidden_valid');
 
-      $("[name='region']").parent().load(baseurl + 'list/region/', { country:a2 }, function() {
-          if ($("select[name='region']").children("option").size() > 1) {
-            $("select[name='region']").attr('value', '{/literal}{$smarty.request.region}{literal}');
+      $("[name='administrativearea']").parent().load(baseurl + 'list/administrativearea/', { country:a2 }, function() {
+          if ($("select[name='administrativearea']").children("option").size() > 1) {
+            $("select[name='administrativearea']").attr('value', '{/literal}{$smarty.request.administrativearea}{literal}');
 
-            $("tr#region_ln").show();
+            $("tr#administrativearea_list").show();
           } else {
-            $("select[name='region']").attr('value', '');
+            $("select[name='administrativearea']").attr('value', '');
 
-            $("tr#region_ln").hide();
+            $("tr#administrativearea_list").hide();
           }
         });
     } else {
       $(".autocomplete[name='countryTxt']").removeClass('hidden_valid');
 
-      $("select[name='region']").attr('value', '');
+      $("select[name='administrativearea']").attr('value', '');
+      $("select[name='subadministrativearea']").attr('value', '');
 
-      $("tr#region_ln").hide();
+      $("tr#administrativearea_list").hide();
+      $("tr#subadministrativearea_list").hide();
+    }
+  }
+
+  // when changing administrativearea, open up subadministrativearea choice
+  function changeAdministrativeArea(id) {
+    if (id) {
+      $("[name='subadministrativearea']").parent().load(baseurl + 'list/subadministrativearea/', { administrativearea:id }, function() {
+          if ($("select[name='subadministrativearea']").children("option").size() > 1) {
+            $("select[name='subadministrativearea']").attr('value', '{/literal}{$smarty.request.subadministrativearea}{literal}');
+            $("tr#subadministrativearea_list").show();
+          } else {
+            $("select[name='subadministrativearea']").attr('value', '');
+            $("tr#subadministrativearea_list").hide();
+          }
+        });
+    } else {
+      $("select[name='subadministrativearea']").attr('value', '');
+      $("tr#subadministrativearea_list").hide();
     }
   }
 
       if (nameRealField == name)
         return null;
 
-      // if changing country, might want to open region choice
+      // if changing country, might want to open administrativearea choice
       if (nameRealField == 'country')
         return function(i) {
             if (i.extra[0] < 0) {
       }
     }
 
-  $(document).ready(function() {
+  $(function() {
       $(".autocompleteTarget").hide();
       $(".autocomplete").show().each(function() {
         targeted = $("../.autocompleteTarget",this)[0];
       $(".autocomplete[name='countryTxt']").change(function() { changeCountry(''); });
 
       changeCountry({/literal}'{$smarty.request.country}'{literal});
+      changeAdministrativeArea({/literal}'{$smarty.request.administrativearea}'{literal});
 
       $(".autocomplete[name='schoolTxt']").change(function() { changeSchool(''); });
 
@@ -264,7 +285,7 @@ function cleanForm(f) {
               f.egal2.value = '>=';
             }
           }
-          $(document).ready(function() { updatepromofields($('select[name=egal1]')[0]); });
+          $(function() { updatepromofields($('select[name=egal1]')[0]); });
           {/literal}
         /*]]>*/</script>
         <select name="egal1" onchange="updatepromofields(this)" style="text-align:center">
@@ -354,10 +375,16 @@ function cleanForm(f) {
         <a href="country" class="autocompleteToSelect">{icon name="table" title="Tous les pays"}</a>
       </td>
     </tr>
-    <tr id="region_ln">
-      <td>Région ou département</td>
+    <tr id="administrativearea_list">
+      <td>Région, province, état&hellip;</td>
       <td>
-        <input name="region" type="hidden" size="32" value="{$smarty.request.region}"/>
+        <input name="administrativearea" type="hidden" size="32" value="{$smarty.request.administrativearea}" />
+      </td>
+    </tr>
+    <tr id="subadministrativearea_list">
+      <td>Département, comté&hellip;</td>
+      <td>
+        <input name="subadministrativearea" type="hidden" size="32" value="{$smarty.request.subadministrativearea}" />
       </td>
     </tr>
     <tr>
@@ -497,6 +524,7 @@ function cleanForm(f) {
       </td>
         {/if}
         {if $smarty.session.auth ge AUTH_COOKIE}
+    </tr>
     <tr>
       <td colspan="2">
           <input type='checkbox' name='order' value='date_mod' {if $smarty.request.order eq "date_mod"}checked='checked'{/if} id="order"/>
index 9807c61..a0fa530 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 381d450..58b0d58 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 8d8b1e4..b8988b3 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
   {if $search_results_nb eq 1}{literal}
     <script type="text/javascript">
       // popup automatically if only one result
-      var alinks = document.getElementById('content').getElementsByTagName('a');
-      for (i = 0; i < alinks.length; i++) {
-        if (alinks[i].className == 'popup2') {
-          popWin(alinks[i], 840, 600);
-          break;
-        }
-      }
+      $(function() {
+        $('#content a.popup2').click();
+      });
     </script>
   {/literal}{/if}
 
index 228ba81..f513fc4 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
@@ -66,7 +66,7 @@
 {if $show_js}
 {literal}
 <script type="text/javascript">
-  $(document).ready(function() {
+  $(function() {
     $("#quick_form input[name='quick']").focus();
   });
 </script>
index 8cdeac7..52f34b8 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index ab57b71..40559e6 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
 Actuellement, {$mentors_number} mentors et référents se sont déclarés sur {#globals.core.sitename#}.
 </p>
 
-{javascript name=ajax}
 {javascript name=jquery.jstree}
 {javascript name=jobtermstree}
 <script type="text/javascript">//<![CDATA[
 
 var baseurl = platal_baseurl + "referent/";
 {literal}
-var Ajax2 = new AjaxEngine();
 
 /** Hides or display tree of all job terms */
 function toggleJobTermsTree()
index be77976..1846e97 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index f36feab..c904f1c 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 013c189..b1cb6e6 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 4723f3e..558086e 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
@@ -21,7 +21,7 @@
 {**************************************************************************}
 
 <div>
-  Plat/al <a href="changelog">{#globals.version#}</a> - Copyright © 1999-2010 <a href="http://x-org.polytechnique.org/">Polytechnique.org</a>
+  Plat/al <a href="changelog">{#globals.version#}</a> - Copyright © 1999-2011 <a href="http://x-org.polytechnique.org/">Polytechnique.org</a>
   &nbsp;-&nbsp;
   <a href="Reference/Convention-AX">Lien avec l'AX</a>
   &nbsp;-&nbsp;
index 1970992..78affff 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 57b687a..d9e53a4 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index b78620c..95ee884 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
 {*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
 {*                                                                        *}
 {**************************************************************************}
-          <table>
-            <tr>
-              <td class="date-heure">
-                <script type="text/javascript">
-                  <!--
-                  document.write(getNow());
-                  //-->
-                </script>
-              </td>
-              <td class="inscrits">
-                {$globals->core->NbIns|number_format} polytechniciens sur le web
-                {if t($smarty.request.quick)}
-                  {assign var=requestQuick value=$smarty.request.quick|smarty:nodefaults}
-                {else}
-                  {assign var=requestQuick value='Recherche dans l\'annuaire'}
-                {/if}
-                <form action="search" method="get">
-                    <div>
-                        <button id="quick_button" type="submit" style="display: none"
-                                onclick="if ($('#quick').val() === 'Recherche dans l\'annuaire') $('#quick').val('')">
-                          OK
-                        </button>
-                        <input type="text" size="20" name="quick" id="quick" class="quick_search"
-                               value="{$requestQuick}"
-                               onfocus="if (this.value === 'Recherche dans l\'annuaire') this.value='';
-                                        $('#quick_button').show()"
-                               onblur="if (this.value === '') this.value='{$requestQuick|escape:javascript}'"
-                               />
-                    </div>
-                </form>
-                {if $smarty.session.auth gt AUTH_PUBLIC && $smarty.session.notifs}
-                <a href="carnet/panel">{$smarty.session.notifs} événement{if $smarty.session.notifs gt 1}s{/if}</a>
-                {/if}
-              </td>
-            </tr>
-          </table>
+
+<table>
+  <tr>
+    <td class="date-heure"></td>
+    <td class="inscrits">
+      {$globals->core->NbIns|number_format} polytechniciens sur le web
+      {if t($smarty.request.quick)}
+        {assign var=requestQuick value=$smarty.request.quick|smarty:nodefaults}
+      {else}
+        {assign var=requestQuick value='Recherche dans l\'annuaire'}
+      {/if}
+      <form action="search" method="get">
+          <div>
+              <button id="quick_button" type="submit" style="display: none">
+                OK
+              </button>
+              <input type="text" size="20" name="quick" id="quick" class="quick_search"
+                     value="{$requestQuick}" />
+          </div>
+      </form>
+      {if $smarty.session.auth gt AUTH_PUBLIC && $smarty.session.notifs}
+      <a href="carnet/panel">{$smarty.session.notifs} événement{if $smarty.session.notifs gt 1}s{/if}</a>
+      {/if}
+    </td>
+  </tr>
+</table>
 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index 66e41e2..696dc7a 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index ce82b94..ea8d1f2 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 8857323..dac7c4d 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index dd63773..e31a983 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index fe108ed..c8b017f 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 35c62dc..dcbbad1 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 41f517c..fc46d53 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index a262554..9dd40f8 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index d34754d..46b9abd 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 3953c99..519442e 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 58562a8..fa7acdb 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 637090b..e8e18b8 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 24c785b..be3b1c5 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 9fc4419..ce5db23 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 6de1aae..4143611 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index d42e16d..99c1922 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index a8e629c..fe9381e 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index fc229d5..b6d8a8d 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
diff --git a/templates/survey/admin.tpl b/templates/survey/admin.tpl
deleted file mode 100644 (file)
index 5772098..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-{**************************************************************************}
-{*                                                                        *}
-{*  Copyright (C) 2003-2010 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>Sondages</h1>
-
-<table class="bicol">
-  <tr>
-    <th>
-      Sondages en cours
-    </th>
-  </tr>
-  {iterate item=s from=$survey_current}
-  <tr class="{cycle name=cs_cycle values="impair,pair"}">
-    <td class="half">
-      &bull;
-      <a href="survey/admin/{$s.id}">
-        {$s.title} [{$s.end|date_format:"%x"} - {$survey_modes[$s.mode]}]
-      </a>
-    </td>
-  </tr>
-  {assign var="has_cs" value="true"}
-  {/iterate}
-  {if !$has_cs}
-  <tr>
-    <td class="half">Aucun sondage en cours</td>
-  </tr>
-  {/if}
-</table>
-
-<br />
-
-<table class="bicol">
-  <tr>
-    <th>
-      Anciens sondages
-    </th>
-  </tr>
-  {iterate item=s from=$survey_old}
-  <tr class="{cycle name=os_cycle values="impair,pair"}">
-    <td class="half">
-      &bull;
-      <a href="survey/admin/{$s.id}">
-        {$s.title} [{$s.end|date_format:"%x"} - {$survey_modes[$s.mode]}]
-      </a>
-    </td>
-  </tr>
-  {assign var="has_os" value="true"}
-  {/iterate}
-  {if !$has_os}
-  <tr>
-    <td class="half">Aucun ancien sondage</td>
-  </tr>
-  {/if}
-</table>
-
-{* vim:set et sw=2 sts=2 ts=8 enc=utf-8: *}
diff --git a/templates/survey/edit.questions.tpl b/templates/survey/edit.questions.tpl
new file mode 100644 (file)
index 0000000..a8a9646
--- /dev/null
@@ -0,0 +1,92 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2011 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               *}
+{*                                                                        *}
+{**************************************************************************}
+
+{literal}
+<script id="q_edit_new" type="text/x-jquery-tmpl">
+  <div style="clear: both; padding-top: 1em" class="q_edit" id="q_edit[${qid}]">
+    <div>
+      <span class="q_edit_label" style="font-weight: bold">Question ${qid + 1}</span> 
+      (<a onclick="$(this).removeQuestion()" style="text-decoration: none">
+        {/literal}{icon name="delete"}{literal} Supprimer
+      </a>)
+    </div>
+    Titre&nbsp;: <input type="text" name="q_edit[${qid}][label]"
+                        value="{{if label}}${label}{{/if}}" /><br />
+    Type de question&nbsp;: <select name="q_edit[${qid}][type]">
+      <option value=""></option>
+      <option value="section" {{if type}}{{if type == 'section'}}selected="selected"{{/if}}{{/if}}>
+        Section
+      </option>
+      <option value="text" {{if type}}{{if type == 'text'}}selected="selected"{{/if}}{{/if}}>
+        Texte
+      </option>
+      <option value="multiple" {{if type}}{{if type == 'multiple'}}selection="selected"{{/if}}{{/if}}>
+        Question à choix multiples
+      </option>
+    </select>
+    <div class="q_edit_form">
+      {{tmpl "#q_edit_base"}}
+    </div>
+  </div>
+</script>
+
+<script id="q_edit_base" type="text/x-jquery-tmpl">
+  {{if type}}
+    {{tmpl "#q_edit_" + type}}
+  {{/if}}
+</script>
+
+<script id="q_edit_text" type="text/x-jquery-tmpl">
+</script>
+
+<script id="q_edit_section" type="text/x-jquery-tmpl">
+  <div id="section_${qid}" style="padding-left: 4ex; border-left: 1px solid white">
+    {{if children}}
+      {{tmpl(children) "#q_edit_new"}}
+    {{/if}}
+    <div class="add_question">
+      <a onclick="$(this).addQuestion()" style="text-decoration: none">
+        {/literal}{icon name="add"}{literal} Ajouter une question
+      </a>
+    </div>
+  </div>
+</script>
+
+<script id="q_edit_multiple" typex="text/x-jquery-tmpl">
+  <div id="q_edit[${qid}][answers]">
+    <div class="add_answer">
+      <a onclick="$(this).multipleAddAnswer()">
+        {/literal}{icon name="add"}{literal} Ajouter une réponse
+      </a>
+    </div>
+    <div>
+      Ajouter une case Autre ?
+      <select name="q_edit[${qid}][allow_other]">
+        <option name="1">Oui</option>
+        <option name="" selected="selected">Non</option>
+      </select>
+    </div>
+  </div>
+</script>
+{/literal}
+
+{* vim:set et sw=2 sts=2 ts=8 enc=utf-8: *}
diff --git a/templates/survey/edit.tpl b/templates/survey/edit.tpl
new file mode 100644 (file)
index 0000000..d2abf46
--- /dev/null
@@ -0,0 +1,76 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2011 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>Edition de sondage</h1>
+
+<form action="survey/edit/{$survey->shortname}" method="post" id="form">
+  <fieldset>
+    <legend>Description du sondage</legend>
+
+    Titre&nbsp;: <input type="text" name="title" value="{$survey->title}" /><br />
+    Nom&nbsp;: <input type="text" name="shortname" value="{$survey->shortname}" /><br />
+    Description&nbsp;:<br /><textarea name="description" style="width: 100%">{$survey->description}</textarea>
+  </fieldset>
+
+  <fieldset>
+    <legend>Paramètre du sondage</legend>
+    Premier jour&nbsp;: <input type="text" class="datepicker" name="begin" value="{$survey->begin}" /><br />
+    Dernier jour&nbsp;: <input type="text" class="datepicker" name="end" value="{$survey->end}" /><br />
+    Sondage anonyme&nbsp;: <label>Oui&nbsp;<input type="radio" name="anonymous" value="1" checked="checked" /></label>
+    <label><input type="radio" name="anonymous" value="0" />&nbsp;Non</label>
+  </fieldset>
+
+  <h2>Questions</h2>
+
+  <div id="questions" class="q_edit">
+    <div class="add_question">
+      <a onclick="$(this).addQuestion()" style="text-decoration: none">
+        {icon name="add"} Ajouter une question
+      </a>
+    </div>
+  </div>
+
+  <div class="center">
+    <input type="submit" name="valid" value="Soumettre" />
+  </div>
+</form>
+
+{include file="survey/vote.questions.tpl"}
+{include file="survey/edit.questions.tpl"}
+
+{literal}
+<script type="text/javascript">
+  //<![CDATA[
+  var questions = {/literal}{$survey->exportQuestionsToJSON()|smarty:nodefaults}{literal};
+
+  $(function() {
+    $('#form').submit(function() {
+      $(this).buildParentsQuestions();
+      return true;
+    });
+    $('#questions').prepareQuestions(questions);
+  });
+  //]]>
+</script>
+{/literal}
+
+{* vim:set et sw=2 sts=2 ts=8 enc=utf-8: *}
diff --git a/templates/survey/edit_checkbox.tpl b/templates/survey/edit_checkbox.tpl
deleted file mode 100644 (file)
index 3569cb6..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-{**************************************************************************}
-{*                                                                        *}
-{*  Copyright (C) 2003-2010 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               *}
-{*                                                                        *}
-{**************************************************************************}
-
-{include file='survey/edit_radio.tpl'}
-
-{* vim:set et sw=2 sts=2 ts=8 enc=utf-8: *}
diff --git a/templates/survey/edit_new.tpl b/templates/survey/edit_new.tpl
deleted file mode 100644 (file)
index ea6d666..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-{**************************************************************************}
-{*                                                                        *}
-{*  Copyright (C) 2003-2010 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               *}
-{*                                                                        *}
-{**************************************************************************}
-    <tr>
-      <td class="titre">Type</td>
-      <td>
-        <select name="survey_type" id="survey_type" onchange="Ajax.update_html('survey_form', 'survey/ajax/' + document.getElementById('survey_type').value); return false">
-        {foreach from=$survey_types key='stype_v' item='stype_t'}
-          <option value="{$stype_v}"{if $survey_type eq $stype_v} selected="selected"{/if}>{$stype_t}</option>
-        {/foreach}
-        </select>
-      </td>
-    </tr>
-    {if $survey_type == "new"}
-      {include file='survey/edit_question.tpl'}
-    {else}
-      {include file="survey/edit_$survey_type.tpl"}
-    {/if}
-
-{* vim:set et sw=2 sts=2 ts=8 enc=utf-8: *}
diff --git a/templates/survey/edit_newsurvey.tpl b/templates/survey/edit_newsurvey.tpl
deleted file mode 100644 (file)
index ec9e61e..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-{**************************************************************************}
-{*                                                                        *}
-{*  Copyright (C) 2003-2010 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               *}
-{*                                                                        *}
-{**************************************************************************}
-
-    <tr>
-      <td colspan='2'>
-        Remplissez ici une description générale du sondage, puis cliquer sur "Continuer"
-        pour passer à l'édition des questions.
-      </td>
-    </tr>
-{include file='survey/edit_root.tpl'}
-
-{* vim:set et sw=2 sts=2 ts=8 enc=utf-8: *}
diff --git a/templates/survey/edit_num.tpl b/templates/survey/edit_num.tpl
deleted file mode 100644 (file)
index b62ed4b..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-{**************************************************************************}
-{*                                                                        *}
-{*  Copyright (C) 2003-2010 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               *}
-{*                                                                        *}
-{**************************************************************************}
-
-    {include file='survey/edit_question.tpl'}
-
-{* vim:set et sw=2 sts=2 ts=8 enc=utf-8: *}
diff --git a/templates/survey/edit_question.tpl b/templates/survey/edit_question.tpl
deleted file mode 100644 (file)
index 11e0858..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-{**************************************************************************}
-{*                                                                        *}
-{*  Copyright (C) 2003-2010 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               *}
-{*                                                                        *}
-{**************************************************************************}
-
-    <tr>
-      <td class="titre">Question</td>
-      <td><input type="text" name="survey_question[question]" size="50" maxlength="200" value="{$survey_current.question}"{if $disable_question} disabled="disabled"{/if}/></td>
-    </tr>
-    <tr>
-      <td class="titre">Commentaire</td>
-      <td><textarea name="survey_question[comment]" rows="5" cols="60">{$survey_current.comment}</textarea></td>
-    </tr>
-    <tr>
-      <td></td>
-      <td class="smaller">
-        <a href="wiki_help/notitle" class="popup3">
-          {icon name=information title="Syntaxe wiki"} Voir la syntaxe wiki autorisée pour le commentaire d'une question
-        </a>
-      </td>
-    </tr>
-    <script type="text/javascript">//<![CDATA[
-      var id = new Array();
-      id['choices'] = {$survey_current.choices|@count};
-      id['subquestions'] = {$survey_current.subquestions|@count};
-      {literal}
-      function newField(name, tid)
-      {
-        fid = "t" + id[name];
-        $("#" + name + "_" + tid).before('<div id="' + name + '_' + fid + '">'
-            + '<input id="' + name + '_' + fid + '_field" type="text" name="survey_question[' + name + '][' + fid + ']" size="50" maxlength="200" value="" />&nbsp;'
-            + '<a href="javascript:removeField(&quot;' + name + '&quot;,&quot;' + fid + '&quot;)"><img src="images/icons/delete.gif" alt="" title="Supprimer" /></a>'
-            + '</div>');
-        id[name]++;
-        $("#" + name + "_" + fid + "_field").focus();
-      }
-      function removeField(name, tid)
-      {
-        $("#" + name + "_" + tid).remove();
-      }
-      {/literal}
-    //]]></script>
-
-{* vim:set et sw=2 sts=2 ts=8 enc=utf-8: *}
diff --git a/templates/survey/edit_radio.tpl b/templates/survey/edit_radio.tpl
deleted file mode 100644 (file)
index 8b4e1b2..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-{**************************************************************************}
-{*                                                                        *}
-{*  Copyright (C) 2003-2010 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               *}
-{*                                                                        *}
-{**************************************************************************}
-
-    {include file='survey/edit_question.tpl'}
-    <tr>
-      <td class="titre">Choix</td>
-      <td>
-        {foreach from=$survey_current.choices key=value item=choice}
-        <div id="choices_t{$value}">
-          <input type="text" name="survey_question[choices][t{$value}]" size="50" maxlength="200" value="{$choice}" />
-          <a href="javascript:removeField('choices','t{$value}')">{icon name=delete title="Supprimer"}</a>
-        </div>
-        {/foreach}
-        <div id="choices_last">
-          <a href="javascript:newField('choices','last')">{icon name=add}</a>
-        </div>
-      </td>
-    </tr>
-
-{* vim:set et sw=2 sts=2 ts=8 enc=utf-8: *}
diff --git a/templates/survey/edit_root.tpl b/templates/survey/edit_root.tpl
deleted file mode 100644 (file)
index 3bc93cf..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-{**************************************************************************}
-{*                                                                        *}
-{*  Copyright (C) 2003-2010 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               *}
-{*                                                                        *}
-{**************************************************************************}
-
-    <tr>
-      <td class="titre">Titre</td>
-      <td><input type="text" name="survey_question[title]" size="50" maxlength="200" value="{$survey_current.title}"/></td>
-    </tr>
-    <tr>
-      <td class="titre">Commentaire</td>
-      <td><textarea name="survey_question[description]" rows="5" cols="60">{$survey_current.description}</textarea></td>
-    </tr>
-    <tr>
-      <td></td>
-      <td class="smaller">
-        <a href="wiki_help/notitle" class="popup3">
-          {icon name=information title="Syntaxe wiki"} Voir la syntaxe wiki autorisée pour le commentaire du sondage
-        </a>
-      </td>
-    </tr>
-    <tr>
-      <td class="titre">Date de fin</td>
-      <td>
-        {valid_date name="survey_question[end]" value=$survey_current.end to=90}
-    <script type="text/javascript">//<![CDATA[
-      {literal}
-      $(document).ready(function() {
-        function hidePromo(value) {
-          if (value == "0" || value == "") {
-            $("#ln_promo").hide();
-            $("#ln_promo_exp").hide();
-          } else {
-            $("#ln_promo").show();
-            $("#ln_promo_exp").show();
-          }
-        }
-        $("[name='survey_question[mode]']").change(function() { hidePromo(this.value); });
-        hidePromo({/literal}"{$survey_current.mode}"{literal});
-      });
-      {/literal}
-    //]]></script>
-      </td>
-    </tr>
-    <tr>
-      <td class="titre">Type de sondage</td>
-      <td>
-        <select name="survey_question[mode]">
-          {foreach from=$survey_modes item=text key=name}
-          <option value="{$name}" {if $name eq $survey_current.mode}selected="selected"{/if}>{$text}</option>
-          {/foreach}
-        </select>
-      </td>
-    </tr>
-    <tr id="ln_promo">
-      <td class="titre">Promotions</td>
-      <td><input type="text" name="survey_question[promos]" size="50" maxlength="200" value="{$survey_current.promos}"/></td>
-    </tr>
-    <tr id="ln_promo_exp">
-      <td></td>
-      <td class="smaller">
-        Exemple&nbsp;: 1954,1986-1989,-1942,2000-&nbsp;&nbsp;&nbsp;restreindra le sondage à toutes les promotions suivantes&nbsp;:<br/>
-        1954, 1986 à 1989, toutes jusqu'à 1942 et toutes à partir 2000 (les bornes sont systématiquement incluses).<br />
-        Pour sélectionner toutes les promotions, laisser le vide.
-      </td>
-    </tr>
-
-{* vim:set et sw=2 sts=2 ts=8 enc=utf-8: *}
diff --git a/templates/survey/edit_survey.tpl b/templates/survey/edit_survey.tpl
deleted file mode 100644 (file)
index 0d3160b..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-{**************************************************************************}
-{*                                                                        *}
-{*  Copyright (C) 2003-2010 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>Sondage&nbsp;:
-  {if $survey_type == 'newsurvey'} créer un nouveau sondage
-  {elseif $survey_type == 'new'} ajouter une question
-  {elseif $survey_type == 'root'} modifier la description
-  {else} modifier une question
-  {/if}
-</h1>
-
-<form action="{$survey_formaction}" method="post">
-  <input type="hidden" name="survey_action" value="{$survey_action}"/>
-  <input type="hidden" name="survey_qid" value="{$survey_qid}"/>
-  <table class="bicol" id="survey_form">
-    {include file="survey/edit_$survey_type.tpl"}
-  </table>
-  <div class="center">
-    <input type="submit" name="survey_submit" value="{if $survey_type == 'newsurvey'}Continuer{else}Valider{/if}"/>
-    <input type="reset" name="survey_reset" value="Réinitialiser"/>
-    <input type="submit" name="survey_cancel" value="Annuler"/>
-  </div>
-</form>
-
-{* vim:set et sw=2 sts=2 ts=8 enc=utf-8: *}
diff --git a/templates/survey/edit_text.tpl b/templates/survey/edit_text.tpl
deleted file mode 100644 (file)
index b62ed4b..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-{**************************************************************************}
-{*                                                                        *}
-{*  Copyright (C) 2003-2010 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               *}
-{*                                                                        *}
-{**************************************************************************}
-
-    {include file='survey/edit_question.tpl'}
-
-{* vim:set et sw=2 sts=2 ts=8 enc=utf-8: *}
diff --git a/templates/survey/edit_textarea.tpl b/templates/survey/edit_textarea.tpl
deleted file mode 100644 (file)
index b62ed4b..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-{**************************************************************************}
-{*                                                                        *}
-{*  Copyright (C) 2003-2010 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               *}
-{*                                                                        *}
-{**************************************************************************}
-
-    {include file='survey/edit_question.tpl'}
-
-{* vim:set et sw=2 sts=2 ts=8 enc=utf-8: *}
diff --git a/templates/survey/error.tpl b/templates/survey/error.tpl
deleted file mode 100644 (file)
index 63c96d4..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-{**************************************************************************}
-{*                                                                        *}
-{*  Copyright (C) 2003-2010 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>Sondages&nbsp;: erreur</h1>
-
-{if !is_null($survey_errors) && is_array($survey_errors)}
-<table class="bicol">
-  <tr>
-    <th colspan='2'>Une ou plusieurs erreurs sont survenues</th>
-  </tr>
-  {foreach from=$survey_errors item=survey_error}
-  <tr class="{cycle values="impair,pair"}">
-    <td>&bull; {$survey_error.error}</td>
-    <td><a href="survey/edit/question/{$survey_error.question}">corriger</a></td>
-  </tr>
-  {/foreach}
-</table>
-{elseif $survey_message neq ""}
-  {$survey_message}
-{else}
-Une erreur inconnue est survenue dans l'édition de ce sondage. N'hésite pas à <a href='send_bug/{ $smarty.server.REQUEST_URI }'>signaler ce bug</a> s'il persiste.
-{/if}
-<br/>
-<a href="{$survey_link}">Retour</a>
-
-{* vim:set et sw=2 sts=2 ts=8 enc=utf-8: *}
index 1110521..6f8d914 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
 
 <h1>Sondages</h1>
 
-{* Survey::MODE_ALL equals 0. *}
-{assign var=SurveyMODE_ALL value=0}
-{if $survey_current->total() > 0 || $smarty.session.auth}
-<table class="bicol">
+{if $active->total() > 0}
+<table class="bicol" id="surveyList">
   <tr>
-    <th colspan="3">
+    <th>
       Sondages en cours
     </th>
+    {if hasPerm('admin')}
+    <th></th>
+    {/if}
   </tr>
-  {iterate item=s from=$survey_current}
-  {if $smarty.session.auth || $s.mode == $SurveyMODE_ALL}
-  <tr class="{cycle name=cs_cycle values="impair,pair"}">
-    <td class="half" style="clear: both">
-      <a href="survey/vote/{$s.id}">{$s.title}</a>
-      {if $s.uid eq $smarty.session.user->id() || hasPerm('admin')}
-      (<a href="survey/result/{$s.id}">résultats partiels</a>)
-      {/if}
-    </td>
+  {iterate from=$active item=survey}
+  <tr class="{cycle values="impair,pair"}">
     <td>
-      {$s.end|date_format:"%x"}
+      <a href="survey/vote/{$survey->shortname}">{$survey->title}</a>
     </td>
-    <td>
-      {$survey_modes[$s.mode]}
+    {if hasPerm('admin')}
+    <td style="text-align: right">
+      <a href="survey/edit/{$survey->shortname}">{icon name=page_edit}</a>
     </td>
+    {/if}
   </tr>
-    {assign var="has_cs" value="true"}
-  {/if}
   {/iterate}
-  <tr class="impair">
-    <td colspan="3" style="text-align: right">
-      {if $smarty.session.auth}<a href="survey/edit/new">{icon name=page_edit} Proposer un sondage</a>{/if}
-    </td>
-  </tr>
 </table>
 {/if}
-
 <br />
-
-<table class="bicol">
-  <tr>
-    <th colspan="3">
-      Anciens sondages
-    </th>
-  </tr>
-  {iterate item=s from=$survey_old}
-    {if $smarty.session.auth || $s.mode == $SurveyMODE_ALL}
-  <tr class="{cycle name=os_cycle values="impair,pair"}">
-    <td>
-      <a href="survey/result/{$s.id}">
-        {$s.title}
-      </a>
-    </td>
-    <td>
-      {$s.end|date_format:"%x"}
-    </td>
-    <td>
-      {$survey_modes[$s.mode]}
-    </td>
-  </tr>
-      {assign var="has_os" value="true"}
-    {/if}
-  {/iterate}
-  {if !$has_os}
-  <tr>
-    <td class="half">Aucun ancien sondage</td>
-  </tr>
-  {/if}
-</table>
+<div class="center">
+  <a href="survey/edit">{icon name=page_edit} Proposer un nouveau sondage</a>
+</div>
 
 {* vim:set et sw=2 sts=2 ts=8 enc=utf-8: *}
diff --git a/templates/survey/show_checkbox.tpl b/templates/survey/show_checkbox.tpl
deleted file mode 100644 (file)
index 8fc5388..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-{**************************************************************************}
-{*                                                                        *}
-{*  Copyright (C) 2003-2010 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 $survey_resultmode}
-  <ul>
-  {foreach item=sresult from=$squestion.result}
-    <li>{$squestion.choices[$sresult.answer]}&nbsp;: {$sresult.count*100/$survey.votes|string_format:"%.1f"}% ({$sresult.count} votes)</li>
-  {/foreach}
-  </ul>
-{else}
-  {assign var=sid value=$survey.id}
-  {assign var=sqid value=$squestion.id}
-  {if $survey_votemode}
-    {html_checkboxes name="survey$sid[$sqid]" options=$squestion.choices separator='<br/>'}
-  {else}
-    {html_checkboxes name="survey$sid[$sqid]" options=$squestion.choices separator='<br/>' disabled='disabled'}
-  {/if}
-{/if}
-
-{* vim:set et sw=2 sts=2 ts=8 enc=utf-8: *}
diff --git a/templates/survey/show_num.tpl b/templates/survey/show_num.tpl
deleted file mode 100644 (file)
index 37ca12f..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-{**************************************************************************}
-{*                                                                        *}
-{*  Copyright (C) 2003-2010 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               *}
-{*                                                                        *}
-{**************************************************************************}
-
-{include file='survey/show_text.tpl'}
-
-{* vim:set et sw=2 sts=2 ts=8 enc=utf-8: *}
diff --git a/templates/survey/show_radio.tpl b/templates/survey/show_radio.tpl
deleted file mode 100644 (file)
index 473bb05..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-{**************************************************************************}
-{*                                                                        *}
-{*  Copyright (C) 2003-2010 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 $survey_resultmode}
-  <ul>
-  {foreach item=sresult from=$squestion.result}
-    <li>{$squestion.choices[$sresult.answer]}&nbsp;: {$sresult.count*100/$survey.votes|string_format:"%.1f"}% ({$sresult.count} votes)</li>
-  {/foreach}
-  </ul>
-{else}
-  {assign var=sid value=$survey.id}
-  {assign var=sqid value=$squestion.id}
-  {if $survey_votemode}
-    {html_radios name="survey$sid[$sqid]" options=$squestion.choices separator='<br/>'}
-  {else}
-    {html_radios name="survey$sid[$sqid]" options=$squestion.choices separator='<br/>' disabled='disabled'}
-  {/if}
-{/if}
-
-{* vim:set et sw=2 sts=2 ts=8 enc=utf-8: *}
diff --git a/templates/survey/show_radiotable.tpl b/templates/survey/show_radiotable.tpl
deleted file mode 100644 (file)
index 9f24aa1..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-{**************************************************************************}
-{*                                                                        *}
-{*  Copyright (C) 2003-2010 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               *}
-{*                                                                        *}
-{**************************************************************************}
-
-<table class="bicol">
-  <tr class="pair">
-    <td></td>
-  {foreach from=$squestion.choices item=schoice}
-    <td>{$schoice}</td>
-  {/foreach}
-  </tr>
-{foreach from=$squestion.subquestions item=ssubq key=ssqid}
-  <tr class="{cycle values="impair,pair"}">
-    <td>{$ssubq}</td>
-    {assign var=sid value=$survey.id}
-    {assign var=sqid value=$squestion.id}
-    {if $survey_resultmode}
-      {foreach from=$squestion.choices item=schoice key=value}
-        <td>
-          {$squestion.result.$ssqid.$value*100/$survey.votes|string_format:"%.1f"}% ({$squestion.result.$ssqid.$value} votes)
-        </td>
-      {/foreach}
-    {else}
-      {foreach from=$squestion.choices item=schoice key=value}
-        <td>
-          <label><input type="radio" name="survey{$sid}[{$sqid}][{$ssqid}]" value="{$value}" {if !$survey_votemode}disabled="disabled" {/if}/></label>
-        </td>
-      {/foreach}
-    {/if}
-  </tr>
-{/foreach}
-</table>
-
-{* vim:set et sw=2 sts=2 ts=8 enc=utf-8: *}
diff --git a/templates/survey/show_root.tpl b/templates/survey/show_root.tpl
deleted file mode 100644 (file)
index ca606fd..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-{**************************************************************************}
-{*                                                                        *}
-{*  Copyright (C) 2003-2010 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>Sondage&nbsp;: {$survey.title}</h1>
-<form action="survey/vote{if $survey_votemode}/{$survey.id}{/if}" method='post'>
-<table style="width: 100%">
-  <tr>
-    <td>
-    <table class="bicol">
-      <tr class="pair">
-        <td colspan="2">{$survey.description|miniwiki|smarty:nodefaults}</td>
-      </tr>
-      <tr>
-        <td class="titre">Fin du sondage&nbsp;:</td>
-        <td>{$survey.end|date_format:"%x"}</td>
-      </tr>
-      <tr>
-        <td class="titre">Type de sondage&nbsp;:</td>
-        <td>{$survey_modes[$survey.mode]}</td>
-      </tr>
-      {if $survey.mode != Survey::MODE_ALL}
-      <tr>
-        <td class="titre">Promotions&nbsp;:</td>
-        <td>
-          {if $survey.promos eq "#"}
-          <span class="erreur">erreur</span>
-          {elseif $survey.promos eq ""}
-          aucune restriction
-          {else}
-          {$survey.promos}
-          {/if}
-        </td>
-      </tr>
-      {/if}
-      {if $survey_warning}
-      <tr class="pair">
-        <td colspan="2">{$survey_warning}</td>
-      </tr>
-      {/if}
-    </table>
-    {if $survey_resultmode}
-    <p class="smaller">{$survey.votes} personnes ont répondu à ce sondage.<br />
-      Récupérer <a href="survey/result/{$survey.id}/csv">l'ensemble des résultats</a> au format csv
-    </p>
-    {/if}
-    </td>
-    {if $survey_editmode && !$survey.valid}
-      {assign var="survey_editallmode" value=true}
-    {/if}
-    {if $survey_editmode}
-    <td style="width: 30%">
-      <a href='survey/edit/question/root'>{icon name=page_edit alt="Modifier" title="Modifier la description"}</a>
-      {if $survey_editallmode}<br /><a href='survey/edit/add/0'>{icon name=add title="Ajouter une question au début" alt="Ajouter"}</a>{/if}
-    </td>
-    {/if}
-  </tr>
-  {if is_array($survey.questions)}
-  {foreach from=$survey.questions item=squestion}
-  <tr>
-    <td>
-      {include file='survey/show_question.tpl' squestion=$squestion}
-    </td>
-    {if $survey_editallmode}
-    <td class="smaller" style="width: 30%; vertical-align: middle">
-      <a href='survey/edit/question/{$squestion.id}'>{icon name=page_edit title="Modifier cette question" alt="Modifier"}</a><br />
-      <a href='survey/edit/del/{$squestion.id}'>{icon name=delete title="Supprimer cette question" alt="Supprimer"}</a><br />
-      <a href='survey/edit/add/{$squestion.id+1}'>{icon name=add title="Ajouter une question après" alt="Ajouter"}</a>
-    </td>
-    {/if}
-  </tr>
-  {/foreach}
-  {/if}
-</table>
-<p class="center">
-  {if $smarty.session.survey_validate || ($survey_editmode && !$survey_updatemode)}
-  <a href='survey/edit/valid'>
-    {icon name=tick}
-    Proposer ce sondage
-  </a> |
-  <a href='survey/edit/cancel'>
-    {icon name=cross}
-    Annuler totalement la création de ce sondage
-  </a>
-  {elseif $survey_adminmode}
-  {if !$survey.valid}<a href="survey/admin/valid/{$survey.id}">Valider ce sondage</a> | {/if}
-  <a href="survey/admin/edit/{$survey.id}">{icon name=tick} Modifier ce sondage</a> |
-  <a href="survey/admin/del/{$survey.id}">{icon name=cross} Supprimer ce sondage</a> |
-  <a href="survey/admin">Retour</a>
-  {elseif $survey_votemode}
-  <input type='submit' name='survey_submit' value='Voter'/>
-  <input type='submit' name='survey_cancel' value='Annuler'/>
-  {else}
-  <a href="survey">Retour</a>
-  {/if}
-</p>
-</form>
-
-{* vim:set et sw=2 sts=2 ts=8 enc=utf-8: *}
diff --git a/templates/survey/show_text.tpl b/templates/survey/show_text.tpl
deleted file mode 100644 (file)
index 595b171..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-{**************************************************************************}
-{*                                                                        *}
-{*  Copyright (C) 2003-2010 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 $survey_resultmode}
-  {if count($squestion.result) == 0}
-  Aucune réponse n'a été donnée.
-  {else}
-    {if count($squestion.result) ==1}
-    Une réponse donnée par une d{else}Quelques réponses données par l{/if}es personnes sondées&nbsp;:
-    <ul>
-    {assign var=nbhidden value=0}
-    {foreach item=sresult from=$squestion.result}
-      {if trim($result.answer)}
-      <li>{$sresult.answer}</li>
-      {else}
-      {assign var=nbhidden value=$nbhidden+1}
-      {/if}
-    {/foreach}
-    {if $nbhidden > 0}
-      <li>{$nbhidden} réponse{if $nbhidden > 1}s{/if} vide{if $nbhidden > 1}s{/if}</li>
-    {/if}
-    </ul>
-  {/if}
-{else}
-  <input type="text" name="survey{$survey.id}[{$squestion.id}]" value="" size="50" maxlength="200" {if !$survey_votemode}disabled="disabled"{/if}/>
-{/if}
-
-{* vim:set et sw=2 sts=2 ts=8 enc=utf-8: *}
diff --git a/templates/survey/show_textarea.tpl b/templates/survey/show_textarea.tpl
deleted file mode 100644 (file)
index 6f18e90..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-{**************************************************************************}
-{*                                                                        *}
-{*  Copyright (C) 2003-2010 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 $survey_resultmode}
-  {if count($squestion.result) == 0}
-  Aucune réponse n'a été donnée.
-  {else}
-    {if count($squestion.result) ==1}
-    Une réponse donnée par une d{else}Quelques réponses données par l{/if}es personnes sondées&nbsp;:
-    <ul>
-    {assign var=nbhidden value=0}
-    {foreach item=sresult from=$squestion.result}
-      {if trim($result.answer)}
-      <li>{$sresult.answer}</li>
-      {else}
-      {assign var=nbhidden value=$nbhidden+1}
-      {/if}
-    {/foreach}
-    {if $nbhidden > 0}
-      <li><em>{$nbhidden} réponse{if $nbhidden > 1}s{/if} vide{if $nbhidden > 1}s{/if}</em></li>
-    {/if}
-    </ul>
-  {/if}
-{else}
-  <textarea name="survey{$survey.id}[{$squestion.id}]" rows="5" cols="60" {if !$survey_votemode}disabled="disabled"{/if}></textarea>
-{/if}
-
-{* vim:set et sw=2 sts=2 ts=8 enc=utf-8: *}
diff --git a/templates/survey/success.tpl b/templates/survey/success.tpl
deleted file mode 100644 (file)
index a2ad4bb..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-{**************************************************************************}
-{*                                                                        *}
-{*  Copyright (C) 2003-2010 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>Sondages&nbsp;: succès</h1>
-
-{if $survey_message neq ""}
-  {$survey_message}
-{else}
-  Opération réussie
-{/if}
-<br/>
-<a href="{$survey_link}">Retour</a>
-
-{* vim:set et sw=2 sts=2 ts=8 enc=utf-8: *}
similarity index 75%
rename from templates/survey/edit_checkboxtable.tpl
rename to templates/survey/vote.questions.tpl
index 14b11d9..a42428b 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
 {*                                                                        *}
 {**************************************************************************}
 
-{include file='survey/edit_radiotable.tpl'}
+{literal}
+<script id="question_base" type="text/x-jquery-tmpl">
+  {{tmpl "#question_" + type}}
+</script>
+
+<script id="question_section" type="text/x-jquery-tmpl">
+  <fieldset>
+    <legend>${label}</legend>
+
+    {{tmpl(children) "#question_base"}}
+  </fieldset>
+</script>
+
+<script id="question_text" type="text/x-jquery-tmpl">
+  <div>
+    <div>${label}</div>
+    <input type="text" name="qid[${qid}]" value="" />
+  </div>
+</script>
+{/literal}
 
 {* vim:set et sw=2 sts=2 ts=8 enc=utf-8: *}
similarity index 73%
rename from templates/survey/confirm.tpl
rename to templates/survey/vote.tpl
index b6f5552..0a771da 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
 {*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
 {*                                                                        *}
 {**************************************************************************}
-<h1>Sondages&nbsp;: confirmation</h1>
-
-<form action="{$survey_formaction}" method="post">
-  {if is_array($survey_formhidden)}
-    {foreach from=$survey_formhidden item=s_value key=s_key}
-  <input type="hidden" name="survey_{$s_key}" value="{$s_value}"/>
-    {/foreach}
-  {/if}
-  {if $survey_message neq ""}
-    {$survey_message}
-  {else}
-    Une confirmation est requise
-  {/if}
-  <br/>
-  <input type="submit" name="survey_submit" value="Confirmer"/>
-  <input type="submit" name="survey_cancel" value="Annuler"/>
+
+<h1>{$survey->title}</h1>
+
+<p>{$survey->description|miniwiki}</p>
+
+<form action="survey/vote/{$survey->shortname}" method="post">
+  <div id="questions">
+  </div>
+
+  <div class="center">
+    {xsrf_token_field}
+    <input type="submit" name="vote" value="Enregister mon vote" />
+  </div>
 </form>
 
+{include file="survey/vote.questions.tpl"}
+
+<script type="text/javascript">
+  //<![CDATA[
+  var questions = {$survey->exportQuestionsToJSON()|smarty:nodefaults};
+
+  $($("#questions").showQuestions(questions));
+  //]]>
+</script>
+
 {* vim:set et sw=2 sts=2 ts=8 enc=utf-8: *}
index a8c457e..1bbc4fd 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index a65d73b..b122562 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index a75ad85..dd3e7bc 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 2d2ac0c..b99311c 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index dca4813..018dffc 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 20ff2b6..aa7ed2e 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index b8a29af..6e67ba5 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
             <div>
               <select name="right" onchange="this.form.submit()" style="margin: 0; padding: 0">
                 {if hasPerm('admin') || ($suid && $smarty.session.suid.perms->hasFlag('admin'))}
-                <option value="admin" {if hasPerm('admin')}selected="selected"{/if}>Administrateur</option>
+                <option value="admin" {if hasPerm('admin') && !($suid && $smarty.session.suid.perms->hasFlag('admin'))}selected="selected"{/if}>Administrateur</option>
                 {/if}
-                <option value="anim" {if $is_admin && !hasPerm('admin')}selected="selected"{/if}>Animateur</option>
+                <option value="anim" {if $is_admin && !( hasPerm('admin') && !($suid && $smarty.session.suid.perms->hasFlag('admin')))}selected="selected"{/if}>Animateur</option>
                 <option value="member" {if !$is_admin && $is_member}selected="selected"{/if}>Membre</option>
                 <option value="logged" {if !$is_admin && !$is_member}selected="selected"{/if}>Non-membre</option>
               </select>
             - <a href="send_bug/{ $smarty.server.REQUEST_URI }" class="popup_840x600">signaler un bug</a>
           {/if}
           <br />
-          Plat/al {#globals.version#} - © Copyright 1999-2010 <a href="http://x-org.polytechnique.org/">Association Polytechnique.org</a>
+          Plat/al {#globals.version#} - © Copyright 1999-2011 <a href="http://x-org.polytechnique.org/">Association Polytechnique.org</a>
           <div class="pem">
             <a href="{$globals->baseurl}/pem/{$platal->pl_self()|replace:'/':'_'}/200">Liste1</a>
             <a href="{$globals->baseurl}/pem/{$platal->pl_self()|replace:'/':'_'}/400">Liste2</a>
index e2a1320..740430c 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 9b67d36..c40815f 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index f05b1c0..7a52462 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software, you can redistribute it and/or modify  *}
index 6816e40..99292bc 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
@@ -123,6 +123,19 @@ function deadlineChange(box)
       </td>
     </tr>
     <tr>
+      <td class="titre">
+        Notifier lors d'une inscriptions&nbsp;:
+      </td>
+      <td>
+        <select name="subscription_notification">
+          <option value='creator' {if $evt.subscription_notification eq 'creator'}selected='selected'{/if}>le créateur de l'événement</option>
+          <option value='animator' {if $evt.subscription_notification eq 'animator'}selected='selected'{/if}>les animateurs du groupe</option>
+          <option value='both' {if $evt.subscription_notification eq 'both'}selected='selected'{/if}>le créateur de l'événement et les animateurs du groupe</option>
+          <option value='nobody' {if $evt.subscription_notification eq 'nobody'}selected='selected'{/if}>personne</option>
+        </select>
+      </td>
+    </tr>
+    <tr>
       <td class='titre'>
         Options&nbsp;:
       </td>
@@ -167,7 +180,6 @@ function deadlineChange(box)
           <li>&lt;salutation&gt;, &lt;prenom&gt;, &lt;nom&gt;, &lt;montant&gt; et &lt;comment&gt; seront <strong>automatiquement</strong> remplacés par les informations adaptées.</li>
           <li><a href="wiki_help" class="popup3">{icon name=information} Tu peux utiliser une syntaxe wiki pour formatter ton texte.</a></li>
         </ul>
-        {javascript name=ajax}
         <div id="pay_preview" style="display: none">
           <strong>Aperçu du texte&nbsp;:</strong>
           <hr />
index 9447847..21940e7 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
@@ -73,7 +73,7 @@
         modifier
         {icon name=date_edit title="Édition de l'événement"}</a>]
       &nbsp;
-      [<a href="javascript:dynpostkv('{$platal->pl_self()}?token={xsrf_token}',{if !$archive}'archive'{else}'unarchive'{/if},{$e.eid})">
+      [<a href="javascript:$.dynPost('{$platal->pl_self()}?token={xsrf_token}',{if !$archive}'archive'{else}'unarchive'{/if},{$e.eid})">
         {if !$archive}
           archiver
           {icon name=package_add title="Archivage"}</a>]
@@ -82,7 +82,7 @@
           {icon name=package_delete title="Désarchivage"}</a>]
         {/if}
       &nbsp;
-      [<a href="javascript:dynpostkv('{$platal->ns}events?token={xsrf_token}','del',{$e.eid})"
+      [<a href="javascript:$.dynPost('{$platal->ns}events?token={xsrf_token}','del',{$e.eid})"
         onclick="return confirm('Supprimer l\'événement effacera la liste des inscrits et des paiements.\n Es-tu sûr de vouloir supprimer l\'événement&nbsp;?')">
         supprimer
       {icon name=delete title='Suppression'}</a>]
index a215378..13b7909 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 3f74368..61c7f23 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
similarity index 73%
rename from templates/survey/show_question.tpl
rename to templates/xnetevents/subscription-notif.mail.tpl
index 4acb162..e66d452 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
 {*                                                                        *}
 {**************************************************************************}
 
-  <h2>{$squestion.question}</h2>
-{if $squestion.comment != ''}
-  {$squestion.comment|miniwiki|smarty:nodefaults}<br/>
-{/if}
-{assign var='squestion_type' value=$squestion.type}
-{include file="survey/show_$squestion_type.tpl"}
+{config_load file="mails.conf" section="xnet_notification"}
+{if $mail_part eq 'head'}
+{from full=#from#}
+{subject text="[`$group`] $event"}
+{elseif $mail_part eq 'wiki'}
+Chers organisateurs,
+
+{$name} a mis a jour son inscription à cet événement. En voici le détail :
+{foreach from=$subs item=count key=i}
+{assign var=j value=$i-1}
+* {$moments.$j.titre} : {$count} personne{if $count > 1}s{/if}
+{/foreach}
 
-{* vim:set et sw=2 sts=2 ts=8 enc=utf-8: *}
+{include file="include/signature.mail.tpl"}
+{/if}
+{* vim:set et sw=2 sts=2 sws=2: *}
index eab92b5..28d18ec 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index b387273..81f12e3 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index eb9d165..2174220 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 79c7123..ae21a1f 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 006b3c0..130a254 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software, you can redistribute it and/or modify  *}
index dd0dc5a..54bcd53 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 0119ece..12dc248 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
   </tr>
   {/if}
 
+  {if $asso->positions|count}
+  <tr>
+    <td class="titre">
+      Bureau&nbsp;:
+    </td>
+    <td>
+      {foreach from=$asso->positions item=position}
+      <em>&bull;&nbsp;{$position.position}&nbsp;:</em> {profile user=$position.uid promo=true}<br />
+      {/foreach}
+    </td>
+  </tr>
+  {/if}
+
   {if $asso->forum}
   <tr>
     <td class="titre">
@@ -82,7 +95,7 @@
   {if $asso->ax}
   <tr>
     <td class="titre center" colspan="2">
-      groupe agréé par l'AX
+      groupe agréé par l'AX {if $asso->axDate}le {$asso->axDate}{/if}
     </td>
   </tr>
   {/if}
index ffd10e6..e0c77d6 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
@@ -79,7 +79,8 @@
     <tr>
       <td class="titre center" colspan="2">
         <label><input type="checkbox" value="1" name="ax" {if $asso->ax}checked="checked"{/if} />
-        groupe agréé par l'AX</label>
+        groupe agréé par l'AX</label> le <input type="text" size="10" maxlength="10" value="{$asso->axDate}" name="axDate" />
+        <small>(ex: 01/01/1970)</small>
       </td>
     </tr>
   </table>
     </tr>
 
     <tr>
+      <td class="titre">
+        Message de bienvenue&nbsp;:<br />
+        <em>envoyé à l'inscription</em>
+      </td>
+      <td>
+        <textarea cols='40' rows='8' name='welcome_msg'>{$asso->welcome_msg}</textarea>
+      </td>
+    </tr>
+
+    <tr>
       <td class="titre center" colspan="2">
         Diffusion de la liste des membres&nbsp;:
         <select name="pub">
   </div>
 
   <div class="center">
-    {javascript name=ajax}
     <div id="preview_descr" style="display: none; text-align: justify"></div>
     <br />
     <a href="wiki_help" class="popup3">
index acab579..2af3009 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 99a96d3..870bf9f 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index c323428..8e55619 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 019f3fa..dc33788 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 05b9b09..c8e38cb 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
@@ -29,8 +29,8 @@ function xStateChange(box)
     document.getElementById('xprenom').style.display = state;
     document.getElementById('xpromo').style.display = state;
     document.getElementById('xsearch').style.display = state;
-    Ajax.update_html('search_result',
-      '{/literal}{$platal->ns}{literal}member/new/ajax?login=' + document.getElementById('email').value);
+    $('#search_result').updateHtml('{/literal}{$platal->ns}{literal}member/new/ajax?login='
+                                  + $('#email').val());
 }
 
 var nom;
@@ -46,8 +46,7 @@ function searchX()
     var nom = document.getElementById('nom').value;
     var prenom = document.getElementById('prenom').value;
     var promo = document.getElementById('promo').value;
-    Ajax.update_html('search_result',
-      '{/literal}{$platal->ns}{literal}member/new/ajax?prenom=' + prenom + '&nom=' + nom + '&promo=' + promo);
+    $('#search_result').updateHtml('{/literal}{$platal->ns}{literal}member/new/ajax?prenom=' + prenom + '&nom=' + nom + '&promo=' + promo);
 }
 {/literal}
 //]]></script>
index 9bc5502..444344d 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index ea1050d..ca37807 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
         </select>
       </td>
     </tr>
+    <tr class="pair">
+      <td class="titre">
+        Poste&nbsp;:
+      </td>
+      <td>
+        <select name="group_position">
+          <option value=""{if $user->group_position eq ''} selected="selected"{/if}></option>
+          {foreach from=$positions item=position}
+          <option value="{$position}"{if $user->group_position eq $position} selected="selected"{/if}>{$position}</option>
+          {/foreach}
+        </select>
+      </td>
+    </tr>
     {if !$user->profile()}
     <tr class="impair">
       <td class="titre">
index 7589bed..6234ef8 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index ad23030..0372333 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index cbfef3d..4542dbd 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 9e677bc..654c45f 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 102fb48..4dbe5bf 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index a706ea6..c5e8441 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index 177ec28..75dcdbc 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index de2d2f2..a56029c 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
index be22639..e703d5b 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 #***************************************************************************
-#*  Copyright (C) 2003-2010 Polytechnique.org                              *
+#*  Copyright (C) 2003-2011 Polytechnique.org                              *
 #*  http://opensource.polytechnique.org/                                   *
 #*                                                                         *
 #*  This program is free software; you can redistribute it and/or modify   *
index 55db353..7ba74b4 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 #***************************************************************************
-#*  Copyright (C) 2003-2010 Polytechnique.org                              *
+#*  Copyright (C) 2003-2011 Polytechnique.org                              *
 #*  http://opensource.polytechnique.org/                                   *
 #*                                                                         *
 #*  This program is free software; you can redistribute it and/or modify   *
index da3d69c..e20a0d0 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index e55d8ae..718f381 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
diff --git a/upgrade/1.1.0/01_new_mail_schema.sql b/upgrade/1.1.0/01_new_mail_schema.sql
new file mode 100644 (file)
index 0000000..6113714
--- /dev/null
@@ -0,0 +1,84 @@
+DROP TABLE IF EXISTS email_source_account;
+DROP TABLE IF EXISTS email_source_other;
+DROP TABLE IF EXISTS homonyms_list;
+DROP TABLE IF EXISTS email_redirect_account;
+DROP TABLE IF EXISTS email_redirect_other;
+DROP TABLE IF EXISTS email_virtual;
+DROP TABLE IF EXISTS email_virtual_domains;
+
+CREATE TABLE email_source_account (
+       email  VARCHAR(255) NOT NULL PRIMARY KEY,
+       uid    INT(11) UNSIGNED NOT NULL,
+       type   ENUM('forlife','alias') NOT NULL DEFAULT 'forlife',
+       flags  SET('bestalias','usage','marital') NOT NULL DEFAULT '',
+       expire DATE DEFAULT NULL,
+       KEY (uid),
+       KEY (type),
+    FOREIGN KEY (uid) REFERENCES accounts (uid) ON UPDATE CASCADE ON DELETE CASCADE
+) ENGINE=InnoDB,  CHARSET=utf8 ;
+
+CREATE TABLE email_source_other (
+       email VARCHAR(255) NOT NULL PRIMARY KEY,
+       hrmid VARCHAR(255) NOT NULL,
+       type  ENUM('homonym','ax','honeypot'),
+       expire DATE NOT NULL DEFAULT '0000-00-00'
+) ENGINE=InnoDB,  CHARSET=utf8 ;
+
+CREATE TABLE homonyms_list (
+       hrmid VARCHAR(255) NOT NULL,
+       uid   INT(11) UNSIGNED NOT NULL,
+       KEY(hrmid)
+) ENGINE=InnoDB,  CHARSET=utf8 ;
+
+CREATE TABLE email_redirect_account (
+       uid           INT(11) UNSIGNED NOT NULL,
+       redirect      VARCHAR(255) NOT NULL DEFAULT '',
+       rewrite       VARCHAR(255) NOT NULL DEFAULT '',
+       type          ENUM('smtp','googleapps','imap','homonym') NOT NULL DEFAULT 'smtp',
+       action        ENUM('default',
+                          'drop_spams',
+                          'let_spams',
+                          'tag_and_drop_spams',
+                          'tag_spams',
+                          'imap_and_bounce',
+                          'homonym')
+               NOT NULL DEFAULT 'default',
+       broken        DATE NOT NULL DEFAULT '0000-00-00',
+       broken_level  TINYINT(1) NOT NULL DEFAULT 0,
+       last          DATE NOT NULL DEFAULT '0000-00-00',
+       flags         ENUM('active','inactive','broken','disabled') NOT NULL,
+       hash          VARCHAR(32) DEFAULT NULL,
+       allow_rewrite TINYINT(1) DEFAULT 0,
+       KEY (uid),
+       KEY (redirect)
+) ENGINE=InnoDB,  CHARSET=utf8 ;
+
+CREATE TABLE email_redirect_other (
+       hrmid         VARCHAR(255) NOT NULL DEFAULT '',
+       redirect      VARCHAR(255) NOT NULL DEFAULT '',
+       type          ENUM('smtp','googleapps','imap','homonym') NOT NULL DEFAULT 'smtp',
+       action        ENUM('default',
+                          'drop_spams',
+                          'let_spams',
+                          'tag_and_drop_spams',
+                          'tag_spams',
+                          'imap_and_bounce',
+                          'homonym')
+               NOT NULL DEFAULT 'default',
+       KEY (hrmid),
+       KEY (redirect)
+) ENGINE=InnoDB,  CHARSET=utf8 ;
+
+CREATE TABLE email_virtual (
+       email    VARCHAR(255) NOT NULL,
+       redirect VARCHAR(255) NOT NULL,
+       type     ENUM('user','list','domain','event','admin','partner'),
+       expire   DATE NOT NULL DEFAULT '0000-00-00',
+       KEY (email)
+) ENGINE=InnoDB,  CHARSET=utf8 ;
+
+CREATE TABLE email_virtual_domains (
+       domain VARCHAR(255) NOT NULL PRIMARY KEY
+) ENGINE=InnoDB,  CHARSET=utf8;
+
+-- vim:set syntax=mysql:
diff --git a/upgrade/1.1.0/02_new_mail_insertion.sql b/upgrade/1.1.0/02_new_mail_insertion.sql
new file mode 100644 (file)
index 0000000..6bb273a
--- /dev/null
@@ -0,0 +1,392 @@
+INSERT INTO email_source_account (uid,email,type,flags,expire)
+       SELECT a.uid,CONCAT(a.alias,'@polytechnique.org'),IF(a.type='a_vie','forlife','alias'),REPLACE(a.flags,'epouse','marital'),a.expire
+       FROM aliases AS a
+       WHERE a.type = 'a_vie'
+        OR a.type = 'alias';
+INSERT INTO email_source_account (uid,email,type,flags,expire)
+       SELECT a.uid,CONCAT(a.alias,'@m4x.org'),IF(a.type='a_vie','forlife','alias'),REPLACE(a.flags,'epouse','marital'),a.expire
+       FROM aliases AS a
+       WHERE a.type = 'a_vie'
+        OR a.type = 'alias';
+INSERT INTO email_source_account (uid,email,type,flags,expire)
+       SELECT a.uid,CONCAT(a.alias,'@m4x.net'),IF(a.type='a_vie','forlife','alias'),REPLACE(a.flags,'epouse','marital'),a.expire
+       FROM aliases AS a
+       WHERE a.type = 'a_vie'
+        OR a.type = 'alias';
+INSERT INTO email_source_account (uid,email,type)
+       SELECT a.uid,v.alias,'alias'
+       FROM virtual AS v
+       LEFT JOIN virtual_redirect AS vr ON (v.vid=vr.vid)
+       LEFT JOIN accounts AS a ON ( a.hruid=LEFT(vr.redirect,LOCATE('@',vr.redirect)-1) )
+       WHERE v.type='user'
+        AND v.alias LIKE "%@melix.net"
+        AND a.uid IS NOT NULL;
+INSERT INTO email_source_account (uid,email,type)
+       SELECT a.uid,REPLACE(v.alias,'@melix.net','@melix.org'),'alias'
+       FROM virtual AS v
+       LEFT JOIN virtual_redirect AS vr ON (v.vid=vr.vid)
+       LEFT JOIN accounts AS a ON ( a.hruid=LEFT(vr.redirect,LOCATE('@',vr.redirect)-1) )
+       WHERE v.type='user'
+        AND v.alias LIKE "%@melix.net"
+        AND a.uid IS NOT NULL;
+
+INSERT INTO email_source_other (hrmid,email,type)
+       SELECT CONCAT(CONCAT('h.',a.alias),'.polytechnique.org'),
+              CONCAT(a.alias,'@polytechnique.org'),'homonym'
+       FROM aliases AS a
+       WHERE a.type = 'homonyme'
+       GROUP BY (a.alias);
+INSERT INTO email_source_other (hrmid,email,type)
+       SELECT CONCAT(CONCAT('h.',a.alias),'.polytechnique.org'),
+              CONCAT(a.alias,'@m4x.org'),'homonym'
+       FROM aliases AS a
+       WHERE a.type = 'homonyme'
+       GROUP BY (a.alias);
+INSERT INTO email_source_other (hrmid,email,type)
+       SELECT CONCAT(CONCAT('h.',a.alias),'.polytechnique.org'),
+              CONCAT(a.alias,'@m4x.net'),'homonym'
+       FROM aliases AS a
+       WHERE a.type = 'homonyme'
+       GROUP BY (a.alias);
+
+INSERT INTO homonyms_list (hrmid,uid)
+       SELECT CONCAT(CONCAT('h.',a.alias),'.polytechnique.org'), h.uid
+       FROM homonyms AS h
+       INNER JOIN aliases AS a ON (a.uid=h.homonyme_id)
+       WHERE a.type = 'homonyme';
+
+INSERT INTO email_redirect_account (uid,redirect,rewrite,type,action,
+                           broken,broken_level,last,flags,hash,allow_rewrite)
+       SELECT a.uid,e.email,e.rewrite,'smtp',ef.email,
+              e.panne,e.panne_level,e.last,IF(e.flags='','inactive',IF(e.flags='disable','disabled',IF(e.flags='panne','broken',e.flags))),e.hash,e.allow_rewrite
+       FROM emails AS e
+       LEFT JOIN emails AS ef ON (e.uid=ef.uid)
+       LEFT JOIN accounts AS a ON (e.uid=a.uid)
+       WHERE e.flags != 'filter'
+        AND  ef.flags = 'filter';
+INSERT INTO email_redirect_account (uid,redirect,type,action,flags)
+       SELECT a.uid,CONCAT(a.hruid,"@g.polytechnique.org"),'googleapps',ef.email,'active'
+       FROM email_options AS eo
+       LEFT JOIN accounts AS a ON (a.uid=eo.uid)
+       LEFT JOIN emails AS ef ON (eo.uid=ef.uid)
+       WHERE FIND_IN_SET('googleapps',eo.storage)
+        AND ef.flags="filter";
+INSERT INTO email_redirect_account (uid,redirect,type,action,flags)
+       SELECT a.uid,CONCAT(a.hruid,"@imap.polytechnique.org"),'imap','let_spams','active'
+       FROM email_options AS eo
+       LEFT JOIN accounts AS a ON (a.uid=eo.uid)
+       WHERE FIND_IN_SET('imap',eo.storage);
+
+INSERT INTO email_redirect_other (hrmid,type,action)
+       SELECT eso.hrmid,'homonym','homonym'
+       FROM email_source_other AS eso
+       WHERE eso.type = 'homonym'
+       GROUP BY (eso.hrmid);
+
+INSERT INTO email_virtual (email,redirect,type)
+       SELECT v.alias,vr.redirect,IF(v.type='dom','domain',IF(v.type='evt','event',v.type))
+       FROM virtual AS v
+       LEFT JOIN virtual_redirect AS vr ON (vr.vid=v.vid)
+       WHERE v.alias NOT LIKE "%@melix.net"
+        AND vr.vid IS NOT NULL
+        AND v.alias != '@melix.org';
+INSERT INTO email_virtual (email,redirect,type)
+       SELECT CONCAT(a.alias,"@polytechnique.org"),
+              CONCAT(
+                'polytechnique.org_',
+                REPLACE(
+                  REPLACE(
+                    REPLACE(
+                      CONCAT(a.alias, '+post@listes.polytechnique.org'),
+                      '-admin+post', '+admin'
+                    ),
+                    '-owner+post', '+owner'
+                  ),
+                  '-bounces+post', '+bounces'
+                )
+              ),
+              'list'
+       FROM aliases AS a
+       WHERE type='liste';
+INSERT INTO email_virtual (email,redirect,type)
+       SELECT CONCAT(a.alias,"@m4x.org"),
+              CONCAT(
+                'polytechnique.org_',
+                REPLACE(
+                  REPLACE(
+                    REPLACE(
+                      CONCAT(a.alias, '+post@listes.polytechnique.org'),
+                      '-admin+post', '+admin'
+                    ),
+                    '-owner+post', '+owner'
+                  ),
+                  '-bounces+post', '+bounces'
+                )
+              ),
+              'list'
+       FROM aliases AS a
+       WHERE type='liste';
+INSERT INTO email_virtual (email,redirect,type)
+       SELECT CONCAT(a.alias,"@m4x.net"),
+              CONCAT(
+                'polytechnique.org_',
+                REPLACE(
+                  REPLACE(
+                    REPLACE(
+                      CONCAT(a.alias, '+post@listes.polytechnique.org'),
+                      '-admin+post', '+admin'
+                    ),
+                    '-owner+post', '+owner'
+                  ),
+                  '-bounces+post', '+bounces'
+                )
+              ),
+              'list'
+       FROM aliases AS a
+       WHERE type='liste';
+INSERT INTO email_virtual (email,redirect,type)
+       SELECT v.alias,vr.redirect,'user'
+       FROM virtual AS v
+       LEFT JOIN virtual_redirect AS vr ON (v.vid=vr.vid)
+       LEFT JOIN accounts AS a ON ( a.hruid=LEFT(vr.redirect,LOCATE('@',vr.redirect)-1) )
+       WHERE v.type='user'
+        AND v.alias LIKE "%@melix.net"
+        AND vr.vid IS NOT NULL
+        AND a.uid IS NULL;
+INSERT INTO email_virtual (email,redirect,type)
+       SELECT REPLACE(v.alias,'@melix.net','@melix.org'),vr.redirect,'user'
+       FROM virtual AS v
+       LEFT JOIN virtual_redirect AS vr ON (v.vid=vr.vid)
+       LEFT JOIN accounts AS a ON ( a.hruid=LEFT(vr.redirect,LOCATE('@',vr.redirect)-1) )
+       WHERE v.type='user'
+        AND v.alias LIKE "%@melix.net"
+        AND vr.vid IS NOT NULL
+        AND a.uid IS NULL;
+
+-- Note: There are some adresses on virtual that have no match on the virtual_redirect.
+--       The adresses in this situation are dropped.
+
+INSERT INTO email_virtual_domains (domain)
+       VALUES ("polytechnique.org"),
+              ("m4x.org"),
+              ("m4x.net");
+INSERT INTO email_virtual_domains (domain)
+       SELECT domain
+       FROM virtual_domains;
+
+-- From aliases file
+INSERT INTO email_virtual (email,redirect,type) VALUES
+       ("otrs.platal@polytechnique.org","otrs@svoboda.polytechnique.org","admin"),
+       ("otrs.platal@m4x.org","otrs.platal@polytechnique.org","admin"),
+       ("otrs.platal@m4x.net","otrs.platal@polytechnique.org","admin"),
+       ("validation@polytechnique.org","hotliners@staff.polytechnique.org","admin"),
+       ("validation@m4x.org","validation@polytechnique.org","admin"),
+       ("validation@m4x.net","validation@polytechnique.org","admin"),
+       ("listes+admin@polytechnique.org","br@staff.polytechnique.org","admin"),
+       ("listes+admin@m4x.org","listes+admin@polytechnique.org","admin"),
+       ("listes+admin@m4x.net","listes+admin@polytechnique.org","admin"),
+       ("listes@polytechnique.org","otrs.platal+listes@polytechnique.org","admin"),
+       ("listes@m4x.org","listes@polytechnique.org","admin"),
+       ("listes@m4x.net","listes@polytechnique.org","admin"),
+       ("gld@polytechnique.org","listes@polytechnique.org","admin"),
+       ("gld@m4x.org","gld@polytechnique.org","admin"),
+       ("gld@m4x.net","gld@polytechnique.org","admin"),
+       ("support@polytechnique.org","otrs.platal+support@polytechnique.org","admin"),
+       ("support@m4x.org","support@polytechnique.org","admin"),
+       ("support@m4x.net","support@polytechnique.org","admin"),
+       ("contact@polytechnique.org","otrs.platal+contact@polytechnique.org","admin"),
+       ("contact@m4x.org","contact@polytechnique.org","admin"),
+       ("contact@m4x.net","contact@polytechnique.org","admin"),
+       ("register@polytechnique.org","otrs.platal+register@polytechnique.org","admin"),
+       ("register@m4x.org","register@polytechnique.org","admin"),
+       ("register@m4x.net","register@polytechnique.org","admin"),
+       ("info@polytechnique.org","otrs.platal+info@polytechnique.org","admin"),
+       ("info@m4x.org","info@polytechnique.org","admin"),
+       ("info@m4x.net","info@polytechnique.org","admin"),
+       ("bug@polytechnique.org","otrs.platal+bug@polytechnique.org","admin"),
+       ("bug@m4x.org","bug@polytechnique.org","admin"),
+       ("bug@m4x.net","bug@polytechnique.org","admin"),
+       ("resetpass@polytechnique.org","otrs.platal+resetpass@polytechnique.org","admin"),
+       ("resetpass@m4x.org","resetpass@polytechnique.org","admin"),
+       ("resetpass@m4x.net","resetpass@polytechnique.org","admin"),
+       ("association@polytechnique.org","otrs.platal+association@polytechnique.org","admin"),
+       ("association@m4x.org","association@polytechnique.org","admin"),
+       ("association@m4x.net","association@polytechnique.org","admin"),
+       ("x-org@polytechnique.org","association@polytechnique.org","admin"),
+       ("x-org@m4x.org","x-org@polytechnique.org","admin"),
+       ("x-org@m4x.net","x-org@polytechnique.org","admin"),
+       ("manageurs@polytechnique.org","otrs@support.manageurs.com","partner"),
+       ("manageurs@m4x.org","manageurs@polytechnique.org","partner"),
+       ("manageurs@m4x.net","manageurs@polytechnique.org","partner"),
+       ("fondation@polytechnique.org","fondation@fondationx.org","partner"),
+       ("fondation@m4x.org","fondation@polytechnique.org","partner"),
+       ("fondation@m4x.net","fondation@polytechnique.org","partner"),
+       ("ax@polytechnique.org","ax@wanadoo.fr","partner"),
+       ("ax@m4x.org","ax@polytechnique.org","partner"),
+       ("ax@m4x.net","ax@polytechnique.org","partner"),
+       ("annuaire-ax@polytechnique.org","annuaire-ax@wanadoo.fr","partner"),
+       ("annuaire-ax@m4x.org","annuaire-ax@polytechnique.org","partner"),
+       ("annuaire-ax@m4x.net","annuaire-ax@polytechnique.org","partner"),
+       ("ax-bdc@polytechnique.org","ax-bdc@wanadoo.fr","partner"),
+       ("ax-bdc@m4x.org","ax-bdc@polytechnique.org","partner"),
+       ("ax-bdc@m4x.net","ax-bdc@polytechnique.org","partner"),
+       ("jaune@polytechnique.org","null@hruid.polytechnique.org","partner"),
+       ("jaune@m4x.org","jaune@polytechnique.org","partner"),
+       ("jaune@m4x.net","jaune@polytechnique.org","partner"),
+       ("jaune+rouge@polytechnique.org","jaune_rouge@wanadoo.fr","partner"),
+       ("jaune+rouge@m4x.org","jaune+rouge@polytechnique.org","partner"),
+       ("jaune+rouge@m4x.net","jaune+rouge@polytechnique.org","partner"),
+       ("xcourseaularge@polytechnique.org","info@xcourseaularge.polytechnique.org","partner"),
+       ("xcourseaularge@m4x.org","xcourseaularge@polytechnique.org","partner"),
+       ("xcourseaularge@m4x.net","xcourseaularge@polytechnique.org","partner"),
+       ("xim@polytechnique.org","membres@x-internet.polytechnique.org","partner"),
+       ("xim@m4x.org","xim@polytechnique.org","partner"),
+       ("xim@m4x.net","xim@polytechnique.org","partner"),
+       ("x-consult@polytechnique.org","info@x-consult.polytechnique.org","partner"),
+       ("x-consult@m4x.org","x-consult@polytechnique.org","partner"),
+       ("x-consult@m4x.net","x-consult@polytechnique.org","partner"),
+       ("xmcb@polytechnique.org","xmcb@x-consult.polytechnique.org","partner"),
+       ("xmcb@m4x.org","xmcb@polytechnique.org","partner"),
+       ("xmcb@m4x.net","xmcb@polytechnique.org","partner"),
+       ("x-maroc@polytechnique.org","allam@mtpnet.gov.ma","partner"),
+       ("x-maroc@m4x.org","x-maroc@polytechnique.org","partner"),
+       ("x-maroc@m4x.net","x-maroc@polytechnique.org","partner"),
+       ("x-musique@polytechnique.org","xmusique@free.fr","partner"),
+       ("x-musique@m4x.org","x-musique@polytechnique.org","partner"),
+       ("x-musique@m4x.net","x-musique@polytechnique.org","partner"),
+       ("x-resistance@polytechnique.org","info@xresistance.org","partner"),
+       ("x-resistance@m4x.org","x-resistance@polytechnique.org","partner"),
+       ("x-resistance@m4x.net","x-resistance@polytechnique.org","partner"),
+       ("x-israel@polytechnique.org","info@x-israel.polytechnique.org","partner"),
+       ("x-israel@m4x.org","x-israel@polytechnique.org","partner"),
+       ("x-israel@m4x.net","x-israel@polytechnique.org","partner"),
+       ("gpx@polytechnique.org","g.p.x@infonie.fr","partner"),
+       ("gpx@m4x.org","gpx@polytechnique.org","partner"),
+       ("gpx@m4x.net","gpx@polytechnique.org","partner"),
+       ("g.p.x@polytechnique.org","gpx@polytechnique.org","partner"),
+       ("g.p.x@m4x.org","g.p.x@polytechnique.org","partner"),
+       ("g.p.x@m4x.net","g.p.x@polytechnique.org","partner"),
+       ("pointgamma@polytechnique.org","gamma@frankiz.polytechnique.fr","partner"),
+       ("pointgamma@m4x.org","pointgamma@polytechnique.org","partner"),
+       ("pointgamma@m4x.net","pointgamma@polytechnique.org","partner"),
+       ("xmpentrepreneur@polytechnique.org","xmp.entrepreneur@gmail.com","partner"),
+       ("xmpentrepreneur@m4x.org","xmpentrepreneur@polytechnique.org","partner"),
+       ("xmpentrepreneur@m4x.net","xmpentrepreneur@polytechnique.org","partner"),
+       ("xmp-entrepreneur@polytechnique.org","xmp.entrepreneur@gmail.com","partner"),
+       ("xmp-entrepreneur@m4x.org","xmp-entrepreneur@polytechnique.org","partner"),
+       ("xmp-entrepreneur@m4x.net","xmp-entrepreneur@polytechnique.org","partner"),
+       ("xmpangels@polytechnique.org","xmpangels@xmp-ba.m4x.org","partner"),
+       ("xmpangels@m4x.org","xmpangels@polytechnique.org","partner"),
+       ("xmpangels@m4x.net","xmpangels@polytechnique.org","partner"),
+       ("xmp-angels@polytechnique.org","xmpangels@xmp-ba.m4x.org","partner"),
+       ("xmp-angels@m4x.org","xmp-angels@polytechnique.org","partner"),
+       ("xmp-angels@m4x.net","xmp-angels@polytechnique.org","partner"),
+       ("relex@polytechnique.org","relex@staff.polytechnique.org","admin"),
+       ("relex@m4x.org","relex@polytechnique.org","admin"),
+       ("relex@m4x.net","relex@polytechnique.org","admin"),
+       ("tresorier@polytechnique.org","tresorier@staff.polytechnique.org","admin"),
+       ("tresorier@m4x.org","tresorier@polytechnique.org","admin"),
+       ("tresorier@m4x.net","tresorier@polytechnique.org","admin"),
+       ("aaege-sso@polytechnique.org","aaege-sso@staff.polytechnique.org","admin"),
+       ("aaege-sso@m4x.org","aaege-sso@polytechnique.org","admin"),
+       ("aaege-sso@m4x.net","aaege-sso@polytechnique.org","admin"),
+       ("innovation@polytechnique.org","innovation@staff.polytechnique.org","admin"),
+       ("innovation@m4x.org","innovation@polytechnique.org","admin"),
+       ("innovation@m4x.net","innovation@polytechnique.org","admin"),
+       ("groupes@polytechnique.org","groupes@staff.polytechnique.org","admin"),
+       ("groupes@m4x.org","groupes@polytechnique.org","admin"),
+       ("groupes@m4x.net","groupes@polytechnique.org","admin"),
+       ("br@polytechnique.org","br@staff.polytechnique.org","admin"),
+       ("br@m4x.org","br@polytechnique.org","admin"),
+       ("br@m4x.net","br@polytechnique.org","admin"),
+       ("ca@polytechnique.org","ca@staff.polytechnique.org","admin"),
+       ("ca@m4x.org","ca@polytechnique.org","admin"),
+       ("ca@m4x.net","ca@polytechnique.org","admin"),
+       ("personnel@polytechnique.org","br@staff.polytechnique.org","admin"),
+       ("personnel@m4x.org","personnel@polytechnique.org","admin"),
+       ("personnel@m4x.net","personnel@polytechnique.org","admin"),
+       ("cil@polytechnique.org","cil@staff.polytechnique.org","admin"),
+       ("cil@m4x.org","cil@polytechnique.org","admin"),
+       ("cil@m4x.net","cil@polytechnique.org","admin"),
+       ("opensource@polytechnique.org","contact@polytechnique.org","admin"),
+       ("opensource@m4x.org","opensource@polytechnique.org","admin"),
+       ("opensource@m4x.net","opensource@polytechnique.org","admin"),
+       ("forums@polytechnique.org","forums@staff.m4x.org","admin"),
+       ("forums@m4x.org","forums@polytechnique.org","admin"),
+       ("forums@m4x.net","forums@polytechnique.org","admin"),
+       ("telepaiement@polytechnique.org","telepaiement@staff.m4x.org","admin"),
+       ("telepaiement@m4x.org","telepaiement@polytechnique.org","admin"),
+       ("telepaiement@m4x.net","telepaiement@polytechnique.org","admin"),
+       ("hotliners@polytechnique.org","hotliners@staff.m4x.org","admin"),
+       ("hotliners@m4x.org","hotliners@polytechnique.org","admin"),
+       ("hotliners@m4x.net","hotliners@polytechnique.org","admin"),
+       ("kes@polytechnique.org","kes@frankiz.polytechnique.fr","partner"),
+       ("kes@m4x.org","kes@polytechnique.org","partner"),
+       ("kes@m4x.net","kes@polytechnique.org","partner"),
+       ("kes1999@polytechnique.org","cariokes@polytechnique.org","partner"),
+       ("kes1999@m4x.org","kes1999@polytechnique.org","partner"),
+       ("kes1999@m4x.net","kes1999@polytechnique.org","partner"),
+       ("kes2000@polytechnique.org","kestinpowers@polytechnique.org","partner"),
+       ("kes2000@m4x.org","kes2000@polytechnique.org","partner"),
+       ("kes2000@m4x.net","kes2000@polytechnique.org","partner");
+
+INSERT INTO email_source_other (hrmid,email,type) VALUES
+       ("ax.test.polytechnique.org","AX-test@polytechnique.org","ax"),
+       ("ax.test.polytechnique.org","AX-test@m4x.org","ax"),
+       ("ax.test.polytechnique.org","AX-test@m4x.net","ax"),
+       ("ax.nicolas.zarpas.polytechnique.org","AX-nicolas.zarpas@polytechnique.org","ax"),
+       ("ax.nicolas.zarpas.polytechnique.org","AX-nicolas.zarpas@m4x.org","ax"),
+       ("ax.nicolas.zarpas.polytechnique.org","AX-nicolas.zarpas@m4x.net","ax"),
+       ("ax.carrieres.polytechnique.org","AX-carrieres@polytechnique.org","ax"),
+       ("ax.carrieres.polytechnique.org","AX-carrieres@m4x.org","ax"),
+       ("ax.carrieres.polytechnique.org","AX-carrieres@m4x.net","ax"),
+       ("ax.info1.polytechnique.org","AX-info1@polytechnique.org","ax"),
+       ("ax.info1.polytechnique.org","AX-info1@m4x.org","ax"),
+       ("ax.info1.polytechnique.org","AX-info1@m4x.net","ax"),
+       ("ax.info2.polytechnique.org","AX-info2@polytechnique.org","ax"),
+       ("ax.info2.polytechnique.org","AX-info2@m4x.org","ax"),
+       ("ax.info2.polytechnique.org","AX-info2@m4x.net","ax"),
+       ("ax.bal.polytechnique.org","AX-bal@polytechnique.org","ax"),
+       ("ax.bal.polytechnique.org","AX-bal@m4x.org","ax"),
+       ("ax.bal.polytechnique.org","AX-bal@m4x.net","ax"),
+       ("ax.annuaire.polytechnique.org","AX-annuaire@polytechnique.org","ax"),
+       ("ax.annuaire.polytechnique.org","AX-annuaire@m4x.org","ax"),
+       ("ax.annuaire.polytechnique.org","AX-annuaire@m4x.net","ax"),
+       ("ax.jaune-rouge.polytechnique.org","AX-jaune-rouge@polytechnique.org","ax"),
+       ("ax.jaune-rouge.polytechnique.org","AX-jaune-rouge@m4x.org","ax"),
+       ("ax.jaune-rouge.polytechnique.org","AX-jaune-rouge@m4x.net","ax"),
+       ("honey.jean-pierre.bilah.1980.polytechnique.org","jean-pierre.bilah.1980@polytechnique.org","honeypot"),
+       ("honey.jean-pierre.bilah.1980.polytechnique.org","jean-pierre.bilah.1980@m4x.org","honeypot"),
+       ("honey.jean-pierre.bilah.1980.polytechnique.org","jean-pierre.bilah.1980@m4x.net","honeypot"),
+       ("honey.jean-pierre.bilah.1980.polytechnique.org","jean-pierre.blah.1980@polytechnique.org","honeypot"),
+       ("honey.jean-pierre.bilah.1980.polytechnique.org","jean-pierre.blah.1980@m4x.org","honeypot"),
+       ("honey.jean-pierre.bilah.1980.polytechnique.org","jean-pierre.blah.1980@m4x.net","honeypot");
+
+INSERT INTO email_redirect_other (hrmid,redirect,type,action) VALUES
+       ("ax.nicolas.zarpas.polytechnique.org","nicolas.zarpas-ax@wanadoo.fr","smtp","tag_spams"),
+       ("ax.carrieres.polytechnique.org","manuela.brasseur-bdc@wanadoo.fr","smtp","tag_spams"),
+       ("ax.info1.polytechnique.org","sylvie.clairefond-ax@wanadoo.fr","smtp","tag_spams"),
+       ("ax.info2.polytechnique.org","catherine.perot-ax@wanadoo.fr","smtp","tag_spams"),
+       ("ax.bal.polytechnique.org","baldelx-ax@wanadoo.fr","smtp","tag_spams"),
+       ("ax.annuaire.polytechnique.org","annuaire-ax@wanadoo.fr","smtp","tag_spams"),
+       ("ax.jaune-rouge.polytechnique.org","jaune_rouge@wanadoo.fr","smtp","tag_spams"),
+       ("honey.jean-pierre.bilah.1980.polytechnique.org","jean-pierre.bilah.1980.mbox@murphy.m4x.org","smtp","let_spams"),
+       ("honey.jean-pierre.bilah.1980.polytechnique.org","raphael.barrois.2006@polytechnique.org","smtp","let_spams");
+
+-- Drop renamed list
+DELETE FROM email_virtual WHERE email LIKE "tech-email%@polytechnique.org";
+DELETE FROM email_virtual WHERE email LIKE "tech-email%@m4x.org";
+DELETE FROM email_virtual WHERE email LIKE "tech-email%@m4x.net";
+
+-- Imap and bounce
+UPDATE email_redirect_account AS e,
+       (SELECT IF( SUM(IF(type!='imap',1,0))=0, 'imap_only', 'normal' ) AS status, uid
+            FROM email_redirect_account
+           WHERE flags = 'active'
+        GROUP BY uid) AS sub
+    SET e.action='imap_and_bounce'
+  WHERE sub.status='imap_only'
+    AND sub.uid = e.uid
+    AND type='imap';
+
+-- vim:set syntax=mysql:
diff --git a/upgrade/1.1.0/03_new_mail_delete_old.sql b/upgrade/1.1.0/03_new_mail_delete_old.sql
new file mode 100644 (file)
index 0000000..eed44e6
--- /dev/null
@@ -0,0 +1,9 @@
+DROP TABLE aliases;
+DROP TABLE virtual;
+DROP TABLE virtual_redirect;
+DROP TABLE homonyms;
+DROP TABLE emails;
+DROP TABLE email_options;
+DROP TABLE domain;
+
+-- vim:set syntax=mysql:
diff --git a/upgrade/1.1.0/04_xnetgrp.sql b/upgrade/1.1.0/04_xnetgrp.sql
new file mode 100644 (file)
index 0000000..377a21c
--- /dev/null
@@ -0,0 +1,5 @@
+ALTER TABLE groups ADD COLUMN axDate DATE DEFAULT NULL;
+ALTER TABLE group_members ADD COLUMN position ENUM('Président', 'Vice-président', 'Trésorier', 'Vice-trésorier', 'Secrétaire', 'Directeur', 'Délégué général', 'Secrétaire général', 'Membre du bureau') DEFAULT NULL;
+ALTER TABLE groups ADD COLUMN welcome_msg MEDIUMTEXT DEFAULT NULL;
+
+-- vim:set syntax=mysql:
diff --git a/upgrade/1.1.0/05_permissions.sql b/upgrade/1.1.0/05_permissions.sql
new file mode 100644 (file)
index 0000000..6a6615d
--- /dev/null
@@ -0,0 +1,9 @@
+ALTER TABLE accounts CHANGE COLUMN user_perms user_perms
+    SET('groups', 'mail', 'directory_ax', 'directory_private', 'edit_directory',
+        'forums', 'lists', 'payment', 'api_user_readonly') DEFAULT NULL;
+
+ALTER TABLE account_types CHANGE COLUMN perms perms
+    SET('groups', 'mail', 'directory_ax', 'directory_private', 'edit_directory',
+        'forums', 'lists', 'payment', 'api_user_readonly') NOT NULL;
+
+-- vim:set syntax=mysql:
diff --git a/upgrade/1.1.0/05_xnetevents.sql b/upgrade/1.1.0/05_xnetevents.sql
new file mode 100644 (file)
index 0000000..d67ad18
--- /dev/null
@@ -0,0 +1,3 @@
+ALTER TABLE group_events ADD COLUMN subscription_notification ENUM('nobody', 'creator', 'animator', 'both') NOT NULL DEFAULT 'nobody';
+
+-- vim:set syntax=mysql:
diff --git a/upgrade/1.1.0/06_language.sql b/upgrade/1.1.0/06_language.sql
new file mode 100644 (file)
index 0000000..85d6a29
--- /dev/null
@@ -0,0 +1,12 @@
+UPDATE profile_langskill_enum SET id = SUBSTRING(id, 1, 3);
+ALTER TABLE profile_langskills DROP FOREIGN KEY profile_langskills_ibfk_2;
+ALTER TABLE profile_langskill_enum CHANGE COLUMN id iso_639_2b CHAR(3) NOT NULL DEFAULT '';
+ALTER TABLE profile_langskills ADD FOREIGN KEY (lid) REFERENCES profile_langskill_enum (iso_639_2b) ON DELETE CASCADE ON UPDATE CASCADE;
+ALTER TABLE profile_langskill_enum ADD COLUMN iso_639_2t CHAR(3) NOT NULL DEFAULT '';
+ALTER TABLE profile_langskill_enum ADD COLUMN iso_639_1 CHAR(2) DEFAULT NULL;
+ALTER TABLE profile_langskill_enum CHANGE COLUMN langue_en language_en VARCHAR(255) NOT NULL DEFAULT '';
+ALTER TABLE profile_langskill_enum CHANGE COLUMN langue_fr language VARCHAR(255) NOT NULL DEFAULT '';
+ALTER TABLE profile_langskill_enum ADD KEY (iso_639_2t);
+ALTER TABLE profile_langskill_enum ADD KEY (iso_639_1);
+
+-- vim:set syntax=mysql:
diff --git a/upgrade/1.1.0/10_surveys.sql b/upgrade/1.1.0/10_surveys.sql
new file mode 100644 (file)
index 0000000..e6e5f47
--- /dev/null
@@ -0,0 +1,88 @@
+#RENAME TABLE surveys TO old_surveys,
+#             survey_answers TO old_survey_answers,
+#             survey_votes TO old_survey_votes;
+
+DROP TABLE IF EXISTS survey_vote_answers;
+DROP TABLE IF EXISTS survey_voters;
+DROP TABLE IF EXISTS survey_votes;
+DROP TABLE IF EXISTS survey_questions;
+DROP TABLE IF EXISTS surveys;
+
+CREATE TABLE surveys (
+    id          INT(11) UNSIGNED NOT NULL auto_increment,
+    uid         INT(11) UNSIGNED NOT NULL,
+    shortname   VARCHAR(32) NOT NULL,
+    title       VARCHAR(255) NOT NULL,
+    description TEXT NOT NULL,
+    begin       DATE NOT NULL,
+    end         DATE NOT NULL,
+
+    voters      TEXT DEFAULT NULL COMMENT "Filter users who can vote",
+    viewers     TEXT DEFAULT NULL COMMENT "Filter users who can see the results",
+
+    flags       SET('validated', 'anonymous'),
+
+    PRIMARY KEY id (id),
+    UNIQUE KEY shortname (shortname),
+    FOREIGN KEY (uid) REFERENCES accounts (uid)
+                      ON UPDATE CASCADE
+                      ON DELETE CASCADE
+) ENGINE=InnoDB, CHARSET=utf8, COMMENT="Describe a survey";
+
+CREATE TABLE survey_questions (
+    sid         INT(11) UNSIGNED NOT NULL,
+    qid         INT(11) UNSIGNED NOT NULL,
+    parent      INT(11) UNSIGNED DEFAULT NULL COMMENT "Id of the parent question",
+
+    type        VARCHAR(32) NOT NULL, -- XXX: Use an enum of possible types?
+    label       TEXT DEFAULT NULL,
+    parameters  TEXT DEFAULT NULL COMMENT "Parameters of the question",
+    flags       SET('multiple', 'mandatory', 'noanswer') NOT NULL DEFAULT '',
+
+    PRIMARY KEY id (sid, qid),
+    FOREIGN KEY (sid) REFERENCES surveys (id)
+                      ON UPDATE CASCADE
+                      ON DELETE CASCADE
+) ENGINE=InnoDB, CHARSET=utf8, COMMENT="Describe the questions of the surveys";
+
+CREATE TABLE survey_votes (
+    vid         INT(11) UNSIGNED NOT NULL auto_increment,
+    sid         INT(11) UNSIGNED NOT NULL,
+
+    PRIMARY KEY vid (vid),
+    FOREIGN KEY (sid) REFERENCES surveys (id)
+                      ON UPDATE CASCADE
+                      ON DELETE CASCADE
+) ENGINE=InnoDB, CHARSET=utf8, COMMENT="Identify unique votes";
+
+CREATE TABLE survey_voters (
+    sid         INT(11) UNSIGNED NOT NULL,
+    uid         INT(11) UNSIGNED NOT NULL,
+    vid         INT(11) UNSIGNED DEFAULT NULL, -- NULL for anonymous votes
+
+    PRIMARY KEY id (sid, uid),
+    FOREIGN KEY (uid) REFERENCES accounts (uid)
+                      ON UPDATE CASCADE
+                      ON DELETE CASCADE,
+    FOREIGN KEY (sid) REFERENCES surveys (id)
+                      ON UPDATE CASCADE
+                      ON DELETE CASCADE
+) ENGINE=InnoDB, CHARSET=utf8, COMMENT="List voters";
+
+CREATE TABLE survey_vote_answers (
+    sid         INT(11) UNSIGNED NOT NULL,
+    qid         INT(11) UNSIGNED NOT NULL,
+    vid         INT(11) UNSIGNED NOT NULL,
+
+    answer      TEXT DEFAULT NULL,
+
+    PRIMARY KEY id (sid, vid, qid),
+    FOREIGN KEY (vid) REFERENCES survey_votes (vid)
+                      ON UPDATE CASCADE
+                      ON DELETE CASCADE,
+    FOREIGN KEY (sid, qid) REFERENCES survey_questions (sid, qid)
+                           ON UPDATE CASCADE
+                           ON DELETE CASCADE
+) ENGINE=InnoDB, CHARSET=utf8, COMMENT="Answers to the surveys";
+
+-- vim:set syntax=mysql:
diff --git a/upgrade/1.1.0/connect.db.inc.php b/upgrade/1.1.0/connect.db.inc.php
new file mode 120000 (symlink)
index 0000000..442fab7
--- /dev/null
@@ -0,0 +1 @@
+../../bin/connect.db.inc.php
\ No newline at end of file
diff --git a/upgrade/1.1.0/languages.php b/upgrade/1.1.0/languages.php
new file mode 100755 (executable)
index 0000000..5736497
--- /dev/null
@@ -0,0 +1,34 @@
+#!/usr/bin/php5
+<?php
+
+require_once 'connect.db.inc.php';
+
+$globals->debug = 0; // Do not store backtraces.
+
+// First build the list provided by the iso codes.
+$list = array();
+exec('isoquery --iso=639', $list);
+
+foreach ($list as $key => $item) {
+    $array = explode("\t", $item);
+    unset($list[$key]);
+    $list[$array[0]] = array();
+    foreach (array('iso_639_2t', 'iso_639_1') as $i => $field) {
+        $list[$array[0]][$field] = $array[$i + 1];
+    }
+}
+
+$res = XDB::iterator('SELECT  iso_639_2b
+                        FROM  profile_langskill_enum
+                       WHERE  iso_639_2b IN {?}',
+                     array_keys($list));
+while ($item = $res->next()) {
+    $id = $item['iso_639_2b'];
+    XDB::execute('UPDATE  profile_langskill_enum
+                     SET  iso_639_2t = {?}, iso_639_1 = {?}
+                   WHERE  iso_639_2b = {?}',
+                 $list[$id]['iso_639_2t'], (($list[$id]['iso_639_1']) ? $list[$id]['iso_639_1'] : null), $id);
+}
+
+/* vim:set et sw=4 sts=4 ts=4: */
+?>
diff --git a/upgrade/1.1.0/old_surveys.inc.php b/upgrade/1.1.0/old_surveys.inc.php
new file mode 100644 (file)
index 0000000..497a7f8
--- /dev/null
@@ -0,0 +1,823 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2011 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 Survey : root of any survey, contains all questions
+class Survey
+{
+    // {{{ static properties and functions, regarding survey modes and question types
+    const MODE_ALL    = 0;
+    const MODE_XANON  = 1;
+    const MODE_XIDENT = 2;
+    private static $longModes = array(self::MODE_ALL    => "sondage ouvert à tout le monde, anonyme",
+                                      self::MODE_XANON  => "sondage restreint aux polytechniciens, anonyme",
+                                      self::MODE_XIDENT => "sondage restreint aux polytechniciens, non anonyme");
+    private static $shortModes = array(self::MODE_ALL    => "tout le monde, anonyme",
+                                       self::MODE_XANON  => "polytechniciens, anonyme",
+                                       self::MODE_XIDENT => "polytechniciens, non anonyme");
+
+    public static function getModes($long = true) {
+        return ($long)? self::$longModes : self::$shortModes;
+    }
+
+    private static $types = array('text'          => 'Texte court',
+                                  'textarea'      => 'Texte long',
+                                  'num'           => 'Numérique',
+                                  'radio'         => 'Choix multiples (une réponse)',
+                                  'checkbox'      => 'Choix multiples (plusieurs réponses)',
+                                  'radiotable'    => 'Questions multiples à choix multiples (une réponse)',
+                                  'checkboxtable' => 'Questions multiples à choix mutliples (plusieurs réponses)');
+
+    public static function getTypes()
+    {
+        return self::$types;
+    }
+
+    public static function isType($t)
+    {
+        return array_key_exists($t, self::$types);
+    }
+    // }}}
+
+    // {{{ properties, constructor and basic methods
+    private $id;
+    private $title;
+    private $description;
+    private $end;
+    private $mode;
+    private $promos;
+    private $valid;
+    private $questions;
+    private $creator;
+
+    public function __construct($args, $id = -1, $valid = false, $questions = null)
+    {
+        $this->update($args);
+        $this->id = $id;
+        $this->valid = $valid;
+        $this->questions = ($questions == null)? array() : $questions;
+    }
+
+    public function update($args)
+    {
+        $this->title       = $args['title'];
+        $this->description = $args['description'];
+        $this->end         = $args['end'];
+        $this->mode        = (isset($args['mode']))? $args['mode'] : self::MODE_ALL;
+        $this->creator     = $args['uid'];
+        if ($this->mode == self::MODE_ALL) {
+            $args['promos'] = '';
+        }
+        $args['promos'] = str_replace(' ', '', $args['promos']);
+        $this->promos  = ($args['promos'] == '' || preg_match('#^(\d{4}-?|(\d{4})?-\d{4})(,(\d{4}-?|(\d{4})?-\d{4}))*$#', $args['promos']))? $args['promos'] : '#';
+    }
+
+    public function canSeeEarlyResults(User $user)
+    {
+        return $user->id() == $this->creator || $user->checkPerms('admin');
+    }
+    // }}}
+
+    // {{{ functions to access general information
+    public function isMode($mode)
+    {
+        return ($this->mode == $mode);
+    }
+
+    public function checkPromo($promo)
+    {
+        if ($this->promos == '') {
+            return true;
+        }
+        $promos = explode(',', $this->promos);
+        foreach ($promos as $p) {
+            if ((preg_match('#^\d{4}$#', $p) && $p == $promo) ||
+                (preg_match('#^\d{4}-$#', $p) && intval(substr($p, 0, 4)) <= $promo) ||
+                (preg_match('#^-\d{4}$#', $p) && intval(substr($p, 1)) >= $promo) ||
+                (preg_match('#^\d{4}-\d{4}$#', $p) &&
+                    (intval(substr($p, 0, 4)) <= $promo && intval(substr($p, 5)) >= $promo ||
+                     intval(substr($p, 0, 4)) >= $promo && intval(substr($p, 5)) <= $promo ))) {
+                    return true;
+            }
+        }
+        return false;
+    }
+
+    public function isValid()
+    {
+        return $this->valid;
+    }
+
+    public function isEnded()
+    {
+        return (strtotime($this->end) - time() <= 0);
+    }
+
+    public function getTitle()
+    {
+        return $this->title;
+    }
+    // }}}
+
+    // {{{ function toArray() : converts a question (or the whole survey) to array, with results if the survey is ended
+    public function toArray($i = 'all')
+    {
+        if ($i != 'all' && $i != 'root') { // if a specific question is requested, then just returns this question converted to array
+            $i = intval($i);
+            if (array_key_exists($i, $this->questions)) {
+                return $this->questions[$i]->toArray();
+            } else {
+                return null;
+            }
+        } else { // else returns the root converted to array in any case
+            $a = array('title'       => $this->title,
+                       'description' => $this->description,
+                       'end'         => $this->end,
+                       'mode'        => $this->mode,
+                       'promos'      => $this->promos,
+                       'valid'       => $this->valid,
+                       'type'        => 'root');
+            if ($this->id != -1) {
+                $a['id'] = $this->id;
+            }
+            if ($this->isEnded()) { // if the survey is ended, then adds here the number of votes
+                $sql = 'SELECT COUNT(id)
+                          FROM survey_votes
+                         WHERE survey_id={?};';
+                $tot = XDB::query($sql, $this->id);
+                $a['votes'] = $tot->fetchOneCell();
+            }
+            if ($i == 'all' && count($this->questions) > 0) { // if the whole survey is requested, then returns all the questions converted to array
+                $qArr = array();
+                for ($k = 0; $k < count($this->questions); $k++) {
+                    $q = $this->questions[$k]->toArray();
+                    $q['id'] = $k;
+                    if ($this->isEnded()) { // if the survey is ended, then adds here the results of this question
+                        $q['result'] = $this->questions[$k]->getResultArray($this->id, $k);
+                    }
+                    $qArr[$k] = $q;
+                }
+                $a['questions'] = $qArr;
+            }
+            return $a;
+        }
+    }
+    // }}}
+
+    // {{{ function toCSV() : builds a CSV file containing all the results of the survey
+    public function toCSV($sep = ',', $enc = '"', $asep='|')
+    {
+        $nbq = count($this->questions);
+        //require_once dirname(__FILE__) . '/../../classes/varstream.php';
+        VarStream::init();
+        global $csv_output;
+        $csv_output = '';
+        $csv = fopen('var://csv_output', 'w');
+        $line = ($this->isMode(self::MODE_XIDENT))? array('id', 'Nom', 'Prenom', 'Promo') : array('id');
+        $qids = array();
+        for ($qid = 0; $qid < $nbq; $qid++) {
+            $qids[$qid] = count($line); // stores the first id of a question (in case of questions with subquestions)
+            array_splice($line, count($line), 0, $this->questions[$qid]->getCSVColumns()); // the first line contains the questions
+        }
+        $nbf = count($line);
+        $users = array();
+        if ($this->isMode(self::MODE_XIDENT)) { // if the mode is non anonymous
+            $users = User::getBulkUsersWithUIDs(XDB::fetchAllAssoc('vid', 'SELECT  v.id AS vid, v.uid
+                                                                             FROM  survey_votes AS v
+                                                                            WHERE  v.survey_id = {?}
+                                                                         ORDER BY  vid ASC',
+                                                                    $this->id));
+        }
+        $sql = 'SELECT v.id AS vid, a.question_id AS qid, a.answer AS answer
+                  FROM survey_votes AS v
+            INNER JOIN survey_answers AS a ON a.vote_id=v.id
+                 WHERE v.survey_id={?}
+              ORDER BY vid ASC, qid ASC, answer ASC';
+        $res = XDB::iterator($sql, $this->id); // retrieves all answers from database
+        $vid = -1;
+        $vid_ = 0;
+        while (($cur = $res->next()) != null) {
+            if ($vid != $cur['vid']) { // if the vote id changes, then starts a new line
+                fputcsv($csv, $line, $sep, $enc); // stores the former line into $csv_output
+                $vid = $cur['vid'];
+                $line = array_fill(0, $nbf, ''); // creates an array full of empty string
+                $line[0] = $vid_; // the first field is a 'clean' vote id (not the one stored in database)
+                if ($this->isMode(self::MODE_XIDENT)) { // if the mode is non anonymous
+                    if (array_key_exists($vid, $users)) { // and if the user data can be found
+                        $line[1] = $users[$vid]->lastName(); // adds the user data (in the first fields of the line)
+                        $line[2] = $users[$vid]->firstName();;
+                        $line[3] = $users[$vid]->promo();
+                    }
+                }
+                $vid_++;
+            }
+            $ans = $this->questions[$cur['qid']]->formatAnswer($cur['answer']); // formats the current answer
+            if (!is_null($ans)) {
+                if (is_array($ans)) {
+                    $fid = $qids[$cur['qid']] + $ans['id']; // computes the field id
+                    $a = $ans['answer'];
+                } else {
+                    $fid = $qids[$cur['qid']];
+                    $a = $ans;
+                }
+                if ($line[$fid] != '') {  // if this field already contains something
+                    $line[$fid] .= $asep; // then adds a separator before adding the new answer
+                }
+                $line[$fid] .= $a; // adds the current answer to the correct field
+            }
+        }
+        fputcsv($csv, $line, $sep, $enc); // stores the last line into $csv_output
+        return $csv_output;
+    }
+    // }}}
+
+    // {{{ function factory($type, $args) : builds a question according to the given type
+    public function factory($t, $args)
+    {
+        switch ($t) {
+        case 'text':
+            return new SurveyText($args);
+        case 'textarea':
+            return new SurveyTextarea($args);
+        case 'num':
+            return new SurveyNum($args);
+        case 'radio':
+            return new SurveyRadio($args);
+        case 'checkbox':
+            return new SurveyCheckbox($args);
+        case 'radiotable':
+            return new SurveyRadioTable($args);
+        case 'checkboxtable':
+            return new SurveyCheckboxTable($args);
+        default:
+            return null;
+        }
+    }
+    // }}}
+
+    // {{{ questions manipulation functions
+    public function addQuestion($i, $c)
+    {
+        $i = intval($i);
+        if ($this->valid || $i > count($this->questions)) {
+            return false;
+        } else {
+            array_splice($this->questions, $i, 0, array($c));
+            return true;
+        }
+    }
+
+    public function delQuestion($i)
+    {
+        $i = intval($i);
+        if ($this->valid || !array_key_exists($i, $this->questions)) {
+            return false;
+        } else {
+            array_splice($this->questions, $i, 1);
+            return true;
+        }
+    }
+
+    public function editQuestion($i, $a)
+    {
+        if ($i == 'root') {
+            $this->update($a);
+        } else {
+            $i = intval($i);
+            if ($this->valid ||!array_key_exists($i, $this->questions)) {
+                return false;
+            } else {
+                $this->questions[$i]->update($a);
+            }
+        }
+        return true;
+    }
+    // }}}
+
+    // {{{ function checkSyntax() : checks syntax of the questions (currently the root only) before storing the survey in database
+    private static $errorMessages = array(
+        "datepassed"  => "la date de fin de sondage est déjà dépassée : vous devez préciser une date future",
+        "promoformat" => "les restrictions à certaines promotions sont mal formattées"
+    );
+
+    public function checkSyntax()
+    {
+        $rArr = array();
+        // checks that the end date given is not already passed
+        // (unless the survey has already been validated : an admin can have a validated survey expired)
+        if (!$this->valid && $this->isEnded()) {
+            $rArr[] = array('question' => 'root', 'error' => self::$errorMessages["datepassed"]);
+        }
+        if ($this->promos != '' && !preg_match('#^(\d{4}-?|(\d{4})?-\d{4})(,(\d{4}-?|(\d{4})?-\d{4}))*$#', $this->promos)) {
+            $rArr[] = array('question' => 'root', 'error' => self::$errorMessages["promoformat"]);
+        }
+        return (empty($rArr))? null : $rArr;
+    }
+    // }}}
+
+    // {{{ functions that manipulate surveys in database
+    // {{{ static function retrieveList() : gets the list of available survey (current, old and not validated surveys)
+    public static function retrieveList($type, $tpl = true)
+    {
+        switch ($type) {
+        case 'c':
+        case 'current':
+            $where = 'end > NOW()';
+            break;
+        case 'o':
+        case 'old':
+            $where = 'end <= NOW()';
+            break;
+        default:
+            return null;
+        }
+        $sql = 'SELECT id, title, end, mode
+                  FROM surveys
+                 WHERE '.$where.'
+              ORDER BY end DESC;';
+        if ($tpl) {
+            return XDB::iterator($sql);
+        } else {
+            return XDB::iterRow($sql);
+        }
+    }
+    // }}}
+
+    // {{{ static function retrieveSurvey() : gets a survey in database (and unserialize the survey object structure)
+    public static function retrieveSurvey($sid)
+    {
+        $sql = 'SELECT questions, title, description, end, mode, promos, uid
+                  FROM surveys
+                 WHERE id={?}';
+        $res = XDB::query($sql, $sid);
+        $data = $res->fetchOneAssoc();
+        if (is_null($data) || !is_array($data)) {
+            return null;
+        }
+        $survey = new Survey($data, $sid, true, unserialize($data['questions']));
+        return $survey;
+    }
+    // }}}
+
+    // {{{ static function retrieveSurveyInfo() : gets information about a survey (title, description, end date, restrictions) but does not unserialize the survey object structure
+    public static function retrieveSurveyInfo($sid)
+    {
+        $sql = 'SELECT title, description, end, mode, promos
+                  FROM surveys
+                 WHERE id={?}';
+        $res = XDB::query($sql, $sid);
+        return $res->fetchOneAssoc();
+    }
+    // }}}
+
+    // {{{ static function retrieveSurveyReq() : gets a survey request to validate
+    public static function retrieveSurveyReq($id)
+    {
+        $surveyreq = Validate::get_request_by_id($id);
+        if ($surveyreq == null) {
+            return null;
+        }
+        $data = array('title'       => $surveyreq->title,
+                      'description' => $surveyreq->description,
+                      'end'         => $surveyreq->end,
+                      'mode'        => $surveyreq->mode,
+                      'promos'      => $surveyreq->promos);
+        $survey = new Survey($data, $id, false, $surveyreq->questions);
+        return $survey;
+    }
+    // }}}
+
+    // {{{ function proposeSurvey() : stores a proposition of survey in database (before validation)
+    public function proposeSurvey()
+    {
+        $surveyreq = new SurveyReq($this->title, $this->description, $this->end, $this->mode, $this->promos, $this->questions, S::user());
+        return $surveyreq->submit();
+    }
+    // }}}
+
+    // {{{ function updateSurvey() : updates a survey in database (before validation)
+    public function updateSurvey()
+    {
+        if ($this->valid) {
+            $sql = 'UPDATE surveys
+                       SET questions={?},
+                           title={?},
+                           description={?},
+                           end={?},
+                           mode={?},
+                           promos={?}
+                     WHERE id={?};';
+            return XDB::execute($sql, serialize($this->questions), $this->title, $this->description, $this->end, $this->mode, $this->promos, $this->id);
+        } else {
+            $surveyreq = Validate::get_request_by_id($this->id);
+            if ($surveyreq == null) {
+                return false;
+            }
+            return $surveyreq->updateReq($this->title, $this->description, $this->end, $this->mode, $this->promos, $this->questions);
+        }
+    }
+    // }}}
+
+    // {{{ functions vote() and hasVoted() : handles vote to a survey
+    public function vote($uid, $args)
+    {
+        XDB::execute('INSERT INTO  survey_votes
+                              SET  survey_id = {?}, uid = {?}',
+                     $this->id, ($uid == 0) ? null : $uid); // notes the user as having voted
+        $vid = XDB::insertId();
+        for ($i = 0; $i < count($this->questions); $i++) {
+            $ans = $this->questions[$i]->checkAnswer($args[$i]);
+            if (!is_null($ans) && is_array($ans)) {
+                foreach ($ans as $a) {
+                    XDB::execute('INSERT INTO survey_answers
+                                          SET vote_id     = {?},
+                                              question_id = {?},
+                                              answer      = {?}', $vid, $i, $a);
+                }
+            }
+        }
+    }
+
+    public function hasVoted($uid)
+    {
+        $res = XDB::query('SELECT  id
+                             FROM  survey_votes
+                            WHERE  survey_id = {?} AND uid = {?};', $this->id, $uid); // checks whether the user has already voted
+        return ($res->numRows() != 0);
+    }
+    // }}}
+
+    // {{{ static function deleteSurvey() : deletes a survey (and all its votes)
+    public static function deleteSurvey($sid)
+    {
+        $sql = 'DELETE s.*, v.*, a.*
+                  FROM surveys AS s
+             LEFT JOIN survey_votes AS v
+                    ON v.survey_id=s.id
+             LEFT JOIN survey_answers AS a
+                    ON a.vote_id=v.id
+                 WHERE s.id={?};';
+        return XDB::execute($sql, $sid);
+    }
+    // }}}
+
+    // {{{ static function purgeVotes() : clears all votes concerning a survey (I'm not sure whether it's really useful)
+    public static function purgeVotes($sid)
+    {
+        $sql = 'DELETE v.*, a.*
+                  FROM survey_votes AS v
+             LEFT JOIN survey_answers AS a
+                    ON a.vote_id=v.id
+                 WHERE v.survey_id={?};';
+        return XDB::execute($sql, $sid);
+    }
+    // }}}
+
+    // }}}
+}
+// }}}
+
+// {{{ abstract class SurveyQuestion
+abstract class SurveyQuestion
+{
+    // {{{ common properties, constructor, and basic methods
+    private $question;
+    private $comment;
+
+    public function __construct($args)
+    {
+        $this->update($args);
+    }
+
+    public function update($a)
+    {
+        $this->question = $a['question'];
+        $this->comment  = $a['comment'];
+    }
+
+    abstract protected function getQuestionType();
+    // }}}
+
+    // {{{ function toArray() : converts to array
+    public function toArray()
+    {
+        return array('type' => $this->getQuestionType(), 'question' => $this->question, 'comment' => $this->comment);
+    }
+    // }}}
+
+    // {{{ function checkSyntax() : checks question elements (before storing into database), not currently needed (with new structure)
+    protected function checkSyntax()
+    {
+        return null;
+    }
+    // }}}
+
+    // {{{ function checkAnswer : returns a correct answer (or a null value if error)
+    public function checkAnswer($ans)
+    {
+        return null;
+    }
+    // }}}
+
+    // {{{ functions regarding the results of a survey
+    abstract public function getResultArray($sid, $qid);
+
+    public function formatAnswer($ans)
+    {
+        return $ans;
+    }
+
+    public function getCSVColumns()
+    {
+        return $this->question;
+    }
+    // }}}
+}
+// }}}
+
+// {{{ abstract class SurveySimple and its derived classes : "open" questions
+// {{{ abstract class SurveySimple extends SurveyQuestion
+abstract class SurveySimple extends SurveyQuestion
+{
+    public function checkAnswer($ans)
+    {
+        return array($ans);
+    }
+
+    public function getResultArray($sid, $qid)
+    {
+        $sql = 'SELECT answer
+                  FROM survey_answers
+                 WHERE vote_id IN (SELECT id FROM survey_votes WHERE survey_id={?})
+                   AND question_id={?}
+              ORDER BY RAND()
+                 LIMIT 5;';
+        $res = XDB::query($sql, $sid, $qid);
+        return $res->fetchAllAssoc();
+    }
+}
+// }}}
+
+// {{{ class SurveyText extends SurveySimple : simple text field, allowing a few words
+class SurveyText extends SurveySimple
+{
+    public function getQuestionType()
+    {
+        return "text";
+    }
+}
+// }}}
+
+// {{{ class SurveyTextarea extends SurveySimple : textarea field, allowing longer comments
+class SurveyTextarea extends SurveySimple
+{
+    public function getQuestionType()
+    {
+        return "textarea";
+    }
+}
+// }}}
+
+// {{{ class SurveyNum extends SurveySimple : allows numerical answers
+class SurveyNum extends SurveySimple
+{
+    public function checkAnswer($ans)
+    {
+        return array(intval($ans));
+    }
+
+    protected function getQuestionType()
+    {
+        return "num";
+    }
+}
+// }}}
+// }}}
+
+// {{{ abstract class SurveyList and its derived classes : restricted questions that allows only a list of possible answers
+// {{{ abstract class SurveyList extends SurveyQuestion
+abstract class SurveyList extends SurveyQuestion
+{
+    protected $choices;
+
+    public function update($args)
+    {
+        parent::update($args);
+        $this->choices = array();
+        foreach ($args['choices'] as $val) {
+            if (trim($val) || trim($val) == '0') {
+                $this->choices[] = $val;
+            }
+        }
+    }
+
+    public function toArray()
+    {
+        $rArr = parent::toArray();
+        $rArr['choices'] = $this->choices;
+        return $rArr;
+    }
+
+    public function getResultArray($sid, $qid)
+    {
+        $sql = 'SELECT answer, COUNT(id) AS count
+                  FROM survey_answers
+                 WHERE vote_id IN (SELECT id FROM survey_votes WHERE survey_id={?})
+                   AND question_id={?}
+              GROUP BY answer ASC';
+        $res = XDB::query($sql, $sid, $qid);
+        return $res->fetchAllAssoc();
+    }
+
+    public function formatAnswer($ans)
+    {
+        if (array_key_exists($ans, $this->choices)) {
+            return $this->choices[$ans];
+        } else {
+            return null;
+        }
+    }
+}
+// }}}
+
+// {{{ class SurveyRadio extends SurveyList : radio question, allows one answer among the list offered
+class SurveyRadio extends SurveyList
+{
+    public function checkAnswer($ans)
+    {
+        $a = intval($ans);
+        return (array_key_exists($a, $this->choices))? array($a) : null;
+    }
+
+    protected function getQuestionType()
+    {
+        return "radio";
+    }
+}
+// }}}
+
+// {{{ class SurveyCheckbox extends SurveyList : checkbox question, allows any number of answers among the list offered
+class SurveyCheckbox extends SurveyList
+{
+    public function checkAnswer($ans)
+    {
+        $rep = array();
+        foreach ($ans as $a) {
+            $a = intval($a);
+            if (array_key_exists($a, $this->choices)) {
+                $rep[] = $a;
+            }
+        }
+        return (count($rep) == 0)? null : $rep;
+    }
+
+    protected function getQuestionType()
+    {
+        return "checkbox";
+    }
+}
+// }}}
+// }}}
+
+// {{{ abstract class SurveyTable and its derived classes : table question, each column represents a choice, each line represents a question
+// {{{ abstract class SurveyTable extends SurveyList
+abstract class SurveyTable extends SurveyList
+{
+    protected $subquestions;
+
+    public function update($args)
+    {
+        parent::update($args);
+        $this->subquestions = array();
+        foreach ($args['subquestions'] as $val) {
+            if (trim($val) || trim($val) == '0') {
+                $this->subquestions[] = $val;
+            }
+        }
+    }
+
+    public function toArray()
+    {
+        $rArr = parent::toArray();
+        $rArr['subquestions'] = $this->subquestions;
+        return $rArr;
+    }
+
+    public function getResultArray($sid, $qid)
+    {
+        $sql = 'SELECT answer, COUNT(id) AS count
+                  FROM survey_answers
+                 WHERE vote_id IN (SELECT id FROM survey_votes WHERE survey_id={?})
+                   AND question_id={?}
+              GROUP BY answer ASC';
+        $res = XDB::iterator($sql, $sid, $qid);
+        $result = array();
+        for ($i = 0; $i < count($this->subquestions); $i++) {
+            $result[$i] = array_fill(0, count($this->choices), 0);
+        }
+        while ($r = $res->next()) {
+            list($i, $j) = explode(':', $r['answer']);
+            $result[$i][$j] = $r['count'];
+        }
+        return $result;
+    }
+
+    public function formatAnswer($ans)
+    {
+        list($q, $c) = explode(':', $ans);
+        if (array_key_exists($q, $this->subquestions) && array_key_exists($c, $this->choices)) {
+            return array('id' => $q, 'answer' => $this->choices[$c]);
+        } else {
+            return null;
+        }
+    }
+
+    public function getCSVColumns()
+    {
+        $q = parent::getCSVColumns();
+        if (empty($this->subquestions)) {
+            return $q;
+        }
+        $a = array();
+        for ($k = 0; $k < count($this->subquestions); $k++) {
+            $a[$k] = $q.' : '.$this->subquestions[$k];
+        }
+        return $a;
+    }
+}
+// }}}
+
+// {{{ class SurveyRadioTable extends SurveyTable : SurveyTable with radio type choices
+class SurveyRadioTable extends SurveyTable
+{
+    public function checkAnswer($ans)
+    {
+        $rep = array();
+        foreach ($ans as $k => $a) {
+            if (!array_key_exists($k, $this->subquestions)) {
+                continue;
+            }
+            $a = intval($a);
+            if (array_key_exists($a, $this->choices)) {
+                $rep[] = $k . ':' . $a;
+            }
+        }
+        return (count($rep) == 0)? null : $rep;
+    }
+
+    protected function getQuestionType()
+    {
+        return "radiotable";
+    }
+
+}
+// }}}
+
+// {{{ class SurveyCheckboxTable extends SurveyTable : SurveyTable with checkbox type choices
+class SurveyCheckboxTable extends SurveyTable
+{
+    public function checkAnswer($ans)
+    {
+        $rep = array();
+        foreach ($ans as $k => $aa) {
+            if (!array_key_exists($k, $this->subquestions)) {
+                continue;
+            }
+            foreach ($aa as $a) {
+                $a = intval($a);
+                if (array_key_exists($a, $this->choices)) {
+                    $rep[] = $k . ':' . $a;
+                }
+            }
+        }
+        return (count($rep) == 0)? null : $rep;
+    }
+
+    protected function getQuestionType()
+    {
+        return "checkboxtable";
+    }
+
+}
+// }}}
+// }}}
+
+// vim:set et sw=4 sts=4 ts=4 foldmethod=marker enc=utf-8:
+?>
diff --git a/upgrade/1.1.0/update.sh b/upgrade/1.1.0/update.sh
new file mode 100755 (executable)
index 0000000..ac34396
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+. ../inc/pervasive.sh
+
+###########################################################
+[ "$DATABASE" != "x4dat" ] || die "Cannot target x4dat"
+copy_db
+
+confirm "* Running database upgrade scripts"
+#mysql_run_directory .
index b846b39..7455441 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
index 0928200..dcf3f3e 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *