From 7e0635c236b71673d8bd8e7e24ae76fa3a5cf01c Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Tue, 20 Sep 2011 11:23:12 +0200 Subject: [PATCH] Moves and displays skills with mentoring informations (Closes #1535). MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Jacob --- ChangeLog | 3 ++ classes/profile.php | 42 +++++++++++++++++++++++- include/profilefields.inc.php | 62 ++++++++++++++++++++++++++++++++++++ templates/profile/fiche_referent.tpl | 31 +++++++++++++++++- 4 files changed, 136 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index eb4cc5a..a06af61 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,9 @@ Bug/Wish: - #1512: Allows payments for unlogged users -JAC - #1537: Replaces payments page on main site by a donation page -JAC + * Profile: + - #1535: Moves and displays skills with mentoring informations -JAC + ================================================================================ VERSION 1.1.3 10 09 2011 diff --git a/classes/profile.php b/classes/profile.php index 6574d0a..669ed00 100644 --- a/classes/profile.php +++ b/classes/profile.php @@ -111,10 +111,12 @@ class Profile implements PlExportable const FETCH_MENTOR_TERMS = 0x000400; const FETCH_DELTATEN = 0x000800; const FETCH_PARTNER = 0x001000; + const FETCH_SKILL = 0x002000; + const FETCH_LANGUAGE = 0x004000; const FETCH_MINIFICHES = 0x00012D; // FETCH_ADDRESSES | FETCH_EDU | FETCH_JOBS | FETCH_NETWORKING | FETCH_PHONES - const FETCH_ALL = 0x001FFF; // OR of FETCH_* + const FETCH_ALL = 0x007FFF; // OR of FETCH_* static public $descriptions = array( 'search_names' => 'Noms', @@ -833,6 +835,44 @@ class Profile implements PlExportable } } + /* Skills */ + private $skills = null; + public function setSkills(ProfileSkills $skills) + { + $this->skills = $skills; + } + public function getSkills() + { + if ($this->skills == null && !$this->fetched(self::FETCH_SKILL)) { + $this->setSkills($this->getProfileField(self::FETCH_SKILL)); + } + + if ($this->skills == null) { + return array(); + } else { + return $this->skills->skills; + } + } + + /* Languades */ + private $languages = null; + public function setLanguages(ProfileLanguages $languages) + { + $this->languages = $languages; + } + public function getLanguages() + { + if ($this->languages == null && !$this->fetched(self::FETCH_LANGUAGE)) { + $this->setLanguages($this->getProfileField(self::FETCH_LANGUAGE)); + } + + if ($this->languages == null) { + return array(); + } else { + return $this->languages->languages; + } + } + /** DeltaTen */ diff --git a/include/profilefields.inc.php b/include/profilefields.inc.php index c1dd074..96502f8 100644 --- a/include/profilefields.inc.php +++ b/include/profilefields.inc.php @@ -36,6 +36,8 @@ abstract class ProfileField Profile::FETCH_MENTOR_COUNTRY => 'ProfileMentoringCountries', Profile::FETCH_JOB_TERMS => 'ProfileJobTerms', Profile::FETCH_MENTOR_TERMS => 'ProfileMentoringTerms', + Profile::FETCH_SKILL => 'ProfileSkills', + Profile::FETCH_LANGUAGE => 'ProfileLanguages', Profile::FETCH_PARTNER => 'ProfilePartnerSharing', ); @@ -722,6 +724,66 @@ class ProfileMentoringTerms extends ProfileJobTerms } } // }}} +// {{{ class ProfileSkills [ Field ] +class ProfileSkills extends ProfileField +{ + public $skills = array(); + + public function __construct(PlInnerSubIterator $it) + { + $this->pid = $it->value(); + while ($skill = $it->next()) { + $this->skills[$skill['cid']] = $skill; + } + } + + public static function fetchData(array $pids, Visibility $visibility) + { + $data = XDB::iterator('SELECT ps.cid, pse.text_fr, ps.level, ps.pid + FROM profile_skills AS ps + INNER JOIN profile_skill_enum AS pse ON (pse.id = ps.cid) + WHERE ps.pid IN {?} + ORDER BY ' . XDB::formatCustomOrder('ps.pid', $pids), + $pids); + return PlIteratorUtils::subIterator($data, PlIteratorUtils::arrayValueCallback('pid')); + } +} +// }}} +// {{{ class ProfileLanguages [ Field ] +class ProfileLanguages extends ProfileField +{ + public $languages = array(); + + public function __construct(PlInnerSubIterator $it) + { + 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' + ); + + $this->pid = $it->value(); + while ($language = $it->next()) { + $this->languages[$language['lid']] = $language; + $this->languages[$language['lid']]['level'] = $levels[$language['level']]; + } + } + + public static function fetchData(array $pids, Visibility $visibility) + { + $data = XDB::iterator('SELECT ps.lid, pse.language, ps.level, ps.pid + FROM profile_langskills AS ps + INNER JOIN profile_langskill_enum AS pse ON (pse.iso_639_2b = ps.lid) + WHERE ps.pid IN {?} + ORDER BY ' . XDB::formatCustomOrder('ps.pid', $pids), + $pids); + return PlIteratorUtils::subIterator($data, PlIteratorUtils::arrayValueCallback('pid')); + } +} +// }}} // {{{ class ProfilePartnerSharing [ Field ] class ProfilePartnerSharing extends ProfileField { diff --git a/templates/profile/fiche_referent.tpl b/templates/profile/fiche_referent.tpl index 0fe683d..fa72041 100644 --- a/templates/profile/fiche_referent.tpl +++ b/templates/profile/fiche_referent.tpl @@ -26,6 +26,8 @@ {assign var=terms value=$profile->getMentoringTerms()} {assign var=countries value=$profile->getMentoringCountries()} +{assign var=skills value=$profile->getSkills()} +{assign var=languages value=$profile->getLanguages()}
@@ -36,8 +38,35 @@
+ {if $skills|count || $languages|count} +
+

Compétences :

+ {if $skills|count} +
+ Professionnelles :
+
    + {foreach from=$skills item="skill"} +
  • {$skill.text_fr} ({$skill.level})
  • + {/foreach} +
+
+ {/if} + {if $languages|count} +
+ Linguistiques :
+
    + {foreach from=$languages item="language"} +
  • {$language.language} ({$language.level})
  • + {/foreach} +
+
+ {/if} +
 
+
+ {/if} + {if $profile->mentor_expertise != '' || $terms|count || $countries|count } -
+

Informations de référent :

{if $profile->mentor_expertise}
-- 2.1.4