<?php
/***************************************************************************
- * Copyright (C) 2003-2011 Polytechnique.org *
+ * Copyright (C) 2003-2014 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
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',
);
public static function fetchData(array $pids, Visibility $visibility)
{
- $data = XDB::iterator('SELECT pm.pid, pm.mid, pm.gid, pme.text, pme.img, pmge.text AS grade
+ $data = XDB::iterator('SELECT pm.pid, pm.mid, pm.gid, pme.text, pme.img, pmge.text AS grade, pm.level
FROM profile_medals AS pm
LEFT JOIN profiles AS p ON (pm.pid = p.pid)
LEFT JOIN profile_medal_enum AS pme ON (pme.id = pm.mid)
}
}
// }}}
+// {{{ 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
{
static public function get($id)
{
- if (!array_key_exists($id, self::$companies)) {
+ if (!is_null($id) && !array_key_exists($id, self::$companies)) {
self::preload();
}
if (isset(self::$companies[$id])) {
}
// }}}
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8:
?>