Merge commit 'origin/fusionax' into account
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Wed, 14 Jan 2009 22:34:15 +0000 (23:34 +0100)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Wed, 14 Jan 2009 22:34:15 +0000 (23:34 +0100)
Conflicts:

include/userset.inc.php
modules/profile/general.inc.php

Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
13 files changed:
bin/cron/checkdb.php
htdocs/javascript/profile.js
include/name.func.inc.php
include/notifs.inc.php
include/user.func.inc.php
include/userset.inc.php
modules/profile/general.inc.php
templates/profile/general.searchname.tpl
templates/profile/general.tpl
templates/profile/orange.tpl
upgrade/newdirectory-0.0.1/00_names.sql
upgrade/newdirectory-0.0.1/10_promotion.sql
upgrade/newdirectory-0.0.1/14_watchnames.sql [new file with mode: 0644]

index c56a8b6..822cda5 100755 (executable)
@@ -188,25 +188,13 @@ 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");
-        
+check("SELECT  s.uid, d.public_name
+         FROM  profile_name_search AS s
+   INNER JOIN  profile_display     AS d ON (d.pid = s.uid)
+        WHERE  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
index 8d1544a..b54277f 100644 (file)
@@ -107,9 +107,9 @@ function prepareType(i)
     selectType(document.forms.prof_annu["edus[" + i + "][degreeid]"], document.forms.prof_annu["edu_" + i + "_tmp"].value);
 }
 
-function displayNamesAdvanced()
+function toggleNamesAdvanced()
 {
-    $('.names_advanced').show();
+    $('.names_advanced').toggle();
 }
 
 function addSearchName()
index ddb85a1..53d4241 100644 (file)
@@ -79,12 +79,13 @@ function build_full_name(&$search_names, &$sn_types)
     }
     if (isset($search_names[$sn_types['Nom marital']])
         || isset($search_names[$sn_types['Pseudonyme (nom de plume)']])) {
+        $name .= " (";
         if (isset($search_names[$sn_types['Nom marital']])) {
             $user = S::user();
             if ($user->isFemale()) {
-                $name .= " (Mme ";
+                $name .= "Mme ";
             } else {
-                $name .= " (M ";
+                $name .= "M ";
             }
             $name .= $search_names[$sn_types['Nom marital']][0];
             if (isset($search_names[$sn_types['Pseudonyme (nom de plume)']])) {
index 8e53ac7..b1cf91d 100644 (file)
@@ -146,7 +146,7 @@ function select_notifs($mail, $uid=null, $last=null, $iterator=true)
 // {{{
 
 global $prf_desc;
-$prf_desc = array('nom' => 'Son patronyme',
+$prf_desc = array('search_names' => 'L\'un de ses noms',
                   'freetext' => 'Le texte libre',
                   'mobile' => 'Son numéro de téléphone portable',
                   'nationalite' => 'Sa nationalité',
index 4e974d6..a22013c 100644 (file)
@@ -271,7 +271,7 @@ function &get_user_details($login, $from_uid = '', $view = 'private')
                        u.matricule_ax,
                        m.expertise != '' AS is_referent,
                        (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
+                       d.public_name, d.private_name
                  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')
@@ -285,7 +285,6 @@ function &get_user_details($login, $from_uid = '', $view = 'private')
             LEFT JOIN  photo                 AS p   ON (p.uid = u.user_id)
             LEFT JOIN  profile_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)
            INNER JOIN  profile_display       AS d   ON (d.pid = u.user_id)
                 WHERE  a.alias = {?}
              GROUP BY  u.user_id";
index 8de820b..9d31ff4 100644 (file)
@@ -161,11 +161,11 @@ class MinificheView extends MultipageView
         global $globals;
         $this->entriesPerPage = $globals->search->per_page;
         if (@$params['with_score']) {
-            $this->addSortKey('score', array('-score', '-date', '-d.promo', 'name_sort'), 'pertinence');
+            $this->addSortKey('score', array('-score', '-date', '-d.promo', 'sort_name'), 'pertinence');
         }
-        $this->addSortKey('name', array('name_sort'), 'nom');
-        $this->addSortKey('promo', array('-d.promo', 'name_sort'), 'promotion');
-        $this->addSortKey('date_mod', array('-date', '-d.promo', 'name_sort'), 'dernière modification');
+        $this->addSortKey('name', array('sort_name'), 'nom');
+        $this->addSortKey('promo', array('-d.promo', 'sort_name'), 'promotion');
+        $this->addSortKey('date_mod', array('-date', '-d.promo', 'sort_name'), 'dernière modification');
         parent::__construct($set, $data, $params);
     }
 
@@ -196,7 +196,7 @@ class MinificheView extends MultipageView
                 edu3.grad_year AS edugrad_year3, f3.field AS edufield3, edu3.program AS eduprogram3,
                 adr.city, gp.a2, gp.pays AS countrytxt, gr.name AS region,
                 (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" .
+                d.directory_name, d.sort_name" .
                 (S::logged() ? ", c.contact AS contact" : '');
     }
 
@@ -232,7 +232,6 @@ class MinificheView extends MultipageView
                  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')
-                INNER JOIN  profile_names_display         AS nd   ON (nd.user_id = u.user_id)
                 INNER JOIN  profile_display               AS d    ON (d.pid = u.user_id)" . (S::logged() ?
                 "LEFT JOIN  contacts                      AS c    ON (c.contact = u.user_id AND c.uid = " . S::v('uid') . ")"
                  : "");
@@ -267,9 +266,9 @@ class MentorView extends MultipageView
     {
         $this->entriesPerPage = 10;
         $this->addSortKey('rand', array('RAND(' . S::i('uid') . ')'), 'aléatoirement');
-        $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');
+        $this->addSortKey('name', array('sort_name'), 'nom');
+        $this->addSortKey('promo', array('-d.promo', 'sort_name'), 'promotion');
+        $this->addSortKey('date_mod', array('-date', '-d.promo', 'sort_name'), 'dernière modification');
         parent::__construct($set, $data, $params);
     }
 
@@ -277,13 +276,12 @@ class MentorView extends MultipageView
     {
         return "m.uid, d.promo, u.hruid,
                 m.expertise, mp.country, ms.sectorid, ms.subsectorid,
-                nd.display AS name_display, nd.tooltip AS name_tooltip, nd.sort AS name_sort";
+                d.directory_name, d.sort_name";
     }
 
     public function joins()
     {
-        return "INNER JOIN  profile_names_display AS nd ON (nd.user_id = u.user_id)
-                INNER JOIN  profile_display       AS d  ON (d.pid = u.user_id)";
+        return "INNER JOIN  profile_display AS d ON (d.pid = u.user_id)";
     }
 
     public function bounds()
@@ -314,25 +312,24 @@ class TrombiView extends MultipageView
     public function __construct(PlSet &$set, $data, array $params)
     {
         $this->entriesPerPage = 24;
-        $this->order = explode(',', Env::v('order', 'name_sort'));
+        $this->order = explode(',', Env::v('order', 'sort_name'));
         if (@$params['with_score']) {
-            $this->addSortKey('score', array('-score', '-watch_last', '-promo', 'name_sort'), 'pertinence');
+            $this->addSortKey('score', array('-score', '-watch_last', '-d.promo', 'sort_name'), 'pertinence');
         }
-        $this->addSortKey('name', array('name_sort'), 'nom');
-        $this->addSortKey('promo', array('-promo', 'name_sort'), 'promotion');
+        $this->addSortKey('name', array('sort_name'), 'nom');
+        $this->addSortKey('promo', array('-d.promo', 'sort_name'), 'promotion');
         parent::__construct($set, $data, $params);
     }
 
     public function fields()
     {
-        return "u.user_id, nd.display AS name_display, nd.tooltip AS name_tooltip, nd.sort AS name_sort, u.promo, d.promo, u.hruid ";
+        return "u.user_id, d.directory_name, d.sort_name, u.promo, d.promo, u.hruid ";
     }
 
     public function joins()
     {
-        return "INNER JOIN  photo                 AS p  ON (p.uid = u.user_id)
-                INNER JOIN  profile_display       AS d  ON (d.pid = u.user_id)
-                INNER JOIN  profile_names_display AS nd ON (nd.user_id = u.user_id)";
+        return "INNER JOIN  photo           AS p  ON (p.uid = u.user_id)
+                INNER JOIN  profile_display AS d  ON (d.pid = u.user_id)";
     }
 
     public function bounds()
index baa845d..e882eac 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-class ProfileNom implements ProfileSetting
+class ProfileSearchNames implements ProfileSetting
 {
+    private $public_name;
+    private $private_name;
+    private $directory_name;
+    private $short_name;
+    private $sort_name;
+
     private function matchWord($old, $new, $newLen)
     {
         return ($i = strpos($old, $new)) !== false
@@ -34,34 +40,137 @@ class ProfileNom implements ProfileSetting
         return preg_replace('/[^A-Z]/', ' ', $value);
     }
 
-    public function value(ProfilePage &$page, $field, $value, &$success)
+    private function prepare(ProfilePage &$page, $field, $value, $init, &$success)
     {
         $success = true;
-        $current = S::v($field);
-        $init    = S::v($field . '_ini');
-        if (is_null($value)) {
-            return $current;
-        }
-        if ($value == $current || $value == $init) {
-            return $value;
-        }
         $ini = $this->prepareField($init);
-        $old = $this->prepareField($current);
         $new = $this->prepareField($value);
-        $newLen = strlen($new);
-        $success = $this->matchWord($old, $new, $newLen)
-                || $this->matchWord($ini, $new, $newLen)
-                || ($field == 'nom' && $new == 'DE ' . $old);
+        $newLen  = strlen($new);
+        $success = $this->matchWord($ini, $new, $newLen)
+                   || ($field == 'Nom patronymique' && $new == 'DE ' . $ini);
         if (!$success) {
-            Platal::page()->trigError("Le $field que tu as choisi ($value) est trop loin de ton $field initial ($init)"
-                                    . (($init == $current)? "" : " et de ton prénom précédent ($current)"));
+            $field = strtolower($field);
+            Platal::page()->trigError("Le " . $field . " que tu as choisi (" . $value .
+                                      ") est trop loin de ton " . $field . " initial (" . $init . ").");
+        }
+        return $success ? $value : $init;
+    }
+
+    public function value(ProfilePage &$page, $field, $value, &$success)
+    {
+        $success = true;
+        $success_tmp = true;
+        if (is_null($value)) {
+            $sn_all = XDB::iterator("SELECT  CONCAT(sn.particle, sn.name) AS name,
+                                             sn.particle, sn.typeid, e.name AS type,
+                                             FIND_IN_SET('has_particle', e.flags) AS has_particle,
+                                             FIND_IN_SET('always_displayed', e.flags) AS always_displayed,
+                                             FIND_IN_SET('public', e.flags) AS pub
+                                       FROM  profile_name_search      AS sn
+                                 INNER JOIN  profile_name_search_enum AS e  ON (e.id = sn.typeid)
+                                      WHERE  sn.pid = {?} AND NOT FIND_IN_SET('not_displayed', e.flags)
+                                   ORDER BY  NOT FIND_IN_SET('always_displayed', e.flags), e.id, sn.name",
+                                    S::v('uid'));
+
+            $sn_types = XDB::iterator("SELECT  id, name, FIND_IN_SET('has_particle', flags) AS has_particle
+                                         FROM  profile_name_search_enum
+                                        WHERE  NOT FIND_IN_SET('not_displayed', flags)
+                                               AND FIND_IN_SET('always_displayed', flags)
+                                     ORDER BY  id");
+
+            $value = array();
+            $sn = $sn_all->next();
+            while ($sn_type = $sn_types->next()) {
+                if ($sn_type['id'] == $sn['typeid']) {
+                    $value[] = $sn;
+                    $sn = $sn_all->next();
+                } else {
+                    $value[] = array('typeid' => $sn_type['id'],
+                                     'type'   => $sn_type['name'],
+                                     'pub'    => 1,
+                                     'has_particle'     => $sn_type['has_particle'],
+                                     'always_displayed' => 1);
+                }
+            }
+            do {
+                $value[] = $sn;
+            } while ($sn = $sn_all->next());
+        } else {
+            $res = XDB::query("SELECT  s.particle, s.name
+                                 FROM  profile_name_search      AS s
+                           INNER JOIN  profile_name_search_enum AS e ON (e.id = s.typeid)
+                                WHERE  s.pid = {?} AND e.name LIKE '%initial'
+                             ORDER BY  e.name = 'Prénom initial'",
+                             S::i('uid'));
+            $res = $res->fetchAllAssoc();
+            $initial = array();
+            $initial['Nom patronymique'] = $res[0]['particle'] . $res[0]['name'];
+            $initial['Prénom'] = $res[1]['name'];
+            $search_names = array();
+            foreach ($value as $key => &$sn) {
+                $sn['name'] = trim($sn['name']);
+                if ($sn['type'] == 'Prénom' || $sn['type'] == 'Nom patronymique') {
+                    $sn['name'] = $this->prepare($page, $sn['type'], $sn['name'],
+                                                 $initial[$sn['type']], $success_tmp);
+                    $success = $success && $success_tmp;
+                }
+                if ($sn['name'] != '') {
+                    if (!isset($search_names[$sn['typeid']])) {
+                        $search_names[$sn['typeid']] = array($sn['name'], $name);
+                    } else {
+                        $search_names[$sn['typeid']] = array_merge($search_names[$sn['typeid']], array($name));
+                    }
+                }
+            }
+            require_once 'name.func.inc.php';
+            $sn_types_public  = build_types('public');
+            $sn_types_private = build_types('private');
+            $full_name        = build_full_name($search_names, $sn_types_public);
+            $this->directory_name = build_directory_name($search_names, $sn_types_public, $full_name);
+            $this->short_name     = short_name($search_names, $sn_types_public);
+            $this->sort_name      = short_name($search_names, $sn_types_public);
+            $this->public_name    = build_public_name($search_names, $sn_types_public, $full_name);
+            $this->private_name   = $this->public_name . build_private_name($search_names, $sn_types_private);
+            Platal::page()->assign('public_name', $this->public_name);
+            Platal::page()->assign('private_name', $this->private_name);
         }
-        return $success ? $value : $current;
+        return $value;
     }
 
-    public function save(ProfilePage &$page, $field, $new_value)
+    public function save(ProfilePage &$page, $field, $value)
     {
-        $_SESSION[$field] = $new_value;
+        XDB::execute("DELETE FROM  s
+                            USING  profile_name_search      AS s
+                       INNER JOIN  profile_name_search_enum AS e ON (s.typeid = e.id)
+                            WHERE  s.pid = {?} AND NOT FIND_IN_SET('not_displayed', e.flags)",
+                     S::i('uid'));
+        foreach ($value as $sn) {
+            if ($sn['name'] != '') {
+                if ($sn['particle']) {
+                    list($particle, $name) = explode(' ', $sn['name'], 2);
+                    $particle = trim($particle) . ' ';
+                    if (!$name) {
+                        list($particle, $name) = explode('\'', $sn['name'], 2);
+                        $particle = trim($particle);
+                    }
+                } else {
+                    $particle = '';
+                    $name     = $sn['name'];
+                }
+                $name = trim($name);
+                XDB::execute("INSERT INTO  profile_name_search (particle, name, typeid, pid)
+                                   VALUES  ({?}, {?}, {?}, {?})",
+                             $particle, $name, $sn['typeid'], S::i('uid'));
+            }
+        }
+        XDB::execute("UPDATE  profile_display
+                         SET  public_name = {?}, private_name = {?},
+                              directory_name = {?}, short_name = {?}, sort_name = {?}
+                       WHERE  pid = {?}",
+                     $this->public_name, $this->private_name, $this->directory_name,
+                     $this->short_name, $this->sort_name, S::v('uid'));
+        /*require_once('user.func.inc.php');
+        user_reindex(S::v('uid'));*/
     }
 }
 
@@ -241,6 +350,8 @@ class ProfileGeneral extends ProfilePage
     public function __construct(PlWizard &$wiz)
     {
         parent::__construct($wiz);
+        $this->settings['search_names']
+                                  = new ProfileSearchNames();
         $this->settings['birthdate'] = new ProfileDate();
         $this->settings['freetext_pub']
                                   = $this->settings['photo_pub']
@@ -249,13 +360,8 @@ class ProfileGeneral extends ProfilePage
                                   = $this->settings['nationality1']
                                   = $this->settings['nationality2']
                                   = $this->settings['nationality3']
-                                  = $this->settings['nick']
                                   = $this->settings['yourself']
-                                  = $this->settings['display_name']
-                                  = $this->settings['sort_name']
-                                  = $this->settings['tooltip_name']
-                                  = $this->settings['promo_display']
-                                  = $this->settings['search_names']
+                                  = $this->settings['promo']
                                   = null;
         $this->settings['synchro_ax']
                                   = new ProfileBool();
@@ -269,27 +375,27 @@ class ProfileGeneral extends ProfilePage
         $this->watched= array('freetext' => true, 'tels' => true,
                               'networking' => true, 'edus' => true,
                               'nationality1' => true, 'nationality2' => true,
-                              'nationality3' => true, 'nick' => true);
+                              'nationality3' => true, 'search_names' => true);
     }
 
     protected function _fetchData()
     {
         // Checkout all data...
-        $res = XDB::query("SELECT  p.promo AS promo_display, e.entry_year AS entry_year, e.grad_year AS grad_year,
+        $res = XDB::query("SELECT  p.promo, e.entry_year AS entry_year, e.grad_year AS grad_year,
                                    pr.nationality1, pr.nationality2, pr.nationality3, pr.birthdate,
                                    t.display_tel as mobile, t.pub as mobile_pub,
                                    d.email_directory as email_directory,
-                                   pr.freetext, pr.freetext_pub as freetext_pub,
-                                   n.yourself, n.display AS display_name, n.sort AS sort_name,
-                                   n.tooltip AS tooltip_name
+                                   pr.freetext, pr.freetext_pub as freetext_pub
                              FROM  profiles              AS pr
-                       INNER JOIN  profile_names_display AS n ON (n.user_id = pr.pid)
                        INNER JOIN  profile_display       AS p ON (p.pid = pr.pid)
                        INNER JOIN  profile_education     AS e ON (e.uid = pr.pid AND FIND_IN_SET('primary', e.flags))
                         LEFT JOIN  profile_phones        AS t ON (t.uid = pr.pid AND link_type = 'user')
                         LEFT JOIN  profile_directory     AS d ON (d.uid = pr.pid)
                             WHERE  pr.pid = {?}", $this->pid());
         $this->values = $res->fetchOneAssoc();
+        if ($this->owner) {
+            $this->values['yourself'] = $this->owner->displayName();
+        }
 
         // Retreive photo informations
         $res = XDB::query("SELECT  pub
@@ -307,43 +413,7 @@ class ProfileGeneral extends ProfilePage
             $this->values['nouvellephoto'] = 0;
         }
 
-        // Retreive search names info
-        $sn_all = XDB::iterator("SELECT  IF(sn.particle = '', sn.name, CONCAT(sn.particle, ' ', sn.name)) AS name,
-                                         sn.particle, sn.typeid, e.name AS type,
-                                         FIND_IN_SET('has_particle', e.flags) AS has_particle,
-                                         FIND_IN_SET('always_displayed', e.flags) AS always_displayed,
-                                         FIND_IN_SET('public', e.flags) AS pub
-                                   FROM  profile_name_search      AS sn
-                             INNER JOIN  profile_name_search_enum AS e  ON (e.id = sn.typeid)
-                                  WHERE  sn.pid = {?} AND NOT FIND_IN_SET('not_displayed', e.flags)
-                               ORDER BY  NOT FIND_IN_SET('always_displayed', e.flags), e.id, sn.name",
-                                $this->pid());
-
-        $sn_types = XDB::iterator("SELECT  id, name, FIND_IN_SET('has_particle', flags) AS has_particle
-                                     FROM  profile_name_search_enum
-                                    WHERE  NOT FIND_IN_SET('not_displayed', flags)
-                                           AND FIND_IN_SET('always_displayed', flags)
-                                 ORDER BY  id");
-
-        $this->values['search_names'] = array();
-        $sn = $sn_all->next();
-        while ($sn_type = $sn_types->next()) {
-            if ($sn_type['id'] == $sn['typeid']) {
-                $this->values['search_names'][] = $sn;
-                $sn = $sn_all->next();
-            } else {
-                $this->values['search_names'][] = array('typeid' => $sn_type['id'],
-                                                        'type'   => $sn_type['name'],
-                                                        'pub'    => 1,
-                                                        'has_particle'     => $sn_type['has_particle'],
-                                                        'always_displayed' => 1);
-            }
-        }
-        do {
-            $this->values['search_names'][] = $sn;
-        } while ($sn = $sn_all->next());
-
-        // Proposes choice for promo_display
+        // Proposes choice for promotion
         if ($this->values['entry_year'] != $this->values['grad_year'] - 3) {
             for ($i = $this->values['entry_year']; $i < $this->values['grad_year'] - 2; $i++) {
                 $this->values['promo_choice'][] = "X" . $i;
@@ -393,72 +463,16 @@ class ProfileGeneral extends ProfilePage
                            WHERE  uid = {?}",
                          $this->values['photo_pub'], $this->pid());
         }
-
-        if ($this->changed['yourself'] || $this->changed['search_names']) {
-            if ($this->changed['search_names']) {
-                XDB::execute("DELETE FROM  s
-                                    USING  profile_name_search      AS s
-                               INNER JOIN  profile_name_search_enum AS e ON (s.typeid = e.id)
-                                    WHERE  s.pid = {?} AND NOT FIND_IN_SET('not_displayed', e.flags)",
-                             $this->pid());
-                $search_names = array();
-                foreach ($this->values['search_names'] as $sn) {
-                    if ($sn['name'] != '') {
-                        if ($sn['particle']) {
-                            list($particle, $name) = explode(' ', $sn['name'], 2);
-                            if (!$name) {
-                                list($particle, $name) = explode('\'', $sn['name'], 2);
-                            }
-                        } else {
-                            $particle = '';
-                            $name     = $sn['name'];
-                        }
-                        $particle   = trim($particle);
-                        $name       = trim($name);
-                        $sn['name'] = trim($sn['name']);
-                        XDB::execute("INSERT INTO  profile_name_search (particle, name, typeid, pid)
-                                           VALUES  ({?}, {?}, {?}, {?})",
-                                     $particle, $name, $sn['typeid'], $this->pid());
-                        if (!isset($search_names[$sn['typeid']])) {
-                            $search_names[$sn['typeid']] = array($sn['name'], $name);
-                        } else {
-                            $search_names[$sn['typeid']] = array_merge($search_names[$sn['typeid']], array($name));
-                        }
-                    }
-                }
-
-                require_once 'name.func.inc.php';
-                $sn_types_public  = build_types('public');
-                $sn_types_private = build_types('private');
-                $full_name      = build_full_name($search_names, $sn_types_public);
-                $directory_name = build_directory_name($search_names, $sn_types_public, $full_name);
-                $short_name     = short_name($search_names, $sn_types_public);
-                $sort_name      = short_name($search_names, $sn_types_public);
-                $this->values['public_name']  = build_public_name($search_names, $sn_types_public, $full_name);
-                $this->values['private_name'] = $public_name . build_private_name($search_names, $sn_types_private);
-                XDB::execute("UPDATE  profile_display
-                                 SET  yourself = {?}, public_name = {?}, private_name = {?},
-                                      directory_name = {?}, short_name = {?}, sort_name = {?}
-                               WHERE  pid = {?}",
-                             $this->values['yourself'], $this->values['public_name'],
-                             $this->values['private_name'], $directory_name, $short_name,
-                             $sort_name, $this->pid());
-                /*if ($this->changed['search_names']) {
-                    require_once('user.func.inc.php');
-                    user_reindex(S::v('uid'));
-                }*/
-            } else {
-                XDB::execute("UPDATE  profile_display
-                                 SET  yourself = {?}
-                               WHERE  pid = {?}",
-                             $this->values['yourself'], $this->pid());
-            }
+        if ($this->changed['yourself']) {
+            XDB::execute('UPDATE  accounts
+                             SET  display_name = {?}
+                           WHERE  pid = {?}', $this->pid());
         }
-        if ($this->changed['promo_display']) {
+        if ($this->changed['promo']) {
             XDB::execute("UPDATE  profile_display
                              SET  promo = {?}
                            WHERE  pid = {?}",
-                         $this->values['promo_display'], $this->pid());
+                         $this->values['promo'], $this->pid());
         }
     }
 
@@ -478,6 +492,14 @@ class ProfileGeneral extends ProfilePage
                                 FROM  profile_networking_enum AS nw
                             ORDER BY  name");
         $page->assign('network_list', $res->fetchAllAssoc());
+
+        $res = XDB::query("SELECT  public_name, private_name
+                             FROM  profile_display
+                            WHERE  pid = {?}",
+                             S::v('uid'));
+        $res = $res->fetchOneRow();
+        $page->assign('public_name', $res[0]);
+        $page->assign('private_name', $res[1]);
     }
 }
 
index 8faef48..ff873ee 100644 (file)
@@ -20,7 +20,7 @@
 {*                                                                        *}
 {**************************************************************************}
 
-<tr id="search_name_{$i}"{if $class} class="{$class}" style="{$style}"{/if}>
+<tr id="search_name_{$i}"{if $class} class="{$class}" {if !$error_name}style="{$style}"{/if}{/if}>
   <td>
     <input type="hidden" name="search_names[{$i}][always_displayed]" value="{$sn.always_displayed}"/>
     <input type="hidden" name="search_names[{$i}][has_particle]" value="{$sn.has_particle}"/>
index ce203c6..8205ece 100644 (file)
@@ -32,7 +32,7 @@
       {$public_name}
     </td>
     <td rowspan="2">
-      <a href="javascript:displayNamesAdvanced();">
+      <a href="javascript:toggleNamesAdvanced();">
         {icon name="page_edit" title="Plus de détail"}
       </a>
     </td>
@@ -55,7 +55,7 @@
     </td>
     <td></td>
   </tr>
-  <tr class="names_advanced" style="display: none">
+  <tr class="names_advanced" {if !$errors.search_names}style="display: none"{/if}>
     <td colspan="3">
       <span class="titre">Gestion de tes noms, prénoms, surnoms...</span>
       <span class="smaller">Ils déterminent la façon dont ton nom apparaît sur les annuaires
     </td>
   </tr>
   {foreach from=$search_names item=sn key=id}
-    {include file="profile/general.searchname.tpl" i=$id sn=$sn class="names_advanced" style="display: none"}
+    {include file="profile/general.searchname.tpl" i=$id sn=$sn
+    class="names_advanced" style="display: none" error_name=$errors.search_names}
   {/foreach}
-  <tr class="names_advanced" id="searchname" style="display: none">
+  <tr class="names_advanced" id="searchname" {if !$errors.search_names}style="display: none"{/if}>
     <td colspan="2">
       <div id="sn_add" class="center">
         <a href="javascript:addSearchName();">
     </td>
     <td>
       {if !$promo_choice}
-        <span class="nom">{$promo_display}</span>
+        <span class="nom">{$promo}</span>
+        <input type="hidden" name="promo" value="{$promo}"/>
       {else}
-        <select name="promo_display">
+        <select name="promo">
         {foreach from=$promo_choice item="promo_to_display"}
-          <option value="{$promo_to_display}" {if $promo_to_display eq $promo_display}selected="selected"{/if}>{$promo_to_display}</option>
+          <option value="{$promo_to_display}" {if $promo_to_display eq $promo}selected="selected"{/if}>{$promo_to_display}</option>
         {/foreach}
         </select>
       {/if}
index 7ce37cc..628ad9a 100644 (file)
@@ -35,7 +35,7 @@
   Afin de pouvoir être considéré{if $sexe}e{/if} à la fois dans ta promotion d'origine et ta
   ou tes promotions d'adoption tu peux entrer ici ton année de sortie de l'école.
   Plus précisément, il s'agit de l'année d'entrée en quatrième année ou année d'application.
-  Pour tes cocons d'origine ({$promo_display}) il s'agit de l'année {math equation="a + b" a=$promo b=3}.
+  Pour tes cocons d'origine ({$promo}) il s'agit de l'année {math equation="a + b" a=$promo b=3}.
 </p>
 
 <br />
index fdbea10..c4a0ce4 100644 (file)
@@ -1,3 +1,5 @@
+DROP TABLE IF EXISTS profile_display;
+
 CREATE TABLE  profile_display (
   pid INT(11) NOT NULL DEFAULT 0,
   yourself VARCHAR(255) NOT NULL,
@@ -7,7 +9,7 @@ CREATE TABLE  profile_display (
   short_name VARCHAR(255) NOT NULL,
   sort_name VARCHAR(255) NOT NULL,
   promo VARCHAR(255) DEFAULT '' NOT NULL,
-  PRIMARY KEY(uid)
+  PRIMARY KEY(pid)
 ) CHARSET=utf8;
 
 INSERT INTO  profile_display (pid, yourself, public_name, private_name, directory_name, short_name, sort_name)
@@ -15,7 +17,7 @@ INSERT INTO  profile_display (pid, yourself, public_name, private_name, director
              CONCAT(u.prenom, ' ', IF(u.nom_usage != '', CONCAT(u.nom_usage, ' (', u.nom, ')') , u.nom)),
              CONCAT(u.prenom, ' ', IF(u.nom_usage != '', CONCAT(u.nom_usage, ' (', u.nom, ')') , u.nom),
                IF(q.profile_nick != '', CONCAT(' (alias ', q.profile_nick, ')'), '')),
-             CONCAT(IF(u.nom_usage != '', CONCAT(u.nom_usage, ' (', u.nom, ')') , u.nom), ', ', u.prenom),
+             CONCAT(IF(u.nom_usage != '', CONCAT(u.nom_usage, ' (', u.nom, ')') , u.nom), ' ', u.prenom),
              CONCAT(u.prenom, ' ', IF(u.nom_usage != '', u.nom_usage, u.nom)),
              CONCAT(IF(u.nom_usage != '', u.nom_usage, u.nom), ' ', u.prenom)
        FROM  auth_user_md5   AS u
index 785ce31..de629b4 100644 (file)
@@ -4,9 +4,9 @@ INSERT INTO  profile_education (id, uid, grad_year, entry_year, eduid, degreeid,
   LEFT JOIN  profile_education_enum        AS e ON (e.abbreviation = "X")
   LEFT JOIN  profile_education_degree_enum AS d ON (d.degree = "Ingénieur");
 
-REPLACE IGNORE INTO  profile_display (pid, promo)
-             SELECT  uid, CONCAT("X", entry_year)
-               FROM  profile_education
-              WHERE  FIND_IN_SET('primary', flags);
+    UPDATE  profile_display   AS d
+INNER JOIN  profile_education AS e ON (d.pid = e.uid)
+       SET  d.promo = CONCAT("X", entry_year)
+     WHERE  FIND_IN_SET('primary', e.flags);
 
 -- vim:set syntax=mysql:
diff --git a/upgrade/newdirectory-0.0.1/14_watchnames.sql b/upgrade/newdirectory-0.0.1/14_watchnames.sql
new file mode 100644 (file)
index 0000000..8baebda
--- /dev/null
@@ -0,0 +1,13 @@
+ALTER TABLE watch_profile MODIFY field enum('search_names', 'nom', 'freetext', 'mobile', 'nationalite',
+                                            'nationalite2', 'nationalite3', 'nick', 'web', 'networking',
+                                            'edus', 'addresses', 'section', 'binets', 'medals', 'cv',
+                                            'jobs', 'photo');
+
+UPDATE watch_profile SET field = 'search_names' WHERE field = 'nom' OR field = 'nick';
+
+ALTER TABLE watch_profile MODIFY field enum('search_names', 'freetext', 'mobile', 'nationalite',
+                                            'nationalite2', 'nationalite3', 'web', 'networking','edus',
+                                            'addresses', 'section', 'binets', 'medals', 'cv', 'jobs',
+                                            'photo');
+
+# vim:set syntax=mysql: