Add job entry year (Closes #1445).
authorStéphane Jacob <sj@m4x.org>
Tue, 12 Apr 2011 16:47:25 +0000 (18:47 +0200)
committerStéphane Jacob <sj@m4x.org>
Tue, 12 Apr 2011 17:04:26 +0000 (19:04 +0200)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
ChangeLog
modules/profile/jobs.inc.php
templates/profile/jobs.job.tpl
upgrade/1.1.1/04_jobs.sql [new file with mode: 0644]

index 8fb9376..29e38c6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,9 @@ Bug/Wish:
     * Emails:
         - #1459: Lists and administrates aliases on main domain            -JAC
 
+    * Profile:
+        - #1445: Add job entry year                                        -JAC
+
 From 1.1.0 branch:
 
     * Search:
index b343ade..d8d27c8 100644 (file)
@@ -68,7 +68,7 @@ class ProfileSettingJob implements ProfileSetting
         $jobs  = XDB::fetchAllAssoc('SELECT  j.id, j.jobid, je.name,
                                              j.description, j.email AS w_email,
                                              j.email_pub AS w_email_pub,
-                                             j.url AS w_url, j.pub
+                                             j.url AS w_url, j.pub, j.entry_year AS w_entry_year
                                        FROM  profile_job      AS j
                                   LEFT JOIN  profile_job_enum AS je ON (j.jobid = je.id)
                                       WHERE  j.pid = {?}
@@ -183,6 +183,11 @@ class ProfileSettingJob implements ProfileSetting
         }
         $job['w_phone'] = Phone::formatFormArray($job['w_phone'], $s, $maxPublicity);
 
+        if ($job['w_entry_year'] && strlen($job['w_entry_year']) != 4) {
+            $job['w_entry_year_error'] = true;
+            $success = false;
+        }
+
         unset($job['removed']);
         unset($job['new']);
     }
@@ -272,16 +277,16 @@ class ProfileSettingJob implements ProfileSetting
         foreach ($value as $id => &$job) {
             if (($job['pub'] != 'private' || $deletePrivate) && (isset($job['name']) && $job['name'])) {
                 if (isset($job['jobid']) && $job['jobid']) {
-                    XDB::execute('INSERT INTO  profile_job (pid, id, description, email,
+                    XDB::execute('INSERT INTO  profile_job (pid, id, description, email, entry_year,
                                                             url, pub, email_pub, jobid)
-                                       VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})',
-                                 $page->pid(), $id, $job['description'], $job['w_email'],
+                                       VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})',
+                                 $page->pid(), $id, $job['description'], $job['w_email'], $job['w_entry_year'],
                                  $job['w_url'], $job['pub'], $job['w_email_pub'], $job['jobid']);
                 } else {
-                    XDB::execute('INSERT INTO  profile_job (pid, id, description, email,
+                    XDB::execute('INSERT INTO  profile_job (pid, id, description, email, entry_year,
                                                             url, pub, email_pub)
-                                       VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, {?})',
-                                 $page->pid(), $id, $job['description'], $job['w_email'],
+                                       VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})',
+                                 $page->pid(), $id, $job['description'], $job['w_email'], $job['w_entry_year'],
                                  $job['w_url'], $job['pub'], $job['w_email_pub']);
                     $request = new EntrReq(S::user(), $page->profile, $id, $job['name'], $job['hq_acronym'], $job['hq_url'],
                                            $job['hq_email'], $job['hq_fixed'], $job['hq_fax'], $job['hq_address']);
index 58c2aef..8150c41 100644 (file)
                  name="{$jobpref}[w_url]" value="{$job.w_url}" />
       </td>
     </tr>
+    <tr class="pair" {if $hiddenjob}style="display: none"{/if}>
+      <td class="titre">Année&nbsp;d'entrée</td>
+      <td>
+          <input type="text" size="4" maxlength="4" {if t($job.w_entry_year_error)}class="error"{/if}
+                 name="{$jobpref}[w_entry_year]" value="{$job.w_entry_year}" />
+          <small>(avec 4 chiffres, par exemple 1983)</small>
+      </td>
+    </tr>
     <tr id="{$jobid}_w_address" class="pair" {if $hiddenjob || $hiddenaddr}style="display: none"{/if}>
       <td colspan="2">
         <div style="float: left">
diff --git a/upgrade/1.1.1/04_jobs.sql b/upgrade/1.1.1/04_jobs.sql
new file mode 100644 (file)
index 0000000..4d0187e
--- /dev/null
@@ -0,0 +1,3 @@
+ALTER TABLE profile_job ADD COLUMN entry_year CHAR(4) DEFAULT NULL;
+
+-- vim:set syntax=mysql: