const NETWORKING_IM = 0x020000;
const NETWORKING_SOCIAL = 0x040000;
- const FETCH_ADDRESSES = 0x00001;
- const FETCH_CORPS = 0x00002;
- const FETCH_EDU = 0x00004;
- const FETCH_JOBS = 0x00008;
- const FETCH_MEDALS = 0x00010;
- const FETCH_NETWORKING = 0x00020;
- const FETCH_PHONES = 0x00040;
- const FETCH_PHOTO = 0x00080;
-
- const FETCH_ALL = 0x000FF;
+ const FETCH_ADDRESSES = 0x000001;
+ const FETCH_CORPS = 0x000002;
+ const FETCH_EDU = 0x000004;
+ const FETCH_JOBS = 0x000008;
+ const FETCH_MEDALS = 0x000010;
+ const FETCH_NETWORKING = 0x000020;
+ const FETCH_PHONES = 0x000040;
+ const FETCH_PHOTO = 0x000080;
+
+ // xor of all FETCH_XYZ
+ const FETCH_ALL = 0x0000FF;
private $pid;
private $hrpid;
$this->hrpid = $this->data['hrpid'];
if (!S::logged()) {
$this->setVisibilityLevel(self::VISIBILITY_PUBLIC);
+ } else {
+ $this->setVisibilityLevel(self::VISIBILITY_PRIVATE);
}
}
if ($this->addresses == null) {
$this->setAddresses($this->getProfileField('ProfileAddresses'));
}
+
+ if ($this->addresses == null) {
+ return PlIteratorUtils::emptyIterator();
+ }
return $this->addresses->get($flags, $limit);
}
if ($this->educations == null) {
$this->setEducations($this->getProfileField('ProfileEducation'));
}
+
+ if ($this->educations == null) {
+ return PlIteratorUtils::emptyIterator();
+ }
return $this->educations->get($flags, $limit);
}
if ($this->networks == null) {
$this->setNetworking($this->getProfileField('ProfileNetworking'));
}
+ if ($this->networks == null) {
+ return PlIteratorUtils::emptyIterator();
+ }
return $this->networks->get($flags, $limit);
}
/** Jobs
*/
+ private $jobs = null;
+ public function setJobs(ProfileJobs $jobs)
+ {
+ $this->jobs = $jobs;
+ $this->consolidateFields();
+ }
public function getJobs($flags, $limit = null)
{
- $where = XDB::format('pj.pid = {?}', $this->id());
- $cond = 'TRUE';
- if ($this->visibility) {
- $where .= ' AND pj.pub IN ' . XDB::formatArray($this->visibility);
- $cond = 'pj.email_pub IN ' . XDB::formatArray($this->visibility);
- }
- $limit = is_null($limit) ? '' : XDB::format('LIMIT {?}', (int)$limit);
- return XDB::iterator('SELECT pje.name, pje.acronym, pje.url, pje.email, pje.NAF_code,
- pj.description, pj.url AS user_site,
- IF (' . $cond . ', pj.email, NULL) AS user_email,
- pjse.name AS sector, pjsse.name AS subsector,
- pjssse.name AS subsubsector
- FROM profile_job AS pj
- INNER JOIN profile_job_enum AS pje ON (pje.id = pj.jobid)
- 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 ' . $where . '
- ORDER BY pj.id
- ' . $limit);
- }
-
- public function getMailJob()
+ if ($this->jobs == null) {
+ $this->setJobs($this->getProfileField('ProfileJobs'));
+ }
+
+ if ($this->jobs == null) {
+ return PlIteratorUtils::emptyIterator();
+ }
+ return $this->jobs->get($flags, $limit);
+ }
+
+ public function getMainJob()
{
$job = $this->getJobs(self::JOBS_MAIN, 1);
if ($job->total() != 1) {
FROM profile_binets
WHERE pid = {?}', $this->id());
}
+ public function getBinetsNames()
+ {
+ return XDB::fetchColumn('SELECT text
+ FROM profile_binets AS pb
+ LEFT JOIN profile_binet_enum AS pbe ON (pbe.id = pb.binet_id)
+ WHERE pb.pid = {?}', $this->id());
+ }
+
+ /* Medals
+ */
+ private $medals = null;
+ public function setMedals(ProfileMedals $medals)
+ {
+ $this->medals = $medals;
+ }
+ public function getMedals()
+ {
+ if ($this->medals == null) {
+ $this->setMedals($this->getProfileField('ProfileMedals'));
+ }
+ if ($this->medals == null) {
+ return array();
+ }
+ return $this->medals->medals;
+ }
public function owner()
{
}
- $it = XDB::Iterator('SELECT p.*, p.sex = \'female\' AS sex, pe.entry_year, pe.grad_year,
+ $it = XDB::Iterator('SELECT p.*, p.sex = \'female\' AS sex, pe.entry_year, pe.grad_year, pse.text AS section,
pn_f.name AS firstname, pn_l.name AS lastname, pn_n.name AS nickname,
IF(pn_uf.name IS NULL, pn_f.name, pn_uf.name) AS firstname_ordinary,
IF(pn_ul.name IS NULL, pn_l.name, pn_ul.name) AS lastname_ordinary,
FROM profiles AS p
INNER JOIN profile_display AS pd ON (pd.pid = p.pid)
INNER JOIN profile_education AS pe ON (pe.pid = p.pid AND FIND_IN_SET(\'primary\', pe.flags))
+ LEFT JOIN profile_section_enum AS pse ON (pse.id = p.section)
INNER JOIN profile_name AS pn_f ON (pn_f.pid = p.pid
AND pn_f.typeid = ' . self::getNameTypeId('firstname', true) . ')
INNER JOIN profile_name AS pn_l ON (pn_l.pid = p.pid
$pf->setCorps($vals[Profile::FETCH_CORPS]);
}
if ($this->hasData(Profile::FETCH_EDU, $vals)) {
- $pf->setEdu($vals[Profile::FETCH_EDU]);
+ $pf->setEducations($vals[Profile::FETCH_EDU]);
}
if ($this->hasData(Profile::FETCH_MEDALS, $vals)) {
$pf->setMedals($vals[Profile::FETCH_MEDALS]);