Moves and displays skills with mentoring informations (Closes #1535).
authorStéphane Jacob <sj@m4x.org>
Tue, 20 Sep 2011 09:23:12 +0000 (11:23 +0200)
committerStéphane Jacob <sj@m4x.org>
Tue, 20 Sep 2011 09:23:12 +0000 (11:23 +0200)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
ChangeLog
classes/profile.php
include/profilefields.inc.php
templates/profile/fiche_referent.tpl

index eb4cc5a..a06af61 100644 (file)
--- 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
 
index 6574d0a..669ed00 100644 (file)
@@ -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
      */
 
index c1dd074..96502f8 100644 (file)
@@ -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
 {
index 0fe683d..fa72041 100644 (file)
@@ -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()}
 <div id="fiche">
 <div id="fiche_referent">
   <div id="fiche_identite">
   </div>
   <div class="spacer"></div>
 
+  {if $skills|count || $languages|count}
+  <div class="part">
+    <h2>Compétences&nbsp;:</h2>
+    {if $skills|count}
+    <div style="float: left">
+      <em>Professionnelles&nbsp;:</em><br />
+      <ul>
+        {foreach from=$skills item="skill"}
+        <li>{$skill.text_fr} ({$skill.level})</li>
+        {/foreach}
+      </ul>
+    </div>
+    {/if}
+    {if $languages|count}
+    <div {if $skills|count}style="float: right"{/if}>
+      <em>Linguistiques&nbsp;:</em><br />
+      <ul>
+        {foreach from=$languages item="language"}
+        <li>{$language.language} ({$language.level})</li>
+        {/foreach}
+      </ul>
+    </div>
+    {/if}
+    <div class="spacer">&nbsp;</div>
+  </div>
+  {/if}
+
   {if $profile->mentor_expertise != '' || $terms|count || $countries|count }
-  <div id="part">
+  <div class="part">
     <h2>Informations de référent&nbsp;:</h2>
     {if $profile->mentor_expertise}
     <div class="rubrique_referent">