Displayed promotion is now linked to the primery education.
authorStéphane Jacob <jacou@melix.net>
Mon, 13 Oct 2008 15:55:21 +0000 (17:55 +0200)
committerStéphane Jacob <jacou@melix.net>
Mon, 20 Oct 2008 22:02:13 +0000 (00:02 +0200)
19 files changed:
classes/user.php
include/user.func.inc.php
include/userset.inc.php
include/validations.inc.php
include/validations/orange.inc.php
modules/admin.php
modules/events.php
modules/profile.php
modules/profile/general.inc.php
templates/events/index.tpl
templates/include/minifiche.tpl
templates/include/plview.referent.tpl
templates/include/plview.trombi.tpl
templates/include/trombi.tpl
templates/profile/general.tpl
templates/profile/orange.tpl
templates/profile/profile.tpl
upgrade/newdirectory-0.0.1/06_education.sql
upgrade/newdirectory-0.0.1/10_promotion.sql [new file with mode: 0644]

index eb112ca..e7c7472 100644 (file)
@@ -117,7 +117,7 @@ class User extends PlUser
         }
 
         global $globals;
-        $res = XDB::query("SELECT  u.hruid, u.promo,
+        $res = XDB::query("SELECT  u.hruid, d.promo_display AS promo,
                                    CONCAT(af.alias, '@{$globals->mail->domain}') AS forlife,
                                    CONCAT(ab.alias, '@{$globals->mail->domain}') AS bestalias,
                                    CONCAT(u.prenom, ' ', IF(u.nom_usage <> '', u.nom_usage, u.nom)) AS full_name,
@@ -126,6 +126,7 @@ class User extends PlUser
                                    q.core_mail_fmt AS email_format,
                                    u.perms
                              FROM  auth_user_md5 AS u
+                       INNER JOIN  profile_display AS d ON (d.uid = u.user_id)
                         LEFT JOIN  auth_user_quick AS q ON (q.user_id = u.user_id)
                         LEFT JOIN  aliases AS af ON (af.id = u.user_id AND af.type = 'a_vie')
                         LEFT JOIN  aliases AS ab ON (ab.id = u.user_id AND FIND_IN_SET('bestalias', ab.flags))
index 104dd64..549d811 100644 (file)
@@ -256,7 +256,7 @@ function get_user_details_adr($uid, $view = 'private') {
 
 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,
+    $reqsql = "SELECT  u.user_id, d.promo_display, 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_freetext AS freetext,
                        q.profile_freetext_pub AS freetext_pub,
@@ -271,20 +271,21 @@ function &get_user_details($login, $from_uid = '', $view = 'private')
                        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
-                 FROM  auth_user_md5   AS u
-           INNER JOIN  auth_user_quick AS q   USING(user_id)
-           INNER JOIN  aliases         AS a   ON (u.user_id = a.id AND a.type = 'a_vie')
-           INNER JOIN  aliases         AS a2  ON (u.user_id = a2.id AND FIND_IN_SET('bestalias', a2.flags))
-            LEFT JOIN  contacts        AS c   ON (c.uid = {?} and c.contact = u.user_id)
-            LEFT JOIN  profile_corps   AS co  ON (co.uid = u.user_id)
-            LEFT JOIN  geoloc_pays     AS gp1 ON (gp1.a2 = u.nationalite)
-            LEFT JOIN  geoloc_pays     AS gp2 ON (gp2.a2 = u.nationalite2)
-            LEFT JOIN  geoloc_pays     AS gp3 ON (gp3.a2 = u.nationalite3)
-           INNER JOIN  sections        AS s   ON (s.id  = u.section)
-            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)
+                 FROM  auth_user_md5         AS u
+           INNER JOIN  auth_user_quick       AS q   USING(user_id)
+           INNER JOIN  aliases               AS a   ON (u.user_id = a.id AND a.type = 'a_vie')
+           INNER JOIN  aliases               AS a2  ON (u.user_id = a2.id AND FIND_IN_SET('bestalias', a2.flags))
+            LEFT JOIN  contacts              AS c   ON (c.uid = {?} and c.contact = u.user_id)
+            LEFT JOIN  profile_corps         AS co  ON (co.uid = u.user_id)
+            LEFT JOIN  geoloc_pays           AS gp1 ON (gp1.a2 = u.nationalite)
+            LEFT JOIN  geoloc_pays           AS gp2 ON (gp2.a2 = u.nationalite2)
+            LEFT JOIN  geoloc_pays           AS gp3 ON (gp3.a2 = u.nationalite3)
+           INNER JOIN  sections              AS s   ON (s.id  = u.section)
+            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)
+           INNER JOIN  profile_display       AS d   ON (d.uid = u.user_id)
                 WHERE  a.alias = {?}
              GROUP BY  u.user_id";
     $res  = XDB::query($reqsql, $from_uid, $login);
@@ -292,7 +293,6 @@ function &get_user_details($login, $from_uid = '', $view = 'private')
     $uid  = $user['user_id'];
     // hide orange status, cv, nickname, section
     if (!has_user_right('private', $view)) {
-        $user['promo_sortie'] = $user['promo'] + 3;
         $user['cv'] = '';
         $user['nickname'] = '';
         $user['section'] = '';
index 7bbb1f8..c7d09f4 100644 (file)
@@ -171,8 +171,7 @@ class MinificheView extends MultipageView
     public function fields()
     {
         global $globals;
-        return "u.user_id AS id, u.*,
-                CONCAT(a.alias, '@{$globals->mail->domain}') AS bestemail,
+        return "u.user_id AS id, u.*, d.promo_display,
                 u.perms != 'pending' AS inscrit,
                 u.perms != 'pending' AS wasinscrit,
                 u.deces != 0 AS dcd, u.deces, u.matricule_ax,
@@ -229,9 +228,9 @@ 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)" .
-                (S::logged() ?
-                "LEFT JOIN  contacts                      AS c   ON (c.contact = u.user_id AND c.uid = " . S::v('uid') . ")"
+                INNER JOIN  profile_names_display         AS nd   ON (nd.user_id = u.user_id)
+                INNER JOIN  profile_display               AS d    ON (d.uid = u.user_id)" . (S::logged() ?
+                "LEFT JOIN  contacts                      AS c    ON (c.contact = u.user_id AND c.uid = " . S::v('uid') . ")"
                  : "");
     }
 
@@ -272,14 +271,15 @@ class MentorView extends MultipageView
 
     public function fields()
     {
-        return "m.uid, u.promo, u.hruid,
+        return "m.uid, d.promo_display, u.hruid,
                 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)";
+        return "INNER JOIN  profile_names_display AS nd ON (nd.user_id = u.user_id)
+                INNER JOIN  profile_display       AS d  ON (d.uid = u.user_id)";
     }
 
     public function bounds()
@@ -321,12 +321,13 @@ class TrombiView extends MultipageView
 
     public function fields()
     {
-        return "u.user_id, nd.display AS name_display, nd.tooltip AS name_tooltip, nd.sort AS name_sort, u.promo, u.hruid ";
+        return "u.user_id, nd.display AS name_display, nd.tooltip AS name_tooltip, nd.sort AS name_sort, u.promo, d.promo_display, u.hruid ";
     }
 
     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_display       AS d  ON (d.uid = u.user_id)
                 INNER JOIN  profile_names_display AS nd ON (nd.user_id = u.user_id)";
     }
 
@@ -421,11 +422,12 @@ class GeolocView implements PlView
             header('Content-Type: text/xml');
             header('Pragma:');
             $only_current = Env::v('only_current', false)? ' AND FIND_IN_SET(\'active\', adrf.statut)' : '';
-            $it =& $this->set->get('u.user_id AS id, u.prenom, u.nom, u.promo, al.alias',
-                                   "INNER JOIN  adresses AS adrf  ON (adrf.uid = u.user_id $only_current)
-                                     LEFT JOIN  aliases  AS al   ON (u.user_id = al.id
-                                                                   AND FIND_IN_SET('bestalias', al.flags))
-                                    INNER JOIN  adresses AS avg ON (" . getadr_join('avg') . ")",
+            $it =& $this->set->get('u.user_id AS id, u.prenom, u.nom, d.promo_display, al.alias',
+                                   "INNER JOIN  adresses        AS adrf ON (adrf.uid = u.user_id $only_current)
+                                    INNER JOIN  profile_display AS d    ON (d.uid = u.user_id)
+                                     LEFT JOIN  aliases         AS al   ON (u.user_id = al.id
+                                                                            AND FIND_IN_SET('bestalias', al.flags))
+                                    INNER JOIN  adresses        AS avg  ON (" . getadr_join('avg') . ")",
                                    'adrf.cityid = ' . Env::i('cityid'), null, null, 11);
             $page->assign('users', $it);
             break;
index 734a407..4cefdbe 100644 (file)
@@ -85,6 +85,10 @@ abstract class Validate
         $this->stamp  = date('YmdHis');
         $this->unique = $_unique;
         $this->type   = $_type;
+        $res = XDB::query("SELECT  promo_display AS promo
+                             FROM  profile_display
+                            WHERE  uid={?}", $_uid);
+        $this->promo = $res->fetchOneCell();
     }
 
     // }}}
index 2cd3918..3b960d0 100644 (file)
@@ -29,8 +29,8 @@ class OrangeReq extends Validate
 
     public $promo_sortie;
 
-    public $rules = "A priori accepter (la validation sert à repousser les
-    petits malins). Refuse si tu connais la personne et que tu es sure
+    public $rules = "À priori accepter (la validation sert à repousser les
+    petits malins). Refuse si tu connais la personne et que tu es sûr
     qu'elle n'est pas orange.";
 
     // }}}
@@ -40,7 +40,10 @@ class OrangeReq extends Validate
     {
         parent::__construct($_user, true, 'orange');
         $this->promo_sortie  = $_sortie;
-        $res = XDB::query("SELECT promo FROM auth_user_md5 WHERE user_id = {?}", $_user->id());
+        $res = XDB::query("SELECT  entry_year
+                             FROM  profile_education
+                            WHERE  uid = {?} AND FIND_IN_SET('primary', flags)", $_uid);
+        $this->promo = $res->fetchOneCell();
     }
 
     // }}}
@@ -65,10 +68,11 @@ class OrangeReq extends Validate
     protected function _mail_body($isok)
     {
         if ($isok) {
-            $res = "  La demande de changement de promo de sortie que tu as demandée vient d'être effectuée.";
-            return $res;
+            return "  La demande de changement de promotion de sortie que tu as demandée vient d'être effectuée. "
+                   . "Si tu le souhaites, tu peux maintenant modifier l'affichage de ta promotion sur le site sur la page suivante : "
+                   . "https://www.polytechnique.org/profile/edit";
         } else {
-            return "  La demande de changement de promo de sortie tu avais faite a été refusée.";
+            return "  La demande de changement de promotion de sortie tu avais faite a été refusée.";
         }
     }
 
@@ -77,7 +81,9 @@ class OrangeReq extends Validate
 
     public function commit()
     {
-        XDB::execute("UPDATE auth_user_md5 set promo_sortie = {?} WHERE user_id = {?}",$this->promo_sortie, $this->user->id());
+        XDB::execute("UPDATE  profile_education
+                         SET  grad_year = {?}
+                       WHERE  uid = {?} AND FIND_IN_SET('primary', flags)", $this->promo_sortie, $this->uid);
         return true;
     }
 
index a9eddc6..6d42c02 100644 (file)
@@ -714,7 +714,7 @@ class AdminModule extends PLModule
                 $action = Env::v('valid_promo') == 'Ajouter des membres' ? 'add' : 'ax';
                 pl_redirect('admin/promo/' . $action . '/' . Env::i('promo'));
             } else {
-                $page->trigError('Promo non valide');
+                $page->trigError('Promotion non valide.');
             }
         }
 
index 33f1c6d..4a106e1 100644 (file)
@@ -159,16 +159,17 @@ class EventsModule extends PLModule
 
         // Fetch the events to display, along with their metadata.
         $array = array();
-        $it = XDB::iterator("SELECT  e.id,e.titre,e.texte,e.post_id,a.user_id,a.nom,a.prenom,a.promo,a.hruid,
+        $it = XDB::iterator("SELECT  e.id, e.titre, e.texte, e.post_id, a.user_id, a.nom, a.prenom, d.promo_display ,a.hruid,
                                      p.x, p.y, p.attach IS NOT NULL AS img, FIND_IN_SET('wiki', e.flags) AS wiki,
                                      FIND_IN_SET('important', e.flags) AS important,
                                      e.creation_date > DATE_SUB(CURDATE(), INTERVAL 2 DAY) AS news,
                                      e.peremption < DATE_ADD(CURDATE(), INTERVAL 2 DAY) AS end,
                                      ev.user_id IS NULL AS nonlu
                                FROM  evenements       AS e
-                          LEFT JOIN  evenements_photo AS p ON (e.id = p.eid)
-                         INNER JOIN  auth_user_md5    AS a ON e.user_id=a.user_id
-                          LEFT JOIN  evenements_vus AS ev ON (e.id = ev.evt_id AND ev.user_id = {?})
+                          LEFT JOIN  evenements_photo AS p  ON (e.id = p.eid)
+                         INNER JOIN  auth_user_md5    AS a  ON (e.user_id = a.user_id)
+                         INNER JOIN  profile_display  AS d  ON (d.uid = a.user_id)
+                          LEFT JOIN  evenements_vus   AS ev ON (e.id = ev.evt_id AND ev.user_id = {?})
                               WHERE  FIND_IN_SET('valide', e.flags) AND peremption >= NOW()
                                      AND (e.promo_min = 0 || e.promo_min <= {?})
                                      AND (e.promo_max = 0 || e.promo_max >= {?})
index f0b6b1b..ac42c04 100644 (file)
@@ -517,14 +517,17 @@ class ProfileModule extends PLModule
 
         require_once 'validations.inc.php';
 
-        $res = XDB::query(
-                "SELECT  u.promo, u.promo_sortie
-                   FROM  auth_user_md5  AS u
-                  WHERE  user_id={?}", S::v('uid'));
+        $res = XDB::query("SELECT  e.entry_year, e.grad_year, d.promo_display, FIND_IN_SET('femme', u.flags) AS sexe
+                             FROM  auth_user_md5     AS u
+                       INNER JOIN  profile_display   AS d ON (d.uid = u.user_id)
+                       INNER JOIN  profile_education AS e ON (e.uid = u.user_id AND FIND_IN_SET('primary', e.flags))
+                            WHERE  u.user_id = {?}", S::v('uid'));
 
-        list($promo, $promo_sortie_old) = $res->fetchOneRow();
+        list($promo, $promo_sortie_old, $promo_display, $sexe) = $res->fetchOneRow();
         $page->assign('promo_sortie_old', $promo_sortie_old);
-        $page->assign('promo',  $promo);
+        $page->assign('promo', $promo);
+        $page->assign('promo_display', $promo_display);
+        $page->assign('sexe', $sexe);
 
         if (!Env::has('promo_sortie')) {
             return;
@@ -535,18 +538,18 @@ class ProfileModule extends PLModule
         $promo_sortie = Env::i('promo_sortie');
 
         if ($promo_sortie < 1000 || $promo_sortie > 9999) {
-            $page->trigError('L\'année de sortie doit être un nombre de quatre chiffres');
+            $page->trigError('L\'année de sortie doit être un nombre de quatre chiffres.');
         }
         elseif ($promo_sortie < $promo + 3) {
-            $page->trigError('Trop tôt');
+            $page->trigError('Trop tôt !');
         }
         elseif ($promo_sortie == $promo_sortie_old) {
             $page->trigWarning('Tu appartiens déjà à la promotion correspondante à cette année de sortie.');
         }
         elseif ($promo_sortie == $promo + 3) {
-            XDB::execute(
-                "UPDATE  auth_user_md5 set promo_sortie={?}
-                  WHERE  user_id={?}", $promo_sortie, S::v('uid'));
+            XDB::execute("UPDATE  profile_education
+                             SET  grad_year = {?}
+                           WHERE  uid = {?} AND FIND_IN_SET('primary', flags)", $promo_sortie, S::v('uid'));
                 $page->trigSuccess('Ton statut "orange" a été supprimé.');
                 $page->assign('promo_sortie_old', $promo_sortie);
         }
index 59ed455..7620240 100644 (file)
@@ -102,7 +102,7 @@ class ProfileEdu implements ProfileSetting
             $value = array();
             $res = XDB::iterator("SELECT  eduid, degreeid, fieldid, grad_year, program
                                     FROM  profile_education
-                                   WHERE  uid = {?}
+                                   WHERE  uid = {?} AND !FIND_IN_SET('primary', flags)
                                 ORDER BY  id",
                                  S::v('uid'));
             while($edu = $res->next()) {
@@ -130,7 +130,7 @@ class ProfileEdu implements ProfileSetting
     public function save(ProfilePage &$page, $field, $value)
     {
         XDB::execute("DELETE FROM  profile_education
-                            WHERE  uid = {?}",
+                            WHERE  uid = {?} AND !FIND_IN_SET('primary', flags)",
                      S::i('uid'));
         foreach ($value as $eduid=>&$edu) {
             if ($edu['eduid'] != '') {
@@ -278,6 +278,7 @@ class ProfileGeneral extends ProfilePage
                                   = $this->settings['display_name']
                                   = $this->settings['sort_name']
                                   = $this->settings['tooltip_name']
+                                  = $this->settings['promo_display']
                                   = null;
         $this->settings['synchro_ax']
                                   = new ProfileBool();
@@ -297,8 +298,8 @@ class ProfileGeneral extends ProfilePage
     protected function _fetchData()
     {
         // Checkout all data...
-        $res = XDB::query("SELECT  u.promo, u.promo_sortie, u.nom_usage, u.nationalite,
-                                   u.nationalite2, u.nationalite3, u.naissance,
+        $res = XDB::query("SELECT  p.promo_display, e.entry_year AS entry_year, e.grad_year AS grad_year,
+                                   u.nom_usage, u.nationalite, u.nationalite2, u.nationalite3, u.naissance,
                                    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,
@@ -306,10 +307,12 @@ class ProfileGeneral extends ProfilePage
                                    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)
+                       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)
+                       INNER JOIN  profile_display       AS p ON (p.uid = u.user_id)
+                       INNER JOIN  profile_education     AS e ON (e.uid = u.user_id AND FIND_IN_SET('primary', e.flags))
+                        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)
                             WHERE  u.user_id = {?}", S::v('uid', -1));
         $this->values = $res->fetchOneAssoc();
 
@@ -340,6 +343,13 @@ class ProfileGeneral extends ProfilePage
                             ORDER BY t.tel_id",
                              S::v('uid'));
         $this->values['tels'] = $res->fetchAllAssoc();
+
+        // Proposes choice for promo_display
+        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;
+            }
+        }
     }
 
     protected function _saveData()
@@ -359,13 +369,13 @@ class ProfileGeneral extends ProfilePage
                 $this->values['nationalite3'] = NULL;
             }
 
-           XDB::execute("UPDATE  auth_user_md5
-                            SET  nationalite = {?}, nationalite2 = {?}, nationalite3 = {?}, nom={?}, prenom={?}, naissance={?}
-                          WHERE  user_id = {?}",
-                         $this->values['nationalite'], $this->values['nationalite2'], $this->values['nationalite3'],
-                         $this->values['nom'], $this->values['prenom'],
-                         preg_replace('@(\d{2})/(\d{2})/(\d{4})@', '\3-\2-\1', $this->values['naissance']),
-                         S::v('uid'));
+            XDB::execute("UPDATE  auth_user_md5
+                             SET  nationalite = {?}, nationalite2 = {?}, nationalite3 = {?}, nom={?}, prenom={?}, naissance={?}
+                           WHERE  user_id = {?}",
+                          $this->values['nationalite'], $this->values['nationalite2'], $this->values['nationalite3'],
+                          $this->values['nom'], $this->values['prenom'],
+                          preg_replace('@(\d{2})/(\d{2})/(\d{4})@', '\3-\2-\1', $this->values['naissance']),
+                          S::v('uid'));
         }
         if ($this->changed['nick'] || $this->changed['freetext'] || $this->changed['freetext_pub'] || $this->changed['synchro_ax']) {
             XDB::execute("UPDATE  auth_user_quick
@@ -399,17 +409,23 @@ class ProfileGeneral extends ProfilePage
         }
         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'));
+            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'));
+        }
+        if ($this->changed['promo_display']) {
+            XDB::execute("UPDATE  profile_display
+                             SET  promo_display = {?}
+                           WHERE  uid = {?}",
+                         $this->values['promo_display'], S::v('uid'));
         }
     }
 
index 11b4608..2185957 100644 (file)
@@ -244,7 +244,7 @@ Bienvenue {$smarty.session.yourself_name}{if $birthday}
         </div>
         Annonce proposée par
         <a href="profile/{$ev.hruid}" class="popup2">
-          {$ev.prenom} {$ev.nom} X{$ev.promo}
+          {$ev.prenom} {$ev.nom} {$ev.promo_display}
         </a>
       </td>
     </tr>
index 54aeb9b..5fc6f95 100644 (file)
@@ -47,7 +47,7 @@
       {if $c.iso3166_3}
       <img src='images/flags/{$c.iso3166_3}.gif' alt='{$c.nat3}' height='11' title='{$c.nat3}' />&nbsp;
       {/if}
-      X {$c.promo}{if $c.eduname0}, {education_fmt name=$c.eduname0 url=$c.eduurl0 degree=$c.edudegree0
+      {$c.promo_display}{if $c.eduname0}, {education_fmt name=$c.eduname0 url=$c.eduurl0 degree=$c.edudegree0
                                      grad_year=$c.edugrad_year0 field=$c.edufield0 program=$c.eduprogram0 sexe=$c.sexe}{*
       *}{/if}{if $c.eduname1}, {education_fmt name=$c.eduname1 url=$c.eduurl1 degree=$c.edudegree1
                                      grad_year=$c.edugrad_year1 field=$c.edufield1 program=$c.eduprogram1 sexe=$c.sexe}{*
index 6e5d547..d1253a6 100644 (file)
@@ -27,7 +27,7 @@
       <span {if $p.name_tooltip}class="hinted" title="{$p.name_tooltip}"{/if}>{$p.name_display}</span>
     </div> 
     <div class="edu"> 
-      X{$p.promo
+      {$p.promo_display
     </div> 
     <div class="bits" style="width: 40%;"> 
       <span class='smaller'> 
index 7bd988c..730e499 100644 (file)
   <tr>
     <td class="center" style="vertical-align: bottom; padding-bottom: 15px">
       <a href="{$mainsiteurl}profile/{$set[trombi.index_prev].hruid}" class="popup2">
-        <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}
+        <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_display}){/if}
       </a>
     </td>
     <td class="center" style="vertical-align: bottom; padding-bottom: 15px">
       <a href="{$mainsiteurl}profile/{$set[trombi].hruid}" class="popup2">
-        <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}
+        <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_display}){/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].hruid}" class="popup2">
-        <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}
+        <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_display}){/if}
       </a>
     {/if}
     </td>
@@ -90,7 +91,8 @@
   <tr style="margin-top: 0; padding-top: 0">
     <td class="center" style="vertical-align: bottom">
       <a href="{$mainsiteurl}profile/{$set[trombi].hruid}" class="popup2">
-        <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 href="{$mainsiteurl}profile/{$set[trombi].forlife}" class="popup2">
+        <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_display}){/if}
       </a>
     </td>
     <td></td><td></td>
index 88a8c83..f5ababa 100644 (file)
@@ -37,7 +37,7 @@
       {/if}
       <br />
       <a href="{if $urlmainsite}{$urlmainsite}{/if}profile/{$p.forlife}" class="popup2">
-        <span {if $p.name_tooltip}class="hinted" title="{$p.name_tooltip}"{/if}>{$p.name_display}</span>{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_display}){/if}
       </a>
     </td>
   {if $loop eq "3"}
index 2d05eea..ca61ca1 100644 (file)
       <span class="titre">Promotion</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" {if ($promo_sortie -3 == $promo)} {popup text="pour les oranges"}{/if}>{icon name="page_edit" title="modifier"}</a></span>
+      {if !$promo_choice}
+        <span class="nom">{$promo_display}</span>
+      {else}
+        <select name="promo_display">
+        {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>
+        {/foreach}
+        </select>
+      {/if}
+      <span class="lien"><a href="profile/orange" {if ($grad_year -3 == $entry_year)} {popup text="pour les oranges"}{/if}>{icon name="page_edit" title="modifier"}</a></span>
     </td>
   </tr>
   <tr>
index 52bc047..bf54ca1 100644 (file)
 {else}
 
 <p>
-  Afin de pouvoir être considéré(e) à la fois dans ta promotion d'origine et ta
+  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 (X{$promo}) il s'agit de l'année {math equation="a + b" a=$promo b=3}.
+  Pour tes cocons d'origine ({$promo_display}) il s'agit de l'année {math equation="a + b" a=$promo b=3}.
 </p>
 
 <br />
index 2ebcb43..405e3af 100644 (file)
@@ -140,13 +140,10 @@ function chgMainWinLoc(strPage)
       {if $x.iso3166_3}
       <img src='images/flags/{$x.iso3166_3}.gif' alt='{$x.nationalite3}' height='11' title='{$x.nationalite3}' />&nbsp;
       {/if}
-      {$user->promo()}
-      {if $x.promo_sortie && ($x.promo_sortie-3 > $x.promo)}
-        - X {math equation="a-b" a=$x.promo_sortie b=3}
+      {$user->promo()}
+      {if $logged && $x.is_referent}
+      [<a href="referent/{$x.forlife}" class='popup2'>Ma fiche référent</a>]
       {/if}
-        {if $logged && $x.is_referent}
-        [<a href="referent/{$user->login()}" class='popup2'>Ma fiche référent</a>]
-        {/if}
       {if $x.education}
         &nbsp;-&nbsp;Formation&nbsp;:
         <ul>
index 42d3ac6..be4f85e 100644 (file)
@@ -33,7 +33,7 @@ CREATE TABLE IF NOT EXISTS profile_education_enum (
 ) CHARSET=utf8;
 
 CREATE TABLE IF NOT EXISTS profile_education (
-  id INT(2) NOT NULL DEFAULT 0,
+  id TINYINT(2) UNSIGNED NOT NULL DEFAULT 0,
   uid INT(11) NOT NULL DEFAULT 0,
   eduid INT(4) NOT NULL DEFAULT 0,
   degreeid INT(4) NOT NULL DEFAULT 0,
diff --git a/upgrade/newdirectory-0.0.1/10_promotion.sql b/upgrade/newdirectory-0.0.1/10_promotion.sql
new file mode 100644 (file)
index 0000000..fb3b7b5
--- /dev/null
@@ -0,0 +1,16 @@
+INSERT INTO  profile_education (id, uid, grad_year, entry_year, eduid, degreeid, flags)
+     SELECT  100, user_id, promo_sortie, promo, 20, 2, 'primary'
+       FROM  auth_user_md5;
+
+CREATE TABLE  profile_display (
+  uid INT(11) NOT NULL DEFAULT 0,
+  promo_display VARCHAR(255) DEFAULT '' NOT NULL,
+  PRIMARY KEY(uid)
+) CHARSET=utf8;
+
+INSERT IGNORE INTO  profile_display (uid, promo_display)
+            SELECT  uid, CONCAT("X", entry_year)
+              FROM  profile_education
+             WHERE  FIND_IN_SET('primary', flags);
+
+-- vim:set syntax=mysql: