From 285e2fe72d086ae94fc95696a0cefc8755113277 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Tue, 20 Sep 2011 09:51:43 +0200 Subject: [PATCH] Moves skills edition to mentor edition page. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Jacob --- modules/profile.php | 3 +- modules/profile/mentor.inc.php | 101 ++++++++++++++++++++++++++++++ modules/profile/page.inc.php | 1 - modules/profile/skills.inc.php | 138 ----------------------------------------- templates/profile/mentor.tpl | 73 ++++++++++++++++++++++ templates/profile/skill.tpl | 96 ---------------------------- 6 files changed, 175 insertions(+), 237 deletions(-) delete mode 100644 modules/profile/skills.inc.php delete mode 100644 templates/profile/skill.tpl diff --git a/modules/profile.php b/modules/profile.php index 93fc9f3..5988743 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -301,7 +301,7 @@ class ProfileModule extends PLModule { global $globals; - if (in_array($hrpid, array('general', 'adresses', 'emploi', 'poly', 'deco', 'skill', 'mentor', 'deltaten'))) { + if (in_array($hrpid, array('general', 'adresses', 'emploi', 'poly', 'deco', 'mentor', 'deltaten'))) { $aux = $opened_tab; $opened_tab = $hrpid; $hrpid = $aux; @@ -333,7 +333,6 @@ class ProfileModule extends PLModule } $wiz->addPage('ProfilePageDecos', 'Décorations - Medailles', 'deco'); if (S::user()->checkPerms(User::PERM_DIRECTORY_PRIVATE)) { - $wiz->addPage('ProfilePageSkills', 'Compétences diverses', 'skill'); $wiz->addPage('ProfilePageMentor', 'Mentoring', 'mentor'); } if (S::user()->checkPerms(User::PERM_DIRECTORY_PRIVATE) && $profile->isDeltatenEnabled(Profile::DELTATEN_OLD)) { diff --git a/modules/profile/mentor.inc.php b/modules/profile/mentor.inc.php index 7a14e2d..279a105 100644 --- a/modules/profile/mentor.inc.php +++ b/modules/profile/mentor.inc.php @@ -19,6 +19,91 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ +class ProfileSettingSkill implements ProfileSetting +{ + private $table; + private $id; + private $skill_field; + private $text_field; + + public function __construct($table, $id, $skill, $text) + { + $this->table = $table; + $this->id = $id; + $this->skill_field = $skill; + $this->text_field = $text; + } + + public function value(ProfilePage $page, $field, $value, &$success) + { + if (is_null($value)) { + $value = array(); + $res = XDB::iterRow("SELECT s.{$this->id}, s.{$this->text_field}, i.level + FROM profile_{$this->table}_enum AS s + INNER JOIN profile_{$this->table}s AS i ON (s.{$this->id} = i.{$this->skill_field}) + WHERE i.pid = {?}", + $page->pid()); + while (list($sid, $text, $level) = $res->next()) { + $value[$sid] = array('text' => $text, 'level' => $level); + } + } + if (!is_array($value)) { + $value = array(); + } else { + foreach ($value as $id=>&$skill) { + if (!isset($skill['text']) || empty($skill['text'])) { + $res = XDB::query("SELECT {$this->text_field} + FROM profile_{$this->table}_enum + WHERE {$this->id} = {?}", $id); + $skill['text'] = $res->fetchOneCell(); + } + } + } + ksort($value); + $success = true; + return $value; + } + + public function save(ProfilePage $page, $field, $value) + { + XDB::execute("DELETE FROM profile_{$this->table}s + WHERE pid = {?}", + $page->pid()); + if (!count($value)) { + return; + } + foreach ($value as $id=>&$skill) { + XDB::execute("INSERT INTO profile_{$this->table}s (pid, {$this->skill_field}, level) + VALUES ({?}, {?}, {?})", + $page->pid(), $id, $skill['level']); + } + } + + public function getText($value) { + $skills = array(); + + 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); + } +} + /** Terms associated to profile mentoring */ class ProfileSettingTerms implements ProfileSetting { @@ -143,6 +228,8 @@ class ProfilePageMentor extends ProfilePage $this->settings['expertise'] = null; $this->settings['terms'] = new ProfileSettingTerms(); $this->settings['countries'] = new ProfileSettingCountry(); + $this->settings['competences'] = new ProfileSettingSkill('skill', 'id', 'cid', 'text_fr'); + $this->settings['langues'] = new ProfileSettingSkill('langskill', 'iso_639_2b', 'lid', 'language'); } protected function _fetchData() @@ -179,6 +266,20 @@ class ProfilePageMentor extends ProfilePage FROM geoloc_countries ORDER BY country")); $page->assign('hrpid', $this->profile->hrpid); + $page->assign('comp_list', XDB::iterator("SELECT id, text_fr, FIND_IN_SET('titre',flags) AS title + FROM profile_skill_enum")); + $page->assign('comp_level', array('initié' => 'initié', + 'bonne connaissance' => 'bonne connaissance', + 'expert' => 'expert')); + $page->assign('lang_list', XDB::iterator('SELECT iso_639_2b, language + FROM profile_langskill_enum + ORDER BY language')); + $page->assign('lang_level', 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')); } } diff --git a/modules/profile/page.inc.php b/modules/profile/page.inc.php index c6eae36..02f3316 100644 --- a/modules/profile/page.inc.php +++ b/modules/profile/page.inc.php @@ -435,7 +435,6 @@ require_once dirname(__FILE__) . '/addresses.inc.php'; require_once dirname(__FILE__) . '/groups.inc.php'; require_once dirname(__FILE__) . '/decos.inc.php'; require_once dirname(__FILE__) . '/jobs.inc.php'; -require_once dirname(__FILE__) . '/skills.inc.php'; require_once dirname(__FILE__) . '/mentor.inc.php'; require_once dirname(__FILE__) . '/deltaten.inc.php'; diff --git a/modules/profile/skills.inc.php b/modules/profile/skills.inc.php deleted file mode 100644 index 3145811..0000000 --- a/modules/profile/skills.inc.php +++ /dev/null @@ -1,138 +0,0 @@ -table = $table; - $this->id = $id; - $this->skill_field = $skill; - $this->text_field = $text; - } - - public function value(ProfilePage $page, $field, $value, &$success) - { - if (is_null($value)) { - $value = array(); - $res = XDB::iterRow("SELECT s.{$this->id}, s.{$this->text_field}, i.level - FROM profile_{$this->table}_enum AS s - INNER JOIN profile_{$this->table}s AS i ON (s.{$this->id} = i.{$this->skill_field}) - WHERE i.pid = {?}", - $page->pid()); - while (list($sid, $text, $level) = $res->next()) { - $value[$sid] = array('text' => $text, 'level' => $level); - } - } - if (!is_array($value)) { - $value = array(); - } else { - foreach ($value as $id=>&$skill) { - if (!isset($skill['text']) || empty($skill['text'])) { - $res = XDB::query("SELECT {$this->text_field} - FROM profile_{$this->table}_enum - WHERE {$this->id} = {?}", $id); - $skill['text'] = $res->fetchOneCell(); - } - } - } - ksort($value); - $success = true; - return $value; - } - - public function save(ProfilePage $page, $field, $value) - { - XDB::execute("DELETE FROM profile_{$this->table}s - WHERE pid = {?}", - $page->pid()); - if (!count($value)) { - return; - } - foreach ($value as $id=>&$skill) { - XDB::execute("INSERT INTO profile_{$this->table}s (pid, {$this->skill_field}, level) - VALUES ({?}, {?}, {?})", - $page->pid(), $id, $skill['level']); - } - } - - public function getText($value) { - $skills = array(); - - 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); - } -} - -class ProfilePageSkills extends ProfilePage -{ - protected $pg_template = 'profile/skill.tpl'; - - public function __construct(PlWizard $wiz) - { - parent::__construct($wiz); - $this->settings['competences'] = new ProfileSettingSkill('skill', 'id', 'cid', 'text_fr'); - $this->settings['langues'] = new ProfileSettingSkill('langskill', 'iso_639_2b', 'lid', 'language'); - } - - public function _prepare(PlPage $page, $id) - { - $page->assign('comp_list', XDB::iterator("SELECT id, text_fr, FIND_IN_SET('titre',flags) AS title - FROM profile_skill_enum")); - $page->assign('comp_level', array('initié' => 'initié', - 'bonne connaissance' => 'bonne connaissance', - 'expert' => 'expert')); - $page->assign('lang_list', XDB::iterator('SELECT iso_639_2b, language - FROM profile_langskill_enum - ORDER BY language')); - $page->assign('lang_level', 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')); - } -} - -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: -?> diff --git a/templates/profile/mentor.tpl b/templates/profile/mentor.tpl index 02ffefd..83c1585 100644 --- a/templates/profile/mentor.tpl +++ b/templates/profile/mentor.tpl @@ -46,6 +46,79 @@
  • ou bien, plus âgés, qui souhaitent réorienter leur carrière.
  • + + + + + + + + + + +
    +
    + + {icon name="flag_red" title="privé"} +
    + Compétences professionnelles +
    + Domaine : + + +
    + {foreach from=$competences item=competence key=id} + {include file="profile/skill.skill.tpl" cat='competences' skill=$competence id=$id levels=$comp_level} + {/foreach} +
    + + + + + + + + + + + +
    +
    + + {icon name="flag_red" title="privé"} +
    + Compétences linguistiques +
    + Domaine : + + +
    + {foreach from=$langues item=langue key=id} + {include file="profile/skill.skill.tpl" cat='langues' skill=$langue id=$id levels=$lang_level} + {/foreach} +
    +
    diff --git a/templates/profile/skill.tpl b/templates/profile/skill.tpl deleted file mode 100644 index 7b423a8..0000000 --- a/templates/profile/skill.tpl +++ /dev/null @@ -1,96 +0,0 @@ -{**************************************************************************} -{* *} -{* Copyright (C) 2003-2011 Polytechnique.org *} -{* http://opensource.polytechnique.org/ *} -{* *} -{* This program is free software; you can redistribute it and/or modify *} -{* it under the terms of the GNU General Public License as published by *} -{* the Free Software Foundation; either version 2 of the License, or *} -{* (at your option) any later version. *} -{* *} -{* This program is distributed in the hope that it will be useful, *} -{* but WITHOUT ANY WARRANTY; without even the implied warranty of *} -{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *} -{* GNU General Public License for more details. *} -{* *} -{* You should have received a copy of the GNU General Public License *} -{* along with this program; if not, write to the Free Software *} -{* Foundation, Inc., *} -{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *} -{* *} -{**************************************************************************} - - - - - - - - - - - -
    -
    - - {icon name="flag_red" title="privé"} -
    - Compétences professionnelles -
    - Domaine : - - -
    - {foreach from=$competences item=competence key=id} - {include file="profile/skill.skill.tpl" cat='competences' skill=$competence id=$id levels=$comp_level} - {/foreach} -
    - - - - - - - - - - - -
    -
    - - {icon name="flag_red" title="privé"} -
    - Compétences linguistiques -
    - Domaine : - - -
    - {foreach from=$langues item=langue key=id} - {include file="profile/skill.skill.tpl" cat='langues' skill=$langue id=$id levels=$lang_level} - {/foreach} -
    - -{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} -- 2.1.4