Adds title to profiles.
authorStéphane Jacob <sj@m4x.org>
Mon, 24 Oct 2011 13:03:56 +0000 (15:03 +0200)
committerStéphane Jacob <sj@m4x.org>
Mon, 24 Oct 2011 13:03:56 +0000 (15:03 +0200)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
include/userset.inc.php
modules/admin.php
modules/fusionax/Anciens.sql
modules/profile/general.inc.php
templates/profile/general.tpl
upgrade/1.0.1/merge.php
upgrade/1.1.4/09_title.sql [new file with mode: 0644]

index 56244d2..ab02377 100644 (file)
@@ -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)
index 9cf5e24..a2d5d59 100644 (file)
@@ -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  ({?}, {?}, {?}, {?}, {?})',
index 0501616..52aa274 100644 (file)
@@ -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
index dc9058d..f382e7b 100644 (file)
@@ -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
index 8a04c66..7e31c5d 100644 (file)
       <a href="javascript:delNationality('3');">{icon name=cross title="Supprimer cette nationalité"}</a>
     </td>
   </tr>
+  <tr>
+    <td><span class="titre">Civilité</span></td>
+    <td>
+      <select name="profile_title">
+        <option value="M" {if $profile_title eq "M"}selected="selected"{/if}>M</option>
+        <option value="MLLE" {if $profile_title eq "MLLE"}selected="selected"{/if}>MLLE</option>
+        <option value="MME" {if $profile_title eq "MME"}selected="selected"{/if}>MME</option>
+      </select>
+    </td>
+  </tr>
 </table>
 
 <table class="bicol" style="margin-bottom: 1em" summary="Profil&nbsp;: Formations à l'X">
index 19f82a7..e41905f 100755 (executable)
@@ -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 (file)
index 0000000..699b422
--- /dev/null
@@ -0,0 +1,3 @@
+ALTER TABLE profiles ADD COLUMN title ENUM('M', 'MLLE', 'MME') NOT NULL DEFAULT 'M';
+
+-- vim:set syntax=mysql: