From 14aba233ad5ca4fced7d0fa015f0a1f7da6d6c49 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Thu, 2 Dec 2010 15:21:55 +0100 Subject: [PATCH] Improves profile modifications display.. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Jacob --- bin/cron/profile_modification.php | 34 +++++++++++++++++++++++++++++++-- classes/address.php | 19 +++++++++++++++---- classes/phone.php | 8 +++++--- modules/profile/general.inc.php | 40 +++++++++++++++++++++++++++++---------- modules/profile/jobs.inc.php | 34 ++++++++++++++++++++++++++------- modules/profile/page.inc.php | 3 ++- modules/profile/skills.inc.php | 22 ++++++++++++++++++--- 7 files changed, 130 insertions(+), 30 deletions(-) diff --git a/bin/cron/profile_modification.php b/bin/cron/profile_modification.php index ef7cbdf..3de42e9 100755 --- a/bin/cron/profile_modification.php +++ b/bin/cron/profile_modification.php @@ -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'], ); diff --git a/classes/address.php b/classes/address.php index f05e2f8..f0ac9e4 100644 --- a/classes/address.php +++ b/classes/address.php @@ -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(), diff --git a/classes/phone.php b/classes/phone.php index 5ca75ee..5dbca0f 100644 --- a/classes/phone.php +++ b/classes/phone.php @@ -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(), diff --git a/modules/profile/general.inc.php b/modules/profile/general.inc.php index fadbbce..a98acac 100644 --- a/modules/profile/general.inc.php +++ b/modules/profile/general.inc.php @@ -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); } } diff --git a/modules/profile/jobs.inc.php b/modules/profile/jobs.inc.php index da10f88..e22791e 100644 --- a/modules/profile/jobs.inc.php +++ b/modules/profile/jobs.inc.php @@ -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']] . ')'; } } diff --git a/modules/profile/page.inc.php b/modules/profile/page.inc.php index 53ffa0e..becd6d1 100644 --- a/modules/profile/page.inc.php +++ b/modules/profile/page.inc.php @@ -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]; } } diff --git a/modules/profile/skills.inc.php b/modules/profile/skills.inc.php index 7fed747..82c30c8 100644 --- a/modules/profile/skills.inc.php +++ b/modules/profile/skills.inc.php @@ -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); } } -- 2.1.4