merge with master
authorPascal Corpet <pascal.corpet@m4x.org>
Tue, 22 Jul 2008 21:12:01 +0000 (23:12 +0200)
committerPascal Corpet <pascal.corpet@m4x.org>
Tue, 22 Jul 2008 21:12:01 +0000 (23:12 +0200)
93 files changed:
bin/cron/checkdb.php
bin/cron/phones.check.php [new file with mode: 0755]
configs/.gitignore
configs/platal.cron.in
htdocs/css/default.css
htdocs/images/networking/aim.png [new file with mode: 0644]
htdocs/images/networking/bonjour.png [new file with mode: 0644]
htdocs/images/networking/facebook.png [new file with mode: 0644]
htdocs/images/networking/gadu-gadu.png [new file with mode: 0644]
htdocs/images/networking/gpg.png [new file with mode: 0644]
htdocs/images/networking/gtalk.png [new file with mode: 0644]
htdocs/images/networking/icq.png [new file with mode: 0644]
htdocs/images/networking/irc.png [new file with mode: 0644]
htdocs/images/networking/jabber.png [new file with mode: 0644]
htdocs/images/networking/lastfm.png [new file with mode: 0644]
htdocs/images/networking/linkedin.png [new file with mode: 0644]
htdocs/images/networking/meanwhile.png [new file with mode: 0644]
htdocs/images/networking/msn.png [new file with mode: 0644]
htdocs/images/networking/myspace.png [new file with mode: 0644]
htdocs/images/networking/netvibes.png [new file with mode: 0644]
htdocs/images/networking/novell.png [new file with mode: 0644]
htdocs/images/networking/qq.png [new file with mode: 0644]
htdocs/images/networking/silc.png [new file with mode: 0644]
htdocs/images/networking/simple.png [new file with mode: 0644]
htdocs/images/networking/skype.png [new file with mode: 0644]
htdocs/images/networking/viadeo.png [new file with mode: 0644]
htdocs/images/networking/web.gif [new file with mode: 0644]
htdocs/images/networking/yahoo.png [new file with mode: 0644]
htdocs/images/networking/youtube.png [new file with mode: 0644]
htdocs/images/networking/zephyr.png [new file with mode: 0644]
htdocs/javascript/profile.js
htdocs/xorg.php
include/emails.combobox.inc.php [new file with mode: 0644]
include/notifs.inc.php
include/profil.func.inc.php
include/user.func.inc.php
include/userset.inc.php
include/webservices/manageurs.server.inc.php
include/xorg/session.inc.php [new file with mode: 0644]
modules/email.php
modules/fusionax.php [new file with mode: 0644]
modules/fusionax/Activites.sql [new file with mode: 0644]
modules/fusionax/Adresses.sql [new file with mode: 0644]
modules/fusionax/Anciens.sql [new file with mode: 0644]
modules/fusionax/Entreprises.sql [new file with mode: 0644]
modules/fusionax/Formations.sql [new file with mode: 0644]
modules/fusionax/import-ax.sh [new file with mode: 0755]
modules/geoloc.php
modules/marketing.php
modules/payment/money/paypal.inc.php
modules/profile.php
modules/profile/addresses.inc.php
modules/profile/general.inc.php
modules/profile/jobs.inc.php
modules/profile/page.inc.php
modules/search.php
modules/search/classes.inc.php
modules/search/search.inc.php
plugins/function.display_address.php
plugins/function.display_phones.php [new file with mode: 0644]
templates/admin/index.tpl
templates/core/vcard.tpl
templates/emails/redirect.tpl
templates/events/index.tpl
templates/fusionax/ids.tpl [new file with mode: 0644]
templates/fusionax/idsMissingInAx.tpl [new file with mode: 0644]
templates/fusionax/idsMissingInXorg.tpl [new file with mode: 0644]
templates/fusionax/import.tpl [new file with mode: 0644]
templates/fusionax/index.tpl [moved from templates/profile/adresses.tel.tpl with 68% similarity]
templates/fusionax/listFusion.tpl [new file with mode: 0644]
templates/fusionax/misc.tpl [new file with mode: 0644]
templates/include/emails.combobox.tpl [new file with mode: 0644]
templates/include/minifiche.tpl
templates/include/plview.referent.tpl
templates/include/plview.trombi.tpl
templates/include/trombi.tpl
templates/marketing/private.tpl
templates/profile/adresses.address.tpl
templates/profile/general.networking.tpl [new file with mode: 0644]
templates/profile/general.searchname.tpl [new file with mode: 0644]
templates/profile/general.tpl
templates/profile/jobs.job.tpl
templates/profile/phone.tpl [new file with mode: 0644]
templates/profile/profile.tpl
templates/search/adv.form.tpl
upgrade/fusionax-0.0.1/00_names.sql [new file with mode: 0644]
upgrade/fusionax-0.0.1/01_addrcomment.sql [new file with mode: 0644]
upgrade/fusionax-0.0.1/02_networking.sql [new file with mode: 0644]
upgrade/fusionax-0.0.1/03_emails.sql [new file with mode: 0644]
upgrade/fusionax-0.0.1/03_telephone.sql [new file with mode: 0644]
upgrade/fusionax-0.0.1/connect.db.inc.php [new file with mode: 0644]
upgrade/fusionax-0.0.1/phones.php [new file with mode: 0755]
upgrade/fusionax-0.0.1/update.sh [new file with mode: 0755]

index b891fec..5103817 100755 (executable)
@@ -73,17 +73,16 @@ if ( PEAR::isError($opts) ) {
 
 /* Validite des flags de transmission */
 check("SELECT  u.user_id, nom, prenom, promo,
-               profile_mobile_pub, emails_alias_pub, profile_web_pub, profile_freetext_pub, profile_medals_pub
+               emails_alias_pub, profile_freetext_pub, profile_medals_pub
          FROM  auth_user_md5 AS u
    INNER JOIN  auth_user_quick AS q USING(user_id)
-        WHERE  (profile_mobile_pub != 'private' AND profile_mobile_pub != 'ax' AND profile_mobile_pub != 'public')
-           OR  (emails_alias_pub != 'private' AND emails_alias_pub != 'public')
-           OR  (profile_web_pub != 'private' AND profile_web_pub != 'public')
+        WHERE  (emails_alias_pub != 'private' AND emails_alias_pub != 'public')
            OR  (profile_freetext_pub != 'private' AND profile_freetext_pub != 'public')
            OR  (profile_medals_pub != 'private' AND profile_medals_pub != 'public')",
     "Utilisateur n'ayant pas de flag de publicite pour leurs donnees de profil");
 check("select uid from adresses where pub != 'private' and pub !='ax' and pub != 'public'", "Utiliseur n'ayant pas de flag de publicite pour une adresse");
-check("select uid from tels where tel_pub != 'private' and tel_pub !='ax' and tel_pub != 'public'", "Utiliseur n'ayant pas de flag de publicite pour un numero de telephone");
+check("select uid from profile_phones where pub != 'private' and pub != 'ax' and pub != 'public'", "Utiliseur n'ayant pas de flag de publicite pour un numero de téléphone");
+check("select uid from profile_networking where pub != 'private' and pub != 'public'", "Utiliseur n'ayant pas de flag de publicité pour une adresse de networking");
 
 /* validite de aliases */
 check("SELECT a.*
@@ -119,6 +118,16 @@ check("select g.* from groupesx_ins as g left join groupesx_def as gd on g.gid=g
 /* validite de photo */
 check("select p.* from photo as p left join auth_user_md5 as u on u.user_id=p.uid where u.prenom is null");
 
+/* validite des formats téléphoniques */
+check("SELECT DISTINCT g.phoneprf from geoloc_pays AS g
+          WHERE EXISTS (SELECT h.phoneprf
+                          FROM geoloc_pays AS h
+                         WHERE h.phoneprf = g.phoneprf AND h.phoneformat != (SELECT i.phoneformat
+                                                                               FROM geoloc_pays AS i
+                                                                              WHERE i.phoneprf = g.phoneprf
+                                                                              LIMIT 1))",
+      "Préfixes téléphoniques qui ont des formats de numéros de téléphones différents selon les pays");
+
 /* validite des champ pays et region */
 check("SELECT a.uid, a.country FROM adresses AS a LEFT JOIN geoloc_pays AS gp ON a.country = gp.a2 WHERE gp.pays IS NULL","donne la liste des pays dans les profils qui n'ont pas d'entree correspondante dans geoloc_pays");
 /* les régions ne sont valides que dans les adresses pros */
@@ -175,7 +184,25 @@ check("SELECT  matricule,nom,prenom,matricule_ax,COUNT(matricule_ax) AS c
         WHERE  matricule_ax != '0'
         GROUP BY  matricule_ax
         having  c > 1", "à chaque personne de l'annuaire de l'AX (identification_ax) doit correspondre AU PLUS UNE personne de notre annuaire (auth_user_md5) -> si ce n'est pas le cas il faut regarder en manuel ce qui ne va pas !");
-
+        
+/* each alumni has one and only one display name by default and one and only one name when we talk to him directly */
+check("SELECT u.`user_id`, u.`nom`, u.`prenom`, COUNT(n.`display`) AS c
+        FROM `auth_user_md5` AS u
+        LEFT JOIN `profile_names_display` AS n ON(u.`user_id` = n.`user_id` AND FIND_IN_SET(n.`reason`, 'default'))
+        GROUP BY u.`user_id`
+        HAVING c != 1", "chaque personne doit avoir un et un seul nom par défaut");
+check("SELECT u.`user_id`, u.`nom`, u.`prenom`, COUNT(n.`display`) AS c
+        FROM `auth_user_md5` AS u
+        LEFT JOIN `profile_names_display` AS n ON(u.`user_id` = n.`user_id` AND FIND_IN_SET(n.`reason`, 'yourself'))
+        GROUP BY u.`user_id`
+        HAVING c != 1", "chaque personne doit avoir un et un seul nom quand on lui parle");
+
+/* no alumni is allowed to have empty names */
+check("SELECT u.`user_id`, u.`nom`, u.`prenom`
+        FROM `auth_user_md5` AS u
+        INNER JOIN `profile_names_search` AS n USING(`user_id`)
+        WHERE n.`search_name` = ''", "liste des personnes qui ont un de leur nom de recherche vide");
+        
 /* verifie qu'il n'y a pas d'utilisateurs ayant un compte Google Apps désactivé et une redirection encore active vers Google Apps */
 check("SELECT  a.alias, g.g_status, u.mail_storage
          FROM  auth_user_md5 AS u
diff --git a/bin/cron/phones.check.php b/bin/cron/phones.check.php
new file mode 100755 (executable)
index 0000000..6f8e14d
--- /dev/null
@@ -0,0 +1,105 @@
+#!/usr/bin/php5
+<?php
+
+require('./connect.db.inc.php');
+
+//next two are required to include 'profil.func.inc.php'
+require_once('xorg.inc.php');
+$page = new XorgPage(null);
+
+require_once('profil.func.inc.php');
+
+$globals->debug = 0; //do not store backtraces
+
+
+function do_update_by_block($values)
+{
+    // Update display_tel by block
+    // Because there is no mysql update syntax for multiple updates in one query
+    // we use a multiple insert syntax which will fail because the key already exist
+    // and then update the display_tel
+    XDB::execute("INSERT INTO  profile_phones (uid, link_type, link_id, tel_id ,tel_type,
+                                          search_tel, display_tel, pub, comment)
+                       VALUES  " . $values . "
+      ON DUPLICATE KEY UPDATE  display_tel = VALUES(display_tel)");
+}
+
+$res = XDB::query("SELECT DISTINCT g.phoneprf FROM geoloc_pays AS g WHERE g.phoneprf IS NOT NULL");
+$prefixes = $res->fetchColumn();
+foreach ($prefixes as $i => $prefix) {
+    $res = XDB::query("SELECT g.phoneformat FROM geoloc_pays AS g
+                        WHERE g.phoneprf = {?} AND g.phoneformat != '' LIMIT 1",
+                      $prefix);
+    if ($res->numRows() > 0) {
+        $format = $res->fetchOneCell();
+        //Build regexp for mysql query
+        $len = strlen($format);
+        $regexp = "^";
+        $nbPar = 0;
+        for ($i = 0; $i < $len; $i++) {
+            $char = $format[$i];
+            switch ($char) {
+            case 'p':
+                $regexp .= $prefix;
+                break;
+            case '#':
+                if ($nbPar == 0) {
+                    $regexp .= '(';
+                    $nbPar++;
+                }
+                $regexp .= '[0-9](';
+                $nbPar++;
+                break;
+            default:
+                //Appends the char after escaping it if necessary
+                $escape = array('[', ']', '{', '}', '(', ')', '*', '+', '?', '.', '^', '$', '|', '\\');
+                if (in_array($char, $escape)) {
+                    $regexp .= '[' . $char . ']';
+                } else {
+                    $regexp .= $char;
+                }
+            }
+        }
+        //allows additionnal spaces and numbers
+        $regexp .= '[0-9 ]*';
+        //closes parenthesis
+        for ($i = 0; $i < $nbPar; $i++) {
+            $regexp .= ')?';
+        }
+        $regexp .= '$';
+        $res = XDB::iterator("SELECT uid, link_type, link_id, tel_id, tel_type, search_tel,
+                                     display_tel, pub, comment
+                                FROM profile_phones
+                               WHERE search_tel LIKE {?} AND display_tel NOT REGEXP {?}",
+                             $prefix . '%', $regexp);
+        if ($res->numRows() > 0)
+        {
+            //To speed up the update of phone numbers, theses updates are grouped by block of 1000
+            $values = '';
+            $i = 0;
+            while ($phone = $res->next()) {
+                $disp = format_display_number($phone['search_tel'], $error, array('format' => $format, 'phoneprf' => $prefix));
+                if ($values != '') {
+                    $values .= ",\n";
+                }
+                $values .= "('"   . addslashes($phone['uid']) . "', '" . addslashes($phone['link_type'])
+                    . "', '" . addslashes($phone['link_id'])
+                    . "', '" . addslashes($phone['tel_id']) . "', '" . addslashes($phone['tel_type'])
+                    . "', '" . addslashes($phone['search_tel']) . "', '" . addslashes($disp)
+                    . "', '" . addslashes($phone['pub']) . "', '" . addslashes($phone['comment']) . "')";
+                $i++;
+                if ($i == 1000) {
+                    do_update_by_block($values);
+                    $values = '';
+                    $i = 0;
+                }
+            }
+            if ($values != '') {
+                do_update_by_block($values);
+            }
+        }
+    }
+}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
index 08b9b45..8767aa4 100644 (file)
@@ -1,3 +1,4 @@
 platal.conf
 platal.cron
+ax_xorg_rsa.pem
 *.pem
index fafa58b..0994ace 100644 (file)
@@ -7,6 +7,7 @@ WD=/home/web/prod/platal/bin/cron
 0 21 * * 1-6   web     cd $WD; ./checkdb.php    | mail -e -s "verifications sur la BDD de plat/al @VERSION@"         br@staff.m4x.org
 0 21 * * 0     web     cd $WD; ./checkdb.php -v | mail -e -s "verifications verbose sur la BDD de plat/al @VERSION@" br@staff.m4x.org
 0 20 * * *      web     cd $WD; ./emails.check.php | mail -e -s "qualite de l'annuaire"                   br@staff.m4x.org
+0 22 * * *      web     cd $WD; ./phones.check.php > /dev/null
 
 # inscription report
 0  6 * * 1     web     cd $WD; ./rapports_inscription.php
index 8a379b2..f76e148 100644 (file)
@@ -107,6 +107,10 @@ p {
     background: inherit;
 }
 
+.hinted {
+    border-bottom: 1px dashed black;
+}
+
 input.error, textarea.error {
     background-color: #faa;
 }
diff --git a/htdocs/images/networking/aim.png b/htdocs/images/networking/aim.png
new file mode 100644 (file)
index 0000000..c47703b
Binary files /dev/null and b/htdocs/images/networking/aim.png differ
diff --git a/htdocs/images/networking/bonjour.png b/htdocs/images/networking/bonjour.png
new file mode 100644 (file)
index 0000000..8ff4740
Binary files /dev/null and b/htdocs/images/networking/bonjour.png differ
diff --git a/htdocs/images/networking/facebook.png b/htdocs/images/networking/facebook.png
new file mode 100644 (file)
index 0000000..2731863
Binary files /dev/null and b/htdocs/images/networking/facebook.png differ
diff --git a/htdocs/images/networking/gadu-gadu.png b/htdocs/images/networking/gadu-gadu.png
new file mode 100644 (file)
index 0000000..2d060a1
Binary files /dev/null and b/htdocs/images/networking/gadu-gadu.png differ
diff --git a/htdocs/images/networking/gpg.png b/htdocs/images/networking/gpg.png
new file mode 100644 (file)
index 0000000..97a6498
Binary files /dev/null and b/htdocs/images/networking/gpg.png differ
diff --git a/htdocs/images/networking/gtalk.png b/htdocs/images/networking/gtalk.png
new file mode 100644 (file)
index 0000000..e80b03b
Binary files /dev/null and b/htdocs/images/networking/gtalk.png differ
diff --git a/htdocs/images/networking/icq.png b/htdocs/images/networking/icq.png
new file mode 100644 (file)
index 0000000..d08637c
Binary files /dev/null and b/htdocs/images/networking/icq.png differ
diff --git a/htdocs/images/networking/irc.png b/htdocs/images/networking/irc.png
new file mode 100644 (file)
index 0000000..19d578d
Binary files /dev/null and b/htdocs/images/networking/irc.png differ
diff --git a/htdocs/images/networking/jabber.png b/htdocs/images/networking/jabber.png
new file mode 100644 (file)
index 0000000..77a3f64
Binary files /dev/null and b/htdocs/images/networking/jabber.png differ
diff --git a/htdocs/images/networking/lastfm.png b/htdocs/images/networking/lastfm.png
new file mode 100644 (file)
index 0000000..d2e1075
Binary files /dev/null and b/htdocs/images/networking/lastfm.png differ
diff --git a/htdocs/images/networking/linkedin.png b/htdocs/images/networking/linkedin.png
new file mode 100644 (file)
index 0000000..3c796dc
Binary files /dev/null and b/htdocs/images/networking/linkedin.png differ
diff --git a/htdocs/images/networking/meanwhile.png b/htdocs/images/networking/meanwhile.png
new file mode 100644 (file)
index 0000000..59b819c
Binary files /dev/null and b/htdocs/images/networking/meanwhile.png differ
diff --git a/htdocs/images/networking/msn.png b/htdocs/images/networking/msn.png
new file mode 100644 (file)
index 0000000..896d90c
Binary files /dev/null and b/htdocs/images/networking/msn.png differ
diff --git a/htdocs/images/networking/myspace.png b/htdocs/images/networking/myspace.png
new file mode 100644 (file)
index 0000000..040f3d1
Binary files /dev/null and b/htdocs/images/networking/myspace.png differ
diff --git a/htdocs/images/networking/netvibes.png b/htdocs/images/networking/netvibes.png
new file mode 100644 (file)
index 0000000..b464fff
Binary files /dev/null and b/htdocs/images/networking/netvibes.png differ
diff --git a/htdocs/images/networking/novell.png b/htdocs/images/networking/novell.png
new file mode 100644 (file)
index 0000000..76ca119
Binary files /dev/null and b/htdocs/images/networking/novell.png differ
diff --git a/htdocs/images/networking/qq.png b/htdocs/images/networking/qq.png
new file mode 100644 (file)
index 0000000..d5f51ac
Binary files /dev/null and b/htdocs/images/networking/qq.png differ
diff --git a/htdocs/images/networking/silc.png b/htdocs/images/networking/silc.png
new file mode 100644 (file)
index 0000000..2fb91eb
Binary files /dev/null and b/htdocs/images/networking/silc.png differ
diff --git a/htdocs/images/networking/simple.png b/htdocs/images/networking/simple.png
new file mode 100644 (file)
index 0000000..14db36c
Binary files /dev/null and b/htdocs/images/networking/simple.png differ
diff --git a/htdocs/images/networking/skype.png b/htdocs/images/networking/skype.png
new file mode 100644 (file)
index 0000000..2b8a088
Binary files /dev/null and b/htdocs/images/networking/skype.png differ
diff --git a/htdocs/images/networking/viadeo.png b/htdocs/images/networking/viadeo.png
new file mode 100644 (file)
index 0000000..ddf5aca
Binary files /dev/null and b/htdocs/images/networking/viadeo.png differ
diff --git a/htdocs/images/networking/web.gif b/htdocs/images/networking/web.gif
new file mode 100644 (file)
index 0000000..9fad760
Binary files /dev/null and b/htdocs/images/networking/web.gif differ
diff --git a/htdocs/images/networking/yahoo.png b/htdocs/images/networking/yahoo.png
new file mode 100644 (file)
index 0000000..4cff5da
Binary files /dev/null and b/htdocs/images/networking/yahoo.png differ
diff --git a/htdocs/images/networking/youtube.png b/htdocs/images/networking/youtube.png
new file mode 100644 (file)
index 0000000..5024200
Binary files /dev/null and b/htdocs/images/networking/youtube.png differ
diff --git a/htdocs/images/networking/zephyr.png b/htdocs/images/networking/zephyr.png
new file mode 100644 (file)
index 0000000..fcc40a8
Binary files /dev/null and b/htdocs/images/networking/zephyr.png differ
index 4c7d01f..d625bfb 100644 (file)
@@ -89,7 +89,78 @@ function selectType(selectCtrl, type)
     }
 }
 
+function addSearchName()
+{
+  var i = 0;
+  while (document.getElementById('search_name_' + i) != null) {
+      i++;
+  }
+  $('#add_search_name').before('<div id="search_name_' + i + '" style="padding:2px" class="center"></div>');
+  Ajax.update_html('search_name_' + i, 'profile/ajax/searchname/' + i,function(){
+    $('#search_name_'+i+' input')[1].focus();
+  });
+}
+
+function removeSearchName(i)
+{
+  if (document.getElementById('search_name_'+i+'_new') != null) {
+    $('#search_name_'+i).remove();
+  } else {
+    removeObject('search_name_'+i, 'search_name['+i+']');
+  }
+}
 
+function addNetworking()
+{
+    var i = 0;
+    var nws = 'networking_';
+    while (document.getElementById(nws + i) != null) {
+        i++;
+    }
+    var namefirst = '';
+    var html = '<tr id="networking_' + i + '">'
+        + '  <td colspan="2">'
+        + '    <div style="float: left; width: 200px;">'
+        + '      <span class="flags">'
+        + '        <input type="checkbox" name="networking[' + i + '][pub]"/>'
+        + '        <img src="images/icons/flag_green.gif" alt="site public" title="site public">'
+        + '      </span>&nbsp;'
+        + '      <select id="networking_type_' + i + '" name="networking[' + i + '][type]" onchange="javascript:updateNetworking(' + i + ');">';
+    for (nw in nw_list) {
+        if (namefirst == '') {
+            namefirst = nw;
+        }
+        html += '  <option value="' + nw_list[nw] + '">' + nw + '</option>';
+    }
+    html += '</select>'
+        + '      <input type="hidden" id="networking_name_' + i + '" name="networking[' + i + '][name]" value="' + namefirst + '"/>'
+        + '    </div>'
+        + '    <div style="float: left">'
+        + '      <input type="text" name="networking[' + i + '][address]" value="" size="30"/>'
+        + '      <a href="javascript:removeNetworking(' + i + ')">'
+        + '        <img src="images/icons/cross.gif" alt="cross" title="Supprimer cet élément"/>'
+        + '      </a>'
+        + '    </div>'
+        + '  </td>'
+        + '</tr>';
+
+    $('#networking').before(html);
+}
+
+function removeNetworking(id)
+{
+    $('#networking_' + id).remove();
+}
+
+function updateNetworking(i)
+{
+    var name = document.getElementById('networking_name_' + i);
+    var type = document.getElementById('networking_type_' + i);
+    if (type != null && name != null) {
+        name.value = type.options[type.selectedIndex].text;
+    }
+
+}
 
 // Addresses
 
@@ -166,18 +237,34 @@ function addAddress()
     Ajax.update_html('addresses_' + i + '_cont', 'profile/ajax/address/' + i, checkCurrentAddress);
 }
 
-function addTel(id)
+function addTel(prefid, prefname)
 {
     var i = 0;
-    var adid = 'addresses_' + id;
-    var tel  = adid + '_tel_';
-    while (document.getElementById(tel + i) != null) {
+    var prefix  = prefid + '_';
+    while (document.getElementById(prefix + i) != null) {
         i++;
     }
-    $('#' + adid + '_add_tel').before('<div id="' + tel + i + '" style="clear: both"></div>');
-    Ajax.update_html(tel + i, 'profile/ajax/tel/' + id + '/' + 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);
 }
 
+function removeTel(id)
+{
+    $('#' + id).remove();
+}
+
+function addPhoneComment(id, pref)
+{
+    document.getElementById(id+'_comment').style.display = '';
+    document.getElementById(id+'_addComment').style.display = 'none';
+}
+
+function removePhoneComment(id, pref)
+{
+    document.getElementById(id+'_comment').style.display = 'none';
+    document.forms.prof_annu[pref+ '[comment]'].value = '';
+    document.getElementById(id+'_addComment').style.display = '';
+}
 
 // Geoloc
 
index 3dc92b2..b5e0726 100644 (file)
@@ -26,6 +26,7 @@ if (!($path = Env::v('n')) || ($path{0} < 'A' || $path{0} > 'Z')) {
                          'geoloc', 'lists', 'marketing', 'payment', 'platal',
                          'profile', 'register', 'search', 'stats', 'admin',
                          'newsletter', 'axletter', 'bandeau', 'survey',
+                         'fusionax',
                          'gadgets', 'googleapps');
     $platal->run();
     exit;
diff --git a/include/emails.combobox.inc.php b/include/emails.combobox.inc.php
new file mode 100644 (file)
index 0000000..1bdab67
--- /dev/null
@@ -0,0 +1,107 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2008 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************/
+
+function fill_email_combobox(PlatalPage& $page)
+{
+    global $globals;
+
+    $uid        = S::v('uid');
+    $forlife    = S::v('forlife');
+    $email_type = "directory";
+
+    $res = XDB::query(
+            "SELECT  email_directory
+               FROM  profile_directory
+              WHERE  uid={?}", $uid);
+    $email_directory = $res->fetchOneCell();
+    if ($email_directory) {
+        $page->assign('email_directory', $email_directory);
+        list($alias, $domain) = explode('@', $email_directory);
+    } else {
+        $page->assign('email_directory', '');
+        $email_type = NULL;
+        $alias = $domain = '';
+    }
+
+    $res = XDB::query(
+            "SELECT  alias
+               FROM  virtual
+         INNER JOIN  virtual_redirect USING(vid)
+              WHERE  (redirect={?} OR redirect={?})
+                     AND alias LIKE '%@{$globals->mail->alias_dom}'",
+            $forlife . '@' . $globals->mail->domain, $forlife . '@' . $globals->mail->domain2);
+    $melix = $res->fetchOneCell();
+    if ($melix) {
+        list($melix) = explode('@', $melix);
+        $page->assign('melix', $melix);
+        if (($domain == $globals->mail->alias_dom) || ($domain == $globals->mail->alias_dom2)) {
+            $email_type = "melix";
+        }
+    }
+
+    $res = XDB::query(
+            "SELECT  alias
+               FROM  aliases
+              WHERE  id={?} AND (type='a_vie' OR type='alias')", $uid);
+    $res = $res->fetchAllAssoc();
+    $page->assign('list_email_X', $res);
+    if (($domain == $globals->mail->domain) || ($domain == $globals->mail->domain2)) {
+        foreach ($res as $res_it) {
+            if ($alias == $res_it['alias']) {
+                $email_type = "X";
+            }
+        }
+    }
+
+    require_once 'emails.inc.php';
+    $redirect = new Redirect($uid);
+    $redir    = array();
+    foreach ($redirect->emails as $redirect_it) {
+        if ($redirect_it instanceof EmailRedirection) {
+            $redir[] = $redirect_it->email;
+            if ($email_directory == $redirect_it->email) {
+                $email_type = "redir";
+            }
+        }
+    }
+    $page->assign('list_email_redir', $redir);
+
+    $res = XDB::query(
+            "SELECT  email
+               FROM  entreprises
+              WHERE  uid={?}", $uid);
+    $res = $res->fetchAllAssoc();
+    $pro = array();
+    foreach ($res as $res_it) {
+        if ($res_it['email'] != '') {
+            $pro[] = $res_it['email'];
+            if ($email_directory == $res_it['email']) {
+                $email_type = "pro";
+            }
+        }
+    }
+    $page->assign('list_email_pro', $pro);
+
+    $page->assign('email_type', $email_type);
+}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
index d48f010..3ee2037 100644 (file)
@@ -143,7 +143,7 @@ $prf_desc = array('nom' => 'Son patronyme',
                   'mobile' => 'Son numéro de téléphone portable',
                   'nationalite' => 'Sa nationalité',
                   'nick' => 'Son surnom',
-                  'web' => 'L\'adresse de son site web',
+                  'networking' => 'La liste de ses adresses de networking',
                   'appli1' => 'Son école d\'application',
                   'appli2' => 'Son école de post-application',
                   'addresses' => 'Ses adresses',
index 8a5edbf..24d5b7e 100644 (file)
@@ -62,16 +62,12 @@ function diff_user_details(&$a, &$b, $view = 'private') { // compute $c = $a - $
                 switch ($val) {
                     case 'adr' : if (!($c['adr'] = diff_user_addresses($a[$val], $bvar, $view))) unset($c['adr']); break;
                     case 'adr_pro' : if (!($c['adr_pro'] = diff_user_pros($a[$val], $bvar, $view))) unset($c['adr_pro']); break;
-                    case 'mobile' : if (same_tel($a[$val], $bvar)) unset($c['mobile']); break;
+                    case 'tels' : if (!($c['tels'] = diff_user_tels($a[$val], $bvar, $view))) unset($c['tels']); break;
                 }
             }
         }
     }
-    // don't modify mobile if you don't have the right
-    if (isset($b['mobile_pub']) && !has_user_right($b['mobile_pub'], $view) && isset($c['mobile']))
-        unset($c['mobile']);
-    if (isset($b['web_pub']) && !has_user_right($b['web_pub'], $view) && isset($c['web']))
-        unset($c['web']);
+    // don't modify freetext if you don't have the right
     if (isset($b['freetext_pub']) && !has_user_right($b['freetext_pub'], $view) && isset($c['freetext']))
         unset($c['freetext']);
     if (!count($c))
@@ -80,15 +76,15 @@ function diff_user_details(&$a, &$b, $view = 'private') { // compute $c = $a - $
 }
 
 function same_tel(&$a, &$b) {
-    $numbera = preg_replace('/[^0-9]/', '', (string) $a);
-    $numberb = preg_replace('/[^0-9]/', '', (string) $b);
+    $numbera = format_phone_number((string) $a);
+    $numberb = format_phone_number((string) $b);
     return $numbera === $numberb;
 }
 function same_address(&$a, &$b) {
     return
         (same_field($a['adr1'],$b['adr1'])) &&
-        (same_field($a['adr1'],$b['adr1'])) &&
-        (same_field($a['adr1'],$b['adr1'])) &&
+        (same_field($a['adr2'],$b['adr2'])) &&
+        (same_field($a['adr3'],$b['adr3'])) &&
         (same_field($a['postcode'],$b['postcode'])) &&
         (same_field($a['city'],$b['city'])) &&
         (same_field($a['countrytxt'],$b['countrytxt'])) &&
@@ -126,49 +122,57 @@ function diff_user_tel(&$a, &$b) {
     return $c;
 }
 
-function diff_user_address($a, $b) {
-    if (isset($b['pub']) && isset($a['pub']) && has_user_right($b['pub'], $a['pub']))
-        $a['pub'] = $b['pub'];
-    if (isset($b['tels'])) {
-        $bvar = $b['tels'];
-
-        $telids_b = array();
-        foreach ($bvar as $i => $telb) $telids_b[$telb['telid']] = $i;
+function diff_user_tels(&$a, &$b)
+{
+    $c = $a;
+    $telids_b = array();
+    foreach ($b as $i => $telb) $telids_b[$telb['telid']] = $i;
 
-        if (isset($a['tels']))
-            $avar = $a['tels'];
-        else
-            $avar = array();
-        $ctels = $avar;
-        foreach ($avar as $j => $tela) {
-            if (isset($tela['telid'])) {
-                // if b has a tel with the same telid, compute diff
-                if (isset($telids_b[$tela['telid']])) {
-                    if (!($ctels[$j] = diff_user_tel($tela, $varb[$telids_b[$tela['adrid']]])))
-                        unset($ctels[$j]);
-                    unset($telids_b[$tela['telid']]);
+    foreach ($a as $j => $tela) {
+        if (isset($tela['telid'])) {
+            // if b has a tel with the same telid, compute diff
+            if (isset($telids_b[$tela['telid']])) {
+                if (!($c[$j] = diff_user_tel($tela, $b[$telids_b[$tela['adrid']]]))) {
+                    unset($c[$j]);
                 }
-            } else {
-                // try to find a match in b
-                foreach ($bvar as $i => $telb) {
-                    if (same_tel($tela['tel'], $telb['tel'])) {
-                        $tela['telid'] = $telb['telid'];
-                        if (!($ctels[$j] = diff_user_tel($tela, $telb)))
-                            unset($ctels[$j]);
-                        unset($telids_b[$tela['telid']]);
-                        break;
+                unset($telids_b[$tela['telid']]);
+            }
+        } else {
+            // try to find a match in b
+            foreach ($b as $i => $telb) {
+                if (same_tel($tela['tel'], $telb['tel'])) {
+                    $tela['telid'] = $telb['telid'];
+                    if (!($c[$j] = diff_user_tel($tela, $telb))) {
+                        unset($c[$j]);
                     }
+                    unset($telids_b[$tela['telid']]);
+                    break;
                 }
             }
         }
+    }
 
-        foreach ($telids_b as $telidb => $i)
-            $ctels[] = array('telid' => $telidb, 'remove' => 1);
+    foreach ($telids_b as $telidb => $i)
+        $c[] = array('telid' => $telidb, 'remove' => 1);
+    return $c;
+}
+
+function diff_user_address($a, $b) {
+    if (isset($b['pub']) && isset($a['pub']) && has_user_right($b['pub'], $a['pub']))
+        $a['pub'] = $b['pub'];
+    if (isset($b['tels'])) {
+        if (isset($a['tels'])) {
+            $avar = $a['tels'];
+        } else {
+            $avar = array();
+        }
+        $ctels = diff_user_tels($avar, $b['tels']);
 
         if (!count($ctels)) {
             $b['tels'] = $avar;
-        } else
+        } else {
             $a['tels'] = $ctels;
+        }
     }
 
     foreach ($a as $val => $avar) {
@@ -229,13 +233,18 @@ function diff_user_pro($a, &$b, $view = 'private') {
     }
     if (isset($b['adr_pub']) && isset($a['adr_pub']) && has_user_right($b['adr_pub'], $a['adr_pub']))
         $a['adr_pub'] = $b['adr_pub'];
-    if (isset($b['tel_pub']) && !has_user_right($b['tel_pub'], $view)) {
-        unset($a['tel']);
-        unset($a['fax']);
-        unset($a['mobile']);
+    if (isset($b['tels'])) {
+        if (isset($a['tels']))
+            $avar = $a['tels'];
+        else
+            $avar = array();
+        $ctels = diff_user_tels($avar, $b['tels']);
+
+        if (!count($ctels)) {
+            $b['tels'] = $avar;
+        } else
+            $a['tels'] = $ctels;
     }
-    if (isset($b['tel_pub']) && isset($a['tel_pub']) && has_user_right($b['tel_pub'], $a['tel_pub']))
-        $a['tel_pub'] = $b['tel_pub'];
     if (isset($b['email_pub']) && !has_user_right($b['email_pub'], $view))
         unset($a['email']);
     if (isset($b['email_pub']) && isset($a['email_pub']) && has_user_right($b['email_pub'], $a['email_pub']))
@@ -284,5 +293,65 @@ function diff_user_pros(&$a, &$b, $view = 'private') {
     return $c;
 }
 
+function format_phone_number($tel)
+{
+    $tel = trim($tel);
+    if (substr($tel, 0, 3) === '(0)') {
+        $tel = '33' . $tel;
+    }
+    $tel = preg_replace('/\(0\)/',  '', $tel);
+    $tel = preg_replace('/[^0-9]/', '', $tel);
+    if (substr($tel, 0, 2) === '00') {
+        $tel = substr($tel, 2);
+    } else if(substr($tel, 0, 1) === '0') {
+        $tel = '33' . substr($tel, 1);
+    }
+    return $tel;
+}
+
+function format_display_number($tel, &$error, $format = array('format'=>'','phoneprf'=>''))
+{
+    $error = false;
+    $ret = '';
+    $tel_length = strlen($tel);
+    if((!isset($format['phoneprf'])) || ($format['phoneprf'] == '')) {
+        $res = XDB::query("SELECT phoneprf, phoneformat AS format
+                             FROM geoloc_pays
+                            WHERE phoneprf = {?} OR phoneprf = {?} OR phoneprf = {?}
+                            LIMIT 1",
+                          substr($tel, 0, 1), substr($tel, 0, 2), substr($tel, 0, 3));
+        if ($res->numRows() == 0) {
+            $error = true;
+            return '+' . $tel;
+        }
+        $format = $res->fetchOneAssoc();
+    }
+    if ($format['format'] == '') {
+        $format['format'] = '+p';
+    }
+    $j = 0;
+    $i = strlen($format['phoneprf']);
+    $length_format = strlen($format['format']);
+    while (($i < $tel_length) && ($j < $length_format)){
+        if ($format['format'][$j] == '#'){
+            $ret .= $tel[$i];
+            $i++;
+        } else if ($format['format'][$j] == 'p') {
+            $ret .= $format['phoneprf'];
+        } else {
+            $ret .= $format['format'][$j];
+        }
+        $j++;
+    }
+    for (; $i < $tel_length - 1; $i += 2) {
+        $ret .= ' ' . substr($tel, $i, 2);
+    }
+    //appends last alone number to the last block
+    if ($i < $tel_length) {
+        $ret .= substr($tel, $i);
+    }
+    return $ret;
+}
+
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
 ?>
index 21bcbb5..8ee201e 100644 (file)
@@ -41,7 +41,7 @@ function user_clear_all_subs($user_id, $really_del=true)
                              'user_id' => array('requests', 'user_changes'));
 
     if ($really_del) {
-        array_push($tables_to_clear['uid'], 'emails', 'groupex.membres', 'contacts', 'adresses', 'tels',
+        array_push($tables_to_clear['uid'], 'emails', 'groupex.membres', 'contacts', 'adresses', 'profile_phones',
                                             'photo', 'perte_pass', 'langues_ins', 'forums.abos', 'forums.profils');
         array_push($tables_to_clear['user_id'], 'newsletter_ins', 'auth_user_quick', 'binets_ins');
         $tables_to_clear['id'] = array('aliases');
@@ -275,8 +275,8 @@ function get_user_details_pro($uid, $view = 'private')
 {
     $sql  = "SELECT  e.entreprise, s.label as secteur , ss.label as sous_secteur , f.fonction_fr as fonction,
                      e.poste, e.adr1, e.adr2, e.adr3, e.postcode, e.city, e.entrid,
-                     gp.pays AS countrytxt, gr.name AS region, e.tel, e.fax, e.mobile, e.entrid,
-                     e.pub, e.adr_pub, e.tel_pub, e.email, e.email_pub, e.web
+                     gp.pays AS countrytxt, gr.name AS region, e.entrid,
+                     e.pub, e.adr_pub, e.email, e.email_pub, e.web
                FROM  entreprises AS e
           LEFT JOIN  emploi_secteur AS s ON(e.secteur = s.id)
           LEFT JOIN  emploi_ss_secteur AS ss ON(e.ss_secteur = ss.id AND e.secteur = ss.secteur)
@@ -310,16 +310,18 @@ function get_user_details_pro($uid, $view = 'private')
                     $all_pro[$i]['region'] = '';
                 }
             }
-            if (!has_user_right($pro['tel_pub'], $view)) {
-                // if no tel was defined, then the viewer will be able to write it
-                if ($pro['tel'] == '' &&
-                    $pro['fax'] == '' &&
-                    $pro['mobile'] == '') {
-                    $all_pro[$i]['tel_pub'] = $view;
-                } else {
-                    $all_pro[$i]['tel'] = '';
-                    $all_pro[$i]['fax'] = '';
-                    $all_pro[$i]['mobile'] = '';
+            $sql = "SELECT  pub AS tel_pub, tel_type, display_tel AS tel, comment
+                      FROM  profile_phones AS t
+                     WHERE  uid = {?} AND link_type = 'pro' AND link_id = {?}
+                  ORDER BY  link_id, tel_type DESC, tel_id";
+            $restel = XDB::iterator($sql, $uid, $pro['entrid']);
+            while ($nexttel = $restel->next()) {
+                if (has_user_right($nexttel['tel_pub'], $view)) {
+                    if (!isset($all_pro[$i]['tels'])) {
+                        $all_pro[$i]['tels'] = array($nexttel);
+                    } else {
+                        $all_pro[$i]['tels'][] = $nexttel;
+                    }
                 }
             }
             if (!has_user_right($pro['email_pub'], $view)) {
@@ -339,9 +341,7 @@ function get_user_details_pro($uid, $view = 'private')
                 $all_pro[$i]['fonction'] == '' &&
                 $all_pro[$i]['secteur'] == '' &&
                 $all_pro[$i]['poste'] == '' &&
-                $all_pro[$i]['tel'] == '' &&
-                $all_pro[$i]['fax'] == '' &&
-                $all_pro[$i]['mobile'] == '' &&
+                (!isset($all_pro[$i]['tels'])) &&
                 $all_pro[$i]['email'] == '')
                 unset($all_pro[$i]);
         }
@@ -358,7 +358,7 @@ function get_user_details_adr($uid, $view = 'private') {
                      gp.pays AS countrytxt,a.region, a.regiontxt,
                      FIND_IN_SET('active', a.statut) AS active, a.adrid,
                      FIND_IN_SET('res-secondaire', a.statut) AS secondaire,
-                     a.pub, gp.display
+                     a.pub, gp.display, a.comment
                FROM  adresses AS a
           LEFT JOIN  geoloc_pays AS gp ON (gp.a2=a.country)
               WHERE  uid= {?} AND NOT FIND_IN_SET('pro',a.statut)
@@ -373,11 +373,10 @@ function get_user_details_adr($uid, $view = 'private') {
             $adrid_index[$adr['adrid']] = $i;
     }
 
-    $sql = "SELECT  t.adrid, t.tel_pub, t.tel_type, t.tel, t.telid
-              FROM  tels AS t
-        INNER JOIN  adresses AS a ON (a.uid = t.uid) AND (a.adrid = t.adrid)
-             WHERE  t.uid = {?} AND NOT FIND_IN_SET('pro',a.statut)
-          ORDER BY  t.adrid, t.tel_type DESC, t.telid";
+    $sql = "SELECT  link_id AS adrid, pub AS tel_pub, tel_type, display_tel AS tel, tel_id AS telid, comment
+              FROM  profile_phones AS t
+             WHERE  uid = {?} AND link_type = 'address'
+          ORDER BY  link_id, tel_type DESC, tel_id";
     $restel = XDB::iterator($sql, $uid);
     while ($nexttel = $restel->next()) {
         if (has_user_right($nexttel['tel_pub'], $view)) {
@@ -401,8 +400,8 @@ function &get_user_details($login, $from_uid = '', $view = 'private')
 {
     $reqsql = "SELECT  u.user_id, u.promo, u.promo_sortie, u.prenom, u.nom, u.nom_usage, u.date, u.cv,
                        u.perms IN ('admin','user','disabled') AS inscrit,  FIND_IN_SET('femme', u.flags) AS sexe, u.deces != 0 AS dcd, u.deces,
-                       q.profile_nick AS nickname, q.profile_from_ax, q.profile_mobile AS mobile, q.profile_web AS web, q.profile_freetext AS freetext,
-                       q.profile_mobile_pub AS mobile_pub, q.profile_web_pub AS web_pub, q.profile_freetext_pub AS freetext_pub,
+                       q.profile_nick AS nickname, q.profile_from_ax, q.profile_freetext AS freetext,
+                       q.profile_freetext_pub AS freetext_pub,
                        q.profile_medals_pub AS medals_pub,
                        IF(gp.nat='',gp.pays,gp.nat) AS nationalite, gp.a2 AS iso3166,
                        a.alias AS forlife, a2.alias AS bestalias,
@@ -410,7 +409,8 @@ function &get_user_details($login, $from_uid = '', $view = 'private')
                        s.text AS section, p.x, p.y, p.pub AS photo_pub,
                        u.matricule_ax,
                        m.expertise != '' AS is_referent,
-                       (COUNT(e.email) > 0 OR FIND_IN_SET('googleapps', u.mail_storage) > 0) AS actif
+                       (COUNT(e.email) > 0 OR FIND_IN_SET('googleapps', u.mail_storage) > 0) AS actif,
+                       nd.display AS name_display, nd.tooltip AS name_tooltip
                  FROM  auth_user_md5   AS u
            INNER JOIN  auth_user_quick AS q  USING(user_id)
            INNER JOIN  aliases         AS a  ON (u.user_id=a.id AND a.type='a_vie')
@@ -421,6 +421,7 @@ function &get_user_details($login, $from_uid = '', $view = 'private')
             LEFT JOIN  photo           AS p  ON (p.uid = u.user_id)
             LEFT JOIN  mentor          AS m  ON (m.uid = u.user_id)
             LEFT JOIN  emails          AS e  ON (e.uid = u.user_id AND e.flags='active')
+           INNER JOIN  profile_names_display AS nd ON (nd.user_id = u.user_id)
                 WHERE  a.alias = {?}
              GROUP BY  u.user_id";
     $res  = XDB::query($reqsql, $from_uid, $login);
@@ -433,20 +434,7 @@ function &get_user_details($login, $from_uid = '', $view = 'private')
         $user['nickname'] = '';
         $user['section'] = '';
     }
-    // hide mobile
-    if (!has_user_right($user['mobile_pub'], $view)) {
-        if ($user['mobile'] == '')
-            $user['mobile_pub'] = $view;
-        else
-            $user['mobile'] = '';
-    }
-    // hide web
-    if (!has_user_right($user['web_pub'], $view)) {
-        if ($user['web'] == '')
-            $user['web_pub'] = $view;
-        else
-            $user['web'] = '';
-    }
+
     // hide freetext
     if (!has_user_right($user['freetext_pub'], $view)) {
         if ($user['freetext'] == '')
@@ -455,6 +443,21 @@ function &get_user_details($login, $from_uid = '', $view = 'private')
             $user['freetext'] = '';
     }
 
+    $sql = "SELECT  pub AS tel_pub, tel_type, display_tel AS tel, comment
+              FROM  profile_phones AS t
+             WHERE  uid = {?} AND link_type = 'user'
+          ORDER BY  tel_type DESC, tel_id";
+    $restel = XDB::iterator($sql, $uid);
+    while ($nexttel = $restel->next()) {
+        if (has_user_right($nexttel['tel_pub'], $view)) {
+            if (!isset($user['tels'])) {
+                $user['tels'] = array($nexttel);
+            } else {
+                $user['tels'][] = $nexttel;
+            }
+        }
+    }
+
     $user['adr_pro'] = get_user_details_pro($uid, $view);
     $user['adr']     = get_user_details_adr($uid, $view);
 
@@ -511,6 +514,19 @@ function &get_user_details($login, $from_uid = '', $view = 'private')
         }
     }
 
+    $user['networking'] = Array();
+    $res = XDB::iterator("SELECT  n.address, n.pub, m.network_type AS type, m.name, m.filter, m.link
+                            FROM  profile_networking AS n
+                      INNER JOIN  profile_networking_enum AS m ON (n.network_type = m.network_type)
+                           WHERE  n.uid = {?}", $uid);
+    while($network = $res->next())
+    {
+        if (has_user_right($network['pub'], $view)) {
+            $network['link'] = str_replace('%s', $network['address'], $network['link']);
+            $user['networking'][] = $network;
+        }
+    }
+
     return $user;
 }
 // }}}
@@ -527,7 +543,7 @@ function add_user_address($uid, $adrid, $adr) {
     if (isset($adr['tels']) && is_array($adr['tels'])) {
         $telid = 0;
         foreach ($adr['tels'] as $tel) if ($tel['tel']) {
-            add_user_tel($uid, $adrid, $telid, $tel);
+            add_user_tel($uid, 'address', $adrid, $telid, $tel);
             $telid ++;
         }
     }
@@ -545,17 +561,17 @@ function update_user_address($uid, $adrid, $adr) {
         $adr['adr1'], $adr['adr2'], $adr['adr3'],
         $adr['postcode'], $adr['city'], $adr['pub'], $adrid, $uid);
     if (isset($adr['tels']) && is_array($adr['tels'])) {
-        $res = XDB::query("SELECT telid FROM tels WHERE uid = {?} AND adrid = {?} ORDER BY telid", $uid, $adrid);
+        $res = XDB::query("SELECT tel_id FROM profile_phones WHERE uid = {?} AND link_type = 'address' AND link_id = {?} ORDER BY tel_id", $uid, $adrid);
         $telids = $res->fetchColumn();
         foreach ($adr['tels'] as $tel) {
             if (isset($tel['telid']) && isset($tel['remove']) && $tel['remove']) {
-                remove_user_tel($uid, $adrid, $tel['telid']);
+                remove_user_tel($uid, 'address', $adrid, $tel['telid']);
                 if (isset($telids[$tel['telid']])) unset($telids[$tel['telid']]);
             } else if (isset($tel['telid'])) {
-                update_user_tel($uid, $adrid, $tel['telid'], $tel);
+                update_user_tel($uid, 'address', $adrid, $tel['telid'], $tel);
             } else {
                 for ($telid = 0; isset($telids[$telid]) && ($telids[$telid] == $telid); $telid++);
-                add_user_tel($uid, $adrid, $telid, $tel);
+                add_user_tel($uid, 'address', $adrid, $telid, $tel);
             }
         }
     }
@@ -564,36 +580,41 @@ function update_user_address($uid, $adrid, $adr) {
 // {{{ function remove_user_address()
 function remove_user_address($uid, $adrid) {
     XDB::execute("DELETE FROM adresses WHERE adrid = {?} AND uid = {?}", $adrid, $uid);
-    XDB::execute("DELETE FROM tels WHERE adrid = {?} AND uid = {?}", $adrid, $uid);
+    XDB::execute("DELETE FROM profile_phones WHERE link_id = {?} AND uid = {?} AND link_type = 'address'", $adrid, $uid);
 }
 // }}}
 // {{{ function add_user_tel()
-function add_user_tel($uid, $adrid, $telid, $tel) {
-    XDB::execute(
-        "INSERT INTO tels SET uid = {?}, adrid = {?}, telid = {?}, tel = {?}, tel_type = {?}, tel_pub = {?}",
-        $uid, $adrid, $telid, $tel['tel'], $tel['tel_type'], $tel['tel_pub']);
+function add_user_tel($uid, $link_type, $link_id, $telid, $tel) {
+    require('profil.func.inc.php');
+    $fmt_phone  = format_phone_number($tel['tel']);
+    $disp_phone = format_display_number($fmt_phone, $error);
+    XDB::execute("INSERT INTO profile_phones (uid, link_type, link_id, tel_id, tel_type, search_tel, display_tel, pub)
+                       VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})",
+                 $uid, $link_type, $link_id, $telid, $tel['tel_type'], $fmt_phone, $disp_phone, $tel['tel_pub']);
 }
 // }}}
 // {{{ function update_user_tel()
-function update_user_tel($uid, $adrid, $telid, $tel) {
-    XDB::execute(
-        "UPDATE tels SET tel = {?}, tel_type = {?}, tel_pub = {?}
-        WHERE telid = {?} AND adrid = {?} AND uid = {?}",
-        $tel['tel'], $tel['tel_type'], $tel['tel_pub'],
-        $telid, $adrid, $uid);
+function update_user_tel($uid, $link_type, $link_id, $telid, $tel) {
+    require('profil.func.inc.php');
+    $fmt_phone  = format_phone_number($tel['tel']);
+    $disp_phone = format_display_number($fmt_phone, $error);
+    XDB::execute("UPDATE profile_phones SET search_tel = {?}, display_tel = {?}, tel_type = {?}, pub = {?}
+                   WHERE link_type = {?} AND tel_id = {?} AND link_id = {?} AND uid = {?}",
+                 $fmt_phone, $disp_phone, $tel['tel_type'], $tel['tel_pub'],
+                 $link_type, $telid, $link_id, $uid);
 }
 // }}}
 // {{{ function remove_user_tel()
-function remove_user_tel($uid, $adrid, $telid) {
-    XDB::execute("DELETE FROM tels WHERE telid = {?} AND adrid = {?} AND uid = {?}",
-                 $telid, $adrid, $uid);
+function remove_user_tel($uid, $link_type, $link_id, $telid) {
+    XDB::execute("DELETE FROM profile_phones WHERE tel_id = {?} AND link_id = {?} AND uid = {?} AND link_type = {?}",
+                 $telid, $link_id, $uid, $link_type);
 }
 // }}}
 // {{{ function add_user_pro()
 function add_user_pro($uid, $entrid, $pro) {
     XDB::execute(
         "INSERT INTO entreprises (`uid`, `entrid`, `entreprise`, `poste`, `secteur`, `ss_secteur`, `fonction`,
-            `adr1`, `adr2`, `adr3`, `postcode`, `city`, `country`, `region`, `tel`, `fax`, `mobile`, `email`, `web`, `pub`, `adr_pub`, `tel_pub`, `email_pub`)
+            `adr1`, `adr2`, `adr3`, `postcode`, `city`, `country`, `region`, `email`, `web`, `pub`, `adr_pub`, `email_pub`)
         SELECT u.user_id, {?}, {?}, {?}, s.id, ss.id, f.id,
         {?}, {?}, {?}, {?}, {?}, gp.a2, gr.region, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}
         FROM auth_user_md5 AS u
@@ -605,10 +626,19 @@ function add_user_pro($uid, $entrid, $pro) {
         WHERE u.user_id = {?}
         LIMIT 1",
         $entrid, $pro['entreprise'], $pro['poste'],
-        $pro['adr1'], $pro['adr2'], $pro['adr3'], $pro['postcode'], $pro['city'], $pro['tel'], $pro['fax'], $pro['mobile'], $pro['email'], $pro['web'], $pro['pub'], $pro['adr_pub'], $pro['tel_pub'], $pro['email_pub'],
+        $pro['adr1'], $pro['adr2'], $pro['adr3'], $pro['postcode'], $pro['city'], $pro['email'], $pro['web'], $pro['pub'], $pro['adr_pub'], $pro['email_pub'],
         $pro['secteur'], $pro['sous_secteur'], $pro['fonction'], $pro['fonction'],
         $pro['countrytxt'], $pro['countrytxt'], $pro['region'],
         $uid);
+    if (isset($pro['tels']) && is_array($pro['tels'])) {
+        $telid = 0;
+        foreach ($pro['tels'] as $tel) {
+            if ($pro['tel']) {
+                add_user_tel($uid, 'pro', $entrid, $telid, $tel);
+                $telid ++;
+            }
+        }
+    }
 }
 // }}}
 // {{{ function update_user_pro()
@@ -646,13 +676,6 @@ function update_user_pro($uid, $entrid, $pro) {
         $args_set[] = $pro['adr_pub'];
     }
 
-    if (isset($pro['tel'])) {
-        $set .= ", e.`tel` = {?}, e.`fax` = {?}, e.`mobile` = {?}, e.tel_pub = {?}";
-        $args_set[] = $pro['tel'];
-        $args_set[] = $pro['fax'];
-        $args_set[] = $pro['mobile'];
-        $args_set[] = $pro['tel_pub'];
-    }
     if (isset($pro['email'])) {
         $set .= ", e.`email` = {?}, e.`email_pub` = {?}";
         $args_set[] = $pro['email'];
@@ -662,14 +685,32 @@ function update_user_pro($uid, $entrid, $pro) {
     $args_where = array($uid, $entrid);
     $args = array_merge(array($query), $args_join, $args_set, $args_where);
     call_user_func_array(array('XDB', 'execute'), $args);
+
+
+    if (isset($pro['tels']) && is_array($pro['tels'])) {
+        $res = XDB::query("SELECT tel_id FROM profile_phones WHERE uid = {?} AND link_type = 'pro' AND link_id = {?} ORDER BY tel_id", $uid, $entrid);
+        $telids = $res->fetchColumn();
+        foreach ($pro['tels'] as $tel) {
+            if (isset($tel['telid']) && isset($tel['remove']) && $tel['remove']) {
+                remove_user_tel($uid, 'pro', $entrid, $tel['telid']);
+                if (isset($telids[$tel['telid']])) unset($telids[$tel['telid']]);
+            } else if (isset($tel['telid'])) {
+                update_user_tel($uid, 'pro', $entrid, $tel['telid'], $tel);
+            } else {
+                for ($telid = 0; isset($telids[$telid]) && ($telids[$telid] == $telid); $telid++);
+                add_user_tel($uid, 'pro', $entrid, $telid, $tel);
+            }
+        }
+    }
 }
 // }}}
 // {{{ function remove_user_pro()
 function remove_user_pro($uid, $entrid) {
     XDB::execute("DELETE FROM entreprises WHERE entrid = {?} AND uid = {?}", $entrid, $uid);
+    XDB::execute("DELETE FROM profile_phones WHERE link_id = {?} AND uid = {?} AND link_type = 'pro'", $entrid, $uid);
 }
 // }}}
-// {{{ function set_user_details()
+// {{{ function set_user_details_addresses()
 function set_user_details_addresses($uid, $adrs) {
     $res = XDB::query("SELECT adrid FROM adresses WHERE uid = {?} AND adrid >= 1 ORDER BY adrid", $uid);
     $adrids = $res->fetchColumn();
@@ -714,9 +755,6 @@ function set_user_details($uid, $details) {
     if (isset($details['nom_usage'])) {
         XDB::execute("UPDATE auth_user_md5 SET nom_usage = {?} WHERE user_id = {?}", strtoupper($details['nom_usage']), $uid);
     }
-    if (isset($details['mobile'])) {
-        XDB::execute("UPDATE auth_user_quick SET profile_mobile = {?} WHERE user_id = {?}", $details['mobile'], $uid);
-    }
     if (isset($details['nationalite'])) {
         XDB::execute(
             "UPDATE auth_user_md5 AS u
@@ -747,6 +785,22 @@ function set_user_details($uid, $details) {
                 $uid, $groupex);
         }
     }
+    if (isset($details['tels']) && is_array($details['tels'])) {
+        $res = XDB::query("SELECT tel_id FROM profile_phones WHERE uid = {?} AND link_type = 'user' ORDER BY tel_id", $uid);
+        $telids = $res->fetchColumn();
+        foreach ($details['tels'] as $tel) {
+            if (isset($tel['telid']) && isset($tel['remove']) && $tel['remove']) {
+                remove_user_tel($uid, 'user', 0, $tel['telid']);
+                if (isset($telids[$tel['telid']])) unset($telids[$tel['telid']]);
+            } else if (isset($tel['telid'])) {
+                update_user_tel($uid, 'user', 0, $tel['telid'], $tel);
+            } else {
+                for ($telid = 0; isset($telids[$telid]) && ($telids[$telid] == $telid); $telid++);
+                add_user_tel($uid, 'user', 0, $telid, $tel);
+            }
+        }
+    }
+
     // applis
     // medals
 }
index f45cf48..31358d2 100644 (file)
@@ -163,11 +163,11 @@ class MinificheView extends MultipageView
         global $globals;
         $this->entriesPerPage = $globals->search->per_page;
         if (@$params['with_score']) {
-            $this->addSortKey('score', array('-score', '-date', '-promo', 'nom', 'prenom'), 'pertinence');
+            $this->addSortKey('score', array('-score', '-date', '-promo', 'name_sort'), 'pertinence');
         }
-        $this->addSortKey('name', array('nom', 'prenom'), 'nom');
-        $this->addSortKey('promo', array('-promo', 'nom', 'prenom'), 'promotion');
-        $this->addSortKey('date_mod', array('-date', '-promo', 'nom', 'prenom'), 'dernière modification');
+        $this->addSortKey('name', array('name_sort'), 'nom');
+        $this->addSortKey('promo', array('-promo', 'name_sort'), 'promotion');
+        $this->addSortKey('date_mod', array('-date', '-promo', 'name_sort'), 'dernière modification');
         parent::__construct($set, $data, $params);
     }
 
@@ -184,8 +184,8 @@ class MinificheView extends MultipageView
                 ad0.text AS app0text, ad0.url AS app0url, ai0.type AS app0type,
                 ad1.text AS app1text, ad1.url AS app1url, ai1.type AS app1type,
                 adr.city, gp.a2, gp.pays AS countrytxt, gr.name AS region,
-                IF(u.nom_usage<>'',u.nom_usage,u.nom) AS sortkey,
-                (COUNT(em.email) > 0 OR FIND_IN_SET('googleapps', u.mail_storage) > 0) AS actif" .
+                (COUNT(em.email) > 0 OR FIND_IN_SET('googleapps', u.mail_storage) > 0) AS actif,
+                nd.display AS name_display, nd.tooltip AS name_tooltip, nd.sort AS name_sort" .
                 (S::logged() ? ", c.contact AS contact" : '');
     }
 
@@ -203,7 +203,8 @@ class MinificheView extends MultipageView
                                                       AND FIND_IN_SET('active', adr.statut)".(S::logged() ? "" : " AND adr.pub = 'public'").")
                  LEFT JOIN  geoloc_pays    AS gp  ON (adr.country = gp.a2)
                  LEFT JOIN  geoloc_region  AS gr  ON (adr.country = gr.a2 AND adr.region = gr.region)
-                 LEFT JOIN  emails         AS em  ON (em.uid = u.user_id AND em.flags = 'active')" .
+                 LEFT JOIN  emails         AS em  ON (em.uid = u.user_id AND em.flags = 'active')
+                INNER JOIN  profile_names_display AS nd  ON (nd.user_id = u.user_id)" .
                 (S::logged() ?
                  "LEFT JOIN  contacts       AS c   On (c.contact = u.user_id AND c.uid = " . S::v('uid') . ")"
                  : "");
@@ -238,17 +239,23 @@ class MentorView extends MultipageView
     {
         $this->entriesPerPage = 10;
         $this->addSortKey('rand', array('RAND(' . S::i('uid') . ')'), 'aléatoirement');
-        $this->addSortKey('name', array('nom', 'prenom'), 'nom');
-        $this->addSortKey('promo', array('-promo', 'nom', 'prenom'), 'promotion');
-        $this->addSortKey('date_mod', array('-date', '-promo', 'nom', 'prenom'), 'dernière modification');
+        $this->addSortKey('name', array('name_sort'), 'nom');
+        $this->addSortKey('promo', array('-promo', 'name_sort'), 'promotion');
+        $this->addSortKey('date_mod', array('-date', '-promo', 'name_sort'), 'dernière modification');
         parent::__construct($set, $data, $params);
     }
 
     public function fields()
     {
-        return "m.uid, u.prenom, u.nom, u.promo,
-                a.alias AS forlife, m.expertise, mp.pid,
-                ms.secteur, ms.ss_secteur";
+        return "m.uid, u.promo,
+                a.alias AS bestalias, m.expertise, mp.pid,
+                ms.secteur, ms.ss_secteur,
+                nd.display AS name_display, nd.tooltip AS name_tooltip, nd.sort AS name_sort";
+    }
+
+    public function joins()
+    {
+        return "INNER JOIN  profile_names_display AS nd ON (nd.user_id = u.user_id)";
     }
 
     public function bounds()
@@ -279,23 +286,24 @@ class TrombiView extends MultipageView
     public function __construct(PlSet &$set, $data, array $params)
     {
         $this->entriesPerPage = 24;
-        $this->order = explode(',', Env::v('order', 'nom,prenom,promo'));
+        $this->order = explode(',', Env::v('order', 'name_sort'));
         if (@$params['with_score']) {
-            $this->addSortKey('score', array('-score', '-watch_last', '-promo', 'nom', 'prenom'), 'pertinence');
+            $this->addSortKey('score', array('-score', '-watch_last', '-promo', 'name_sort'), 'pertinence');
         }
-        $this->addSortKey('name', array('nom', 'prenom'), 'nom');
-        $this->addSortKey('promo', array('-promo', 'nom', 'prenom'), 'promotion');
+        $this->addSortKey('name', array('name_sort'), 'nom');
+        $this->addSortKey('promo', array('-promo', 'name_sort'), 'promotion');
         parent::__construct($set, $data, $params);
     }
 
     public function fields()
     {
-        return "u.user_id, IF(u.nom_usage != '', u.nom_usage, u.nom) AS nom, u.prenom, u.promo, a.alias AS forlife ";
+        return "u.user_id, nd.display AS name_display, nd.tooltip AS name_tooltip, nd.sort AS name_sort, u.promo, a.alias AS forlife ";
     }
 
     public function joins()
     {
-        return "INNER JOIN  photo AS p ON (p.uid = u.user_id) ";
+        return "INNER JOIN  photo AS p ON (p.uid = u.user_id)
+                INNER JOIN  profile_names_display AS nd ON (nd.user_id = u.user_id)";
     }
 
     public function bounds()
@@ -436,7 +444,6 @@ class GadgetView implements PlView
     {
         return "u.user_id AS id,
                 u.*, a.alias AS forlife," .
-                (S::logged() ? "q.profile_mobile AS mobile, " : "IF(q.profile_mobile_pub = 'public', q.profile_mobile, NULL) as mobile, ") .
                "u.perms != 'pending' AS inscrit,
                 u.perms != 'pending' AS wasinscrit,
                 u.deces != 0 AS dcd, u.deces,
index 50a5854..89b1b59 100644 (file)
@@ -27,15 +27,16 @@ function get_annuaire_infos($method, $params) {
         //on ne recupere pas les adresses inutilement
         if(!isset($params[2])){
             $res = XDB::iterRow(
-                    "SELECT  q.profile_mobile AS cell, a.naissance AS age
-                    FROM  auth_user_md5 AS a
-                    INNER JOIN auth_user_quick AS q USING (user_id)
-                    WHERE  a.matricule = {?}", $params[1]);
+                    "SELECT  ph.display_tel  AS cell, a.naissance AS age
+                       FROM  auth_user_md5   AS a
+                 INNER JOIN  auth_user_quick AS q USING (user_id)
+                  LEFT JOIN  profile_phones  AS ph ON (ph.uid = a.user_id AND link_type='user' AND tel_type = 'mobile')
+                      WHERE  a.matricule = {?} LIMIT 1", $params[1]);
             $array = $res->next();
         }
         else{
             $res = XDB::iterRow(
-                 "SELECT     q.profile_mobile AS cell, a.naissance AS age,
+                 "SELECT     a.naissance AS age,
                              adr.adr1, adr.adr2, adr.adr3,
                              adr.postcode, adr.city, adr.country,
                              adr.uid, adr.adrid
@@ -48,10 +49,18 @@ function get_annuaire_infos($method, $params) {
                              FIND_IN_SET('res-secondaire', adr.statut),
                              NOT FIND_IN_SET('courrier', adr.statut)", $params[1]);
             //traitement des adresses si necessaire
-            if(list($cell, $age, $adr['adr1'], $adr['adr2'], $adr['adr3'], $adr['cp'], $adr['ville'],
+            if(list($age, $adr['adr1'], $adr['adr2'], $adr['adr3'], $adr['cp'], $adr['ville'],
                         $adr['pays'], $uid, $adr['adrid']) = $res->next())
             {
-                $array['cell']      = $cell;
+                $sql = XDB::query("SELECT display_tel
+                                     FROM profile_phones
+                                    WHERE uid ={?} AND link_type = 'user' AND tel_type = 'mobile'
+                                    LIMIT 1", $uid);
+                if ($sql->numRows()>0) {
+                    $array['cell'] = $sql->fetchOneCell();
+                } else {
+                    $array['cell'] ='';
+                }
                 $array['age']       = $age;
                 $array['adresse'][] = $adr;
 
@@ -61,7 +70,7 @@ function get_annuaire_infos($method, $params) {
 
                 if ($adresse != 1) { //on ne veut pas la premiere adresse
                     $i = 2;
-                    while(list($cell, $age, $adr['adr1'], $adr['adr2'], $adr['adr3'], $adr['cp'], $adr['ville'],
+                    while(list($age, $adr['adr1'], $adr['adr2'], $adr['adr3'], $adr['cp'], $adr['ville'],
                                 $adr['pays'], , $adr['adrid']) = $res->next())
                     {
                         if($adresse == $i){//si on veut cette adresse en particulier
@@ -81,10 +90,10 @@ function get_annuaire_infos($method, $params) {
                 foreach ($array['adresse'] as $i => $a) $adrid_index[$a['adrid']] = $i;
                 // on rajoute les numéros de tels
                 $restel = XDB::iterator(
-                    "SELECT t.tel, t.tel_type, t.adrid
-                       FROM tels AS t
-                 INNER JOIN adresses AS a ON (t.adrid = a.adrid AND t.uid = a.uid)
-                      WHERE t.uid = {?} AND NOT FIND_IN_SET('pro', a.statut)", $uid);
+                    "SELECT t.display_tel AS tel, t.tel_type, t.link_id as adrid
+                       FROM profile_phones AS t
+                 INNER JOIN adresses AS a ON (t.link_id = a.adrid AND t.uid = a.uid)
+                      WHERE t.uid = {?} AND t.link_type = 'address' AND NOT FIND_IN_SET('pro', a.statut)", $uid);
                 while ($tel = $restel->next()) $array['adresse'][$adrid_index[$tel['adrid']]]['tels'][] = $tel;
                 foreach ($array['adresse'] as $i => $adr) {
                     unset($lasttel);
diff --git a/include/xorg/session.inc.php b/include/xorg/session.inc.php
new file mode 100644 (file)
index 0000000..64020ed
--- /dev/null
@@ -0,0 +1,336 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2008 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************/
+
+require_once 'xorg.misc.inc.php';
+
+class XorgSession
+{
+    // {{{ public static function init
+
+    public static function init()
+    {
+        S::init();
+        if (!S::has('uid')) {
+            try_cookie();
+        }
+        if ((check_ip('dangerous') && S::has('uid')) || check_account()) {
+            $_SESSION['log']->log("view_page", $_SERVER['REQUEST_URI']);
+        }
+    }
+
+    // }}}
+    // {{{ public static function destroy()
+
+    public static function destroy()
+    {
+        S::destroy();
+        XorgSession::init();
+    }
+
+    // }}}
+    // {{{ public static function doAuth()
+
+    public static function doAuth($new_name = false)
+    {
+        global $globals;
+        if (S::identified()) { // ok, c'est bon, on n'a rien à faire
+            return true;
+        }
+
+        if (!Env::has('username') || !Env::has('response')
+        ||  !S::has('challenge'))
+        {
+            return false;
+        }
+
+        // si on vient de recevoir une identification par passwordpromptscreen.tpl
+        // ou passwordpromptscreenlogged.tpl
+        if (S::has('suid')) {
+            $suid = S::v('suid');
+            $login = $uname = $suid['forlife'];
+            $redirect = false;
+        } else {
+            $uname = Env::v('username');
+
+            if (Env::v('domain') == "alias") {
+                $res = XDB::query(
+                    "SELECT redirect
+                       FROM virtual
+                 INNER JOIN virtual_redirect USING(vid)
+                      WHERE alias LIKE {?}", $uname."@".$globals->mail->alias_dom);
+                $redirect = $res->fetchOneCell();
+                if ($redirect) {
+                    $login = substr($redirect, 0, strpos($redirect, '@'));
+                } else {
+                    $login = "";
+                }
+            } else {
+                $login = $uname;
+                $redirect = false;
+            }
+        }
+
+        $field = (!$redirect && preg_match('/^\d*$/', $uname)) ? 'id' : 'alias';
+        $res   = XDB::query(
+                    "SELECT  u.user_id, u.password
+                       FROM  auth_user_md5 AS u
+                 INNER JOIN  aliases       AS a ON ( a.id=u.user_id AND type!='homonyme' )
+                      WHERE  a.$field = {?} AND u.perms IN('admin','user')", $login);
+
+        $logger = S::v('log');
+        if (list($uid, $password) = $res->fetchOneRow()) {
+            require_once('secure_hash.inc.php');
+            $expected_response = hash_encrypt("$uname:$password:".S::v('challenge'));
+            // le password de la base est peut-être encore encodé en md5
+            if (Env::v('response') != $expected_response) {
+                $new_password = hash_xor(Env::v('xorpass'), $password);
+                $expected_response = hash_encrypt("$uname:$new_password:".S::v('challenge'));
+                if (Env::v('response') == $expected_response) {
+                      XDB::execute("UPDATE auth_user_md5 SET password = {?} WHERE user_id = {?}",
+                                   $new_password, $uid);
+                }
+            }
+            if (Env::v('response') == $expected_response) {
+                if (Env::has('domain')) {
+                    if (($domain = Env::v('domain', 'login')) == 'alias') {
+                        setcookie('ORGdomain', "alias", (time()+25920000), '/', '', 0);
+                    } else {
+                        setcookie('ORGdomain', '', (time()-3600), '/', '', 0);
+                    }
+                    // pour que la modification soit effective dans le reste de la page
+                    $_COOKIE['ORGdomain'] = $domain;
+                }
+
+                S::kill('challenge');
+                if ($logger) {
+                    $logger->log('auth_ok');
+                }
+                if (!start_connexion($uid, true)) {
+                    return false;
+                }
+                if (Env::v('remember', 'false') == 'true') {
+                    $cookie = hash_encrypt(S::v('password'));
+                    setcookie('ORGaccess',$cookie,(time()+25920000),'/','',0);
+                    if ($logger) {
+                        $logger->log("cookie_on");
+                    }
+                } else {
+                    setcookie('ORGaccess', '', time() - 3600, '/', '', 0);
+
+                    if ($logger) {
+                        $logger->log("cookie_off");
+                    }
+                }
+                return true;
+            } elseif ($logger) {
+                $logger->log('auth_fail','bad password');
+            }
+        } elseif ($logger) {
+            $logger->log('auth_fail','bad login');
+        }
+
+        return false;
+    }
+
+    // }}}
+    // {{{ public static function doAuthCookie()
+
+    /** Try to do a cookie-based authentication.
+     *
+     * @param page the calling page (by reference)
+     */
+    public static function doAuthCookie()
+
+    {
+        if (S::logged()) {
+            return true;
+        }
+
+        if (Env::has('username') and Env::has('response')) {
+            return XorgSession::doAuth();
+        }
+
+        if ($r = try_cookie()) {
+            return XorgSession::doAuth(($r > 0));
+        }
+
+        return false;
+    }
+
+    // }}}
+    // {{{ public static function make_perms()
+
+    public static function &make_perms($perm)
+    {
+        $flags = new FlagSet();
+        if ($perm == 'disabled' || $perm == 'ext') {
+            return $flags;
+        }
+        $flags->addFlag(PERMS_USER);
+        if ($perm == 'admin') {
+            $flags->addFlag(PERMS_ADMIN);
+        }
+        return $flags;
+    }
+
+    // }}}
+}
+
+// {{{ function try_cookie()
+
+/** réalise la récupération de $_SESSION pour qqn avec cookie
+ * @return  int     0 if all OK, -1 if no cookie, 1 if cookie with bad hash,
+ *                  -2 should not happen
+ */
+function try_cookie()
+{
+    if (Cookie::v('ORGaccess') == '' or !Cookie::has('ORGuid')) {
+        return -1;
+    }
+
+    $res = @XDB::query(
+            "SELECT user_id,password FROM auth_user_md5
+              WHERE user_id = {?} AND perms IN('admin','user')",
+            Cookie::i('ORGuid'));
+
+    if ($res->numRows() != 0) {
+        list($uid, $password) = $res->fetchOneRow();
+        require_once('secure_hash.inc.php');
+        $expected_value       = hash_encrypt($password);
+        if ($expected_value == Cookie::v('ORGaccess')) {
+            if (!start_connexion($uid, false)) {
+                return -3;
+            }
+            return 0;
+        } else {
+            return 1;
+        }
+    }
+
+    return -2;
+}
+
+// }}}
+// {{{ function start_connexion()
+
+/** place les variables de session dépendants de auth_user_md5
+ * et met à jour les dates de dernière connexion si nécessaire
+ * @return void
+ * @see controlpermanent.inc.php controlauthentication.inc.php
+ */
+function start_connexion ($uid, $identified)
+{
+    $res  = XDB::query("
+        SELECT  u.user_id AS uid, nom_usage, perms, promo, promo_sortie,
+                matricule, password, FIND_IN_SET('femme', u.flags) AS femme,
+                a.alias AS forlife, a2.alias AS bestalias,
+                q.core_mail_fmt AS mail_fmt, UNIX_TIMESTAMP(q.banana_last) AS banana_last, q.watch_last, q.core_rss_hash,
+                FIND_IN_SET('watch', u.flags) AS watch_account, q.last_version,
+                nd.display AS display_name, nd.yourself AS yourself_name,
+                nd.firstname AS prenom, nd.lastname AS nom
+          FROM  auth_user_md5   AS u
+    INNER JOIN  auth_user_quick AS q  USING(user_id)
+    INNER JOIN  aliases         AS a  ON (u.user_id = a.id AND a.type='a_vie')
+    INNER JOIN  aliases         AS a2 ON (u.user_id = a2.id AND FIND_IN_SET('bestalias',a2.flags))
+    INNER JOIN  profile_names_display AS nd ON (u.user_id = nd.user_id)
+         WHERE  u.user_id = {?} AND u.perms IN('admin','user')", $uid);
+    $sess = $res->fetchOneAssoc();
+    $res = XDB::query("SELECT  UNIX_TIMESTAMP(s.start) AS lastlogin, s.host
+                         FROM  logger.sessions AS s
+                        WHERE  s.uid = {?} AND s.suid = 0
+                     ORDER BY  s.start DESC
+                        LIMIT  1", $uid);
+    if ($res->numRows()) {
+        $sess = array_merge($sess, $res->fetchOneAssoc());
+    }
+    $suid = S::v('suid');
+
+    if ($suid) {
+        $logger = new CoreLogger($uid, $suid['uid']);
+        $logger->log("suid_start", S::v('forlife')." by {$suid['uid']}");
+        $sess['suid'] = $suid;
+    } else {
+        $logger = S::v('log', new CoreLogger($uid));
+        $logger->log("connexion", Env::v('n'));
+        setcookie('ORGuid', $uid, (time()+25920000), '/', '', 0);
+    }
+
+    $_SESSION         = array_merge($_SESSION, $sess);
+    $_SESSION['log']  = $logger;
+    $_SESSION['auth'] = ($identified ? AUTH_MDP : AUTH_COOKIE);
+    $_SESSION['perms'] =& XorgSession::make_perms($_SESSION['perms']);
+    $mail_subject = null;
+    if (check_account()) {
+        $mail_subject = "Connexion d'un utilisateur surveillé";
+    }
+    if (check_ip('unsafe')) {
+        if ($mail_subject) {
+            $mail_subject .= ' - ';
+        }
+        $mail_subject .= "Une IP surveillee a tente de se connecter";
+        if (check_ip('ban')) {
+            send_warning_mail($mail_subject);
+            $_SESSION = array();
+            $_SESSION['perms'] = new FlagSet();
+            global $page;
+            $newpage = false;
+            if (!$page) {
+                require_once 'xorg.inc.php';
+                new_skinned_page('platal/index.tpl');
+                $newpage = true;
+            }
+            $page->trigError("Une erreur est survenue lors de la procédure d'authentification. "
+                       ."Merci de contacter au plus vite "
+                       ."<a href='mailto:support@polytechnique.org'>support@polytechnique.org</a>");
+            if ($newpage) {
+                $page->run();
+            }
+            return false;
+        }
+    }
+    if ($mail_subject) {
+        send_warning_mail($mail_subject);
+    }
+    set_skin();
+    update_NbNotifs();
+    check_redirect();
+    return true;
+}
+
+// }}}
+
+function set_skin()
+{
+    global $globals;
+    if (S::logged() && (!S::has('skin') || S::has('suid'))) {
+        $uid = S::v('uid');
+        $res = XDB::query("SELECT  skin_tpl
+                          FROM  auth_user_quick AS a
+                          INNER JOIN  skins           AS s ON a.skin = s.id
+                          WHERE  user_id = {?} AND skin_tpl != ''", $uid);
+        if ($_SESSION['skin'] = $res->fetchOneCell()) {
+            return;
+        }
+    }
+}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
index 681c9af..5d55e92 100644 (file)
@@ -239,7 +239,15 @@ class EmailModule extends PLModule
             $actifs = Env::v('emails_actifs', Array());
             print_r(Env::v('emails_rewrite'));
             if (Env::v('emailop') == "ajouter" && Env::has('email')) {
-                $page->assign('retour', $redirect->add_email(Env::v('email')));
+                $new_email = Env::v('email');
+                if ($new_email == "new@new.new") {
+                    $new_email = Env::v('email_new');
+                }
+                $retour = $redirect->add_email($new_email);
+                if ($retour == ERROR_INVALID_EMAIL) {
+                    $page->assign('email', $new_email);
+                }
+                $page->assign('retour', $retour);
             } elseif (empty($actifs)) {
                 $page->assign('retour', ERROR_INACTIVE_REDIRECTION);
             } elseif (is_array($actifs)) {
@@ -272,6 +280,9 @@ class EmailModule extends PLModule
 
         require_once 'googleapps.inc.php';
         $page->assign('googleapps', GoogleAppsAccount::account_status($uid));
+
+        require_once 'emails.combobox.inc.php';
+        fill_email_combobox($page);
     }
 
     function handler_antispam(&$page, $statut_filtre = null)
diff --git a/modules/fusionax.php b/modules/fusionax.php
new file mode 100644 (file)
index 0000000..ff3e33d
--- /dev/null
@@ -0,0 +1,391 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2007 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                *
+ ***************************************************************************/
+
+/**
+ * @brief Module to merge data from AX database
+ *
+ * Module to import data from another database of alumni that had
+ * different schemas. The organization that used this db is called AX
+ * hence the name of this module.
+ *
+ * Datas are stored in an external server and you need a private key
+ * to connect to their server.
+ */
+class FusionAxModule extends PLModule{
+
+    /// path ok private key file to connect to AX server
+    var $ax_xorg_rsa_key;
+
+    function __construct()
+    {
+        $this->ax_xorg_rsa_key =
+            dirname(__FILE__).'/../configs/ax_xorg_rsa.pem';
+    }
+
+    function handlers()
+    {
+        return array(
+            'fusionax'          => $this->make_hook('index', AUTH_MDP, 'admin'),
+            'fusionax/import'   => $this->make_hook('import', AUTH_MDP,'admin'),
+            'fusionax/ids'      => $this->make_hook('ids', AUTH_MDP, 'admin'),
+            'fusionax/misc'     => $this->make_hook('misc', AUTH_MDP, 'admin'),
+        );
+    }
+
+
+    function handler_index(&$page)
+    {
+        global $globals;
+        $page->changeTpl('fusionax/index.tpl');
+        $page->assign('xorg_title','Polytechnique.org - Fusion des annuaires');
+        if (isset($globals->fusionax) && 
+            isset($globals->fusionax->LastUpdate)) {
+            $page->assign(
+                'lastimport', 
+                date("d-m-Y",$globals->fusionax->LastUpdate));
+        } 
+    }
+    
+    /** Import de l'annuaire de l'AX depuis l'export situé sur leur serveur */
+    function handler_import(&$page, $action = 'index', $fileSQL = '')
+    {
+        if ($action == 'index') {
+            $page->changeTpl('fusionax/import.tpl');
+            $page->addJsLink('jquery.js');
+            global $globals;
+            if (isset($globals->fusionax) &&
+                isset($globals->fusionax->LastUpdate)) {
+                $page->assign(
+                    'lastimport',
+                    "le ".date("d/m/Y à H:i",$globals->fusionax->LastUpdate));
+            }
+            if (!file_exists($this->ax_xorg_rsa_key)) {
+                $page->assign(
+                    'keymissing',
+                    $this->ax_xorg_rsa_key);
+            }
+            return;
+        }
+        
+        // toutes les actions sont faites en ajax en utilisant jquery
+        header("Content-type: text/javascript; charset=utf-8");
+        
+        // log des actions
+        $report = array();
+        
+        // création d'un fichier temporaire si nécessaire
+        if (Env::has('tmpdir')) {
+            $tmpdir = Env::v('tmpdir');
+        } else {
+            $tmpdir = tempnam('/tmp', 'fusionax');
+            unlink($tmpdir);
+            mkdir($tmpdir);
+            chmod($tmpdir, 0700);
+            // copie la clef d'authentification (paire de clef RSA dont la
+            // partie publique est sur polytechniciens.com)
+            if (!copy(
+                $this->ax_xorg_rsa_key,
+                $tmpdir.'/ax_xorg_rsa'))
+                $report[] = 'Impossible de copier la clef pour se logger '.
+                    'au serveur AX';
+            chmod($tmpdir.'/ax_xorg_rsa', 0600);
+        }
+        
+        $modulepath = realpath(dirname(__FILE__).'/fusionax/').'/';
+        $olddir = getcwd();
+        chdir($tmpdir);
+        
+        if ($action == 'launch') {
+            // lancement : connexion en ssh et récupération du fichier depuis
+            // polyechniciens.com, décompression de l'archive et séparation en
+            // fichiers par tables
+            exec($modulepath.'import-ax.sh', $report);
+            $report[] = utf8_decode('Récupération du fichier terminé.');
+            $report[] = 'Import dans la base en cours...';
+            $next = 'integrateSQL';
+        } else if ($action == 'integrateSQL') {
+            // intégration des données dans la base MySQL
+            // liste des fichiers sql à exécuter
+            $filesSQL = array(
+                'Activites.sql',
+                'Adresses.sql',
+                'Anciens.sql',
+                'Formations.sql',
+                'Entreprises.sql');
+            if ($fileSQL != '') {
+                // récupère le contenu du fichier sql
+                $queries = explode(';',file_get_contents($modulepath.$fileSQL));
+                foreach ($queries as $q) if (trim($q)) {
+                    // coupe le fichier en requêtes individuelles
+                    if (substr($q,0,2) == '--') {
+                        // affiche les commentaires dans le report
+                        $lines = explode("\n",$q);
+                        $l = $lines[0];
+                        $report[] = addslashes(utf8_decode($l));
+                    }
+                    // exécute la requête
+                    XDB::execute($q);
+                }
+                // trouve le prochain fichier à exécuter
+                $trans = array_flip($filesSQL);
+                $nextfile = $trans[$fileSQL] + 1;
+            } else {
+                $nextfile = 0;
+            }
+            if (!isset($filesSQL[$nextfile])) {
+                // tous les fichiers ont été exécutés, on passe à l'étape
+                // suivante
+                $next = 'clean';
+            } else {
+                // on passe au fichier suivant
+                $next = 'integrateSQL/'.$filesSQL[$nextfile];
+            }
+        } else if ($action == 'clean') {
+            // nettoyage du fichier temporaire
+            chdir($olddir);
+            exec("rm -rf $tmpdir", $report);
+            $report[] = 'Fin de l\'import';
+            global $globals;
+            // met à jour la date de dernier import
+            $globals->change_dynamic_config(
+                array('LastUpdate' => time()),
+                'FusionAx');
+        }
+        $tmpdir = getcwd();
+        chdir($olddir);
+        foreach($report as $t)
+            // affiche les lignes de report
+            echo "$('#fusionax_import').append('".utf8_encode($t)."<br/>');\n";
+        if (isset($next)) {
+            // lance le prochain script s'il y en a un
+            echo "$.getScript('fusionax/import/".$next."?tmpdir=".
+                urlencode($tmpdir)."');";
+        }
+        // exit pour ne pas afficher la page template par défaut
+        exit;
+    }
+    
+    /** Lier les identifiants d'un ancien dans les deux annuaires
+     * @param user_id identifiant dans l'annuaire X.org
+     * @param matricule_ax identifiant dans l'annuaire de l'AX
+     * @return 0 si la liaison a échoué, 1 sinon
+     */          
+    private static function link_by_ids($user_id, $matricule_ax)
+    {
+        if (!XDB::execute("
+        UPDATE fusionax_import AS i 
+            INNER JOIN fusionax_xorg_anciens AS u 
+            SET
+                u.matricule_ax = i.id_ancien,
+                i.user_id = u.user_id,
+                i.date_match_id = NOW()
+            WHERE
+            i.id_ancien = {?} AND u.user_id = {?} AND (
+                u.matricule_ax != {?} OR u.matricule_ax IS NULL OR
+                i.user_id != {?} OR i.user_id IS NULL)",
+            $matricule_ax,
+            $user_id,
+            $matricule_ax,
+            $user_id))
+        {
+            return 0;
+        }
+        return XDB::affectedRows() / 2;  
+    }
+    
+    /** Recherche automatique d'anciens à lier entre les deux annuaires
+     * @param limit nombre d'anciens à trouver au max
+     * @param sure si true, ne trouve que des anciens qui sont quasi sûrs
+     * @return un XOrgDBIterator sur les entrées avec display_name, promo,
+     * user_id, id_ancien et display_name_ax
+     */              
+    private static function find_easy_to_link($limit = 10, $sure = false)
+    {
+        $easy_to_link = XDB::iterator("
+        SELECT 
+            xorg.display_name, xorg.promo, xorg.user_id, ax.id_ancien,
+            CONCAT(ax.prenom,' ',ax.nom_complet,' (X ',ax.promotion_etude,')')
+                 AS display_name_ax,
+            COUNT(*) AS nbMatches
+        FROM fusionax_anciens AS ax
+        INNER JOIN fusionax_import AS i ON (
+            i.id_ancien = ax.id_ancien AND i.user_id IS NULL)
+        LEFT JOIN fusionax_xorg_anciens AS xorg ON (
+            xorg.matricule_ax IS NULL AND 
+            ax.Nom_complet = xorg.nom AND
+            ax.prenom = xorg.prenom AND
+            xorg.promo = ax.promotion_etude)
+        GROUP BY xorg.user_id
+        HAVING
+            xorg.user_id IS NOT NULL AND
+            nbMatches = 1
+            ".($limit?('LIMIT '.$limit):''));
+        if ($easy_to_link->total() > 0 || $sure) {
+            return $easy_to_link;
+        }
+        return XDB::iterator(" 
+        SELECT 
+            xorg.display_name, xorg.promo, xorg.user_id, ax.id_ancien,
+            CONCAT(ax.prenom,' ',ax.nom_complet,' (X ',ax.promotion_etude,')')
+                 AS display_name_ax,
+            COUNT(*) AS nbMatches
+        FROM fusionax_anciens AS ax
+        INNER JOIN fusionax_import AS i ON (
+            i.id_ancien = ax.id_ancien AND i.user_id IS NULL)
+        LEFT JOIN fusionax_xorg_anciens AS xorg ON (
+            xorg.matricule_ax IS NULL AND 
+            (ax.Nom_complet = xorg.nom
+                 OR ax.Nom_complet LIKE CONCAT(xorg.nom,' %')
+                 OR ax.Nom_complet LIKE CONCAT(xorg.nom,'-%')
+                 OR ax.Nom_usuel = xorg.nom
+                 OR xorg.nom LIKE CONCAT('% ',ax.Nom_complet)) AND
+            xorg.promo < ax.promotion_etude + 2 AND
+            xorg.promo > ax.promotion_etude - 2)
+        GROUP BY xorg.user_id
+        HAVING
+            xorg.user_id IS NOT NULL AND
+            nbMatches = 1
+        ".($limit?('LIMIT '.$limit):''));
+    }
+    
+    /** Module de mise en correspondance les ids */
+    function handler_ids(
+        &$page,
+        $part = 'main',
+        $user_id = null,
+        $matricule_ax = null)
+    {
+        global $globals;
+        $page->addJsLink('jquery.js');
+        
+        $page->assign(
+            'xorg_title',
+            'Polytechnique.org - Fusion - Mise en correspondance simple');
+        if ($part == 'missingInAX')
+        {
+            // locate all persons from this database that are not in AX's
+            $page->changeTpl('fusionax/idsMissingInAx.tpl');
+            $missingInAX = XDB::iterator("SELECT 
+                u.promo, u.user_id, u.display_name
+                FROM fusionax_xorg_anciens AS u
+                    WHERE u.matricule_ax IS NULL
+                    LIMIT 20");
+            $page->assign('missingInAX', $missingInAX);
+            return;
+        }
+        if ($part == 'missingInXorg')
+        {
+            // locate all persons from AX's database that are not here
+            $page->changeTpl('fusionax/idsMissingInXorg.tpl');
+            $missingInXorg = XDB::iterator("SELECT
+                a.promotion_etude AS promo,
+                CONCAT(a.prenom, ' ',a.Nom_usuel) AS display_name,
+                a.id_ancien 
+                FROM fusionax_import 
+                    INNER JOIN fusionax_anciens AS a USING (id_ancien)
+                    WHERE fusionax_import.user_id IS NULL
+                    LIMIT 20");
+            $page->assign('missingInXorg', $missingInXorg);
+            return;
+        }
+        if ($part == 'link')
+        {
+            FusionAxModule::link_by_ids($user_id,$matricule_ax);
+            exit;
+        }
+        if ($part == 'linknext')
+        {
+            $linksToDo = FusionAxModule::find_easy_to_link(10);
+            while ($l = $linksToDo->next())
+            {
+                FusionAxModule::link_by_ids($l['user_id'],$l['id_ancien']);
+            }
+            pl_redirect('fusionax/ids#autolink');
+        }
+        if ($part == 'linkall')
+        {
+            $linksToDo = FusionAxModule::find_easy_to_link(0);
+            while ($l = $linksToDo->next())
+            {
+                FusionAxModule::link_by_ids($l['user_id'],$l['id_ancien']);
+            }
+        }
+        {
+            $page->changeTpl('fusionax/ids.tpl');
+            $missingInAX = XDB::query(
+                'SELECT COUNT(*)
+                FROM fusionax_xorg_anciens AS u
+                WHERE u.matricule_ax IS NULL');
+            if ($missingInAX)
+            {
+                $page->assign('nbMissingInAX', $missingInAX->fetchOneCell());
+            }
+            $missingInXorg = XDB::query(
+                'SELECT COUNT(*)
+                FROM fusionax_import AS i
+                WHERE i.user_id IS NULL');
+            if ($missingInXorg)
+            {
+                $page->assign(
+                    'nbMissingInXorg',
+                    $missingInXorg->fetchOneCell());
+            }
+            $easyToLink = FusionAxModule::find_easy_to_link(10);
+            if ($easyToLink->total() > 0)
+            { 
+                $page->assign('easyToLink', $easyToLink);
+            }
+        }
+    }
+    
+    function handler_misc(&$page)
+    {
+        $page->changeTpl('fusionax/misc.tpl');
+        // deceased
+        $deceasedErrorsSql = XDB::query(
+            'SELECT COUNT(*) FROM fusionax_deceased');
+        $page->assign('deceasedErrors',$deceasedErrorsSql->fetchOneCell());
+        $page->assign('deceasedMissingInXorg',XDB::iterator(
+            'SELECT
+                d.user_id,d.id_ancien,d.nom,d.prenom,d.promo,d.deces_ax,
+                CONCAT(d.prenom, " ", d.nom) AS display_name
+            FROM fusionax_deceased AS d
+            WHERE d.deces_xorg = "0000-00-00"
+            LIMIT 10'));
+        $page->assign('deceasedMissingInAX',XDB::iterator(
+            'SELECT
+                d.user_id,d.id_ancien,d.nom,d.prenom,d.promo,d.deces_xorg,
+                CONCAT(d.prenom, " ", d.nom) AS display_name
+            FROM fusionax_deceased AD d
+            WHERE d.deces_ax = "0000-00-00"
+            LIMIT 10'));
+        $page->assign('deceasedDifferent',XDB::iterator(
+            'SELECT
+                d.user_id,d.id_ancien,d.nom,d.prenom,d.promo,
+                d.deces_ax,d.deces_xorg,
+                CONCAT(d.prenom, " ", d.nom) AS display_name
+            FROM fusionax_deceased AS d
+            WHERE d.deces_xorg != "0000-00-00" AND d.deces_ax != "0000-00-00"
+            LIMIT 10'));
+    }
+}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:?>
diff --git a/modules/fusionax/Activites.sql b/modules/fusionax/Activites.sql
new file mode 100644 (file)
index 0000000..7db895a
--- /dev/null
@@ -0,0 +1,22 @@
+-- Import complet des activités professionnelles
+
+DROP TABLE IF EXISTS `fusionax_activites`;
+
+CREATE TABLE IF NOT EXISTS `fusionax_activites` (
+  `AC` varbinary(2) NOT NULL COMMENT 'Vaut toujours AC pour cette table',
+  `id_ancien` varbinary(8) NOT NULL COMMENT 'Id unique de l''ancien',
+  `hash_activite` binary(5) NOT NULL COMMENT 'Hash de cette ligne pour la lier à l''adresse',
+  `Code_etab` varbinary(10) NOT NULL COMMENT 'Code de l''établissement',
+  `Raison_sociale` varchar(100) collate utf8_unicode_ci NOT NULL COMMENT 'Raison sociale de l''établissement',
+  `Libelle_fonctio` varchar(100) collate utf8_unicode_ci NOT NULL COMMENT 'Libéllé de la fonction',
+  `Annuaire` BOOLEAN NOT NULL COMMENT 'publiable dans l''annuaire papier',
+  `Date_maj` DATE NOT NULL COMMENT 'Date de mise à jour de ces informations',
+  PRIMARY KEY( `id_ancien` , `hash_activite` )
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+LOAD DATA LOCAL INFILE 'Activites.txt' INTO TABLE `fusionax_activites` FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r\n'
+(AC, id_ancien, Code_etab, Raison_sociale, Libelle_fonctio, Annuaire, 
+@Ligne1, @Ligne2, @Ligne3, @code_postal, @ville, @zip_cedex, @etat_distr, @pays, @tel, @fax, @StringDate_maj)
+SET 
+`hash_activite` = SUBSTRING( MD5( CONCAT(Code_etab, Libelle_fonctio) ), 1, 5),
+`Date_maj` = CONCAT(SUBSTRING(@StringDate_maj,7),'-',SUBSTRING(@StringDate_maj,4,2),'-',SUBSTRING(@StringDate_maj,1,2));
diff --git a/modules/fusionax/Adresses.sql b/modules/fusionax/Adresses.sql
new file mode 100644 (file)
index 0000000..1b9ed47
--- /dev/null
@@ -0,0 +1,47 @@
+-- Import complet des adresses
+
+DROP TABLE IF EXISTS `fusionax_adresses`;
+
+CREATE TABLE IF NOT EXISTS `fusionax_adresses` (
+  `provenance` varbinary(2) NOT NULL COMMENT 'Vaut AC, AD ou AN selon la provenance de l''info',
+  `id_ancien` varbinary(8) NOT NULL COMMENT 'Id unique de l''ancien',
+  `Type_adr` enum('E', 'P') character set binary NOT NULL DEFAULT 'P' COMMENT 'Type d''adresse : E pour Entreprise, P pour Personnelle',
+  `hash_adresse` binary(5) NOT NULL COMMENT 'Hash pour différencier les diverses adresses',
+  `Ligne1` varchar(60) character set utf8 NOT NULL,
+  `Ligne2` varchar(60) character set utf8 NOT NULL,
+  `Ligne3` varchar(60) character set utf8 NOT NULL,
+  `code_postal` varchar(20) character set utf8 NOT NULL,
+  `ville` varchar(40) character set utf8 NOT NULL,
+  `zip_cedex` varchar(20) character set utf8 NOT NULL,
+  `etat_distr` varchar(20) character set utf8 NOT NULL,
+  `pays` varchar(50) character set utf8 NOT NULL,
+  `tel` varbinary(30) NOT NULL,
+  `fax` varbinary(30) NOT NULL,
+  `Date_maj` date NOT NULL,
+  PRIMARY KEY  (`id_ancien`, `hash_adresse`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+LOAD DATA LOCAL INFILE 'Adresses.txt' INTO TABLE `fusionax_adresses` FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r\n'
+(provenance, id_ancien, @Type_adr, Ligne1, Ligne2, Ligne3, code_postal, ville, zip_cedex, etat_distr, pays, tel, fax, @StringDate_maj)
+SET 
+`Type_adr` = IF(@Type_adr = 'E', 'E', IF(@Type_adr = '', '', 'P')),
+`hash_adresse` = SUBSTRING( MD5( @Type_adr ), 1, 5),
+`Date_maj` = CONCAT(SUBSTRING(@StringDate_maj,7),'-',SUBSTRING(@StringDate_maj,4,2),'-',SUBSTRING(@StringDate_maj,1,2));
+
+LOAD DATA LOCAL INFILE 'Anciens.txt' INTO TABLE `fusionax_adresses` FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r\n'
+(provenance, id_ancien, @Login, @Password, @promotion_etude, @Groupe_promo, @Nom_patronymique, @partic_patro, @prenom, @Nom_usuel, @partic_nom,
+    @Nom_complet, @Civilite, @Code_nationalite, @Type_membre, @corps_sortie, @StringDate_deces, @grade, @Mel_usage, @Mel_publiable,
+    @tel_mobile, @annee_dernCot, @Representant, @Type_adr, Ligne1, Ligne2, Ligne3, code_postal, ville,
+    zip_cedex, etat_distr, pays, tel, fax, @StringDate_maj)
+SET 
+`Type_adr` = IF(@Type_adr = 'E', 'E', IF(@Type_adr = '', '', 'P')),
+`hash_adresse` = SUBSTRING( MD5( @Type_adr ), 1, 5),
+`Date_maj` = CONCAT(SUBSTRING(@StringDate_maj,7),'-',SUBSTRING(@StringDate_maj,4,2),'-',SUBSTRING(@StringDate_maj,1,2));
+
+LOAD DATA LOCAL INFILE 'Activites.txt' INTO TABLE `fusionax_adresses` FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r\n'
+(provenance, id_ancien, @Code_etab, @Raison_sociale, @Libelle_fonctio, @Annuaire, 
+Ligne1, Ligne2, Ligne3, code_postal, ville, zip_cedex, etat_distr, pays, tel, fax, @StringDate_maj)
+SET 
+`Type_adr` = 'E',
+`hash_adresse` = SUBSTRING( MD5( CONCAT(@Code_etab, @Libelle_fonctio) ), 1, 5),
+`Date_maj` = CONCAT(SUBSTRING(@StringDate_maj,7),'-',SUBSTRING(@StringDate_maj,4,2),'-',SUBSTRING(@StringDate_maj,1,2));
diff --git a/modules/fusionax/Anciens.sql b/modules/fusionax/Anciens.sql
new file mode 100644 (file)
index 0000000..4aa07de
--- /dev/null
@@ -0,0 +1,64 @@
+-- Import complet des anciens
+
+DROP TABLE IF EXISTS `fusionax_anciens`;
+
+CREATE TABLE IF NOT EXISTS `fusionax_anciens` (
+  `AN` varbinary(2) NOT NULL COMMENT 'Vaut toujours AN pour cette table',
+  `id_ancien` varbinary(8) NOT NULL COMMENT 'Id unique de l''ancien',
+  `Login` varbinary(15) NOT NULL COMMENT 'Login sur le site de l''AX',
+  `Password` int(11) NOT NULL COMMENT 'Mot de passe sur le site AX',
+  `promotion_etude` int(11) NOT NULL COMMENT 'Promotion avec laquelle il/elle a fait ses études',
+  `Groupe_promo` enum('','A','B','C','N','S') character set binary NOT NULL COMMENT 'Groupe de promotion (code compris seulement par AX)',
+  `Nom_patronymique` varchar(50) character set utf8 NOT NULL COMMENT 'Nom patronymique (nom de jeune fille) sans la particule',
+  `partic_patro` varchar(5) character set utf8 NOT NULL COMMENT 'Particule du nom patronymique',
+  `prenom` varchar(30) character set utf8 NOT NULL COMMENT 'Prénom',
+  `Nom_usuel` varchar(50) character set utf8 NOT NULL COMMENT 'Nom usuel (nom marital par exemple) sans la particule',
+  `partic_nom` varchar(5) character set utf8 NOT NULL COMMENT 'Particule du nom usuel',
+  `Nom_complet` varchar(80) character set utf8 NOT NULL COMMENT 'Nom patronymique complet (avec la particule)',
+  `Civilite` enum('','.','M','MME','MLLE') character set utf8 NOT NULL COMMENT 'Civilité',
+  `Code_nationalite` varbinary(2) NOT NULL COMMENT 'Nationalité (code)',
+  `Type_membre` enum('','*','F','FB','P','PB','T','TB','TA') character set binary NOT NULL COMMENT 'Type de membre (code compris seulement par AX)',
+  `corps_sortie` varchar(10) character set utf8 NOT NULL COMMENT 'Corps de sortie (ou D si aucun)',
+  `Date_deces` DATE COMMENT 'Date de décès',
+  `grade` varbinary(20) NOT NULL COMMENT 'Grade actuel dans son corps',
+  `Mel_usage` varbinary(150) NOT NULL COMMENT 'Adresse e-mail d''usage',
+  `Mel_publiable` tinyint(4) NOT NULL COMMENT 'Autorisation d''utiliser le mail',
+  `tel_mobile` varbinary(30) NOT NULL COMMENT 'Numéro de téléphone mobile',
+  `annee_dernCot` int(11) NOT NULL COMMENT 'Année de dernière cotisation AX',
+  `Representant` enum('','K','DE') character set binary NOT NULL COMMENT 'Représentant de promotion',
+  `hash_adr_defaut` binary(5) NOT NULL COMMENT 'Hash de l''adresse par défaut',
+  `Date_maj` DATE NOT NULL,
+  PRIMARY KEY  (`id_ancien`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+LOAD DATA LOCAL INFILE 'Anciens.txt' INTO TABLE `fusionax_anciens` FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r\n'
+(`AN`, `id_ancien`, `Login`, `Password`, `promotion_etude`, `Groupe_promo`, `Nom_patronymique`, `partic_patro`, `prenom`, Nom_usuel, partic_nom,
+    Nom_complet, Civilite, Code_nationalite, Type_membre, corps_sortie, @StringDate_deces, grade, Mel_usage, Mel_publiable,
+    tel_mobile, annee_dernCot, Representant, @Type_adr_defaut, @AdrC_Ligne1, @AdrC_Ligne2, @AdrC_Ligne3, @AdrC_code_postal, @AdrC_ville,
+    @AdrC_zip_cedex, @AdrC_etat_distr, @AdrC_pays, @tel, @fax, @StringDate_maj)
+SET
+    `hash_adr_defaut` = SUBSTRING( MD5( @Type_adr_defaut ), 1, 5),
+    `Date_maj` = CONCAT(SUBSTRING(@StringDate_maj,7),'-',SUBSTRING(@StringDate_maj,4,2),'-',SUBSTRING(@StringDate_maj,1,2)),
+    `Date_deces` = CONCAT(SUBSTRING(@StringDate_deces,7),'-',SUBSTRING(@StringDate_deces,4,2),'-',SUBSTRING(@StringDate_deces,1,2));
+
+-- Correspondances entre fiches X.org et fiches AX
+DROP TABLE IF EXISTS `fusionax_import`;
+CREATE TABLE IF NOT EXISTS `fusionax_import` (
+  `id_ancien` binary(8) NOT NULL COMMENT 'identifiant AX de l''ancien',
+  `user_id` int(11) default NULL COMMENT 'identifiant x.org de l''ancien si on l''a trouvé',
+  `date_match_id` timestamp NULL default NULL COMMENT 'date de mise en correspondance des identifiants',
+  PRIMARY KEY  (`id_ancien`),
+  KEY `user_id` (`user_id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+INSERT INTO `fusionax_import` ( SELECT `id_ancien`, NULL, NULL FROM `fusionax_anciens` );
+REPLACE INTO `fusionax_import` ( SELECT `matricule_ax`, `user_id`, NOW() FROM `auth_user_md5` );
+
+DROP VIEW IF EXISTS `fusionax_deceased`;
+
+CREATE VIEW `fusionax_deceased` AS 
+SELECT u.user_id, a.id_ancien, u.nom, u.prenom, u.promo, u.deces AS deces_xorg, a.Date_deces AS deces_ax
+FROM `auth_user_md5` AS u
+INNER JOIN fusionax_anciens AS a ON ( a.id_ancien = u.matricule_ax )
+WHERE u.deces != a.Date_deces;
diff --git a/modules/fusionax/Entreprises.sql b/modules/fusionax/Entreprises.sql
new file mode 100644 (file)
index 0000000..651d24b
--- /dev/null
@@ -0,0 +1,17 @@
+-- Import complet des entreprises
+
+DROP TABLE IF EXISTS `fusionax_entreprises`;
+
+CREATE TABLE IF NOT EXISTS `fusionax_entreprises` (
+  `EN` varbinary(2) NOT NULL COMMENT 'Vaut toujours EN pour cette table',
+  `Code_etab` varbinary(10) NOT NULL COMMENT 'Code de l''établissement',
+  `Raison_sociale` varchar(100) collate utf8_unicode_ci NOT NULL COMMENT 'Raison sociale de l''établissement',
+  `Sigle` varchar(50) collate utf8_unicode_ci NOT NULL COMMENT 'Sigle de l''établissement',
+  `Date_maj` DATE NOT NULL COMMENT 'Date de mise à jour de ces informations',
+  PRIMARY KEY(`Code_etab`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+LOAD DATA LOCAL INFILE 'Entreprises.txt' INTO TABLE `fusionax_entreprises` FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r\n'
+(EN, Code_etab, Raison_sociale, Sigle, @Inconnu, @StringDate_maj)
+SET 
+`Date_maj` = CONCAT(SUBSTRING(@StringDate_maj,7),'-',SUBSTRING(@StringDate_maj,4,2),'-',SUBSTRING(@StringDate_maj,1,2));
diff --git a/modules/fusionax/Formations.sql b/modules/fusionax/Formations.sql
new file mode 100644 (file)
index 0000000..7d2854a
--- /dev/null
@@ -0,0 +1,16 @@
+-- Import complet des formations
+
+DROP TABLE IF EXISTS `fusionax_formations`;
+
+CREATE TABLE IF NOT EXISTS `fusionax_formations` (
+  `FO` varbinary(2) NOT NULL COMMENT 'Vaut toujours FO pour cette table',
+  `id_ancien` varbinary(8) NOT NULL COMMENT 'Id unique de l''ancien',
+  `Intitule_formation` varchar(60) collate utf8_unicode_ci NOT NULL COMMENT 'Intitulé de la formation',
+  `Date_maj` DATE NOT NULL COMMENT 'Date de mise à jour de ces informations',
+  PRIMARY KEY (`id_ancien`, `Intitule_formation`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+LOAD DATA LOCAL INFILE 'Formations.txt' INTO TABLE `fusionax_formations` FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r\n'
+(FO, id_ancien, Intitule_formation, @StringDate_maj)
+SET 
+`Date_maj` = CONCAT(SUBSTRING(@StringDate_maj,7),'-',SUBSTRING(@StringDate_maj,4,2),'-',SUBSTRING(@StringDate_maj,1,2));
diff --git a/modules/fusionax/import-ax.sh b/modules/fusionax/import-ax.sh
new file mode 100755 (executable)
index 0000000..35b4b6a
--- /dev/null
@@ -0,0 +1,26 @@
+#! /bin/bash
+
+# import des données
+scp -i ax_xorg_rsa xorg@polytechniciens.com:/home/axasso/ax-import/export_4D.txt.rar .
+unrar e -inul export_4D.txt.rar
+
+# séparation en fichiers de tables 
+cat export-total* | grep ^AD > Adresses.txt
+cat export-total* | grep ^AN > Anciens.txt
+cat export-total* | grep ^FO > Formations.txt
+cat export-total* | grep ^AC > Activites.txt
+cat export-total* | grep ^EN > Entreprises.txt
+
+exit 1
+
+# intégration dans notre bdd
+echo intégration dans notre bdd
+$MYSQL x4dat < Activites.sql
+$MYSQL x4dat < Adresses.sql
+$MYSQL x4dat < Anciens.sql
+$MYSQL x4dat < Formations.sql
+$MYSQL x4dat < Entreprises.sql
+
+# nettoyage
+echo nettoyage
+rm Adresses.txt Anciens.txt Formations.txt Activites.txt Entreprises.txt export_4D.txt.rar export-total*
index 9fb091a..8677233 100644 (file)
@@ -27,6 +27,7 @@ class GeolocModule extends PLModule
             'geoloc'             => $this->make_hook('default', AUTH_COOKIE),
             'admin/geoloc'           => $this->make_hook('admin', AUTH_MDP, 'admin'),
             'admin/geoloc/dynamap'   => $this->make_hook('admin_dynamap', AUTH_MDP, 'admin'),
+            'admin/geoloc/country'   => $this->make_hook('admin_country',  AUTH_MDP, 'admin')
         );
     }
 
@@ -107,6 +108,51 @@ class GeolocModule extends PLModule
         $page->assign("no_coordinates", $noCoordinates);
     }
 
+    function handler_admin_country(&$page, $action = 'list', $id = null)
+    {
+        $page->assign('xorg_title', 'Polytechnique.org - Administration - Pays');
+        $page->assign('title', 'Gestion des pays');
+        $table_editor = new PLTableEditor('admin/geoloc/country', 'geoloc_pays', 'a2', true);
+        $table_editor->describe('a2', 'alpha-2', true);
+        $table_editor->describe('a3', 'alpha-3', false);
+        $table_editor->describe('n3', 'ISO numeric', false);
+        $table_editor->describe('num', 'num', false);
+        $table_editor->describe('worldrgn', 'Continent', false);
+        $table_editor->describe('subd', 'Subdivisions territoriales', false);
+        $table_editor->describe('post', 'post', false);
+        $table_editor->describe('pays', 'Nom (fr)', true);
+        $table_editor->describe('country', 'Nom (en)', true);
+        $table_editor->describe('phoneprf', 'Préfixe téléphonique', true);
+        $table_editor->describe('phoneformat', 'Format du téléphone (ex: (+p) ### ## ## ##)', false);
+        $table_editor->describe('capital', 'Capitale', true);
+        $table_editor->describe('nat', 'Nationalité', true);
+        $table_editor->describe('display', 'Format des adresses', false);
+
+        if ($action == 'update') {
+            if (Post::has('a2') && (Post::v('a2') == $id) && Post::has('phoneprf') && (Post::v('phoneprf') != '')) {
+                if (Post::has('phoneformat')) {
+                    $new_format = Post::v('phoneformat');
+                } else {
+                    $new_format = '';
+                }
+                $res = XDB::query("SELECT phoneformat
+                                     FROM geoloc_pays
+                                    WHERE phoneprf = {?}
+                                    LIMIT 1",
+                                  Post::v('phoneprf'));
+                $old_format = $res->fetchOneCell();
+                if ($new_format != $old_format) {
+                    require_once("profil.func.inc.php");
+                    XDB::execute("UPDATE  geoloc_pays
+                                     SET  phoneformat = {?}
+                                   WHERE  phoneprf = {?}",
+                                 $new_format, Post::v('phoneprf'));
+                }
+            }
+        }
+        $table_editor->apply($page, $action, $id);
+    }
+
 }
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
index 77ee08d..337ee71 100644 (file)
@@ -154,7 +154,7 @@ class MarketingModule extends PLModule
         $res = XDB::iterator(
                 "SELECT  r.*, a.alias
                    FROM  register_marketing AS r
-             INNER JOIN  aliases            AS a ON (r.sender=a.id AND a.type = 'a_vie')
+              LEFT JOIN  aliases            AS a ON (r.sender=a.id AND a.type = 'a_vie')
                   WHERE  uid={?}
                ORDER BY  date", $uid);
         $page->assign('addr', $res);
index e1b4d0f..be68922 100644 (file)
@@ -80,10 +80,11 @@ class PayPal
         $res = XDB::query(
             "SELECT a.adr1 AS address1, a.adr2 AS address2,
                     a.city, a.postcode AS zip, a.country,
-                    IF(t.tel, t.tel, q.profile_mobile) AS night_phone_b
+                    IF(t1.display_tel != '', t1.display_tel, t2.display_tel) AS night_phone_b
                FROM auth_user_quick AS q
           LEFT JOIN adresses  AS a ON (q.user_id = a.uid AND FIND_IN_SET('active', a.statut))
-          LEFT JOIN tels        AS t ON (t.uid = a.uid AND t.adrid = a.adrid)
+          LEFT JOIN profile_phones AS t1 ON (t1.uid = a.uid AND t1.link_type = 'address' AND t1.link_id = a.adrid)
+          LEFT JOIN profile_phones AS t2 ON (t2.uid = a.uid AND t2.link_type = 'user' AND t2.link_id = 0)
               WHERE q.user_id = {?}
               LIMIT 1", S::v('uid'));
         $this->infos['client'] = array_map('replace_accent', array_merge($info_client, $res->fetchOneAssoc()));
index 63e3370..894578a 100644 (file)
@@ -35,9 +35,11 @@ class ProfileModule extends PLModule
             'profile/ajax/address' => $this->make_hook('ajax_address', AUTH_COOKIE, 'user', NO_AUTH),
             'profile/ajax/tel'     => $this->make_hook('ajax_tel',     AUTH_COOKIE, 'user', NO_AUTH),
             'profile/ajax/medal'   => $this->make_hook('ajax_medal',   AUTH_COOKIE, 'user', NO_AUTH),
+            'profile/networking'   => $this->make_hook('networking',   AUTH_PUBLIC),
             'profile/ajax/job'     => $this->make_hook('ajax_job',     AUTH_COOKIE, 'user', NO_AUTH),
             'profile/ajax/secteur' => $this->make_hook('ajax_secteur', AUTH_COOKIE, 'user', NO_AUTH),
             'profile/ajax/skill'   => $this->make_hook('ajax_skill',   AUTH_COOKIE, 'user', NO_AUTH),
+            'profile/ajax/searchname'   => $this->make_hook('ajax_searchname',   AUTH_COOKIE, 'user', NO_AUTH),
             'javascript/applis.js' => $this->make_hook('applis_js', AUTH_COOKIE),
             'javascript/grades.js' => $this->make_hook('grades_js', AUTH_COOKIE),
             'profile/medal'    => $this->make_hook('medal', AUTH_PUBLIC),
@@ -58,6 +60,7 @@ class ProfileModule extends PLModule
             'admin/formations' => $this->make_hook('admin_formations', AUTH_MDP, 'admin'),
             'admin/sections'  => $this->make_hook('admin_sections', AUTH_MDP, 'admin'),
             'admin/secteurs'  => $this->make_hook('admin_secteurs', AUTH_MDP, 'admin'),
+            'admin/networking' => $this->make_hook('admin_networking', AUTH_MDP, 'admin'),
             'admin/trombino'   => $this->make_hook('admin_trombino', AUTH_MDP, 'admin'),
             'admin/ss_secteurs'  => $this->make_hook('admin_ss_secteurs', AUTH_MDP, 'admin'),
             'admin/fonctions'  => $this->make_hook('admin_fonctions', AUTH_MDP, 'admin'),
@@ -123,6 +126,19 @@ class ProfileModule extends PLModule
         exit;
     }
 
+    function handler_networking(&$page, $mid)
+    {
+        $res = XDB::query("SELECT  icon
+                             FROM  profile_networking_enum
+                            WHERE  network_type = {?}",
+                          $mid);
+        $img  = dirname(__FILE__) . '/../htdocs/images/networking/' . $res->fetchOneCell();
+        $type = mime_content_type($img);
+        header("Content-Type: $type");
+        echo file_get_contents($img);
+        exit;
+    }
+
     function handler_photo_change(&$page)
     {
         global $globals;
@@ -386,14 +402,13 @@ class ProfileModule extends PLModule
         $page->assign('adr', array());
     }
 
-    function handler_ajax_tel(&$page, $adid, $telid)
+    function handler_ajax_tel(&$page, $prefid, $prefname, $telid)
     {
         header('Content-Type: text/html; charset=utf-8');
-        $page->changeTpl('profile/adresses.tel.tpl', NO_SKIN);
-        $page->assign('i', $adid);
-        $page->assign('adid', "addresses_$adid");
-        $page->assign('adpref', "addresses[$adid]");
-        $page->assign('t', $telid);
+        $page->changeTpl('profile/phone.tpl', NO_SKIN);
+        $page->assign('prefid', $prefid);
+        $page->assign('prefname', $prefname);
+        $page->assign('telid', $telid);
         $page->assign('tel', array());
     }
 
@@ -451,6 +466,15 @@ class ProfileModule extends PLModule
         }
     }
 
+    function handler_ajax_searchname(&$page, $snid)
+    {
+        header('Content-Type: text/html; charset=utf-8');
+        $page->changeTpl('profile/general.searchname.tpl', NO_SKIN);
+        $page->assign('i', $snid);
+        $page->assign('sn', array());
+        $page->assign('newsn', true);
+    }
+    
     function handler_p_orange(&$page)
     {
         $page->changeTpl('profile/orange.tpl');
@@ -808,6 +832,16 @@ class ProfileModule extends PLModule
         $table_editor->describe('label', 'intitulé', true);
         $table_editor->apply($page, $action, $id);
     }
+    function handler_admin_networking(&$page, $action = 'list', $id = null) {
+        $page->assign('xorg_title', 'Polytechnique.org - Administration - Networking');
+        $page->assign('title', 'Gestion des types de networking');
+        $table_editor = new PLTableEditor('admin/networking', 'profile_networking_enum', 'network_type');
+        $table_editor->describe('name', 'intitulé', true);
+        $table_editor->describe('icon', 'nom de l\'icône', false);
+        $table_editor->describe('filter', 'filtre', true);
+        $table_editor->describe('link', 'lien web', true);
+        $table_editor->apply($page, $action, $id);
+    }
     function handler_admin_medals(&$page, $action = 'list', $id = null) {
         $page->setTitle('Polytechnique.org - Administration - Distinctions');
         $page->assign('title', 'Gestion des Distinctions');
index 780ee03..7317c5d 100644 (file)
@@ -23,34 +23,24 @@ class ProfileAddress extends ProfileGeoloc
 {
     private $bool;
     private $pub;
-    private $tel;
 
     public function __construct()
     {
         $this->bool = new ProfileBool();
         $this->pub  = new ProfilePub();
-        $this->tel  = new ProfileTel();
     }
 
-    private function cleanAddress(ProfilePage &$page, array &$address, &$success)
+    private function cleanAddress(ProfilePage &$page, $adrid, array &$address, &$success)
     {
         if (@$address['changed']) {
             $address['datemaj'] = time();
         }
         $success = true;
-        foreach ($address['tel'] as $t=>&$tel) {
-            if (@$tel['removed'] || !trim($tel['tel'])) {
-                unset($address['tel'][$t]);
-            } else {
-                $tel['pub'] = $this->pub->value($page, 'pub', $tel['pub'], $s);
-                $tel['tel'] = $this->tel->value($page, 'tel', $tel['tel'], $s);
-                if (!$s) {
-                    $tel['error'] = true;
-                    $success = false;
-                }
-            }
-            unset($tel['removed']);
+        if (!isset($address['tel'])) {
+            $address['tel'] = array();
         }
+        $profiletel  = new ProfilePhones('address', $adrid);
+        $address['tel'] = $profiletel->value($page, 'tel', $address['tel'], $s);
         $address['checked'] = $this->bool->value($page, 'checked', $address['checked'], $s);
         $address['secondaire'] = $this->bool->value($page, 'secondaire', $address['secondaire'], $s);
         $address['mail'] = $this->bool->value($page, 'mail', $address['mail'], $s);
@@ -94,7 +84,7 @@ class ProfileAddress extends ProfileGeoloc
             $ls = true;
             $this->geolocAddress($adr, $s);
             $ls = ($ls && $s);
-            $this->cleanAddress($page, $adr, $s);
+            $this->cleanAddress($page, $key, $adr, $s);
             $ls = ($ls && $s);
             if (!trim($adr['text'])) {
                 unset($value[$key]);
@@ -107,12 +97,12 @@ class ProfileAddress extends ProfileGeoloc
 
     private function saveTel($adrid, $telid, array &$tel)
     {
-        XDB::execute("INSERT INTO  tels (uid, adrid, telid,
-                                         tel_type, tel_pub, tel)
-                           VALUES  ({?}, {?}, {?},
+        XDB::execute("INSERT INTO  profile_phones (uid, link_type, link_id, tel_id, tel_type,
+                                              search_tel, display_tel, pub)
+                           VALUES  ({?}, 'address', {?}, {?}, {?},
                                     {?}, {?}, {?})",
-                    S::i('uid'), $adrid, $telid,
-                    $tel['type'], $tel['pub'], $tel['tel']);
+                    S::i('uid'), $adrid, $telid, $tel['type'],
+                    format_phone_number($tel['tel']), $tel['tel'], $tel['pub']);
     }
 
     private function saveAddress($adrid, array &$address)
@@ -137,20 +127,17 @@ class ProfileAddress extends ProfileGeoloc
                                               postcode, city, cityid,
                                               country, region, regiontxt,
                                               pub, datemaj, statut,
-                                              uid, adrid, glat, glng)
+                                              uid, adrid, glat, glng, comment)
                            VALUES  ({?}, {?}, {?},
                                     {?}, {?}, {?},
                                     {?}, {?}, {?},
                                     {?}, FROM_UNIXTIME({?}), {?},
-                                    {?}, {?}, {?}, {?})",
+                                    {?}, {?}, {?}, {?}, {?})",
                      $address['adr1'], $address['adr2'], $address['adr3'],
                      $address['postcode'], $address['city'], $address['cityid'],
                      $address['country'], $address['region'], $address['regiontxt'],
                      $address['pub'], $address['datemaj'], $flags,
-                     S::i('uid'), $adrid, $address['precise_lat'], $address['precise_lon']);
-        foreach ($address['tel'] as $telid=>&$tel) {
-            $this->saveTel($adrid, $telid, $tel);
-        }
+                     S::i('uid'), $adrid, $address['precise_lat'], $address['precise_lon'], $address['comment']);
     }
 
     public function save(ProfilePage &$page, $field, $value)
@@ -158,11 +145,13 @@ class ProfileAddress extends ProfileGeoloc
         XDB::execute("DELETE FROM  adresses
                             WHERE  uid = {?}",
                      S::i('uid'));
-        XDB::execute("DELETE FROM  tels
-                            WHERE  uid = {?}",
+        XDB::execute("DELETE FROM  profile_phones
+                            WHERE  uid = {?} AND link_type = 'address'",
                      S::i('uid'));
         foreach ($value as $adrid=>&$address) {
             $this->saveAddress($adrid, $address);
+            $profiletel = new ProfilePhones('address', $adrid);
+            $profiletel->saveTels('tel', $address['tel']);
         }
     }
 }
@@ -190,7 +179,8 @@ class ProfileAddresses extends ProfilePage
                                    FIND_IN_SET('courrier', a.statut) AS mail,
                                    FIND_IN_SET('temporaire', a.statut) AS temporary,
                                    FIND_IN_SET('active', a.statut) AS current,
-                                   a.glat AS precise_lat, a.glng AS precise_lon
+                                   a.glat AS precise_lat, a.glng AS precise_lon,
+                                   a.comment
                              FROM  adresses AS a
                        INNER JOIN  geoloc_pays AS gp ON(gp.a2 = a.country)
                             WHERE  uid = {?} AND NOT FIND_IN_SET('pro', statut)
@@ -202,10 +192,10 @@ class ProfileAddresses extends ProfilePage
             $this->values['addresses'] = $res->fetchAllAssoc();
         }
 
-        $res = XDB::iterator("SELECT  adrid, tel_type AS type, tel_pub AS pub, tel
-                                FROM  tels
-                               WHERE  uid = {?}
-                            ORDER BY  adrid",
+        $res = XDB::iterator("SELECT  link_id AS adrid, tel_type AS type, pub, display_tel AS tel, comment
+                                FROM  profile_phones
+                               WHERE  uid = {?} AND link_type = 'address'
+                            ORDER BY  link_id",
                              S::i('uid'));
         $i = 0;
         $adrNb = count($this->values['addresses']);
index 8227f36..42dc5cd 100644 (file)
@@ -64,6 +64,22 @@ class ProfileNom implements ProfileSetting
     }
 }
 
+class ProfileSearchName implements ProfileSetting
+{
+
+    public function __construct()
+    {
+    }
+
+    public function value(ProfilePage &$page, $field, $value, &$success)
+    {
+    }
+
+    public function save(ProfilePage &$page, $field, $new_value)
+    {
+    }
+}
+
 class ProfileAppli implements ProfileSetting
 {
     public function value(ProfilePage &$page, $field, $value, &$success)
@@ -90,6 +106,120 @@ class ProfileAppli implements ProfileSetting
     }
 }
 
+class ProfileEmailDirectory implements ProfileSetting
+{
+    private $email;
+
+    public function __construct()
+    {
+    }
+
+    public function value(ProfilePage &$page, $field, $value, &$success)
+    {
+        $p = $page;
+        global $page;
+
+        $success = true;
+        if (!is_null($value)) {
+            $email_stripped = strtolower(trim($value));
+            if ((!isvalid_email($email_stripped)) && ($email_stripped) && ($p->values['email_directory'] == "new@new.new")) {
+                $page->assign('email_error', '1');
+                $page->assign('email_directory_error', $email_stripped);
+                $page->trigError('Adresse Email invalide');
+                $success = false;
+            } else {
+                $page->assign('email_error', '0');
+            }
+        }
+        return $value;
+    }
+
+    public function save(ProfilePage &$page, $field, $value)
+    {
+    }
+}
+
+class ProfileNetworking implements ProfileSetting
+{
+    private $email;
+    private $pub;
+    private $web;
+    private $number;
+
+    public function __construct()
+    {
+        $this->email  = new ProfileEmail();
+        $this->pub    = new ProfilePub();
+        $this->web    = new ProfileWeb();
+        $this->number = new ProfileNumber();
+    }
+
+    public function value(ProfilePage &$page, $field, $value, &$success)
+    {
+        if (is_null($value)) {
+            $value = array();
+            $res = XDB::iterator("SELECT  n.address, n.network_type AS type, n.pub, m.name
+                                    FROM  profile_networking AS n
+                              INNER JOIN  profile_networking_enum AS m ON (n.network_type = m.network_type)
+                                   WHERE  n.uid = {?}",
+                                 S::i('uid'));
+            while($network = $res->next()) {
+                $value[] = $network;
+            }
+        }
+        if (!is_array($value)) {
+            $value = array();
+        }
+        $res = XDB::iterator("SELECT  filter, network_type AS type
+                                FROM  profile_networking_enum;");
+        $filters = array();
+        while($filter = $res->next()) {
+            $filters[$filter['type']] = $filter['filter'];
+        }
+        $success = true;
+        foreach($value as $i=>&$network) {
+            if (!trim($network['address'])) {
+                unset($value[$i]);
+            } else {
+                if (!isset($network['pub'])) {
+                    $network['pub'] = 'private';
+                }
+                $network['error'] = false;
+                $network['pub'] = $this->pub->value($page, 'pub', $network['pub'], $s);
+                $s = true;
+                if ($filters[$network['type']] == 'web') {
+                    $network['address'] = $this->web->value($page, 'address', $network['address'], $s);
+                } elseif ($filters[$network['type']] == 'email') {
+                    $network['address'] = $this->email->value($page, 'address', $network['address'], $s);
+                } elseif ($filters[$network['type']] == 'number') {
+                    $network['address'] = $this->number->value($page, 'address', $network['address'], $s);
+                }
+                if (!$s) {
+                    $success = false;
+                    $network['error'] = true;
+                }
+            }
+        }
+        return $value;
+    }
+
+    public function save(ProfilePage &$page, $field, $value)
+    {
+        XDB::execute("DELETE FROM profile_networking
+                            WHERE uid = {?}",
+                     S::i('uid'));
+        if (!count($value)) {
+            return;
+        }
+        $insert = array();
+        foreach ($value as $id=>$network) {
+            XDB::execute("INSERT INTO  profile_networking (uid, nwid, network_type, address, pub)
+                               VALUES  ({?}, {?}, {?}, {?}, {?})",
+                         S::i('uid'), $id, $network['type'], $network['address'], $network['pub']);
+        }
+    }
+}
+
 class ProfileGeneral extends ProfilePage
 {
     protected $pg_template = 'profile/general.tpl';
@@ -97,43 +227,55 @@ class ProfileGeneral extends ProfilePage
     public function __construct(PlWizard &$wiz)
     {
         parent::__construct($wiz);
-        $this->settings['nom'] = $this->settings['prenom']
-                               = new ProfileNom();
+        $this->settings['nom']    = $this->settings['prenom']
+                                  = new ProfileNom();
         $this->settings['naissance'] = new ProfileDate();
-        $this->settings['mobile_pub']
-                                  = $this->settings['web_pub']
-                                  = $this->settings['freetext_pub']
+        $this->settings['freetext_pub']
                                   = $this->settings['photo_pub']
                                   = new ProfilePub();
         $this->settings['freetext']
                                   = $this->settings['nationalite']
                                   = $this->settings['nick']
+                                  = $this->settings['yourself']
+                                  = $this->settings['display_name']
+                                  = $this->settings['sort_name']
+                                  = $this->settings['tooltip_name']
                                   = null;
         $this->settings['synchro_ax']
                                   = new ProfileBool();
-        $this->settings['mobile'] = new ProfileTel();
-        $this->settings['web'] = new ProfileWeb();
+        $this->settings['email_directory']
+                                  = new ProfileEmail();
+        $this->settings['email_directory_new']
+                                  = new ProfileEmailDirectory();
+        $this->settings['networking'] = new ProfileNetworking();
+        $this->settings['tels'] = new ProfilePhones('user', 0);
         $this->settings['appli1']
                                   = $this->settings['appli2']
                                   = new ProfileAppli();
-        $this->watched= array('nom' => true, 'freetext' => true, 'mobile' => true, 'web' => true,
-                       'appli1' => true, 'appli2' => true, 'nationalite' => true, 'nick' => true);
+        $this->watched= array('nom' => true, 'freetext' => true, 'tels' => true,
+                              'networking' => true, 'appli1' => true, 'appli2' => true,
+                              'nationalite' => true, 'nick' => true);
     }
 
     protected function _fetchData()
     {
         // Checkout all data...
         $res = XDB::query("SELECT  u.promo, u.promo_sortie, u.nom_usage, u.nationalite, u.naissance,
-                                   q.profile_mobile as mobile, q.profile_mobile_pub as mobile_pub,
-                                   q.profile_web as web, q.profile_web_pub as web_pub,
+                                   t.display_tel as mobile, t.pub as mobile_pub,
+                                   d.email_directory as email_directory,
                                    q.profile_freetext as freetext, q.profile_freetext_pub as freetext_pub,
                                    q.profile_nick as nick, q.profile_from_ax as synchro_ax, u.matricule_ax,
                                    IF(a1.aid IS NULL, -1, a1.aid) as appli_id1, a1.type as appli_type1,
-                                   IF(a2.aid IS NULL, -1, a2.aid) as appli_id2, a2.type as appli_type2
-                             FROM  auth_user_md5   AS u
-                       INNER JOIN  auth_user_quick AS q  USING(user_id)
-                        LEFT JOIN  applis_ins      AS a1 ON(a1.uid = u.user_id and a1.ordre = 0)
-                        LEFT JOIN  applis_ins      AS a2 ON(a2.uid = u.user_id and a2.ordre = 1)
+                                   IF(a2.aid IS NULL, -1, a2.aid) as appli_id2, a2.type as appli_type2,
+                                   n.yourself, n.display AS display_name, n.sort AS sort_name,
+                                   n.tooltip AS tooltip_name
+                             FROM  auth_user_md5         AS u
+                       INNER JOIN  auth_user_quick       AS q  ON(u.user_id = q.user_id)
+                       INNER JOIN  profile_names_display AS n  ON(n.user_id = u.user_id)
+                        LEFT JOIN  profile_phones        AS t  ON(u.user_id = t.uid AND link_type = 'user')
+                        LEFT JOIN  profile_directory     AS d  ON(d.uid = u.user_id)
+                        LEFT JOIN  applis_ins            AS a1 ON(a1.uid = u.user_id and a1.ordre = 0)
+                        LEFT JOIN  applis_ins            AS a2 ON(a2.uid = u.user_id and a2.ordre = 1)
                             WHERE  u.user_id = {?}", S::v('uid', -1));
         $this->values = $res->fetchOneAssoc();
 
@@ -158,6 +300,22 @@ class ProfileGeneral extends ProfilePage
                             WHERE  type='photo' AND user_id = {?}",
                           S::v('uid'));
         $this->values['nouvellephoto'] = $res->fetchOneCell();
+
+        // Retreive search names info
+        $this->values['search_names'] = XDB::iterator("
+                              SELECT  sn.search_name, sn.name_type, sn.pub, sn.sn_id
+                                FROM  profile_names_search AS sn
+                               WHERE  sn.user_id = {?}
+                            ORDER BY  sn.name_type, search_score, search_name",
+                          S::v('uid'));
+
+        // Retreive phones
+        $res = XDB::iterator("SELECT t.display_tel AS tel, t.tel_type AS type, t.pub, t.comment
+                                FROM profile_phones AS t
+                               WHERE t.uid = {?} AND t.link_type = 'user'
+                            ORDER BY t.tel_id",
+                             S::v('uid'));
+        $this->values['tels'] = $res->fetchAllAssoc();
     }
 
     protected function _saveData()
@@ -171,19 +329,23 @@ class ProfileGeneral extends ProfilePage
                          preg_replace('@(\d{2})/(\d{2})/(\d{4})@', '\3-\2-\1', $this->values['naissance']),
                          S::v('uid'));
         }
-        if ($this->changed['nick'] || $this->changed['mobile'] || $this->changed['mobile_pub']
-            || $this->changed['web'] || $this->changed['web_pub'] || $this->changed['freetext']
-            || $this->changed['freetext_pub'] || $this->changed['synchro_ax']) {
+        if ($this->changed['nick'] || $this->changed['freetext'] || $this->changed['freetext_pub'] || $this->changed['synchro_ax']) {
             XDB::execute("UPDATE  auth_user_quick
-                             SET  profile_nick= {?}, profile_mobile={?}, profile_mobile_pub={?}, 
-                                  profile_web={?}, profile_web_pub={?}, profile_freetext={?}, 
+                             SET  profile_nick= {?},
+                                  profile_freetext={?},
                                   profile_freetext_pub={?}, profile_from_ax = {?} 
                            WHERE  user_id = {?}", 
-                         $this->values['nick'], $this->values['mobile'], $this->values['mobile_pub'],
-                         $this->values['web'], $this->values['web_pub'],
+                         $this->values['nick'],
                          $this->values['freetext'], $this->values['freetext_pub'],
                          $this->values['synchro_ax'], S::v('uid'));
         }
+        if ($this->changed['email_directory']) {
+            $new_email = ($this->values['email_directory'] == "new@new.new") ?
+                $this->values['email_directory_new'] : $this->values['email_directory'];
+            XDB::execute("REPLACE INTO  profile_directory (uid, email_directory)
+                                VALUES  ({?}, {?})",
+                         S::v('uid'), $new_email);
+        }
         if ($this->changed['nick']) {
             require_once('user.func.inc.php');
             user_reindex(S::v('uid'));
@@ -194,11 +356,33 @@ class ProfileGeneral extends ProfilePage
                            WHERE  uid = {?}",
                          $this->values['photo_pub'], S::v('uid'));
         }
+        if ($this->changed['yourself'] || $this->changed['sort_name'] ||
+            $this-> changed['display_name'] || $this->changed['tooltip_name']) {
+          XDB::execute("UPDATE  profile_names_display AS n
+                           SET  n.yourself = {?},
+                                n.sort = {?}, ". // SET
+                               "n.display = {?}, ". // SET
+                               "n.tooltip = {?} ". // SET
+                        "WHERE  n.user_id = {?}",
+                       $this->values['yourself'],
+                       $this->values['sort_name'],
+                       $this->values['display_name'],
+                       $this->values['tooltip_name'],
+                        S::v('uid'));
+        }
     }
 
     public function _prepare(PlPage &$page, $id)
     {
         require_once "applis.func.inc.php";
+
+        require_once "emails.combobox.inc.php";
+        fill_email_combobox($page);
+
+        $res = XDB::iterator("SELECT  nw.network_type AS type, nw.name
+                                FROM  profile_networking_enum AS nw
+                            ORDER BY  name");
+        $page->assign('network_list', $res->fetchAllAssoc());
     }
 }
 
index ad1e921..90f05cf 100644 (file)
 class ProfileJob extends ProfileGeoloc
 {
     private $pub;
+    private $mail_new;
     private $mail;
     private $web;
-    private $tel;
     private $bool;
     private $checks;
 
     public function __construct()
     {
         $this->pub  = new ProfilePub();
-        $this->mail = new ProfileEmail();
+        $this->mail
+                    = $this->mail_new
+                    = new ProfileEmail();
         $this->web  = new ProfileWeb();
-        $this->tel  = new ProfileTel();
         $this->bool = new ProfileBool();
         $this->checks = array('web' => array('web'),
+                              'mail_new' => array('email_new'),
                               'mail' => array('email'),
-                              'tel' => array('tel', 'fax', 'mobile'),
-                              'pub' => array('pub', 'tel_pub', 'email_pub'));
+                              'pub' => array('pub', 'email_pub'));
     }
 
-    private function cleanJob(ProfilePage &$page, array &$job, &$success)
+    private function cleanJob(ProfilePage &$page,$jobid, array &$job, &$success)
     {
         $success = true;
         foreach ($this->checks as $obj=>&$fields) {
             $chk =& $this->$obj;
             foreach ($fields as $field) {
+                if ($field == "email_new") {
+                    if ($job['email'] == "new@new.new") {
+                        $job['email'] = $job[$field];
+                    }
+                    continue;
+                }
                 $job[$field] = $chk->value($page, $field, $job[$field], $s);
                 if (!$s) {
                     $success = false;
@@ -56,6 +63,11 @@ class ProfileJob extends ProfileGeoloc
         }
         $job['adr']['pub'] = $this->pub->value($page, 'adr_pub', @$job['adr']['pub'], $s);
         $job['adr']['checked'] = $this->bool->value($page, 'adr_checked', @$job['adr']['checked'], $s);
+        if (!isset($job['tel'])) {
+            $job['tel'] = array();
+        }
+        $profiletel = new ProfilePhones('pro', $jobid);
+        $job['tel'] = $profiletel->value($page, 'tel', $job['tel'], $s);
         unset($job['removed']);
         unset($job['new']);
         unset($job['adr']['changed']);
@@ -80,7 +92,7 @@ class ProfileJob extends ProfileGeoloc
             $ls = true;
             $this->geolocAddress($job['adr'], $s);
             $ls = ($ls && $s);
-            $this->cleanJob($page, $job, $s);
+            $this->cleanJob($page, $key, $job, $s);
             $ls = ($ls && $s);
             if (!$init) {
                 $success = ($success && $ls);
@@ -91,32 +103,42 @@ class ProfileJob extends ProfileGeoloc
 
     public function save(ProfilePage &$page, $field, $value)
     {
+        require_once('profil.func.inc.php');
         XDB::execute("DELETE FROM  entreprises
                             WHERE  uid = {?}",
                      S::i('uid'));
+        XDB::execute("DELETE FROM  profile_phones
+                            WHERE  uid = {?} AND link_type = 'pro'",
+                     S::i('uid'));
         $i = 0;
-        foreach ($value as &$job) {
+        foreach ($value as $jobid=>&$job) {
+            if ($job['email'] == "new@new.new") {
+                $job['email'] = $job['email_new'];
+            }
             XDB::execute("INSERT INTO  entreprises (uid, entrid, entreprise, secteur, ss_secteur,
                                                     fonction, poste, adr1, adr2, adr3, postcode,
                                                     city, cityid, country, region, regiontxt,
-                                                    tel, fax, mobile, email, web,
-                                                    pub, adr_pub, tel_pub, email_pub, flags,
+                                                    email, web,
+                                                    pub, adr_pub, email_pub, flags,
                                                     glat, glng)
                                VALUES  ({?}, {?}, {?}, {?}, {?},
                                         {?}, {?}, {?}, {?}, {?}, {?},
                                         {?}, {?}, {?}, {?}, {?},
-                                        {?}, {?}, {?}, {?}, {?},
-                                        {?}, {?}, {?}, {?}, {?},
+                                        {?}, {?},
+                                        {?}, {?}, {?}, {?},
                                         {?}, {?})",
-                         S::i('uid'), $i++, $job['name'], $job['secteur'], $job['ss_secteur'],
+                         S::i('uid'), $i, $job['name'], $job['secteur'], $job['ss_secteur'],
                          $job['fonction'], $job['poste'], $job['adr']['adr1'], $job['adr']['adr2'], $job['adr']['adr3'],
                          $job['adr']['postcode'],
                          $job['adr']['city'], $job['adr']['cityid'], $job['adr']['country'], $job['adr']['region'], 
                          $job['adr']['regiontxt'],
-                         $job['tel'], $job['fax'], $job['mobile'], $job['email'], $job['web'],
-                         $job['pub'], $job['adr']['pub'], $job['tel_pub'], $job['email_pub'],
+                         $job['email'], $job['web'],
+                         $job['pub'], $job['adr']['pub'], $job['email_pub'],
                          $job['adr']['checked'] ? 'geoloc' : '', $job['adr']['precise_lat'],
                          $job['adr']['precise_lon']);
+            $profiletel = new ProfilePhones('pro', $jobid);
+            $profiletel->saveTels('tel', $job['tel']);
+            $i++;
         }
     }
 }
@@ -143,25 +165,27 @@ class ProfileJobs extends ProfilePage
         $this->values['cv'] = $res->fetchOneCell();
 
         // Build the jobs tree
-        $res = XDB::iterRow("SELECT  e.entreprise, e.secteur, e.ss_secteur,
+        $res = XDB::iterRow("SELECT  e.entrid, e.entreprise, e.secteur, e.ss_secteur,
                                      e.fonction, e.poste, e.adr1, e.adr2, e.adr3,
                                      e.postcode, e.city, e.cityid, e.region, e.regiontxt,
                                      e.country, gp.pays, gp.display,
                                      FIND_IN_SET('geoloc', flags),
-                                     e.tel, e.fax, e.mobile, e.email, e.web, e.pub,
-                                     e.adr_pub, e.tel_pub, e.email_pub,
+                                     e.email, e.web, e.pub,
+                                     e.adr_pub, e.email_pub,
                                      e.glat AS precise_lat, e.glng AS precise_lon
                                FROM  entreprises AS e
                           LEFT JOIN  geoloc_pays AS gp ON(gp.a2 = e.country)
-                              WHERE  uid = {?} AND entreprise != ''
+                              WHERE  e.uid = {?} AND entreprise != ''
                            ORDER BY  entrid", S::i('uid'));
         $this->values['jobs'] = array();
-        while (list($name, $secteur, $ss_secteur, $fonction, $poste,
+        while (list($id, $name, $secteur, $ss_secteur, $fonction, $poste,
                     $adr1, $adr2, $adr3, $postcode, $city, $cityid,
                     $region, $regiontxt, $country, $countrytxt, $display,
-                    $checked, $tel, $fax, $mobile, $email, $web,
-                    $pub, $adr_pub, $tel_pub, $email_pub, $glat, $glng) = $res->next()) {
-            $this->values['jobs'][] = array('name'       => $name,
+                    $checked, $email, $web,
+                    $pub, $adr_pub, $email_pub, $glat, $glng
+                   ) = $res->next()) {
+            $this->values['jobs'][] = array('id'         => $id,
+                                            'name'       => $name,
                                             'secteur'    => $secteur,
                                             'ss_secteur' => $ss_secteur,
                                             'fonction'   => $fonction,
@@ -181,15 +205,42 @@ class ProfileJobs extends ProfilePage
                                                                   'checked'    => $checked,
                                                                   'precise_lat'=> $glat,
                                                                   'precise_lon'=> $glng),
-                                            'tel'        => $tel,
-                                            'fax'        => $fax,
-                                            'mobile'     => $mobile,
                                             'email'      => $email,
                                             'web'        => $web,
                                             'pub'        => $pub,
-                                            'tel_pub'    => $tel_pub,
                                             'email_pub'  => $email_pub);
         }
+
+        $res = XDB::iterator("SELECT  link_id AS jobid, tel_type AS type, pub, display_tel AS tel, comment
+                                FROM  profile_phones
+                               WHERE  uid = {?} AND link_type = 'pro'
+                            ORDER BY  link_id",
+                             S::i('uid'));
+        $i = 0;
+        $jobNb = count($this->values['jobs']);
+        while ($tel = $res->next()) {
+            $jobid = $tel['jobid'];
+            unset($tel['jobid']);
+            while ($i < $jobNb && $this->values['jobs'][$i]['id'] < $jobid) {
+                $i++;
+            }
+            if ($i >= $jobNb) {
+                break;
+            }
+            $job =& $this->values['jobs'][$i];
+            if (!isset($job['tel'])) {
+                $job['tel'] = array();
+            }
+            if ($job['id'] == $jobid) {
+                $job['tel'][] = $tel;
+            }
+        }
+        foreach ($this->values['jobs'] as $id=>&$job) {
+            if (!isset($job['tel'])) {
+                $job['tel'] = array();
+            }
+            unset($job['id']);
+        }
     }
 
     protected function _saveData()
@@ -204,6 +255,9 @@ class ProfileJobs extends ProfilePage
 
     public function _prepare(PlPage &$page, $id)
     {
+        require_once "emails.combobox.inc.php";
+        fill_email_combobox($page);
+
         $page->assign('secteurs', XDB::iterator("SELECT  id, label
                                                    FROM  emploi_secteur"));
         $page->assign('fonctions', XDB::iterator("SELECT  id, fonction_fr, FIND_IN_SET('titre', flags) AS title
index 433947e..b380c3e 100644 (file)
@@ -76,6 +76,23 @@ class ProfileEmail extends ProfileNoSave
     }
 }
 
+class ProfileNumber extends ProfileNoSave
+{
+    public function value(ProfilePage &$page, $field, $value, &$success)
+    {
+        if (is_null($value)) {
+            return isset($page->values[$field]) ? $page->values[$field] : S::v($field);
+        }
+        $value = trim($value);
+        $success = empty($value) || is_numeric($value);
+        if (!$success) {
+            global $page;
+            $page->trigError('Numéro invalide');
+        }
+        return $value;
+    }
+}
+
 
 class ProfileTel extends ProfileNoSave
 {
@@ -84,12 +101,95 @@ class ProfileTel extends ProfileNoSave
         if (is_null($value)) {
             return isset($page->values[$field]) ? $page->values[$field] : S::v($field);
         }
-        $success = !preg_match('/[<>{}@&#~\/:;?,!§*_`\[\]|%$^=]/', $value, $matches);
+        require_once('profil.func.inc.php');
+        $value = format_phone_number($value);
+        if($value == '') {
+            $success = true;
+            return $value;
+        }
+        $value = format_display_number($value,$error);
+        $success = !$error;
         if (!$success) {
-            Platal::page()->trigError('Le numéro de téléphone contient un caractère interdit : ' . pl_entities($matches[0][0]));
+            global $page;
+            $page->trigError('Le préfixe international du numéro de téléphone est inconnu. ');
+        }
+        return $value;
+    }
+}
+
+class ProfilePhones implements ProfileSetting
+{
+    private $tel;
+    private $pub;
+    protected $link_type;
+    protected $link_id;
+
+    public function __construct($type, $id)
+    {
+        $this->tel = new ProfileTel();
+        $this->pub = new ProfilePub();
+        $this->link_type = $type;
+        $this->link_id = $id;
+    }
+
+    public function value(ProfilePage &$page, $field, $value, &$success)
+    {
+        $success = true;
+        if (is_null($value)) {
+            $value = isset($page->values[$field]) ? $page->values[$field] : array();
+        }
+        if (!is_array($value)) {
+            $value = array();
+        }
+        foreach ($value as $key=>&$phone) {
+            if (@$phone['removed']) {
+                unset($value[$key]);
+            } else {
+                $phone['pub'] = $this->pub->value($page, 'pub', $phone['pub'], $s);
+                $phone['tel'] = $this->tel->value($page, 'tel', $phone['tel'], $s);
+                if(!isset($phone['type']) || ($phone['type'] != 'fixed' && $phone['type'] != 'mobile' && $phone['type'] != 'fax')) {
+                    $phone['type'] = 'fixed';
+                    $s = false;
+                }
+                if (!$s) {
+                    $phone['error'] = true;
+                    $success = false;
+                }
+                if (!isset($phone['comment'])) {
+                    $phone['comment'] = '';
+                }
+            }
         }
         return $value;
     }
+
+    private function saveTel($telid, array &$phone)
+    {
+        if ($phone['tel'] != '') {
+            XDB::execute("INSERT INTO  profile_phones (uid, link_type, link_id, tel_id, tel_type,
+                                       search_tel, display_tel, pub, comment)
+                               VALUES  ({?}, {?}, {?}, {?}, {?},
+                                       {?}, {?}, {?}, {?})",
+                         S::i('uid'), $this->link_type, $this->link_id, $telid, $phone['type'],
+                        format_phone_number($phone['tel']), $phone['tel'], $phone['pub'], $phone['comment']);
+        }
+    }
+
+    public function save(ProfilePage &$page, $field, $value)
+    {
+        XDB::execute("DELETE FROM  profile_phones
+                            WHERE  uid = {?} AND link_type = {?} AND link_id = {?}",
+                            S::i('uid'), $this->link_type, $this->link_id);
+        $this->saveTels($field, $value);
+    }
+
+    //Only saves phones without a delete operation
+    public function saveTels($field, $value)
+    {
+        foreach ($value as $telid=>&$phone) {
+            $this->saveTel($telid, $phone);
+        }
+    }
 }
 
 class ProfilePub extends ProfileNoSave
index b287c01..7fe8707 100644 (file)
@@ -174,6 +174,8 @@ class SearchModule extends PLModule
                 'secteur' => array('field' => 'id', 'table' => 'emploi_secteur', 'text' => 'label', 'exact' => false),
                 'nationalite' => array('field' => 'a2', 'table' => 'geoloc_pays', 'text' => 'nat', 'exact' => 'false'),
                 'binet' => array('field' => 'id', 'table' => 'binets_def', 'text' => 'text', 'exact' => false),
+                'networking_type' => array('field' => 'network_type', 'table' => 'profile_networking_enum',
+                                           'text' => 'name', 'exact' => false),
                 'groupex' => array('field' => 'id', 'table' => 'groupex.asso',
                                    'text' => "(a.cat = 'GroupesX' OR a.cat = 'Institutions') AND pub = 'public' AND nom",
                                    'exact' => false),
@@ -264,6 +266,13 @@ class SearchModule extends PLModule
                 $beginwith = false;
             $realid = '`binets_def`.`id`';
             break;
+          case 'networking_typeTxt':
+            $db = '`profile_networking_enum` INNER JOIN
+                   `profile_networking` ON(`profile_networking`.`network_type` = `profile_networking_enum`.`network_type`)';
+            $field = '`profile_networking_enum`.`name`';
+            $unique = 'uid';
+            $realid = '`profile_networking_enum`.`network_type`';
+            break;
           case 'city':
             $db = '`geoloc_city` INNER JOIN
                    `adresses` ON(`geoloc_city`.`id` = `adresses`.`cityid`)';
@@ -416,6 +425,11 @@ class SearchModule extends PLModule
           case 'binet':
             $db = '`binets_def`';
             break;
+          case 'networking_type':
+            $db = '`profile_networking_enum`';
+            $field = '`name`';
+            $id = '`network_type`';
+            break;
           case 'country':
             $db = '`geoloc_pays`';
             $field = '`pays`';
index 42ee056..e0eae23 100644 (file)
 // hide private information if not logged
 if (S::logged())
     $globals->search->result_fields .='
-        q.profile_web AS web,
-        q.profile_mobile AS mobile,
         q.profile_freetext AS freetext,
         adr.city, gp.pays AS countrytxt, gr.name AS region,
-        e.entreprise,';
+        e.entreprise,
+        nw.address AS networking_address,
+        nwe.name AS networking_name,';
 else
     $globals->search->result_fields .="
-    IF(q.profile_web_pub='public', q.profile_web, '') AS web,
-        IF(q.profile_mobile_pub='public', q.profile_mobile, '') AS mobile,
         IF(q.profile_freetext_pub='public', q.profile_freetext, '') AS freetext,
         IF(adr.pub='public', adr.city, '') AS city,
         IF(adr.pub='public', gp.pays, '') AS countrytxt,
         IF(adr.pub='public', gr.name, '') AS region,
-        IF(e.pub='public', e.entreprise, '') AS entreprise,";
+        IF(e.pub='public', e.entreprise, '') AS entreprise,
+        IF(nw.pub='public', nw.address, '') AS networking_address,
+        IF(nw.pub='public', nwe.name, '') AS networking_name,";
 @$globals->search->result_where_statement = '
-    LEFT JOIN  applis_ins     AS ai0 ON (u.user_id = ai0.uid AND ai0.ordre = 0)
-    LEFT JOIN  applis_def     AS ad0 ON (ad0.id = ai0.aid)
-    LEFT JOIN  applis_ins     AS ai1 ON (u.user_id = ai1.uid AND ai1.ordre = 1)
-    LEFT JOIN  applis_def     AS ad1 ON (ad1.id = ai1.aid)
-    LEFT JOIN  entreprises    AS e   ON (e.entrid = 0 AND e.uid = u.user_id)
-    LEFT JOIN  emploi_secteur AS es  ON (e.secteur = es.id)
-    LEFT JOIN  fonctions_def  AS ef  ON (e.fonction = ef.id)
-    LEFT JOIN  geoloc_pays    AS n   ON (u.nationalite = n.a2)
-    LEFT JOIN  adresses       AS adr ON (u.user_id = adr.uid AND FIND_IN_SET(\'active\',adr.statut))
-    LEFT JOIN  geoloc_pays    AS gp  ON (adr.country = gp.a2)
-    LEFT JOIN  geoloc_region  AS gr  ON (adr.country = gr.a2 AND adr.region = gr.region)
-    LEFT JOIN  emails         AS em  ON (em.uid = u.user_id AND em.flags = \'active\')';
+    LEFT JOIN  applis_ins              AS ai0 ON (u.user_id = ai0.uid AND ai0.ordre = 0)
+    LEFT JOIN  applis_def              AS ad0 ON (ad0.id = ai0.aid)
+    LEFT JOIN  applis_ins              AS ai1 ON (u.user_id = ai1.uid AND ai1.ordre = 1)
+    LEFT JOIN  applis_def              AS ad1 ON (ad1.id = ai1.aid)
+    LEFT JOIN  entreprises             AS e   ON (e.entrid = 0 AND e.uid = u.user_id)
+    LEFT JOIN  emploi_secteur          AS es  ON (e.secteur = es.id)
+    LEFT JOIN  fonctions_def           AS ef  ON (e.fonction = ef.id)
+    LEFT JOIN  geoloc_pays             AS n   ON (u.nationalite = n.a2)
+    LEFT JOIN  adresses                AS adr ON (u.user_id = adr.uid AND FIND_IN_SET(\'active\',adr.statut))
+    LEFT JOIN  geoloc_pays             AS gp  ON (adr.country = gp.a2)
+    LEFT JOIN  geoloc_region           AS gr  ON (adr.country = gr.a2 AND adr.region = gr.region)
+    LEFT JOIN  emails                  AS em  ON (em.uid = u.user_id AND em.flags = \'active\')
+    LEFT JOIN  profile_networking      AS nw  ON (nw.uid = u.user_id)
+    LEFT JOIN  profile_networking_enum AS nwe ON (nwe.network_type = nw.network_type)';
 
 // }}}
 // {{{ class ThrowError
@@ -209,6 +211,8 @@ class QuickSearch extends SField
     /** stores admin searches */
     var $email;
     var $ip;
+    /** stores phone number */
+    var $phone;
 
     // }}}
     // {{{ constructor
@@ -227,7 +231,7 @@ class QuickSearch extends SField
 
     function isempty()
     {
-        return empty($this->strings) && empty($this->ranges) && empty($this->email) && empty($this->ip);
+        return empty($this->strings) && empty($this->ranges) && empty($this->email) && empty($this->ip) && empty($this->phone);
     }
 
     // }}}
@@ -265,6 +269,12 @@ class QuickSearch extends SField
         foreach ($ranges as $r) {
             if (preg_match('!^([<>]\d{4}|\d{4}(-\d{4})?)$!', $r)) $this->ranges[] = $r;
         }
+
+        $t = preg_replace('!(\d{4}-\d{4}|>\d{4}|<\d{4})!', '', $s);
+        $t = preg_replace('![<>\- ]!', '', $t);
+        if (strlen($t) > 4) {
+            $this->phone = $t;
+        }
     }
 
     // }}}
@@ -308,6 +318,11 @@ class QuickSearch extends SField
             $ip = ip_to_uint($this->ip);
             $where[] = "( ls.ip = $ip OR ls.forward_ip = $ip ) AND ls.suid = 0";
         }
+        if (!empty($this->phone)){
+            require_once("profil.func.inc.php");
+            $phone = format_phone_number($this->phone) . "%";
+            $where[] = 't.search_tel LIKE ' . XDB::escape($phone);
+        }
 
         return join(" AND ", $where);
     }
@@ -333,6 +348,13 @@ class QuickSearch extends SField
         if (!empty($this->ip)) {
             $join .= "INNER JOIN logger.sessions AS ls ON (ls.uid = u.user_id)\n";
         }
+        if (!empty($this->phone)) {
+            if (!S::logged()) {
+                $join .= "INNER JOIN profile_phones AS t ON (t.uid = u.user_id AND t.pub = 'public')";
+            } else {
+                $join .= "INNER JOIN profile_phones AS t ON (t.uid = u.user_id)";
+            }
+        }
         return $join;
     }
     // }}}
@@ -489,6 +511,39 @@ class RefSField extends SField
 // }}}
 
 // {{{ class RefSFieldMultipleTable
+class PhoneSField extends RefSField
+{
+    function PhoneSField($_fieldFormName, $_fieldDbName='', $_refTable, $_refAlias, $_refCondition)
+    {
+        $this->RefSField($_fieldFormName, $_fieldDbName, $_refTable, $_refAlias, $_refCondition, true);
+    }
+
+    function get_request()
+    {
+        require_once("profil.func.inc.php");
+        $this->value = trim(Env::v($this->fieldFormName));
+        $this->value = format_phone_number($this->value);
+    }
+
+    function compare()
+    {
+        return " LIKE '" . addslashes($this->value) . "%'";
+    }
+}
+
+class IndexSField extends RefSField
+{
+    function IndexSField($_fieldFormName, $_fieldDbName='', $_refTable, $_refAlias, $_refCondition)
+    {
+        $this->RefSField($_fieldFormName, $_fieldDbName, $_refTable, $_refAlias, $_refCondition, true);
+    }
+
+    function get_request()
+    {
+        $this->value = trim(Env::v($this->fieldFormName));
+    }
+}
+
 class MapSField extends RefSField
 {
     var $mapId;
index 0d23a78..c8e62fe 100644 (file)
@@ -73,13 +73,21 @@ function advancedSearchFromInput()
 
     $freeField       = new RefSField('free',array('q.profile_freetext'),'','','',false);
 
+    $nwAddressField  = new RefSField('networking_address', array('nw.address'), 'profile_networking', 'nw', 'nw.uid=u.user_id', false);
+    if (Env::v('networking_address') == '') {
+        $nwTypeField     = new IndexSField('networking_type', array('nwe.network_type'), array('profile_networking', 'profile_networking_enum'), array('nw', 'nwe'), array('nw.uid = u.user_id', 'nwe.network_type = nw.network_type'));
+    } else {
+        $nwTypeField     = new IndexSField('networking_type', array('nwe.network_type'), 'profile_networking_enum', 'nwe', 'nwe.network_type = nw.network_type');
+    }
+    $nwPhoneField  = new PhoneSField('phone_number', array('t.search_tel'), 'profile_phones', 't', 't.uid=u.user_id');
     return array(
                 $nameField, $firstnameField, $nicknameField, $promo1Field,
-                $promo2Field, $womanField, $subscriberField, $aliveField, $referentField,
+                $promo2Field, $womanField, $subscriberField, $aliveField,
                 $townField, $countryField, $regionField, $mapField, $entrepriseField,
                 $posteField, $secteurField, $cvField, $natField, $binetField,
                 $groupexField, $sectionField, $schoolField, $diplomaField,
-                $freeField, $fonctionField);
+                $freeField, $fonctionField, $nwAddressField, $nwTypeField,
+                $nwPhoneField, $referentField);
 }
 
 // }}}
index 07ce7c3..c699589 100644 (file)
@@ -40,12 +40,9 @@ function smarty_function_display_address($param, &$smarty)
 {
     require_once('geoloc.inc.php');
     $txtad = get_address_text($param['adr']);
-    if (!$txtad &&
-        !$param['adr']['tels'] && !count($param['adr']['tels']) &&
-        !$param['adr']['tel'] &&
-        !$param['adr']['fax'] &&
-        !$param['adr']['mobile']) return "";
-
+    if (!$txtad && !$param['adr']['tels'] && !count($param['adr']['tels'])) {
+        return "";
+    }
 
     $lines = explode("\n", $txtad);
     $idt   = array_shift($lines);
@@ -61,29 +58,37 @@ function smarty_function_display_address($param, &$smarty)
     $map = "<a href=\"http://maps.google.fr/?q="
         .   urlencode(implode(", ", $lines) . " ($idt)")
         . "\"><img src=\"images/icons/map.gif\" alt=\"Google Maps\" title=\"Carte\"/></a>";
+    $comment = "";
+    if ($param['adr']['comment'] != "")
+    {
+        $commentHtml = str_replace(array('&', '"'), array('&amp;', '&quot;'), $param['adr']['comment']);
+        $commentJs = str_replace(array('\\', '\''), array('\\\\', '\\\''), $commentHtml);
+        $comment = "<img style=\"margin-left: 5px;\" src=\"images/icons/comments.gif\""
+            . " onmouseover=\"return overlib('"
+            . $commentJs
+            . "',WIDTH,250);\""
+            . " onmouseout=\"nd();\""
+            . " alt=\"Commentaire\" title=\""
+            . $commentHtml
+            . "\"/>";
+    }
     if ($restore) {
         array_unshift($lines, $idt);
     }
     if ($param['titre'])
     {
         if ($param['titre_div'])
-            $txthtml .= "<div class='titre'>".pl_entity_decode($param['titre'])."&nbsp;".$map."</div>\n";
+            $txthtml .= "<div class='titre'>".pl_entity_decode($param['titre'])."&nbsp;".$map.$comment."</div>\n";
         else
-            $txthtml .= "<em>".pl_entity_decode($param['titre'])."&nbsp;</em>".$map."<br />\n";
+            $txthtml .= "<em>".pl_entity_decode($param['titre'])."&nbsp;</em>".$map.$comment."<br />\n";
     }
     foreach ($lines as $line)
     {
         $txthtml .= "<strong>".$line."</strong><br/>\n";
     }
-    if ($param['adr']['tel'])
-        $txthtml .= "<div>\n<em>Tél : </em>\n<strong>".$param['adr']['tel']."</strong>\n</div>\n";
-    if ($param['adr']['fax'])
-        $txthtml .= "<div>\n<em>Fax : </em>\n<strong>".$param['adr']['fax']."</strong>\n</div>\n";
-    if ($param['adr']['mobile'])
-        $txthtml .= "<div>\n<em>Tél : </em>\n<strong>".$param['adr']['mobile']."</strong>\n</div>\n";
-    if ($param['adr']['tels'] && count($param['adr']['tels'])) {
-        foreach ($param['adr']['tels'] as $tel)
-            $txthtml .= "<div>\n<em>".$tel['tel_type']."&nbsp;: </em>\n<strong>".$tel['tel']."</strong>\n</div>\n";
+    if(isset($param['adr']['tels'])) {
+        require_once('function.display_phones.php');
+        $txthtml .= smarty_function_display_phones($param['adr'],$smarty);
     }
     if (!$param['nodiv']) {
         $pos = $param['pos'] ? " style='float: " . $param['pos'] . "'" : '';
diff --git a/plugins/function.display_phones.php b/plugins/function.display_phones.php
new file mode 100644 (file)
index 0000000..db21384
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2008 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************/
+
+function smarty_function_display_phones($param, &$smarty)
+{
+    $txthtml = "";
+    if (count($param['tels'])) {
+        foreach ($param['tels'] as $tel) {
+            switch ($tel['tel_type']) {
+            case 'fixed':
+                $tel_type = 'Tél';
+                break;
+            case 'fax':
+                $tel_type = 'Fax';
+                break;
+            case 'mobile':
+                $tel_type = 'Mob';
+                break;
+            default:
+                $tel_type = $tel['tel_type'];
+            }
+            $txthtml .= "<div>\n<em>" . $tel_type . "&nbsp;: </em>\n<strong>" . $tel['tel'] . "</strong>\n";
+            $comment = "";
+            if ($tel['comment'] != "") {
+                $commentHtml = str_replace(array('&', '"'), array('&amp;', '&quot;'), $tel['comment']);
+                $commentJs = str_replace(array('\\', '\''), array('\\\\', '\\\''), $commentHtml);
+                $txthtml .= "<img style=\"margin-left: 5px;\" src=\"images/icons/comments.gif\""
+                            . " onmouseover=\"return overlib('"
+                            . $commentJs
+                            . "',WIDTH,250);\""
+                            . " onmouseout=\"nd();\""
+                            . " alt=\"Commentaire\" title=\""
+                            . $commentHtml
+                            . "\"/>\n";
+            }
+            $txthtml .= "</div>\n";
+        }
+    }
+    return $txthtml;
+}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
index f6b59cc..7ce8ca8 100644 (file)
       <a href="admin/ss_secteurs">Sous-secteurs</a>
       &nbsp;&nbsp;|&nbsp;&nbsp;
       <a href="admin/fonctions">Fonctions</a>
+      &nbsp;&nbsp;|&nbsp;&nbsp;
+      <a href="admin/networking">Networking</a>
     </td>
   </tr>
   <tr class="pair">
       <a href="admin/geoloc">Synchro</a>
       &nbsp;&nbsp;|&nbsp;&nbsp;
       <a href="admin/geoloc/dynamap">Dynamap</a>
+      &nbsp;&nbsp;|&nbsp;&nbsp;
+      <a href="admin/geoloc/country">Pays</a>
     </td>
   </tr>
   <tr class="impair">
index d0524a1..0d9cab5 100644 (file)
@@ -40,8 +40,10 @@ EMAIL;TYPE=internet:{$vcard.forlife}@{#globals.mail.domain2#}
 {if $vcard.virtualalias}
 EMAIL;TYPE=internet:{$vcard.virtualalias}
 {/if}
-{if $vcard.mobile}
-TEL;TYPE=cell:{$vcard.mobile|vcard_enc}
+{if $vcard.tels}
+{foreach item=tel from=$vcard.tels}
+{if $tel.tel_type eq 'mobile'}TEL;TYPE=cell{else}{if $tel.tel_type eq 'fax'}FAX{else}TEL{/if};TYPE=home{/if}:{$tel.tel|vcard_enc}
+{/foreach}
 {/if}
 {if $vcard.adr_pro}
 {if $vcard.adr_pro[0].entreprise}
@@ -53,25 +55,26 @@ TITLE:{$vcard.adr_pro[0].poste|vcard_enc}
 {if $vcard.adr_pro[0].fonction}
 ROLE:{$vcard.adr_pro[0].fonction|vcard_enc}
 {/if}
-{if $vcard.adr_pro[0].tel}
-TEL;TYPE=work:{$vcard.adr_pro[0].tel|vcard_enc}
-{/if}
-{if $vcard.adr_pro[0].fax}
-FAX;TYPE=work:{$vcard.adr_pro[0].fax|vcard_enc}
+{if $vcard.adr_pro[0].tels}
+{foreach item=tel from=$vcard.adr_pro[0].tels}
+{if $tel.tel_type eq 'mobile'}TEL;TYPE=cell,work{else}{if $tel.tel_type eq 'fax'}FAX{else}TEL{/if};TYPE=work{/if}:{$tel.tel|vcard_enc}
+{/foreach}
 {/if}
 ADR;TYPE=work:{format_adr adr=$vcard.adr_pro[0]}
 {/if}
 {foreach item=adr from=$vcard.adr}
 ADR;TYPE=home{if $adr.courier},postal{/if}:{format_adr adr=$adr}
+{if $adr.tels}
 {foreach item=tel from=$adr.tels}
-{if $tel.tel}
-{if $tel.tel_type neq 'Fax'}TEL{else}FAX{/if};TYPE=home:{$tel.tel}
-{/if}
+{if $tel.tel_type eq 'mobile'}TEL;TYPE=cell,home{else}{if $tel.tel_type eq 'fax'}FAX{else}TEL{/if};TYPE=home{/if}:{$tel.tel|vcard_enc}
 {/foreach}
+{/if}
 {/foreach}
-{if $vcard.web}
-URL:{$vcard.web}
+{foreach from=$vcard.networking item=nw}
+{if $nw.filter eq 'web'}
+URL:{$nw.address}
 {/if}
+{/foreach}
 {if strlen(trim($vcard.freetext)) == 0}
 NOTE:(X{$vcard.promo})
 {else}
index 41b5cf0..35b32d2 100644 (file)
@@ -27,6 +27,7 @@
   </p>
 {/if}
 {if $retour == $smarty.const.ERROR_INVALID_EMAIL}
+  {assign var='error_email' value='1'}
   <p class="erreur">
   Erreur: l'email n'est pas valide.
   </p>
         </td>
       </tr>
       {/foreach}
-      <tr class="{cycle values="pair,impair"}"><td colspan="4">
-        <form action="emails/redirect" method="post">
-        <div>
-          &nbsp;<br />
-          Ajouter une adresse email&nbsp;:
-          <input type="text" size="35" maxlength="60" name="email" value="" />
-          &nbsp;&nbsp;<input type="submit" value="ajouter" name="emailop" />
+      <form action="emails/redirect" method="post">
+        {cycle values="pair,impair" assign=class_combobox}
+        {include file="include/emails.combobox.tpl" name="email" val=$email class=$class_combobox error=$error_email}
+        <tr class=$class_combobox><td colspan="4"><div>
+          <input type="submit" value="ajouter" name="emailop" />
           {xsrf_token_field}
-        </div>
-        </form>
-      </td></tr>
+        </div></td></tr>
+      </form>
     </table>
     <script type="text/javascript">showRemove(); activeEnable();</script>
   </div>
index 9ecbe18..3f63968 100644 (file)
@@ -27,7 +27,7 @@
 {else}
 
 <h1 id='pagetop'>
-Bienvenue {$smarty.session.prenom}{if $birthday}
+Bienvenue {$smarty.session.yourself_name}{if $birthday}
   &nbsp;et joyeux anniversaire de la part de toute l'équipe !
 {else},
 {/if}
diff --git a/templates/fusionax/ids.tpl b/templates/fusionax/ids.tpl
new file mode 100644 (file)
index 0000000..fb6df30
--- /dev/null
@@ -0,0 +1,77 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2007 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               *}
+{*                                                                        *}
+{**************************************************************************}
+
+<h2><a href="fusionax">Fusion des annuaires X.org - AX<a> / Identifiants</h2>
+
+<p>Le préalable à toute fusion de renseignements pour une personne entre ce
+que contient la base AX et ce que contient ce site est bien évidemment de
+trouver une correspondance entre les personnes renseignés dans ces annuaires.</p>
+
+{if $nbMissingInAX}
+<h3>Anciens manquants à l'AX</h3>
+
+<p><a href="fusionax/ids/missingInAX">{$nbMissingInAX} ancien{if $nbMissingInAX > 1}s{/if}</a>.</p>
+{/if}
+
+{if $nbMissingInXorg > 0}
+<h3>Anciens manquants à x.org</h3>
+
+<p><a href="fusionax/ids/missingInXorg">{$nbMissingInXorg} ancien{if $nbMissingInXorg > 1}s{/if}</a>.</p>
+{/if}
+
+<h3>Mettre en correspondance</h3>
+<form action="fusionax/ids/lier" method="get">
+       Matricule AX : <input name="matricule_ax" value""/><br/>
+       User ID X.org : <input name="user_id" value=""/><br/>
+       <input type="submit" value="Lier"/>
+</form>
+
+<p></p>
+<div id="autolink" name="autolink">
+<h3>Mise en correspondance automatique</h3>
+{if $easyToLink}
+<p>Ces anciens sont probablement les mêmes (à peu près mêmes nom, prénom, promo)</p>
+{include file="fusionax/listFusion.tpl" fusionList=$easyToLink fusionAction="fusionax/ids/link" name="lier" field1="display_name_ax" namefield1="Ancien AX"}
+<p><a href="fusionax/ids/linknext">Lier toutes les fiches affichées</a> <span id="fusion-reload" style="display:none"> - <a href="fusionax/ids#autolink">Trouver d'autres correspondances</a></span></p>
+<script type="text/javascript">
+{literal}
+//<!--
+$(document).ready(function() {
+    $('#autolink a.fusion-action').click(function(a){
+        $.get(a.currentTarget.href,{},function(){
+            $(a.currentTarget).hide();
+            $('#fusion-reload').show();
+            $('#fusion-reload a').click(function(a) {
+                document.location = a.currentTarget.href;
+                document.location.reload();
+            }); 
+        });
+        return false;
+    });
+});
+//-->
+{/literal}
+</script>
+{else}
+<p>Aucune correspondance automatique n'a été trouvée (mêmes nom, prénom, promo d'étude).</p>
+{/if}
+</div>
diff --git a/templates/fusionax/idsMissingInAx.tpl b/templates/fusionax/idsMissingInAx.tpl
new file mode 100644 (file)
index 0000000..8d5ba8c
--- /dev/null
@@ -0,0 +1,29 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2007 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               *}
+{*                                                                        *}
+{**************************************************************************}
+
+<h2><a href="fusionax">Fusion des annuaires X.org - AX<a> / <a href="fusionax/ids">Identifiants<a> /  Manquants dans l'annuaire de l'AX</h2>
+
+<p></p>
+
+{if $missingInAX}
+{include file='fusionax/listFusion.tpl' fusionList=$missingInAX field1='user_id' namefield1='ID X.org'}
+{/if}
diff --git a/templates/fusionax/idsMissingInXorg.tpl b/templates/fusionax/idsMissingInXorg.tpl
new file mode 100644 (file)
index 0000000..036d6d4
--- /dev/null
@@ -0,0 +1,29 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2007 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               *}
+{*                                                                        *}
+{**************************************************************************}
+
+<h2><a href="fusionax">Fusion des annuaires X.org - AX<a> / <a href="fusionax/ids">Identifiants<a> /  Manquants dans l'annuaire d'X.org</h2>
+
+<p></p>
+
+{if $missingInXorg}
+{include file='fusionax/listFusion.tpl' fusionList=$missingInXorg field1='id_ancien' namefield1='matricule AX'}
+{/if}
diff --git a/templates/fusionax/import.tpl b/templates/fusionax/import.tpl
new file mode 100644 (file)
index 0000000..7982e3d
--- /dev/null
@@ -0,0 +1,50 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2007 Polytechnique.org                             *}
+{*  http://opensource.polytechnique.org/                                  *}
+{*                                                                        *}
+{*  This program is free software; you can redistribute it and/or modify  *}
+{*  it under the terms of the GNU General Public License as published by  *}
+{*  the Free Software Foundation; either version 2 of the License, or     *}
+{*  (at your option) any later version.                                   *}
+{*                                                                        *}
+{*  This program is distributed in the hope that it will be useful,       *}
+{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}
+{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}
+{*  GNU General Public License for more details.                          *}
+{*                                                                        *}
+{*  You should have received a copy of the GNU General Public License     *}
+{*  along with this program; if not, write to the Free Software           *}
+{*  Foundation, Inc.,                                                     *}
+{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
+{*                                                                        *}
+{**************************************************************************}
+
+<script type="text/javascript">
+{literal}
+//<!--
+    $(document).ready(function() {
+        $('#fusionax_import input').click(function() {
+            $('#fusionax_import input').hide();
+            $('#fusionax_import').append('Import en cours : récupération du fichier depuis le serveur de l\'AX...<br/>');
+            $.getScript('fusionax/import/launch');
+        });
+    });
+//-->
+{/literal}
+</script> 
+<h2><a href="fusionax">Fusion des annuaires X.org - AX</a></h2>
+
+<h2>Import de l'annuaire AX</h2>
+{if $lastimport}
+<p>Dernier import {$lastimport}</p>
+{/if}
+
+{if $keymissing}
+<p>Impossible de faire l'import, il manque la clef d'authentification :</p>
+<pre>{$keymissing}</pre>
+{else}
+<div id="fusionax_import">
+<input type="button" value="Lancer l'import"/>
+</div>
+{/if}
similarity index 68%
rename from templates/profile/adresses.tel.tpl
rename to templates/fusionax/index.tpl
index 60c0391..ec652b4 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2008 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2007 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
 {*                                                                        *}
 {**************************************************************************}
 
-{assign var=telpref value="`$adpref`[tel][`$t`]"}
-{assign var=telid value="`$adid`_tel_`$t`"}
-<div style="float: right" class="flags">
-  {include file="include/flags.radio.tpl" name="`$telpref`[pub]" val=$tel.pub}
-</div>
-<span class="titre">N°{$t+1}</span>
-<input type="hidden" name="{$telpref}[removed]" value="0" />
-<input type="text" size="10" maxlength="30" name="{$telpref}[type]" value="{$tel.type|default:"Tél."}" />
-<input type="text" size="19" maxlength="28" name="{$telpref}[tel]" {if $tel.error}class="error"{/if} value="{$tel.tel}" />
-<a href="javascript:removeObject('{$telid}', '{$telpref}')">
-  {icon name=cross title="Supprimer ce numéro de téléphone"}
-</a>
+<h2>Fusion des annuaires X.org - AX</h2>
+<ul>
+<li>Voir la <a href="Fusion">documentation</a></li>
+<li><a href="fusionax/import">Import de la base AX</a> {if $lastimport} - (dernier import le {$lastimport}){/if}</li> 
+<li>Mise en <a href="fusionax/ids">correspondance simple</a></li>
+<li>Corrélation des <a href="fusionax/names">données d'identification</a></li>
+<li>Corrélation des <a href="fusionax/coords">coordonnées</a></li>
+<li>Corrélation des <a href="fusionax/pros">informations professionnelles</a></li>
+<li>Corrélation des <a href="fusionax/studies">informations de formations</a></li>
+<li><a href="fusionax/misc">Divers</a></li>
+</ul>
 
 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
diff --git a/templates/fusionax/listFusion.tpl b/templates/fusionax/listFusion.tpl
new file mode 100644 (file)
index 0000000..cd362f6
--- /dev/null
@@ -0,0 +1,57 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2007 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>
+        <th>Ancien</th>
+        <th>Fiches</th>
+        {if $field1}
+        <th>{$namefield1}</th>
+        {/if}
+        {if $field2}
+        <th>{$namefield2}</th>
+        {/if}
+        {if $fusionAction}
+        <th>Action</th>
+        {/if}
+    </tr>
+{if $fusionList}
+{iterate from=$fusionList item=c}
+    <tr class="{cycle values="pair,impair"}">
+        <td>{$c.display_name} (X {$c.promo})</td>
+        <td style="text-align:center">
+            {if $c.user_id}<a href="admin/user/{$c.user_id}" class="popup2">{icon name="user_suit" title="Administrer utilisateur"}</a>{/if}
+            {if $c.id_ancien}<a href="http://www.polytechniciens.com/?page=AX_FICHE_ANCIEN&amp;anc_id={$c.id_ancien}" class="popup2">{icon name="user_gray" title="fiche AX"}</a>{/if}
+        </td>
+        {if $field1}
+        <td>{$c.$field1}</td>
+        {/if}
+        {if $field2}
+        <td>{$c.$field2}</td>
+        {/if}
+        {if $fusionAction}
+        <td><a class="fusion-action" href="{$fusionAction}/{$c.user_id}/{$c.id_ancien}">{$name}</a></td>
+        {/if}
+    </tr>
+{/iterate}
+{/if}
+</table>
diff --git a/templates/fusionax/misc.tpl b/templates/fusionax/misc.tpl
new file mode 100644 (file)
index 0000000..de6b539
--- /dev/null
@@ -0,0 +1,48 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2007 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               *}
+{*                                                                        *}
+{**************************************************************************}
+
+<h2><a href="fusionax">Fusion des annuaires X.org - AX<a> / Divers</h2>
+
+<h3>Décès</h3>
+
+{if $deceasedErrors}
+
+<p>Voici les {$deceasedErrors} différences entre les deux annuaires pour les renseignements de
+décès.</p>
+
+<p>Anciens déclarés décédés dans l'annuaire AX mais pas sur Xorg</p>
+
+{include file='fusionax/listFusion.tpl' fusionList=$deceasedMissingInXorg field1='deces_ax' namefield1='Décès AX'}
+
+<p>Anciens déclarés décédés dans l'annuaire Xorg mais pas chez l'AX</p>
+
+{include file='fusionax/listFusion.tpl' fusionList=$deceasedMissingInAX field1='deces_xorg' namefield1='Décès X.org'}
+
+<p>Anciens déclarés décédés dans les deux annuaires mais pas avec la même date</p>
+
+{include file='fusionax/listFusion.tpl' fusionList=$deceasedDifferent field1='deces_xorg' field2='deces_ax' namefield1='Décès X.org' namefield2='Décès AX'}
+
+{else}
+
+<p>Aucune différence pour les renseignements de décès entre les deux annuaires.</p>
+
+{/if}
diff --git a/templates/include/emails.combobox.tpl b/templates/include/emails.combobox.tpl
new file mode 100644 (file)
index 0000000..b53b494
--- /dev/null
@@ -0,0 +1,119 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2008 Polytechnique.org                             *}
+{*  http://opensource.polytechnique.org/                                  *}
+{*                                                                        *}
+{*  This program is free software; you can redistribute it and/or modify  *}
+{*  it under the terms of the GNU General Public License as published by  *}
+{*  the Free Software Foundation; either version 2 of the License, or     *}
+{*  (at your option) any later version.                                   *}
+{*                                                                        *}
+{*  This program is distributed in the hope that it will be useful,       *}
+{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}
+{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}
+{*  GNU General Public License for more details.                          *}
+{*                                                                        *}
+{*  You should have received a copy of the GNU General Public License     *}
+{*  along with this program; if not, write to the Free Software           *}
+{*  Foundation, Inc.,                                                     *}
+{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
+{*                                                                        *}
+{**************************************************************************}
+
+<tr {if $class}class="{$class}"{/if}>
+  <td>
+    <span class="titre">{if $name eq "email_directory"}Email annuaire AX
+    {elseif $name eq "email"}Ajouter une adresse email{else}
+    Email professionnel{/if}</span>
+  </td>
+  {if $name eq "email"}<td></td>{/if}
+  <td>
+    <select name="{$name}" id="combobox">
+      {if $email_type eq "directory"}
+        <optgroup label="Email annuaire AX">
+          <option value="{$email_directory}" {if
+          $val eq $email_directory}selected="selected"{/if}>{$email_directory}</option>
+        </optgroup>
+      {/if}
+      {if $name eq "email_directory"}
+        <optgroup label="Emails polytechniciens">
+          {if $melix}
+            <option value="{$melix}@{#globals.mail.alias_dom#}" {if
+            $val eq $melix|cat:'@'|cat:#globals.mail.alias_dom#}selected="selected"{/if}>
+            {$melix}@{#globals.mail.alias_dom#}</option>
+            <option value="{$melix}@{#globals.mail.alias_dom2#}" {if
+            $val eq $melix|cat:'@'|cat:#globals.mail.alias_dom2#}selected="selected"{/if}>
+            {$melix}@{#globals.mail.alias_dom2#}</option>
+          {/if}
+          {foreach from=$list_email_X item=email}
+            <option value="{$email.alias}@{#globals.mail.domain#}" {if
+            $val eq $email.alias|cat:'@'|cat:#globals.mail.domain#}selected="selected"{/if}>
+            {$email.alias}@{#globals.mail.domain#}</option>
+            <option value="{$email.alias}@{#globals.mail.domain2#}" {if
+            $val eq $email.alias|cat:'@'|cat:#globals.mail.domain2#}selected="selected"{/if}>
+            {$email.alias}@{#globals.mail.domain2#}</option>
+          {/foreach}
+        </optgroup>
+      {/if}
+      {if (($name neq "email") && ($list_email_redir|@count neq 0))}
+        <optgroup label="Redirections">
+          {foreach from=$list_email_redir item=email}
+            <option value="{$email}" {if $val eq $email}selected="selected"{/if}>{$email}</option>
+          {/foreach}
+        </optgroup>
+      {/if}
+      {if $list_email_pro|@count neq 0}
+        <optgroup label="Emails professionels">
+          {foreach from=$list_email_pro item=email}
+            <option value="{$email}" {if
+            $val eq $email}selected="selected"{/if}>{$email}</option>
+          {/foreach}
+        </optgroup>
+      {/if}
+      <optgroup label="Autres choix">
+        <option value="new@new.new" {if $error}selected="selected"{/if}>Utiliser une autre adresse email</option>
+        <option value="" {if (($val eq '') && (!$error))}selected="selected"{/if}>{if
+        $name neq "email"}Ne pas mettre d'adresse email{else}&nbsp;{/if}</option>
+      </optgroup>
+    </select>
+    {if $name eq "email_directory"}
+      <input type="checkbox" disabled="disabled" checked="checked"/>
+      {icon name="flag_orange" title="Visible sur l'annuaire"}
+    {elseif $name neq "email"}
+      <span class="flags">
+        {include file="include/flags.radio.tpl" name="`$jobpref`[email_pub]" val=$job.mail_pub}
+      </span>
+    {/if}
+    <br />
+    <span class="new" style="display: none">
+      <input type="text" maxlength="60" {if $error}class="error" value="{$val}"{/if} name="{if (($name neq "email_directory")
+      && ($name neq "email"))}jobs[{$i}][email_new]{else}{$name}_new{/if}"/>
+    </span>
+    <script type="text/javascript">//<![CDATA[
+      {literal}
+      $(function() {
+        $("select#combobox").change(function() {
+          $(".new").hide();
+          if ($("select#combobox").val() == "new@new.new") {
+            $(".new").show();
+          }
+        }).change();
+      });
+      {/literal}
+    // ]]></script>
+  </td>
+  {if $name eq "email"}<td></td>{/if}
+</tr>
+{if $name neq "email"}
+  <tr {if $class}class="{$class}"{/if} class="new" style="display: none">
+    <td colspan="2">
+      <p><small><strong><em>Attention :</em></strong> cette adresse email figurera dans
+      {if $name eq "email_directory"}l'annuaire papier{else}tes informations professionnelles
+      {/if} mais n'est pas ajoutée à la liste de tes redirections. Nous te conseillons fortement de
+      <strong><a href="emails/redirect">l'ajouter là</a></strong>, surtout
+      si tu n'en as plus de valide.</small></p>
+    </td>
+  </tr>
+{/if}
+
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index 862b22b..0b60e96 100644 (file)
     {if $smarty.session.auth ge AUTH_COOKIE}
     <div class="photo">
       <img src="photo/{if $c.inscrit}{$c.forlife}{else}{make_forlife nom=$c.nom prenom=$c.prenom promo=$c.promo}{/if}"
-           alt="{$c.prenom} {$c.nom}" />
+           alt="{$c.name_display}" />
     </div>
     {/if}
 
     <div class="nom">
       {if $c.sexe}&bull;{/if}
       {if !$c.dcd && ($c.inscrit || $smarty.session.auth eq AUTH_PUBLIC)}<a href="profile/{if $c.inscrit}{$c.forlife}{else}{make_forlife nom=$c.nom prenom=$c.prenom promo=$c.promo}{/if}" class="popup2">{/if}
-      {if $c.nom_usage}{$c.nom_usage} {$c.prenom}<br />({$c.nom}){else}{$c.nom} {$c.prenom}{/if}
+      <span {if $c.name_tooltip}class="hinted" title="{$c.name_tooltip}"{/if}>{$c.name_display}</span>
       {if !$c.dcd && ($c.inscrit || $smarty.session.auth eq AUTH_PUBLIC)}</a>{/if}
     </div>
 
index 76dce26..871afaf 100644 (file)
@@ -24,7 +24,7 @@
 {foreach from=$set item=p} 
   <div class="contact"> 
     <div class="nom"> 
-      {$p.nom} {$p.prenom} 
+      <span {if $p.name_tooltip}class="hinted" title="{$p.name_tooltip}"{/if}>{$p.name_display}</span>
     </div> 
     <div class="appli"> 
       X{$p.promo} 
index d0db912..b5b301f 100644 (file)
   <tr>
     <td class="center" style="vertical-align: bottom; padding-bottom: 15px">
       <a href="{$mainsiteurl}profile/{$set[trombi.index_prev].forlife}" class="popup2">
-        {$set[trombi.index_prev].prenom} {$set[trombi.index_prev].nom}{if $trombi_with_promo} ({$set[trombi.index_prev].promo}){/if}
+        <span {if $set[trombi.index_prev].name_tooltip}class="hinted" title="{$set[trombi.index_prev].name_tooltip}"{/if}>{$set[trombi.index_prev].name_display}</span>{if $trombi_with_promo} ({$set[trombi.index_prev].promo}){/if}
       </a>
     </td>
     <td class="center" style="vertical-align: bottom; padding-bottom: 15px">
       <a href="{$mainsiteurl}profile/{$set[trombi].forlife}" class="popup2">
-        {$set[trombi].prenom} {$set[trombi].nom}{if $trombi_with_promo} ({$set[trombi].promo}){/if}
+        <span {if $set[trombi].name_tooltip}class="hinted" title="{$set[trombi].name_tooltip}"{/if}>{$set[trombi].name_display}</span>{if $trombi_with_promo} ({$set[trombi].promo}){/if}
       </a>
     </td>
     <td class="center" style="vertical-align: bottom; padding-bottom: 15px">
     {if $set[trombi.index_next]}
       <a href="{$mainsiteurl}profile/{$set[trombi.index_next].forlife}" class="popup2">
-        {$set[trombi.index_next].prenom} {$set[trombi.index_next].nom}{if $trombi_with_promo} ({$set[trombi.index_next].promo}){/if}
+        <span {if $set[trombi.index_next].name_tooltip}class="hinted" title="{$set[trombi.index_next].name_tooltip}"{/if}>{$set[trombi.index_next].name_display}</span>{if $trombi_with_promo} ({$set[trombi.index_next].promo}){/if}
       </a>
     {/if}
     </td>
@@ -90,7 +90,7 @@
   <tr style="margin-top: 0; padding-top: 0">
     <td class="center" style="vertical-align: bottom">
       <a href="{$mainsiteurl}profile/{$set[trombi].forlife}" class="popup2">
-        {$set[trombi].prenom} {$set[trombi].nom}{if $trombi_with_promo} ({$set[trombi].promo}){/if}
+        <span {if $set[trombi].name_tooltip}class="hinted" title="{$set[trombi].name_tooltip}"{/if}>{$set[trombi].name_display}</span>{if $trombi_with_promo} ({$set[trombi].promo}){/if}
       </a>
     </td>
     <td></td><td></td>
index e49bf6f..88a8c83 100644 (file)
@@ -37,7 +37,7 @@
       {/if}
       <br />
       <a href="{if $urlmainsite}{$urlmainsite}{/if}profile/{$p.forlife}" class="popup2">
-        {$p.prenom} {$p.nom}{if $trombi_show_promo} ({$p.promo}){/if}
+        <span {if $p.name_tooltip}class="hinted" title="{$p.name_tooltip}"{/if}>{$p.name_display}</span>{if $trombi_show_promo} ({$p.promo}){/if}
       </a>
     </td>
   {if $loop eq "3"}
index d15d4a6..2caefb7 100644 (file)
@@ -64,7 +64,10 @@ sa dernière relance date du {$relance|date_format}
     {iterate from=$addr item=a}
     <tr class="{cycle values='impair,pair'}">
       <td>{$a.email}</td>
-      <td><a href="profile/{$a.alias}" class="popup2">{$a.alias}</a> {if $a.type eq user}(*){/if}</td>
+      <td>
+        {if $a.alias neq ''}<a href="profile/{$a.alias}" class="popup2">{$a.alias}</a>
+        {if $a.type eq user}(*){/if}{else}Email connu de l'AX{/if}
+      </td>
       <td>{$a.date|date_format|default:'-'}</td>
       <td>{$a.last|date_format|default:'-'}</td>
       <td class='center'>{$a.nb|default:"-"}</td>
index c0b7287..a778d8d 100644 (file)
                  {if $adr.mail}checked="checked"{/if} />
           <label for="{$adid}_mail">on peut m'y envoyer du courrier par la poste</label>
         </div>
+        <div>
+          <label for="{$adpref}[comment]">Commentaire : </label>
+          <input type="text" size="35" maxlength="100" name="{$adpref}[comment]" id="{$adpref}_comment" value="{$adr.comment}" />
+        </div>
       </div>
     </td>
   </tr>
   <tr class="pair">
     <td>
       {foreach from=$adr.tel key=t item=tel}
-      <div id="{"`$adid`_tel_`$t`"}" style="clear: both">
-      {include file="profile/adresses.tel.tpl" t=$t tel=$tel}
-      </div>
+        <div id="{"`$adid`_tel_`$t`"}" style="clear: both">
+          {include file="profile/phone.tpl" prefname="`$adpref`[tel]" prefid="`$adid`_tel" telid=$t tel=$tel}
+        </div>
       {/foreach}
       {if $adr.tel|@count eq 0}
-      <div id="{"`$adid`_tel_0"}" style="clear: both">
-      {include file="profile/adresses.tel.tpl" t=0 tel=0}
-      </div>
+        <div id="{"`$adid`_tel_0"}" style="clear: both">
+          {include file="profile/phone.tpl" prefname="`$adpref`[tel]" prefid="`$adid`_tel" telid=0 tel=0}
+        </div>
       {/if}
-      <div id="{$adid}_add_tel" class="center" style="clear: both">
-        <a href="javascript:addTel({$i})">
+      <div id="{$adid}_tel_add" class="center" style="clear: both; padding-top: 4px">
+        <a href="javascript:addTel('{$adid}_tel', '{$adpref}[tel]')">
           {icon name=add title="Ajouter un numéro de téléphone"} Ajouter un numéro de téléphone
         </a>
       </div>
diff --git a/templates/profile/general.networking.tpl b/templates/profile/general.networking.tpl
new file mode 100644 (file)
index 0000000..97474a8
--- /dev/null
@@ -0,0 +1,48 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2008 Polytechnique.org                             *}
+{*  http://opensource.polytechnique.org/                                  *}
+{*                                                                        *}
+{*  This program is free software; you can redistribute it and/or modify  *}
+{*  it under the terms of the GNU General Public License as published by  *}
+{*  the Free Software Foundation; either version 2 of the License, or     *}
+{*  (at your option) any later version.                                   *}
+{*                                                                        *}
+{*  This program is distributed in the hope that it will be useful,       *}
+{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}
+{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}
+{*  GNU General Public License for more details.                          *}
+{*                                                                        *}
+{*  You should have received a copy of the GNU General Public License     *}
+{*  along with this program; if not, write to the Free Software           *}
+{*  Foundation, Inc.,                                                     *}
+{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
+{*                                                                        *}
+{**************************************************************************}
+
+<tr id="networking_{$i}">
+  <td colspan="2">
+    <div style="float: left; width: 200px;">
+      <span class="flags">
+        <input type="checkbox"
+          {if $nw.pub neq 'private'} checked="checked"{/if}
+          name="networking[{$i}][pub]"/>
+        {icon name="flag_green" title="site public"}
+      </span>&nbsp;
+      <input type="hidden" name="networking[{$i}][type]" value="{$nw.type}"/>
+      <input type="hidden" name="networking[{$i}][name]" value="{$nw.name}"/>
+      <img src="profile/networking/{$nw.type}" alt="{$nw.name}" title="{$nw.name}" />
+      <span style="">{$nw.name}</span>
+    </div>
+    <div style="float: left">
+      <input type="text" name="networking[{$i}][address]" value="{$nw.address}"
+        {if $nw.error} class="error" {/if}
+        size="30"/>
+      <a href="javascript:removeNetworking({$i})">
+        {icon name=cross title="Supprimer cet élément"}
+      </a>
+    </div>
+  </td>
+</tr>
+
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
diff --git a/templates/profile/general.searchname.tpl b/templates/profile/general.searchname.tpl
new file mode 100644 (file)
index 0000000..085915d
--- /dev/null
@@ -0,0 +1,46 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2008 Polytechnique.org                             *}
+{*  http://opensource.polytechnique.org/                                  *}
+{*                                                                        *}
+{*  This program is free software; you can redistribute it and/or modify  *}
+{*  it under the terms of the GNU General Public License as published by  *}
+{*  the Free Software Foundation; either version 2 of the License, or     *}
+{*  (at your option) any later version.                                   *}
+{*                                                                        *}
+{*  This program is distributed in the hope that it will be useful,       *}
+{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}
+{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}
+{*  GNU General Public License for more details.                          *}
+{*                                                                        *}
+{*  You should have received a copy of the GNU General Public License     *}
+{*  along with this program; if not, write to the Free Software           *}
+{*  Foundation, Inc.,                                                     *}
+{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
+{*                                                                        *}
+{**************************************************************************}
+
+<span class="flags">
+    <input type="checkbox"
+        {if $sn.pub neq 'private'} checked="checked"{/if}
+        {if $sn.pub eq 'always public'} disabled="disabled"{else} name="search_name[{$i}][pub]"{/if}/>
+    {icon name="flag_green" title="site public"}
+</span>&nbsp;
+<input type="text" name="search_name[{$i}][name]" value="{$sn.search_name}" size="30"/>
+<select name="search_name[{$i}][type]">
+  <option value="firstname"{if $sn.name_type eq 'firstname'} selected="selected"{/if}>Prénom</option>
+  <option value="lastname"{if $sn.name_type eq 'lastname'} selected="selected"{/if}>Nom de famille</option>
+  <option value="surname"{if $sn.name_type eq 'surname'} selected="selected"{/if}>Surnom</option>
+</select>
+{if $sn.pub neq 'always public'}
+  <a href="javascript:removeSearchName({$i})">
+    {icon name=cross title="Supprimer ce nom de recherche"}
+  </a>
+  {if $newsn}
+    <span style="display:none" id="search_name_{$i}_new">Nouveau</span>
+  {else}
+    <input type="hidden" name="search_name[{$i}][removed]" value=""/>
+  {/if}
+{else}
+    {icon name="null"}
+{/if}
index 8ff2c03..b85bb41 100644 (file)
   </tr>
   <tr>
     <td>
-      <span class="titre">Nom</span>
-      <span class="comm"></span>
+      <span class="titre">Nom</span><br/>
     </td>
     <td>
-      <input type='text' name='nom' {if $errors.nom}class="error"{/if} value="{$nom}" />
+      {$nom}
+      <input type='hidden' name='nom' {if $errors.nom}class="error"{/if} value="{$nom}" />
     </td>
   </tr>
   <tr>
     <td>
-      <span class="titre">Prénom</span>
-      <span class="comm"></span>
+      <span class="titre">Prénom</span><br/>
     </td>
     <td>
-      <input type='text' name='prenom' {if $errors.prenom}class="error"{/if} value="{$prenom}" />
+      {$prenom}
+      <input type='hidden' name='prenom' {if $errors.prenom}class="error"{/if} value="{$prenom}" />
     </td>
   </tr>
   <tr>
     <td>
-      <span class="titre">Promotion</span>
+      <span class="titre">Affichage de ton nom</span>
     </td>
     <td>
-      <span class="nom">X{$promo}{if ($promo != $promo_sortie - 3)} - X{math equation="a - b" a=$promo_sortie b=3}{/if}</span>
-      <span class="lien"><a href="profile/orange">modifier</a>{if ($promo_sortie -3 == $promo)} pour les oranges{/if}</span>
+      {if $tooltip_name}<span title="{$tooltip_name}" class="hint">{$display_name}</span>{else}{$display_name}{/if}
+      <a href="profile/edit#names_advanced" onclick="$('#names_advanced').show();$(this).hide();document.location = document.location + '#names_advanced';return false">
+        {icon name="page_edit" title="Plus de détail"}
+      </a>
     </td>
   </tr>
   <tr>
     <td>
-      <span class="titre">Nom d'usage</span><br />
-      {if $smarty.session.sexe}
-      <span class="comm">(Notamment nom d'épouse)</span>
-      {else}
-      <span class="comm">(si différent de {$nom} seulement)</span>
-      {/if}
+      <span class="titre">Promotion</span>
     </td>
     <td>
-      <span class="nom">{$nom_usage|default:"Aucun"}</span>
-      <span class="lien"><a href="profile/usage">modifier</a></span>
+      <span class="nom">X{$promo}{if ($promo != $promo_sortie - 3)} - X{math equation="a - b" a=$promo_sortie b=3}{/if}</span>
+      <span class="lien"><a href="profile/orange" {if ($promo_sortie -3 == $promo)} {popup text="pour les oranges"}{/if}>{icon name="page_edit" title="modifier"}</a></span>
     </td>
   </tr>
   <tr>
   </tr>
  </table>
 
+<table class="bicol" style="margin-bottom: 1em;display:none"
+  summary="Profil : Noms" id="names_advanced">
+  <tr>
+    <th colspan="2">
+      Noms
+    </th>
+  </tr>
+  <tr class="impair">
+    <td>
+      <span class="flags">
+        <input type="checkbox" checked="checked" disabled="disabled" />
+        {icon name="flag_green" title="site public"}
+      </span>&nbsp;
+      <span class="titre">Affichage courant de ton nom</span>
+      <a class="popup3" href="Xorg/Profil#name_displayed">{icon name="information" title="aide"}</a>
+    </td>
+    <td>
+      <input type="text" name="display_name" value="{$display_name}" size="40"/>
+    </td>
+  </tr>
+  <tr class="impair">
+    <td>
+      <span class="titre">explication</span>
+      <a class="popup3" href="Xorg/Profil#name_tooltip">{icon name="information" title="aide"}</a>
+    </td>
+    <td>
+      <input type="text" name="tooltip_name" value="{$tooltip_name}" size="40"/>
+    </td>
+  </tr>
+  <tr class="impair">
+    <td>
+      <span class="titre">ranger ce nom à</span>
+      <a class="popup3" href="Xorg/Profil#name_order">{icon name="information" title="aide"}</a>
+    </td>
+    <td>
+      <input type="text" name="sort_name" value="{$sort_name}" size="40"/>
+    </td>
+  </tr>
+  <tr class="impair">
+    <td>
+      <span class="flags">
+        <input type="checkbox" checked="checked" disabled="disabled" />
+        {icon name="flag_red" title="privé"}
+      </span>&nbsp;
+      <span class="titre">Comment on doit t'appeller</span>
+      <a class="popup3" href="Xorg/Profil#name_yourself">{icon name="information" title="aide"}</a>
+    </td>
+    <td>
+      <input type="text" name="yourself" value="{$yourself}" size="40"/>
+    </td>
+  </tr>
+  <tr class="impair">
+    <td colspan="2">
+      <span class="titre">Recherche</span><span class="smaller">, ta fiche apparaît quand on cherche un de ces noms</span>
+      <a class="popup3" href="Xorg/Profil#name_search">{icon name="information" title="aide"}</a>
+      {iterate from=$search_names item="sn"}
+      <div id="search_name_{$sn.sn_id}" style="padding:2px" class="center">
+        {include file="profile/general.searchname.tpl" i=$sn.sn_id sn=$sn}
+      </div>
+      {/iterate}
+      <div id="add_search_name" class="center" style="clear: both">
+        <a href="javascript:addSearchName()">
+          {icon name=add title="Ajouter un nom de recherche"} Ajouter un nom
+        </a>
+      </div>
+    </td>
+</table>
+
 {if !$no_private_key}
 <table class="bicol"  style="margin-bottom: 1em"
   summary="Profil&nbsp;: Informations générales">
     </th>
   </tr>
   <tr>
-    <td>
-      <span class="flags">
-        <input type="checkbox" checked="checked" disabled="disabled" />
-        {icon name="flag_red" title="privé"}
-      </span>&nbsp;
-      <span class="titre">Surnom</span>
-    </td>
-    <td>
-      <input type="text" size="35" maxlength="64"
-             {if $errors.nick}class="error"{/if} name="nick" value="{$nick}" />
+    <td colspan="2">
+      <span class="titre">Téléphones personnels</span>
     </td>
   </tr>
   <tr>
-    <td>
-      <span class="titre">Téléphone mobile</span>
-    </td>
-    <td>
-      <input type="text" size="18" maxlength="18" name="mobile"
-             {if $errors.mobile}class="error"{/if} value="{$mobile}" />
-      <span class="flags">
-        {include file="include/flags.radio.tpl" name="mobile_pub" val=$mobile_pub}
-      </span>
+    <td colspan="2">
+      {foreach from=$tels key=telid item=tel}
+        <div id="tels_{$telid}" style="clear: both; padding-top: 4px; padding-bottom: 4px">
+          {include file="profile/phone.tpl" prefname='tels' prefid='tels' telid=$telid tel=$tel}
+        </div>
+      {/foreach}
+      {if $tels|@count eq 0}
+        <div id="tels_0" style="clear: both; padding-top: 4px; padding-bottom: 4px">
+          {include file="profile/phone.tpl" prefname='tels' preid='tels' telid=0 tel=0}
+        </div>
+      {/if}
+      <div id="tels_add" class="center" style="clear: both; padding-top: 4px;">
+        <a href="javascript:addTel('tels', 'tels');">
+          {icon name=add title="Ajouter un téléphone"}Ajouter un téléphone
+        </a>
+      </div>
     </td>
   </tr>
+  {if $email_error}
+    {include file="include/emails.combobox.tpl" name="email_directory" val=$email_directory_error error=$email_error}
+  {else}{include file="include/emails.combobox.tpl" name="email_directory" val=$email_directory error=$email_error}{/if}
   <tr>
-    <td>
-      <span class="flags">
-        <input type="checkbox" name="web_pub" {if $web_pub eq 'public'}checked="checked"{/if} />
-        {icon name="flag_green" title="site public"}
-      </span>&nbsp;
-      <span class="titre">Page web Perso</span>
+    <td colspan="2">
+      <span class="titre">Messageries, networking et sites web</span>
     </td>
-    <td>
-      <input type="text" size="35" maxlength="95" name="web"
-             {if $errors.web}class="error"{/if} value="{$web}" />
+  </tr>
+  {foreach from=$networking item=network key=id}
+    {include file="profile/general.networking.tpl" nw=$network i=$id}
+  {/foreach}
+  <tr id="networking">
+    <script type="text/javascript">//<![CDATA[
+      var nw_list = new Array();
+      {foreach from=$network_list item=network}
+        nw_list['{$network.name}'] = {$network.type};
+      {/foreach}
+    //]]></script>
+    <td colspan="2">
+      <div id="nw_add" class="center">
+        <a href="javascript:addNetworking();">
+          {icon name=add title="Ajouter une adresse"} Ajouter une adresse
+        </a>
+      </div>
     </td>
   </tr>
+<!--  <tr id="networking">
+    <td colspan="2">
+      <div style="float: left; width: 200px;">
+        <span class="titre" style="margin-left:1em;">Type à ajouter</span>
+      </div>
+      <div style="float: left;">
+        <div id="nw_type_ac" style="background-color: white; border: solid 1px black; position: absolute; width: 208px; display: none">TEST</div>
+        <input type="text" size="30" id="nw_type" name="nw_type" onkeyup="updateNetworking()">
+        <span id="nw_add" style="display: none">
+          <a href="javascript:addNetworking();">{icon name=add title="Ajouter cette adresse"}</a>
+        </span>
+      </div>
+    </td>
+  </tr>-->
   <tr class="pair">
     <td>
       <div>
           <input type="checkbox" name="freetext_pub" {if $freetext_pub eq 'public'}checked="checked"{/if} />
           {icon name="flag_green" title="site public"}
         </span>&nbsp;
-        <span class="titre">Complément libre</span><br />
-        <span class="comm">Commentaire ? ICQ ? etc...</span>
+        <span class="titre">Commentaire</span>
       </div>
       <div class="smaller" style="margin-top: 30px">
         <a href="wiki_help/notitle" class="popup3">
index 366e804..9d5e890 100644 (file)
         <a href="mailto:support@{#globals.mail.domain#}">contacte-nous</a>.</small>
       </td>
     </tr>
-    <tr class="pair">
-      <td colspan="2">
-        <span class="titre">Email professionnel&nbsp;:</span>
-        <input type="text" size="30" maxlength="60" {if $job.email_error}class="error"{/if}
-               name="{$jobpref}[email]" value="{$job.email}" />
-        <span class="flags">
-          {include file="include/flags.radio.tpl" name="`$jobpref`[email_pub]" val=$job.mail_pub}
-        </span>
-      </td>
-    </tr>
+    {include file="include/emails.combobox.tpl" name=$jobpref|cat:'[email]' val=$job.email class="pair" i=$i error=$job.email_error}
     <tr class="pair">
       <td colspan="2">
         <div style="float: left">
             {include file="geoloc/form.address.tpl" name="`$jobpref`[adr]" id="`$jobid`_adr" adr=$job.adr}
           </div>
         </div>
-        <div style="float: right; width: 50%">
-          <div class="titre">Téléphone</div>
-          <div class="flags">
-            {include file="include/flags.radio.tpl" name="`$jobpref`[tel_pub]" val=$job.tel_pub}
+      </td>
+    </tr>
+    <tr class="pair">
+      <td colspan="2">
+        {foreach from=$job.tel key=t item=tel}
+          <div id="{"`$jobid`_tel_`$t`"}" style="clear: both">
+            {include file="profile/phone.tpl" prefname="`$jobpref`[tel]" prefid="`$jobid`_tel" telid=$t tel=$tel}
+          </div>
+        {/foreach}
+        {if $job.tel|@count eq 0}
+          <div id="{"`$jobid`_tel_0"}" style="clear: both">
+            {include file="profile/phone.tpl" prefname="`$jobpref`[tel]" prefid="`$jobid`_tel" telid=0 tel=0}
           </div>
-          <table style="clear: both">
-            <tr>
-              <td>Bureau&nbsp;:</td>
-              <td>
-                <input type="text" size="18" maxlength="18" {if $job.tel_error}class="error"{/if}
-                       name="{$jobpref}[tel]" value="{$job.tel}" />
-              </td>
-            </tr>
-            <tr>
-              <td>Fax&nbsp;:</td>
-              <td>
-                <input type="text" size="18" maxlength="18" {if $job.fax_error}class="error"{/if}
-                       name="{$jobpref}[fax]" value="{$job.fax}" /></td>
-            </tr>
-            <tr>
-              <td>Mobile&nbsp;:</td>
-              <td>
-                <input type="text" size="18" maxlength="18" {if $job.mobile_error}class="error"{/if}
-                       name="{$jobpref}[mobile]" value="{$job.mobile}" />
-              </td>
-            </tr>
-          </table>
+        {/if}
+        <div id="{$jobid}_tel_add" class="center" style="clear: both; padding-top: 4px;">
+          <a href="javascript:addTel('{$jobid}_tel', '{$jobpref}[tel]')">
+            {icon name=add title="Ajouter un numéro de téléphone"} Ajouter un numéro de téléphone
+          </a>
         </div>
       </td>
     </tr>
diff --git a/templates/profile/phone.tpl b/templates/profile/phone.tpl
new file mode 100644 (file)
index 0000000..40715be
--- /dev/null
@@ -0,0 +1,51 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2008 Polytechnique.org                             *}
+{*  http://opensource.polytechnique.org/                                  *}
+{*                                                                        *}
+{*  This program is free software; you can redistribute it and/or modify  *}
+{*  it under the terms of the GNU General Public License as published by  *}
+{*  the Free Software Foundation; either version 2 of the License, or     *}
+{*  (at your option) any later version.                                   *}
+{*                                                                        *}
+{*  This program is distributed in the hope that it will be useful,       *}
+{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}
+{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}
+{*  GNU General Public License for more details.                          *}
+{*                                                                        *}
+{*  You should have received a copy of the GNU General Public License     *}
+{*  along with this program; if not, write to the Free Software           *}
+{*  Foundation, Inc.,                                                     *}
+{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
+{*                                                                        *}
+{**************************************************************************}
+
+{assign var=telpref value="`$prefname`[`$telid`]"}
+{assign var=id value="`$prefid`_`$telid`"}
+<div class="titre" style="float: left; width: 2.5em">N°{$telid+1}</div>
+<div style="float: left;">
+  <select name="{$telpref}[type]">
+    <option value="fixed"{if $tel.type eq 'fixed'} selected="selected"{/if}>Fixe</option>
+    <option value="mobile"{if $tel.type eq 'mobile'} selected="selected"{/if}>Mobile</option>
+    <option value="fax"{if $tel.type eq 'fax'} selected="selected"{/if}>Fax</option>
+  </select>
+  <input type="hidden" name="{$telpref}[removed]" value="0"/>
+  <input type="text" size="19" maxlength="28" name="{$telpref}[tel]" {if $tel.error}class="error"{/if} value="{$tel.tel}" />
+  <a href="javascript:removeTel('{$id}')">
+    {icon name=cross title="Supprimer ce numéro de téléphone"}
+  </a>
+  <a id="{$id}_addComment" href="javascript:addPhoneComment('{$id}', '{$telpref}')" {if $tel.comment neq ''}style="display:none" {/if}>
+    {icon name=comments title="Ajouter un commentaire"}
+  </a>
+</div>
+<div style="float: right" class="flags">
+  {include file="include/flags.radio.tpl" name="`$telpref`[pub]" val=$tel.pub}
+</div>
+<div id="{$id}_comment" style="clear: both;{if $tel.comment eq ''} display:none{/if}">
+  Commentaire :
+  <input type="text" size="45" maxlength="80" name="{$telpref}[comment]" {if $tel.error}class="error"{/if} value="{$tel.comment}"/>
+  <a href="javascript:removePhoneComment('{$id}', '{$telpref}')">
+    {icon name=cross title="Supprimer le commentaire"}
+  </a>
+</div>
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index 138fca4..489c3a3 100644 (file)
@@ -50,6 +50,20 @@ function chgMainWinLoc(strPage)
       {if $x.gpxs_join}<div><em class="intitule">Groupe{if count($x.gpxs) > 1}s{/if} et institution{if count($x.gpxs) > 1}s{/if} X&nbsp;: </em>
       <span><br/>{$x.gpxs_join|smarty:nodefaults}</span></div>{/if}
     {/if}
+    {if $x.networking}
+      <h2>Sur le web...</h2>
+      {foreach from=$x.networking item=network}
+        <img style="width: auto; padding: 0" src="profile/networking/{$network.type}" alt="{$network.name}" title="{$network.name}"/>
+        {if $network.filter == 'web'}
+          <a href="{$network.address}">{$network.address}</a>
+        {elseif $network.link != ''}
+          <a href="{$network.link}">{$network.address}</a>
+        {else}
+          {$network.address}
+        {/if}
+        <br/>
+      {/foreach}
+    {/if}
     {if $x.freetext}
     <h2>Commentaires&nbsp;:</h2>
     <span>{$x.freetext|miniwiki|smarty:nodefaults}</span>
@@ -58,11 +72,10 @@ function chgMainWinLoc(strPage)
   <div id="fiche_identite" class="part">
     <div class="civilite">
       {if $x.sexe}&bull;{/if}
-      {$x.prenom} {if $x.nom_usage eq ""}{$x.nom}{else}{$x.nom_usage} ({$x.nom}){/if}
+      <span {if $x.name_tooltip neq ""}class="hinted" title="{$x.name_tooltip}"{/if}>{$x.name_display}</span>
       {if $logged}
       {if $x.nickname} (alias {$x.nickname}){/if}
       {/if}
-      {if $x.web}&nbsp;<a href="{$x.web}">{icon name="world_go" title="Site Web"}</a>{/if}
       {if $logged}
       &nbsp;{if !$x.dcd}<a href="vcard/{$x.forlife}.vcf">{*
         *}{icon name=vcard title="Afficher la carte de visite"}</a>{/if}
@@ -88,7 +101,7 @@ function chgMainWinLoc(strPage)
       le {$x.date|date_format}
     </div>
     {/if}
-    {if $logged || $x.mobile}
+    {if $logged || $x.tels}
     <div class="contact">
       {if $logged}
       <div class='email'>
@@ -111,10 +124,8 @@ function chgMainWinLoc(strPage)
         {/if}
       </div>
       {/if}
-      {if $x.mobile}
-      <div class="mob">
-        <em class="intitule">Mobile&nbsp;: </em>{$x.mobile}
-      </div>
+      {if $x.tels}
+        {display_phones tels=$x.tels}
       {/if}
       <div class='spacer'></div>
     </div>
index 3c6a5ba..b5477bb 100644 (file)
@@ -408,6 +408,29 @@ checked="checked"{/if}/>Chercher uniquement les adresses où les camarades sont
       <td>Commentaire contient</td>
       <td><input type="text" name="free" size="32" value="{$smarty.request.free}" /></td>
     </tr>
+    <tr>
+      <td>Numéro de téléphone</td>
+      <td><input type="text" name="phone_number" size="32" value="{$smarty.request.phone_number}"/></td>
+    </tr>
+    <tr>
+      <td style="vertical-align: middle">
+        <span>Networking et sites webs</span>
+      </td>
+      <td>
+        <table>
+          <tr>
+            <td style="padding-left: 0px;">
+              <input type="text" name="networking_address" size="32" value="{$smarty.request.networking_address}" />
+            </td>
+            <td>
+              <input type="text" name="networking_typeTxt" class="autocomplete" size="10" value="{$smarty.request.networking_typeTxt}" />
+              <input name="networking_type" class="autocompleteTarget" type="hidden" value="{$smarty.request.networking_type}"/>
+              <a href="networking_type" class="autocompleteToSelect">{icon name="table" title="Tous les types d'adresse"}</a>
+            </td>
+          </tr>
+        </table>
+      </td>
+    </tr>
         {if $smarty.session.auth ge AUTH_COOKIE}
     <tr>
       <td colspan="2">
diff --git a/upgrade/fusionax-0.0.1/00_names.sql b/upgrade/fusionax-0.0.1/00_names.sql
new file mode 100644 (file)
index 0000000..e615bfd
--- /dev/null
@@ -0,0 +1,53 @@
+CREATE TABLE IF NOT EXISTS `profile_names_display` (
+  `user_id` int(11) NOT NULL COMMENT 'id of alumni',
+  `display` varchar(100) NOT NULL COMMENT 'name to display',
+  `sort` varchar(100) NOT NULL COMMENT 'name used for sorting',
+  `tooltip` varchar(150) NOT NULL COMMENT 'text to explain display name if needed',
+  `firstname` varchar(50) NOT NULL COMMENT 'first name',
+  `lastname` varchar(50) NOT NULL COMMENT 'last name',
+  `yourself` varchar(100) NOT NULL COMMENT 'name we used to speak to him/her',
+  PRIMARY KEY  (`user_id`),
+  KEY `sort` (`sort`)
+) CHARSET=utf8 COMMENT='Alumnis'' names to display';
+
+INSERT INTO `profile_names_display` (
+    SELECT 
+        `user_id`, 
+        CONCAT(`prenom`, ' ',IF(`nom_usage` != '',CONCAT(`nom_usage`,' (',`nom`,')'),`nom`)), 
+        CONCAT(IF(`nom_usage` != '',`nom_usage`,`nom`),', ',`prenom`),
+        '',
+        `prenom`,
+        IF(`nom_usage` != '',`nom_usage`,`nom`),
+        `prenom`
+        FROM `auth_user_md5`);
+        
+UPDATE `profile_names_display` AS n INNER JOIN `auth_user_md5` AS u ON n.lastname = u.prenom
+SET n.tooltip = CONCAT('Prénom : ', n.firstname,' - Nom : ', n.lastname);
+
+CREATE TABLE IF NOT EXISTS `profile_names_search` (
+  `user_id` int(11) NOT NULL COMMENT 'id of alumni',
+  `sn_id` smallint(6) NOT NULL COMMENT 'id of this search name in all alumni''s search names',
+  `search_name` varchar(50) NOT NULL COMMENT 'name to search for',
+  `name_type` enum('firstname','lastname','surname') NOT NULL default 'lastname' COMMENT 'type of name',
+  `search_score` smallint(6) NOT NULL COMMENT 'used to sort search results',
+  `pub` enum('always public','public','private') NOT NULL default 'private' COMMENT 'searchable on public site or only on private',
+  PRIMARY KEY  (`name_type`,`search_name`,`user_id`),
+  KEY `user_id` (`user_id`)
+) CHARSET=utf8 COMMENT='Names of alumni (search table)';
+
+INSERT INTO `profile_names_search` ( SELECT `user_id`, 0, `nom`, 'lastname', 10, 'always public' FROM `auth_user_md5` WHERE `nom` != '');
+INSERT INTO `profile_names_search` ( SELECT `user_id`, 1, `nom_usage`, 'lastname', 10, 'public' FROM `auth_user_md5` WHERE `nom` != `nom_usage` AND `nom_usage` != '');
+INSERT INTO `profile_names_search` ( SELECT `user_id`, 2, `nom_ini`, 'lastname', 7, 'private' FROM `auth_user_md5` WHERE `nom` != `nom_ini` AND `nom_ini` != '' AND `nom_ini` != `nom_usage`);
+INSERT INTO `profile_names_search` ( SELECT `user_id`, 3, `prenom`, 'firstname', 8, 'always public' FROM `auth_user_md5` WHERE `prenom` != '');
+INSERT INTO `profile_names_search` ( SELECT `user_id`, 4, `prenom_ini`, 'firstname', 5, 'private' FROM `auth_user_md5` WHERE `prenom_ini` != `prenom` AND `prenom_ini` != '');
+INSERT INTO `profile_names_search` ( SELECT `user_id`, 5, `profile_nick`, 'surname', 7, 'private' FROM `auth_user_quick` WHERE `profile_nick` != '');
+
+CREATE OR REPLACE ALGORITHM=MERGE VIEW fusionax_xorg_anciens AS 
+    SELECT
+        u.user_id, u.matricule_ax, u.promo,
+        n.display AS display_name, n.sort AS sort_name,
+        u.nom, u.prenom
+    FROM `auth_user_md5` AS u
+    INNER JOIN `profile_names_display` AS n ON ( n.user_id = u.user_id );
+
+-- vim:set syntax=mysql:
diff --git a/upgrade/fusionax-0.0.1/01_addrcomment.sql b/upgrade/fusionax-0.0.1/01_addrcomment.sql
new file mode 100644 (file)
index 0000000..7de4690
--- /dev/null
@@ -0,0 +1,2 @@
+ALTER TABLE `adresses` ADD `comment` varchar(100) NOT NULL;
+
diff --git a/upgrade/fusionax-0.0.1/02_networking.sql b/upgrade/fusionax-0.0.1/02_networking.sql
new file mode 100644 (file)
index 0000000..17172c9
--- /dev/null
@@ -0,0 +1,44 @@
+CREATE TABLE IF NOT EXISTS `profile_networking_enum` (
+    `network_type` tinyint unsigned NOT NULL,
+    `name` varchar(30) NOT NULL,
+    `icon` varchar(50) NOT NULL COMMENT 'icon filename',
+    `filter` enum('email','web','number','none') NOT NULL DEFAULT 'none' COMMENT 'filter type for addresses',
+    `link` varchar(255) NOT NULL COMMENT 'string used to forge an URL linking to the the profile page',
+    PRIMARY KEY (`network_type`)
+) CHARSET=utf8 COMMENT='types of networking addresses';
+
+CREATE TABLE IF NOT EXISTS `profile_networking` (
+    `uid` int NOT NULL COMMENT 'user id',
+    `nwid` tinyint unsigned NOT NULL COMMENT 'number of the address for the user',
+    `network_type` tinyint unsigned NOT NULL,
+    `address` varchar(255) NOT NULL,
+    `pub` enum('private','public') NOT NULL DEFAULT 'private',
+    PRIMARY KEY (`uid`, `nwid`)
+) CHARSET=utf8 COMMENT='networking addresses';
+
+-- Insert a first address type for old URLs
+INSERT INTO `profile_networking_enum` (`network_type`, `name`, `icon`, `filter`)
+     VALUES (0, 'Page web', 'web.gif', 'web');
+
+INSERT INTO `profile_networking` (`uid`, `nwid`, `network_type`, `address`, `pub`)
+     SELECT `user_id`, 0, 0, `profile_web`, `profile_web_pub`
+       FROM `auth_user_quick`
+      WHERE `profile_web` <> "";
+
+-- Modify watch_profile to update 'field' from web to networking
+ALTER TABLE `watch_profile`
+     MODIFY `field` enum('nom', 'freetext', 'mobile', 'nationalite', 'nick',
+                         'web', 'networking', 'appli1', 'appli2', 'addresses',
+                         'section', 'binets', 'medals', 'cv', 'jobs', 'photo');
+
+UPDATE `watch_profile` SET `field` = 'networking' WHERE `field` = 'web';
+
+ALTER TABLE `watch_profile`
+     MODIFY `field` enum('nom', 'freetext', 'mobile', 'nationalite', 'nick',
+                         'networking', 'appli1', 'appli2', 'addresses',
+                         'section', 'binets', 'medals', 'cv', 'jobs', 'photo');
+
+-- Drop old web URL columns
+ALTER TABLE `auth_user_quick` DROP COLUMN `profile_web`;
+ALTER TABLE `auth_user_quick` DROP COLUMN `profile_web_pub`;
+
diff --git a/upgrade/fusionax-0.0.1/03_emails.sql b/upgrade/fusionax-0.0.1/03_emails.sql
new file mode 100644 (file)
index 0000000..1f2455a
--- /dev/null
@@ -0,0 +1,27 @@
+CREATE TABLE IF NOT EXISTS profile_directory (
+    uid INT NOT NULL,
+    email_directory VARCHAR(255) DEFAULT NULL,
+    PRIMARY KEY (uid)
+) CHARSET=utf8;
+
+INSERT INTO  profile_directory (uid, email_directory)
+     SELECT  user_id, Mel_usage
+       FROM  fusionax_anciens AS ax
+ INNER JOIN  auth_user_md5    AS u ON (ax.id_ancien = CONVERT(u.matricule_ax, BINARY))
+      WHERE  Mel_publiable != '0' AND Mel_usage != '';
+
+
+ALTER TABLE register_marketing MODIFY COLUMN type ENUM('user', 'staff', 'ax');
+
+INSERT IGNORE INTO  register_marketing (uid, email, type)
+            SELECT  user_id, Mel_usage, 'ax'
+              FROM  fusionax_anciens AS ax
+        INNER JOIN  auth_user_md5    AS u ON (ax.id_ancien = CONVERT(u.matricule_ax, BINARY))
+         LEFT JOIN  emails           AS e ON (e.uid = u.user_id AND e.flags = 'active')
+             WHERE  Mel_usage != '' AND
+                    Mel_usage NOT LIKE '%@polytechnique.edu' AND
+                    Mel_usage NOT LIKE '%@polytechnique.org' AND
+                    Mel_usage NOT LIKE '%@m4x.org' AND
+                    Mel_usage NOT LIKE '%@melix.%' AND
+                    e.email IS NULL;
+
diff --git a/upgrade/fusionax-0.0.1/03_telephone.sql b/upgrade/fusionax-0.0.1/03_telephone.sql
new file mode 100644 (file)
index 0000000..f415a79
--- /dev/null
@@ -0,0 +1,21 @@
+CREATE TABLE IF NOT EXISTS `profile_phones` (
+    `uid` smallint unsigned NOT NULL,
+    `link_type` enum('address', 'pro', 'user') NOT NULL DEFAULT 'user' COMMENT 'type of parent element',
+    `link_id` tinyint unsigned NOT NULL COMMENT 'id of his parent element',
+    `tel_id` tinyint unsigned NOT NULL COMMENT 'index of this number for the couple (user, parent element)',
+    `tel_type` enum('fixed', 'mobile', 'fax') NOT NULL DEFAULT 'fixed',
+    `search_tel` varchar(25) NOT NULL COMMENT 'search number in an international format with only digits and the initial +',
+    `display_tel` varchar(30) NOT NULL COMMENT 'display number',
+    `pub` enum('private', 'ax', 'public') NOT NULL DEFAULT 'private',
+    `comment` varchar(80) NOT NULL,
+    PRIMARY KEY(`uid`, `link_type`, `link_id`, `tel_id`),
+    INDEX (`search_tel`)
+);
+
+
+-- Adds a temporary column to convert phone prefixes from varchar to int
+ALTER TABLE `geoloc_pays` ADD COLUMN `tmp_phoneprf` smallint unsigned NULL;
+
+-- Adds phone format column
+ALTER TABLE `geoloc_pays` ADD COLUMN `phoneformat` varchar(25) NOT NULL AFTER `nat`;
+
diff --git a/upgrade/fusionax-0.0.1/connect.db.inc.php b/upgrade/fusionax-0.0.1/connect.db.inc.php
new file mode 100644 (file)
index 0000000..2e66895
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2008 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************/
+
+ini_set('include_path', dirname(__FILE__).'/../../include:' . dirname(__FILE__).'/../../classes:/usr/share/php');
+
+require_once 'xorg.inc.php';
+require_once 'xdb.php';
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
diff --git a/upgrade/fusionax-0.0.1/phones.php b/upgrade/fusionax-0.0.1/phones.php
new file mode 100755 (executable)
index 0000000..6eea87c
--- /dev/null
@@ -0,0 +1,207 @@
+#!/usr/bin/php5
+<?php
+require_once 'connect.db.inc.php';
+
+//next two are required to include 'profil.func.inc.php'
+require_once 'xorg.inc.php';
+$page = new XorgPage(null);
+
+require_once 'profil.func.inc.php';
+
+$globals->debug = 0; //do not store backtraces
+
+
+// Convert phone prefixes from varchar to int
+$prefixes = XDB::iterRow("SELECT a2, phoneprf FROM geoloc_pays WHERE phoneprf IS NOT NULL");
+while (list($id, $pref) = $prefixes->next()) {
+    $pref = preg_replace('/[^0-9]/', '', $pref);
+    if ($pref[0] == '1') {
+        $pref = '1';
+    }
+    if ($pref[0] == '7') {
+        $pref = '7';
+    }
+    if ($pref != '' && strlen($pref) < 4) {
+        XDB::execute("UPDATE geoloc_pays SET tmp_phoneprf = {?} WHERE a2 = {?}", $pref, $id);
+    }
+}
+
+// geoloc_pays post operations
+// Drops old prfix column
+XDB::execute("ALTER TABLE geoloc_pays DROP COLUMN phoneprf");
+// Renames temporary column
+XDB::execute("ALTER TABLE geoloc_pays CHANGE COLUMN tmp_phoneprf phoneprf smallint unsigned NULL AFTER nat");
+// Adds an index on phoneprf column
+XDB::execute("ALTER TABLE geoloc_pays ADD INDEX (phoneprf)");
+// Adds French phone prefix
+XDB::execute("UPDATE geoloc_pays SET phoneprf = '33' WHERE a2 = 'FR'");
+// Adds some phone formats
+XDB::execute("UPDATE geoloc_pays SET phoneformat = '0# ## ## ## ##' WHERE phoneprf = '33'");    //France
+XDB::execute("UPDATE geoloc_pays SET phoneformat = '(+p) ### ### ####' WHERE phoneprf = '1'");  //USA and NANP countries
+
+
+
+//Phone number import
+
+$warnings = 0;
+
+// Import from auth_user_quick
+echo "\nImporting mobile phone numbers from auth_user_quick...\n";
+$phones = XDB::iterRow("SELECT user_id, profile_mobile_pub, profile_mobile FROM auth_user_quick WHERE profile_mobile <> ''");
+while (list($uid, $pub, $phone) = $phones->next()) {
+    $fmt_phone = format_phone_number($phone);
+    if ($fmt_phone != '') {
+        $display   = format_display_number($fmt_phone, $error);
+        if (!XDB::execute("INSERT INTO profile_phones (uid, link_type, link_id, tel_id, tel_type, search_tel, display_tel, pub)
+                                VALUES ({?}, 'user', 0, 0, 'mobile', {?}, {?}, {?})", $uid, $fmt_phone, $display, $pub)) {
+            echo "WARNING: insert of profile mobile phone number failed for user $uid.\n";
+            $warnings++;
+        }
+    }
+}
+
+
+// Import from entreprises
+echo "\nImporting professional phone numbers from entreprises...\n";
+$phones = XDB::iterator("SELECT uid, entrid, tel, fax, mobile, tel_pub FROM entreprises ORDER BY uid");
+while ($row = $phones->next()) {
+    $request = "INSERT INTO profile_phones (uid, link_type, link_id, tel_id, tel_type, search_tel, display_tel, pub)
+                     VALUES ({?}, 'pro', {?}, {?}, {?}, {?}, {?}, {?})";
+    $fmt_fixed   = format_phone_number($row['tel']);
+    $fmt_mobile  = format_phone_number($row['mobile']);
+    $fmt_fax     = format_phone_number($row['fax']);
+    if ($fmt_fixed != '') {
+        $disp_fixed  = format_display_number($fmt_fixed, $error);
+        if (!XDB::execute($request, $row['uid'], $row['entrid'], 0, 'fixed', $fmt_fixed, $disp_fixed, $row['tel_pub'])) {
+            echo 'WARNING: insert of professional fixed phone number failed for user ' . $row['uid'] . ' and entreprise ' . $row['entrid'] . ".\n";
+            $warnings++;
+        }
+    }
+    if ($fmt_mobile != '') {
+        $disp_mobile = format_display_number($fmt_mobile, $error);
+        if (!XDB::execute($request, $row['uid'], $row['entrid'], 1, 'mobile', $fmt_mobile, $disp_mobile, $row['tel_pub'])) {
+            echo 'WARNING: insert of professional mobile number failed for user ' . $row['uid'] . ' and entreprise ' . $row['entrid'] . ".\n";
+            $warnings++;
+        }
+    }
+    if ($fmt_fax != '') {
+        $disp_fax    = format_display_number($fmt_fax, $error);
+        if (!XDB::execute($request, $row['uid'], $row['entrid'], 2, 'fax', $fmt_fax, $disp_fax, $row['tel_pub'])) {
+            echo 'WARNING: insert of professional fax number failed for user ' . $row['uid'] . ' and entreprise ' . $row['entrid'] . ".\n";
+            $warnings++;
+        }
+    }
+}
+
+
+//import from tels
+echo "\nImporting personnal phone numbers from tels...\n";
+$phones = XDB::iterator("SELECT uid, adrid, telid, tel_type, tel_pub, tel FROM tels");
+$conversions = array();
+$autre_count = 0;
+while ($row = $phones->next()) {
+    $fmt_phone  = format_phone_number($row['tel']);
+    if ($fmt_phone != '') {
+        $display    = format_display_number($fmt_phone, $error);
+        $guess_type = guess_phone_type($row['tel_type'], $fmt_phone);
+
+        switch ($guess_type) {
+        case 'fixed':
+        case 'fax':
+        case 'mobile':
+            if (!XDB::execute("INSERT INTO profile_phones (uid, link_type, link_id, tel_id, tel_type, search_tel, display_tel, pub)
+                                    VALUES ({?}, 'address', {?}, {?}, {?}, {?}, {?}, {?})",
+                              $row['uid'], $row['adrid'], $row['telid'], $guess_type, $fmt_phone, $display, $row['tel_pub'])) {
+                echo  'WARNING: insert of address phone number failed for user ' . $row['uid'] . ', address ' . $row['adrid']
+                    . ' and telephone id ' . $row['telid'] . ".\n";
+                $warnings++;
+            } else {
+                if ($row['tel_type'] == 'Autre') {
+                    $autre_count++;
+                } else if (!isset($conversions[$row['tel_type']])) {
+                    $conversions[$row['tel_type']] = $guess_type;
+                }
+            }
+            break;
+        case 'conflict':
+            echo  'WARNING: conflict for user ' . $row['uid'] . ', address ' . $row['adrid']
+                . ' and telephone id ' . $row['telid'] . ': type = "' . $row['tel_type']
+                . '", number = "' .$fmt_phone . "\"\n";
+            $warnings++;
+            break;
+        case 'unknown':
+        default:
+            echo  'WARNING: unknown phone type (' . $row['tel_type'] . ') for user ' . $row['uid'] . ', address ' . $row['adrid']
+                . ' and telephone id ' . $row['telid'] . "\n";
+            $warnings++;
+        }
+    }
+}
+
+echo "\nSummary of automatic phone type conversion\n";
+foreach ($conversions as $old => $new) {
+    echo "* $old => $new\n";
+}
+echo "There was also $autre_count conversions from old type 'Autre' to a new one determined by the phone number.\n";
+
+
+
+//end of import
+if ($warnings) {
+    echo  "\n----------------------------------------------------------------------\n"
+        . " There is $warnings phone numbers that couldn't be imported.\n"
+        . " They need to be manually inserted.\n";
+}
+echo  "\nAfter solving any import problem and checking automatic conversions,\n"
+    . "you can drop useless columns and tables by these requests:\n"
+    . "DROP TABLE IF EXISTS `tels`;\n"
+    . "ALTER TABLE `auth_user_quick` DROP COLUMN `profile_mobile`;\n"
+    . "ALTER TABLE `auth_user_quick` DROP COLUMN `profile_mobile_pub`;\n"
+    . "ALTER TABLE `entreprises` DROP COLUMN `tel`;\n"
+    . "ALTER TABLE `entreprises` DROP COLUMN `fax`;\n"
+    . "ALTER TABLE `entreprises` DROP COLUMN `mobile`;\n"
+    . "ALTER TABLE `entreprises` DROP COLUMN `tel_pub`;\n";
+
+
+// auxilliary functions
+
+function guess_phone_type($str_type, $phone)
+{
+    $str_type = strtolower(trim($str_type));
+
+    // special case for phone type 'autre', guessing by phone number
+    if ($str_type == 'autre') {
+        if (substr($phone, 3) == '336') {
+            return 'mobile';
+        } else {
+            return 'fixed';
+        }
+    }
+
+    if ((strpos($str_type, 'mob') !== false) || (strpos($str_type, 'cell') !== false) || (strpos($str_type, 'port') !== false)) || (strpos($str_type, 'ptb') !== false) {
+        if (substr($phone, 3) == '336' || substr($phone, 2) != '33') {
+            return 'mobile';      //for France check if number is a mobile one
+        } else {
+            return 'conflict';
+        }
+    }
+    if (strpos($str_type, 'fax') !== false) {
+        if (substr($phone, 3) == '336') {
+            return 'conflict';
+        } else {
+            return 'fax';
+        }
+    }
+    if ((strpos($str_type, 'fixe') !== false) || (strpos($str_type, 'tél') !== false) || (strpos($str_type, 'tel') !== false) || (strpos($str_type, 'free') !== false)) {
+        if (substr($phone, 3) == '336') {
+            return 'conflict';
+        } else {
+            return 'fixed';
+        }
+    }
+
+    return 'unknown';
+}
+
+/* vim:set et sw=4 sts=4 ts=4: */
+?>
diff --git a/upgrade/fusionax-0.0.1/update.sh b/upgrade/fusionax-0.0.1/update.sh
new file mode 100755 (executable)
index 0000000..cbdc91e
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+. ../inc/pervasive.sh
+
+mailman_stop
+mailman_templates
+mailman_start
+
+
+###########################################################
+for sql in *.sql
+do
+    echo -n $sql
+    $MYSQL x4dat < $sql &>/dev/null || echo -n " ERROR"
+    echo .
+done
+
+###########################################################
+
+echo "Importing phone numbers"
+
+./phones.php
+
+###########################################################
+
+echo "we will now upgrade the search table (this may be a long operation)
+
+please hit ^D to continue
+"
+
+cat
+
+pushd ../../bin
+./search.rebuild_db.php
+popd
+
+###########################################################
+