X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fprofilefields.inc.php;h=c91403d763344ac620ca0512577a2ebd9ed1d7b3;hb=a19178e9a93c4eb3eb750845e85f87f2294ed1e4;hp=79a3b88df15805ccc5f37c9002977dad1c995b81;hpb=1f8250e4ceb455a4469266b0702c4cad5b2b4be0;p=platal.git diff --git a/include/profilefields.inc.php b/include/profilefields.inc.php index 79a3b88..c91403d 100644 --- a/include/profilefields.inc.php +++ b/include/profilefields.inc.php @@ -26,13 +26,15 @@ abstract class ProfileField { public static $fields = array( - Profile::FETCH_ADDRESSES => 'ProfileAddresses', - Profile::FETCH_CORPS => 'ProfileCorps', - Profile::FETCH_EDU => 'ProfileEducation', - Profile::FETCH_JOBS => 'ProfileJobs', - Profile::FETCH_MEDALS => 'ProfileMedals', - Profile::FETCH_NETWORKING => 'ProfileNetworking', - Profile::FETCH_PHONES => 'ProfilePhones', + Profile::FETCH_ADDRESSES => 'ProfileAddresses', + Profile::FETCH_CORPS => 'ProfileCorps', + Profile::FETCH_EDU => 'ProfileEducation', + Profile::FETCH_JOBS => 'ProfileJobs', + Profile::FETCH_MEDALS => 'ProfileMedals', + Profile::FETCH_NETWORKING => 'ProfileNetworking', + Profile::FETCH_PHONES => 'ProfilePhones', + Profile::FETCH_MENTOR_SECTOR => 'ProfileMentoringSectors', + Profile::FETCH_MENTOR_COUNTRY => 'ProfileMentoringCountries', ); /** The profile to which this field belongs @@ -450,9 +452,9 @@ class ProfileNetworking extends ProfileField foreach ($this->networks as $id => $nw) { // XXX hardcoded reference to web site index if ( - (($flags & self::NETWORKING_WEB) && $nw['network_type'] == 0) + (($flags & Profile::NETWORKING_WEB) && $nw['network_type'] == 0) || - (! ($flags & self::NETWORKING_WEB)) + (! ($flags & Profile::NETWORKING_WEB)) ) { $nws[$id] = $nw; ++$nb; @@ -509,6 +511,59 @@ class ProfileCorps extends ProfileField } } // }}} +// {{{ class ProfileMentoringSectors [ Field ] +class ProfileMentoringSectors extends ProfileField +{ + public $sectors = array(); + + public function __construct(PlInnerSubIterator $it) + { + $this->pid = $it->value(); + while ($sector = $it->next()) { + $this->sectors[] = $sector; + } + } + + public static function fetchData(array $pids, ProfileVisibility $visibility) + { + $data = XDB::iterator('SELECT pms.pid, pjse.name AS sector, pjsse.name AS subsector + FROM profile_mentor_sector AS pms + LEFT JOIN profile_job_sector_enum AS pjse ON (pjse.id = pms.sectorid) + LEFT JOIN profile_job_subsector_enum AS pjsse ON (pjsse.id = pms.subsectorid) + WHERE pms.pid IN {?} + ORDER BY ' . XDB::formatCustomOrder('pms.pid', $pids), + $pids); + + return PlIteratorUtils::subIterator($data, PlIteratorUtils::arrayValueCallback('pid')); + } +} +// }}} +// {{{ class ProfileMentoringCountries [ Field ] +class ProfileMentoringCountries extends ProfileField +{ + public $countries = array(); + + public function __construct(PlInnerSubIterator $it) + { + $this->pid = $it->value(); + while ($country = $it->next()) { + $this->countries[$country['id']] = $country['name']; + } + } + + public static function fetchData(array $pids, ProfileVisibility $visibility) + { + $data = XDB::iterator('SELECT pmc.pid, pmc.country AS id, gc.countryFR AS name + FROM profile_mentor_country AS pmc + LEFT JOIN geoloc_countries AS gc ON (gc.iso_3166_1_a2 = pmc.country) + WHERE pmc.pid IN {?} + ORDER BY ' . XDB::formatCustomOrder('pmc.pid', $pids), + $pids); + + return PlIteratorUtils::subIterator($data, PlIteratorUtils::arrayValueCallback('pid')); + } +} +// }}} /** Loading of data for a Profile : * 1) load jobs, addresses, phones