X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fprofilefields.inc.php;h=61925756e8313f429ea19eb05ebe45e452d13245;hb=e716a2af768e3cec3b43bb9814e043d250b5aa9b;hp=63c0a6ecc22703843a7fb80070206eae0c9733e0;hpb=eb54852e7f50cccff37ee5a6d94f5c7ebeb8fc18;p=platal.git diff --git a/include/profilefields.inc.php b/include/profilefields.inc.php index 63c0a6e..6192575 100644 --- a/include/profilefields.inc.php +++ b/include/profilefields.inc.php @@ -1,6 +1,6 @@ 'ProfileMedals', Profile::FETCH_NETWORKING => 'ProfileNetworking', Profile::FETCH_PHONES => 'ProfilePhones', - Profile::FETCH_MENTOR_SECTOR => 'ProfileMentoringSectors', Profile::FETCH_MENTOR_COUNTRY => 'ProfileMentoringCountries', Profile::FETCH_JOB_TERMS => 'ProfileJobTerms', Profile::FETCH_MENTOR_TERMS => 'ProfileMentoringTerms', @@ -149,14 +148,14 @@ class Company } } - public function setPhone(Phone &$phone) + public function setPhone(Phone $phone) { - if ($phone->linkType() == Phone::LINK_COMPANY && $phone->linkId() == $this->id) { + if ($phone->link_type == Phone::LINK_COMPANY && $phone->link_id == $this->id) { $this->phone = $phone; } } - public function setAddress(Address &$address) + public function setAddress(Address $address) { if ($address->type == Address::LINK_COMPANY && $address->jobid == $this->id) { $this->address = $address; @@ -193,10 +192,6 @@ class Job public $user_site; public $user_email; - public $sector; - public $subsector; - public $subsubsector; - /** Fields are: * pid, id, company_id, description, url, email */ @@ -207,9 +202,12 @@ class Job } $this->company = CompanyList::get($this->jobid); if (is_null($this->company)) { - require_once 'validations.inc.php'; - $entreprise = ProfileValidate::get_typed_requests($this->pid, 'entreprise'); - $this->company = new Company(array('name' => $entreprise[$this->id]->name)); + $entreprises = ProfileValidate::get_typed_requests($this->pid, 'entreprise'); + foreach ($entreprises as $entreprise) { + if ($entreprise->id == $this->id) { + $this->company = new Company(array('name' => $entreprise->name)); + } + } } } @@ -223,21 +221,21 @@ class Job return $this->address; } - public function addPhone(Phone &$phone) + public function addPhone(Phone $phone) { - if ($phone->linkType() == Phone::LINK_JOB && $phone->linkId() == $this->id && $phone->pid() == $this->pid) { + if ($phone->link_type == Phone::LINK_JOB && $phone->link_id == $this->id && $phone->pid == $this->pid) { $this->phones[$phone->uniqueId()] = $phone; } } public function setAddress(Address $address) { - if ($address->type == Address::LINK_JOB && $address->jobid == $this->id && $address->pid == $this->pid) { + if ($address->type == Address::LINK_JOB && $address->id == $this->id && $address->pid == $this->pid) { $this->address = $address; } } - public function addTerm(JobTerm &$term) + public function addTerm(JobTerm $term) { $this->terms[$term->jtid] = $term; } @@ -340,7 +338,7 @@ class ProfileEducation extends ProfileField $data = XDB::iterator('SELECT pe.id, pe.pid, pe.entry_year, pe.grad_year, pe.program, pe.flags, pee.name AS school, pee.abbreviation AS school_short, - pee.url AS school_url, gc.countryFR AS country, + pee.url AS school_url, gc.country, pede.degree, pede.abbreviation AS degree_short, pede.level AS degree_level, pefe.field FROM profile_education AS pe @@ -476,33 +474,6 @@ 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 { @@ -518,7 +489,7 @@ class ProfileMentoringCountries extends ProfileField public static function fetchData(array $pids, ProfileVisibility $visibility) { - $data = XDB::iterator('SELECT pmc.pid, pmc.country AS id, gc.countryFR AS name + $data = XDB::iterator('SELECT pmc.pid, pmc.country AS id, gc.country 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 {?} @@ -572,8 +543,13 @@ class ProfileAddresses extends ProfileField { $p = $phones->get(Profile::PHONE_LINK_ADDRESS | Profile::PHONE_TYPE_ANY); foreach ($p as $phone) { - if ($phone->linkType() == Phone::LINK_ADDRESS && array_key_exists($phone->linkId(), $this->addresses)) { - $this->addresses[$phone->linkId()]->addPhone($phone); + /* We must iterate on the addresses because id is not uniq thus, + * $this->addresse[$phone->link_id] is invalid. + */ + foreach ($this->addresses as $address) { + if ($address->type == Address::LINK_PROFILE && $address->id == $phone->link_id) { + $address->addPhone($phone); + } } } } @@ -631,17 +607,11 @@ class ProfileJobs extends ProfileField public static function fetchData(array $pids, ProfileVisibility $visibility) { CompanyList::preload($pids); - $data = XDB::iterator('SELECT pj.id, pj.pid, pj.description, pj.url as user_site, - IF(pj.email_pub IN {?}, pj.email, NULL) AS user_email, - pj.jobid, pjse.name AS sector, pjsse.name AS subsector, - pjssse.name AS subsubsector - FROM profile_job AS pj - LEFT JOIN profile_job_sector_enum AS pjse ON (pjse.id = pj.sectorid) - LEFT JOIN profile_job_subsector_enum AS pjsse ON (pjsse.id = pj.subsectorid) - LEFT JOIN profile_job_subsubsector_enum AS pjssse ON (pjssse.id = pj.subsubsectorid) - WHERE pj.pid IN {?} AND pj.pub IN {?} - ORDER BY ' . XDB::formatCustomOrder('pid', $pids) . ', - pj.id', + $data = XDB::iterator('SELECT id, pid, description, url as user_site, jobid, + IF(email_pub IN {?}, email, NULL) AS user_email + FROM profile_job + WHERE pid IN {?} AND pub IN {?} + ORDER BY ' . XDB::formatCustomOrder('pid', $pids) . ', id', $visibility->levels(), $pids, $visibility->levels()); return PlIteratorUtils::subIterator($data, PlIteratorUtils::arrayValueCallback('pid')); } @@ -664,8 +634,8 @@ class ProfileJobs extends ProfileField { $p = $phones->get(Profile::PHONE_LINK_JOB | Profile::PHONE_TYPE_ANY); foreach ($p as $phone) { - if ($phone->linkType() == Phone::LINK_JOB && array_key_exists($phone->linkId(), $this->jobs)) { - $this->jobs[$phone->linkId()]->addPhone($phone); + if ($phone->link_type == Phone::LINK_JOB && array_key_exists($phone->link_id, $this->jobs)) { + $this->jobs[$phone->link_id]->addPhone($phone); } } } @@ -675,7 +645,7 @@ class ProfileJobs extends ProfileField $a = $addresses->get(Profile::ADDRESS_PRO); foreach ($a as $address) { if ($address->type == Address::LINK_JOB && array_key_exists($address->jobid, $this->jobs)) { - $this->jobs[$address->jobid]->setAddress($address); + $this->jobs[$address->id]->setAddress($address); } } } @@ -692,7 +662,7 @@ class ProfileJobs extends ProfileField $terms = $jobterms->get(); foreach ($terms as $term) { if ($this->pid == $term->pid && array_key_exists($term->jid, $this->jobs)) { - $this->jobs[$term->jid]->addTerm(&$term); + $this->jobs[$term->jid]->addTerm($term); } } } @@ -786,7 +756,7 @@ class CompanyList if (count($newcompanies)) { $it = Phone::iterate(array(), array(Phone::LINK_COMPANY), $newcompanies); while ($phone = $it->next()) { - self::$companies[$phone->linkId()]->setPhone($phone); + self::$companies[$phone->link_id]->setPhone($phone); } } @@ -800,7 +770,10 @@ class CompanyList if (!array_key_exists($id, self::$companies)) { self::preload(); } - return self::$companies[$id]; + if (isset(self::$companies[$id])) { + return self::$companies[$id]; + } + return null; } }