From fb2c09c9676d912c90a77135610f4cfe8c339f6b Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Mon, 13 Oct 2008 17:55:21 +0200 Subject: [PATCH] Displayed promotion is now linked to the primery education. --- classes/user.php | 3 +- include/user.func.inc.php | 32 +++++++------- include/userset.inc.php | 30 +++++++------ include/validations.inc.php | 4 ++ include/validations/orange.inc.php | 20 ++++++--- modules/admin.php | 2 +- modules/events.php | 9 ++-- modules/profile.php | 25 ++++++----- modules/profile/general.inc.php | 68 ++++++++++++++++++----------- templates/events/index.tpl | 2 +- templates/include/minifiche.tpl | 2 +- templates/include/plview.referent.tpl | 2 +- templates/include/plview.trombi.tpl | 10 +++-- templates/include/trombi.tpl | 2 +- templates/profile/general.tpl | 12 ++++- templates/profile/orange.tpl | 4 +- templates/profile/profile.tpl | 9 ++-- upgrade/newdirectory-0.0.1/06_education.sql | 2 +- upgrade/newdirectory-0.0.1/10_promotion.sql | 16 +++++++ 19 files changed, 155 insertions(+), 99 deletions(-) create mode 100644 upgrade/newdirectory-0.0.1/10_promotion.sql diff --git a/classes/user.php b/classes/user.php index eb112ca..e7c7472 100644 --- a/classes/user.php +++ b/classes/user.php @@ -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)) diff --git a/include/user.func.inc.php b/include/user.func.inc.php index 104dd64..549d811 100644 --- a/include/user.func.inc.php +++ b/include/user.func.inc.php @@ -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'] = ''; diff --git a/include/userset.inc.php b/include/userset.inc.php index 7bbb1f8..c7d09f4 100644 --- a/include/userset.inc.php +++ b/include/userset.inc.php @@ -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; diff --git a/include/validations.inc.php b/include/validations.inc.php index 734a407..4cefdbe 100644 --- a/include/validations.inc.php +++ b/include/validations.inc.php @@ -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(); } // }}} diff --git a/include/validations/orange.inc.php b/include/validations/orange.inc.php index 2cd3918..3b960d0 100644 --- a/include/validations/orange.inc.php +++ b/include/validations/orange.inc.php @@ -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; } diff --git a/modules/admin.php b/modules/admin.php index a9eddc6..6d42c02 100644 --- a/modules/admin.php +++ b/modules/admin.php @@ -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.'); } } diff --git a/modules/events.php b/modules/events.php index 33f1c6d..4a106e1 100644 --- a/modules/events.php +++ b/modules/events.php @@ -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 >= {?}) diff --git a/modules/profile.php b/modules/profile.php index f0b6b1b..ac42c04 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -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); } diff --git a/modules/profile/general.inc.php b/modules/profile/general.inc.php index 59ed455..7620240 100644 --- a/modules/profile/general.inc.php +++ b/modules/profile/general.inc.php @@ -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')); } } diff --git a/templates/events/index.tpl b/templates/events/index.tpl index 11b4608..2185957 100644 --- a/templates/events/index.tpl +++ b/templates/events/index.tpl @@ -244,7 +244,7 @@ Bienvenue {$smarty.session.yourself_name}{if $birthday} Annonce proposée par - {$ev.prenom} {$ev.nom} X{$ev.promo} + {$ev.prenom} {$ev.nom} {$ev.promo_display} diff --git a/templates/include/minifiche.tpl b/templates/include/minifiche.tpl index 54aeb9b..5fc6f95 100644 --- a/templates/include/minifiche.tpl +++ b/templates/include/minifiche.tpl @@ -47,7 +47,7 @@ {if $c.iso3166_3} {$c.nat3}  {/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}{* diff --git a/templates/include/plview.referent.tpl b/templates/include/plview.referent.tpl index 6e5d547..d1253a6 100644 --- a/templates/include/plview.referent.tpl +++ b/templates/include/plview.referent.tpl @@ -27,7 +27,7 @@ {$p.name_display}
- X{$p.promo} + {$p.promo_display}
diff --git a/templates/include/plview.trombi.tpl b/templates/include/plview.trombi.tpl index 7bd988c..730e499 100644 --- a/templates/include/plview.trombi.tpl +++ b/templates/include/plview.trombi.tpl @@ -59,18 +59,19 @@ - {$set[trombi.index_prev].name_display}{if $trombi_with_promo} ({$set[trombi.index_prev].promo}){/if} + {$set[trombi.index_prev].name_display}{if $trombi_with_promo} ({$set[trombi.index_prev].promo_display}){/if} - {$set[trombi].name_display}{if $trombi_with_promo} ({$set[trombi].promo}){/if} + {$set[trombi].name_display}{if $trombi_with_promo} ({$set[trombi].promo_display}){/if} {if $set[trombi.index_next]} - {$set[trombi.index_next].name_display}{if $trombi_with_promo} ({$set[trombi.index_next].promo}){/if} + {$set[trombi.index_next].name_display}{if $trombi_with_promo} ({$set[trombi.index_next].promo_display}){/if} {/if} @@ -90,7 +91,8 @@ - {$set[trombi].name_display}{if $trombi_with_promo} ({$set[trombi].promo}){/if} + + {$set[trombi].name_display}{if $trombi_with_promo} ({$set[trombi].promo_display}){/if} diff --git a/templates/include/trombi.tpl b/templates/include/trombi.tpl index 88a8c83..f5ababa 100644 --- a/templates/include/trombi.tpl +++ b/templates/include/trombi.tpl @@ -37,7 +37,7 @@ {/if}
- {$p.name_display}{if $trombi_show_promo} ({$p.promo}){/if} + {$p.name_display}{if $trombi_show_promo} ({$p.promo_display}){/if} {if $loop eq "3"} diff --git a/templates/profile/general.tpl b/templates/profile/general.tpl index 2d05eea..ca61ca1 100644 --- a/templates/profile/general.tpl +++ b/templates/profile/general.tpl @@ -65,8 +65,16 @@ Promotion - X{$promo}{if ($promo != $promo_sortie - 3)} - X{math equation="a - b" a=$promo_sortie b=3}{/if} - {icon name="page_edit" title="modifier"} + {if !$promo_choice} + {$promo_display} + {else} + + {/if} + {icon name="page_edit" title="modifier"} diff --git a/templates/profile/orange.tpl b/templates/profile/orange.tpl index 52bc047..bf54ca1 100644 --- a/templates/profile/orange.tpl +++ b/templates/profile/orange.tpl @@ -32,10 +32,10 @@ {else}

- 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}.


diff --git a/templates/profile/profile.tpl b/templates/profile/profile.tpl index 2ebcb43..405e3af 100644 --- a/templates/profile/profile.tpl +++ b/templates/profile/profile.tpl @@ -140,13 +140,10 @@ function chgMainWinLoc(strPage) {if $x.iso3166_3} {$x.nationalite3}  {/if} - X {$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} + [Ma fiche référent] {/if} - {if $logged && $x.is_referent} - [Ma fiche référent] - {/if} {if $x.education}  - Formation :
    diff --git a/upgrade/newdirectory-0.0.1/06_education.sql b/upgrade/newdirectory-0.0.1/06_education.sql index 42d3ac6..be4f85e 100644 --- a/upgrade/newdirectory-0.0.1/06_education.sql +++ b/upgrade/newdirectory-0.0.1/06_education.sql @@ -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 index 0000000..fb3b7b5 --- /dev/null +++ b/upgrade/newdirectory-0.0.1/10_promotion.sql @@ -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: -- 2.1.4