Improves profile modifications display..
authorStéphane Jacob <sj@m4x.org>
Thu, 2 Dec 2010 14:21:55 +0000 (15:21 +0100)
committerStéphane Jacob <sj@m4x.org>
Fri, 3 Dec 2010 15:04:10 +0000 (16:04 +0100)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
bin/cron/profile_modification.php
classes/address.php
classes/phone.php
modules/profile/general.inc.php
modules/profile/jobs.inc.php
modules/profile/page.inc.php
modules/profile/skills.inc.php

index ef7cbdf..3de42e9 100755 (executable)
@@ -24,6 +24,36 @@ require_once 'connect.db.inc.php';
 require_once 'plmailer.php';
 global $globals;
 
+$translations = array(
+    'search_names'    => 'Noms',
+    'nationality1'    => 'Nationalité',
+    'nationality2'    => '2e nationalité',
+    'nationality3'    => '3e nationalité',
+    'promo_display'   => 'Promotion affichée',
+    'email_directory' => 'Email annuaire papier',
+    'networking'      => 'Messageries…',
+    'tels'            => 'Téléphones',
+    'edus'            => 'Formations',
+    'promo'           => 'Promotion de sortie',
+    'birthdate'       => 'Date de naissance',
+    'yourself'        => 'Nom affiché',
+    'freetext'        => 'Commentaire',
+    'freetext_pub'    => 'Affichage de ton commentaire',
+    'photo_pub'       => 'Affichage de ta photo',
+    'addresses'       => 'Adresses',
+    'corps'           => 'Corps',
+    'cv'              => 'CV',
+    'jobs'            => 'Emplois',
+    'section'         => 'Section',
+    'binets'          => 'Binets',
+    'medals'          => 'Décorations',
+    'medals_pub'      => 'Affichage de tes décorations',
+    'competences'     => 'Compétences',
+    'langues'         => 'Langues',
+    'expertise'       => 'Expertises (mentoring)',
+    'terms'           => 'Compétences (mentoring)',
+    'countries'       => 'Pays (mentoring)'
+);
 $res = XDB::iterator('SELECT  p.hrpid, pm.pid, a.full_name, pm.field, pm.oldText, pm.newText, p.sex, pd.yourself, al.alias
                         FROM  profile_modifications AS pm
                   INNER JOIN  accounts              AS a  ON (pm.uid = a.uid)
@@ -46,7 +76,7 @@ if ($res->total() > 0) {
     $modifications = array();
     $modifications[] = array(
         'full_name' => $values['full_name'],
-        'field'     => $values['field'],
+        'field'     => $translations[$values['field']],
         'oldText'   => $values['oldText'],
         'newText'   => $values['newText'],
     );
@@ -70,7 +100,7 @@ if ($res->total() > 0) {
         $hrpid = $values['hrpid'];
         $modifications[] = array(
             'full_name' => $values['full_name'],
-            'field'     => $values['field'],
+            'field'     => $translations[$values['field']],
             'oldText'   => $values['oldText'],
             'newText'   => $values['newText'],
         );
index f05e2f8..f0ac9e4 100644 (file)
@@ -642,9 +642,10 @@ class Address
 
     private function toString()
     {
-        $address = 'Adresse : ' . $this->text;
+        $address = $this->text;
         if ($this->type == self::LINK_PROFILE || $this->type == self::LINK_JOB) {
-            $address .= ', affichage : ' . $this->pub;
+            static $pubs = array('public' => 'publique', 'ax' => 'annuaire AX', 'private' => 'privé');
+            $address .= ' (affichage ' . $pubs[$this->pub];
         }
         if ($this->type == self::LINK_PROFILE) {
             static $flags = array(
@@ -656,15 +657,25 @@ class Address
                 'cedex'         => 'type cédex',
             );
 
-            $address .= ', commentaire : ' . $this->comment;
+            if (!$this->flags->hasFlag('temporary')) {
+                $address .= ', permanente';
+            }
+            if (!$this->flags->hasFlag('secondary')) {
+                $address .= ', principale';
+            }
             foreach ($flags as $flag => $flagName) {
                 if ($this->flags->hasFlag($flag)) {
                     $address .= ', ' . $flagName;
                 }
             }
+            if ($this->comment) {
+                $address .= ', commentaire : ' . $this->comment;
+            }
             if ($phones = Phone::formArrayToString($this->phones)) {
                 $address .= ', ' . $phones;
             }
+        } elseif ($this->type == self::LINK_JOB) {
+            $address .= ')';
         }
         return $address;
     }
@@ -794,7 +805,7 @@ class Address
 
     static public function formArrayToString(array $data)
     {
-        return implode(' ; ', self::formArrayWalk($data, 'toString'));
+        return implode(', ', self::formArrayWalk($data, 'toString'));
     }
 
     static public function iterate(array $pids = array(), array $types = array(),
index 5ca75ee..5dbca0f 100644 (file)
@@ -286,8 +286,10 @@ class Phone
 
     private function toString()
     {
-        return 'type : ' . $this->type .', numéro : ' . $this->display
-            . ', commentaire : « ' . $this->comment . ' », affichage : ' . $this->pub;
+        static $pubs = array('public' => 'publique', 'ax' => 'annuaire AX', 'private' => 'privé');
+        static $types = array('fax' => 'fax', 'fixed' => 'fixe', 'mobile' => 'mobile');
+        return $this->display . ' (' . $types[$this->type] . (($this->comment) ? ', commentaire : « ' . $this->comment . ' »' : '')
+            . ', affichage ' . $pubs[$this->pub] . ')';
     }
 
     private function isEmpty()
@@ -372,7 +374,7 @@ class Phone
 
     static public function formArrayToString(array $data)
     {
-        return implode(' ; ', self::formArrayWalk($data, 'toString'));
+        return implode(', ', self::formArrayWalk($data, 'toString'));
     }
 
     static public function iterate(array $pids = array(), array $link_types = array(),
index fadbbce..a98acac 100644 (file)
@@ -237,7 +237,7 @@ class ProfileSettingSearchNames implements ProfileSetting
         $names = array();
         foreach ($value as $name) {
             if ($name['name'] != '') {
-                $names[] = $name['type_name'] . ' : ' . $name['name'];
+                $names[] = mb_strtolower($name['type_name']) . ' : ' . $name['name'];
             }
         }
         return implode(', ' , $names);
@@ -315,12 +315,32 @@ class ProfileSettingEdu implements ProfileSetting
         $degreesList = DirEnum::getOptions(DirEnum::EDUDEGREES);
         $fieldsList = DirEnum::getOptions(DirEnum::EDUFIELDS);
         $educations = array();
-        foreach ($value as $education) {
-            $educations[] = 'Université : ' . $schoolsList[$education['eduid']]
-                          . ', diplôme : ' . $degreesList[$education['degreeid']]
-                          . ', domaine : ' . $fieldsList[$education['fieldid']]
-                          . ', année d\'obtention : ' . $education['grad_year']
-                          . ', intitulé : ' . $education['program'];
+        foreach ($value as $id => $education) {
+            // XXX: the following condition should be removed once there are no more incomplete educations.
+            if (is_null($education['eduid']) || is_null($education['degreeid'])) {
+                if (is_null($education['eduid']) && is_null($education['degreeid'])) {
+                    $educations[$id] = 'formation manquante';
+                } else {
+                    $educations[$id] = (is_null($education['eduid']) ? 'université manquante' : $schoolsList[$education['eduid']]) . ', '
+                                     . (is_null($education['degreeid']) ? 'diplôme manquant' : $degreesList[$education['degreeid']]);
+                }
+            } else {
+                $educations[$id] = $schoolsList[$education['eduid']] . ', ' . $degreesList[$education['degreeid']];
+            }
+
+            $details = array();
+            if ($education['grad_year']) {
+                $details[] = $education['grad_year'];
+            }
+            if ($education['program']) {
+                $details[] = '« ' . $education['program'] . ' »';
+            }
+            if ($education['fieldid']) {
+                $details[] = $fieldsList[$education['fieldid']];
+            }
+            if (count($details)) {
+                $educations[$id] .= ' (' . implode(', ', $details) . ')';
+            }
         }
         return implode(', ', $educations);
     }
@@ -428,12 +448,12 @@ class ProfileSettingNetworking implements ProfileSetting
     }
 
     public function getText($value) {
+        static $pubs = array('public' => 'publique', 'ax' => 'annuaire AX', 'private' => 'privé');
         $networkings = array();
         foreach ($value as $network) {
-            $networkings[] = 'nom : ' . $network['name'] . ', adresse : ' . $network['address']
-                           . ', affichage : ' . $network['pub'];
+            $networkings[] = $network['name'] . ' : ' . $network['address'] . ' (affichage ' . $pubs[$network['pub']] . ')';
         }
-        return implode(' ; ' , $networkings);
+        return implode(', ' , $networkings);
     }
 }
 
index da10f88..e22791e 100644 (file)
@@ -292,15 +292,34 @@ class ProfileSettingJob implements ProfileSetting
 
     public function getText($value)
     {
+        static $pubs = array('public' => 'publique', 'ax' => 'annuaire AX', 'private' => 'privé');
         $jobs = array();
         foreach ($value as $id => $job) {
             $address = Address::formArrayToString(array($job['w_address']));
             $phones = Phone::formArrayToString($job['w_phone']);
-            // TODO: add jobterms here.
-            $jobs[] = 'Entreprise : ' . $job['name']
-                    . ', description : ' . $job['description'] . ', web : ' . $job['w_url']
-                    . ', email : ' . $job['w_email']
-                    . ($phones ? ', ' . $phones : '') . ($address ? ', ' . $address : '');
+            $jobs[$id] = $job['name'];
+            $jobs[$id] .= ($job['description'] ? (', ' . $job['description']) : '');
+            $jobs[$id] .= ' (affichage ' . $pubs[$job['pub']];
+            if (count($job['terms'])) {
+                $terms = array();
+                foreach ($job['terms'] as $term) {
+                    $terms[] = $term['full_name'];
+                }
+                $jobs[$id] .= ', mots-clefs : ' . implode(', ', $terms);
+            }
+            if ($job['w_url']) {
+                $jobs[$id] .= ', page perso : ' . $job['w_url'];
+            }
+            if ($address) {
+                $jobs[$id] .= ', adresse : ' . $address;
+            }
+            if ($job['w_email']) {
+                $jobs[$id] .= ', email : ' . $job['w_email'];
+            }
+            if ($phones) {
+                $jobs[$id] .= ', téléphones : ' . $phones;
+            }
+            $jobs[$id] .= ')';
         }
         return implode(' ; ' , $jobs);
     }
@@ -342,10 +361,11 @@ class ProfileSettingCorps implements ProfileSetting
 
     public function getText($value)
     {
+        static $pubs = array('public' => 'publique', 'ax' => 'annuaire AX', 'private' => 'privé');
         $corpsList = DirEnum::getOptions(DirEnum::CORPS);
         $rankList  = DirEnum::getOptions(DirEnum::CORPSRANKS);
-        return 'Corps actuel : ' . $corpsList[$value['current']] . ' , rang : ' . $corpsList[$value['rank']]
-            . ' , corps d\'origine : ' . $corpsList[$value['original']] . ' , affichage : ' . $value['pub'];
+        return $corpsList[$value['current']] . ', ' . $corpsList[$value['rank']] . ' ('
+            . 'corps d\'origine : ' . $corpsList[$value['original']] . ', affichage ' . $pubs[$value['pub']] . ')';
     }
 }
 
index 53ffa0e..becd6d1 100644 (file)
@@ -156,7 +156,8 @@ class ProfileSettingPub extends ProfileNoSave
     }
 
     public function getText($value) {
-        return $value;
+        static $pubs = array('public' => 'publique', 'ax' => 'annuaire AX', 'private' => 'privé');
+        return $pubs[$value];
     }
 }
 
index 7fed747..82c30c8 100644 (file)
@@ -79,10 +79,26 @@ class ProfileSettingSkill implements ProfileSetting
 
     public function getText($value) {
         $skills = array();
-        foreach ($value as $skill) {
-            $skills[] = 'Compétance : ' . $skill['text'] . ', niveau : ' . $skill['level'];
+
+        if ($this->table == 'langskill') {
+            static $levels = array(
+                1 => 'connaissance basique',
+                2 => 'maîtrise des bases',
+                3 => 'maîtrise limitée',
+                4 => 'maîtrise générale',
+                5 => 'bonne maîtrise',
+                6 => 'maîtrise complète'
+            );
+            foreach ($value as $skill) {
+                $skills[] = $skill['text'] . ' (' . $levels[$skill['level']] . ')';
+            }
+        } else {
+            foreach ($value as $skill) {
+                $skills[] = $skill['text'] . ' (' . $skill['level'] . ')';
+            }
         }
-        return implode(' ; ' , $skills);
+
+        return implode(', ' , $skills);
     }
 }