From 89aba52d37cf54d60000b01079810360b9796481 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Mon, 24 Oct 2011 15:03:56 +0200 Subject: [PATCH] Adds title to profiles. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Jacob --- include/userset.inc.php | 4 ++-- modules/admin.php | 8 +++++--- modules/fusionax/Anciens.sql | 3 ++- modules/profile/general.inc.php | 11 +++++++---- templates/profile/general.tpl | 10 ++++++++++ upgrade/1.0.1/merge.php | 5 +++++ upgrade/1.1.4/09_title.sql | 3 +++ 7 files changed, 34 insertions(+), 10 deletions(-) create mode 100644 upgrade/1.1.4/09_title.sql diff --git a/include/userset.inc.php b/include/userset.inc.php index 56244d2..ab02377 100644 --- a/include/userset.inc.php +++ b/include/userset.inc.php @@ -428,9 +428,9 @@ class AddressesView implements PlView pl_cached_content_headers('text/x-csv', 'iso-8859-1', 1, 'adresses.csv'); $csv = fopen('php://output', 'w'); - fputcsv($csv, array('PROMOTION', 'TITRE', 'NOM', 'SOCIETE', 'ADRESSE', 'EMAIL'), ';'); + fputcsv($csv, array('PROMOTION', 'CIVILITE', 'NOM', 'SOCIETE', 'ADRESSE', 'EMAIL'), ';'); if (!empty($pids)) { - $res = XDB::query("SELECT pd.promo, IF(p.sex = 'female', 'Mme', 'M'), pd.short_name, pje.name, + $res = XDB::query("SELECT pd.promo, p.title, pd.short_name, pje.name, pa.postalText, p.email_directory FROM profile_addresses AS pa INNER JOIN profiles AS p ON (pa.pid = p.pid) diff --git a/modules/admin.php b/modules/admin.php index 9cf5e24..a2d5d59 100644 --- a/modules/admin.php +++ b/modules/admin.php @@ -815,6 +815,7 @@ class AdminModule extends PLModule $page->changeTpl('admin/add_accounts.tpl'); if (Env::has('add_type') && Env::has('people')) { + static $titles = array('male' => 'M', 'female' => 'MLLE'); $lines = explode("\n", Env::t('people')); $separator = Env::t('separator'); $promotion = Env::i('promotion'); @@ -873,9 +874,10 @@ class AdminModule extends PLModule continue; } - XDB::execute('INSERT INTO profiles (hrpid, xorg_id, ax_id, birthdate_ref, sex) - VALUES ({?}, {?}, {?}, {?}, {?})', - $infos['hrid'], $xorgId, (isset($infos[5]) ? $infos[5] : null), $birthDate, $sex); + XDB::execute('INSERT INTO profiles (hrpid, xorg_id, ax_id, birthdate_ref, sex, title) + VALUES ({?}, {?}, {?}, {?}, {?}, {?})', + $infos['hrid'], $xorgId, (isset($infos[5]) ? $infos[5] : null), + $birthDate, $sex, $titles[$sex]); $pid = XDB::insertId(); XDB::execute('INSERT INTO profile_public_names (pid, lastname_initial, lastname_main, firstname_initial, firstname_main) VALUES ({?}, {?}, {?}, {?}, {?})', diff --git a/modules/fusionax/Anciens.sql b/modules/fusionax/Anciens.sql index 0501616..52aa274 100644 --- a/modules/fusionax/Anciens.sql +++ b/modules/fusionax/Anciens.sql @@ -13,6 +13,7 @@ CREATE TABLE IF NOT EXISTS fusionax_anciens ( Nom_usuel VARCHAR(255) NOT NULL COMMENT 'Nom usuel (nom marital par exemple) sans la particule', partic_nom VARCHAR(5) NOT NULL COMMENT 'Particule du nom usuel', Nom_complet VARCHAR(255) NOT NULL COMMENT 'Nom patronymique complet (avec la particule)', + Civilité ENUM('M', 'MLLE', 'MME') NOT NULL DEFAULT 'M', Code_nationalite CHAR(4) NOT NULL COMMENT 'Nationalité (code)', corps_sortie VARCHAR(50) NOT NULL COMMENT 'Corps de sortie (ou D si aucun)', Date_deces DATE COMMENT 'Date de décès', @@ -29,7 +30,7 @@ CREATE TABLE IF NOT EXISTS fusionax_anciens ( LOAD DATA LOCAL INFILE '{?}Anciens.txt' INTO TABLE `fusionax_anciens` CHARACTER SET utf8 FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r\n' (AN, ax_id, @login, @password, promotion_etude, groupe_promo, Nom_patronymique, partic_patro, prenom, Nom_usuel, partic_nom, - Nom_complet, @civilite, Code_nationalite, @type, corps_sortie, @StringDate_deces, grade, Mel_usage, Mel_publiable, @xxx, Mob_publiable, + Nom_complet, Civilite, Code_nationalite, @type, corps_sortie, @StringDate_deces, grade, Mel_usage, Mel_publiable, @xxx, Mob_publiable, tel_mobile, @xxx, @xxx, @xxx, @xxx, @xxx, @xxx, @xxx, @X_M_D, @xxx, @xxx, @xxx, @xxx, @xxx, @xxx, @Type_adr, @Ligne1, @Ligne2, @Ligne3, @code_postal, @ville, @zip_cedex, @etat_distr, @pays, @tel, @fax, @StringDate_maj) SET diff --git a/modules/profile/general.inc.php b/modules/profile/general.inc.php index dc9058d..f382e7b 100644 --- a/modules/profile/general.inc.php +++ b/modules/profile/general.inc.php @@ -633,6 +633,7 @@ class ProfilePageGeneral extends ProfilePage $this->settings['nationality1'] = $this->settings['nationality2'] = $this->settings['nationality3'] = $this->settings['promo_display'] + = $this->settings['profile_title'] = null; $this->settings['email_directory'] = new ProfileSettingEmail(); $this->settings['email_directory_new'] = new ProfileSettingEmailDirectory(); @@ -673,7 +674,8 @@ class ProfilePageGeneral extends ProfilePage $res = XDB::query("SELECT p.nationality1, p.nationality2, p.nationality3, IF(p.birthdate = 0, '', p.birthdate) AS birthdate, p.email_directory as email_directory, pd.promo AS promo_display, p.freetext, p.freetext_pub, p.ax_id AS matricule_ax, pd.yourself, - p.deathdate, IF(p.birthdate_ref = 0, '', p.birthdate_ref) AS birthdate_ref + p.deathdate, IF(p.birthdate_ref = 0, '', p.birthdate_ref) AS birthdate_ref, + p.title AS profile_title FROM profiles AS p INNER JOIN profile_display AS pd ON (pd.pid = p.pid) WHERE p.pid = {?}", $this->pid()); @@ -704,7 +706,7 @@ class ProfilePageGeneral extends ProfilePage { if ($this->changed['nationality1'] || $this->changed['nationality2'] || $this->changed['nationality3'] || $this->changed['birthdate'] || $this->changed['freetext'] || $this->changed['freetext_pub'] - || $this->changed['email_directory']) { + || $this->changed['email_directory'] || $this->changed['profile_title']) { if ($this->values['nationality3'] == "") { $this->values['nationality3'] = NULL; } @@ -737,11 +739,12 @@ class ProfilePageGeneral extends ProfilePage XDB::execute("UPDATE profiles SET nationality1 = {?}, nationality2 = {?}, nationality3 = {?}, birthdate = {?}, - freetext = {?}, freetext_pub = {?}, email_directory = {?} + freetext = {?}, freetext_pub = {?}, email_directory = {?}, title = {?} WHERE pid = {?}", $this->values['nationality1'], $this->values['nationality2'], $this->values['nationality3'], ProfileSettingDate::toSQLDate($this->values['birthdate']), - $this->values['freetext'], $this->values['freetext_pub'], $new_email, $this->pid()); + $this->values['freetext'], $this->values['freetext_pub'], $new_email, + $this->values['profile_title'], $this->pid()); } if ($this->changed['photo_pub']) { XDB::execute("UPDATE profile_photos diff --git a/templates/profile/general.tpl b/templates/profile/general.tpl index 8a04c66..7e31c5d 100644 --- a/templates/profile/general.tpl +++ b/templates/profile/general.tpl @@ -189,6 +189,16 @@ {icon name=cross title="Supprimer cette nationalité"} + + Civilité + + + + diff --git a/upgrade/1.0.1/merge.php b/upgrade/1.0.1/merge.php index 19f82a7..e41905f 100755 --- a/upgrade/1.0.1/merge.php +++ b/upgrade/1.0.1/merge.php @@ -184,6 +184,11 @@ XDB::rawExecute("UPDATE profile_corps AS c XDB::rawExecute("DELETE FROM profile_corps_rank_enum WHERE name LIKE 'DEL%'"); +// Updates title. +XDB::rawExecute("UPDATE profiles AS p + INNER JOIN fusionax_anciens AS f ON (p.pid = f.pid) + SET p.title = f.Civilite"); + // Updates email_directory. XDB::rawExecute("UPDATE profiles AS p INNER JOIN fusionax_anciens AS f ON (p.pid = f.pid) diff --git a/upgrade/1.1.4/09_title.sql b/upgrade/1.1.4/09_title.sql new file mode 100644 index 0000000..699b422 --- /dev/null +++ b/upgrade/1.1.4/09_title.sql @@ -0,0 +1,3 @@ +ALTER TABLE profiles ADD COLUMN title ENUM('M', 'MLLE', 'MME') NOT NULL DEFAULT 'M'; + +-- vim:set syntax=mysql: -- 2.1.4