X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=classes%2Fprofile.php;h=4758abb6926f94ba24426c1ac2e8e59adf005e93;hb=e859bdaf82fa2c0c548a65e54a445a469728fd54;hp=a81087068e0495b620f08e6b1867cbaa134a6c8c;hpb=949fc7367d8a29d15f8d29cdea34491daeec9d41;p=platal.git diff --git a/classes/profile.php b/classes/profile.php index a810870..4758abb 100644 --- a/classes/profile.php +++ b/classes/profile.php @@ -82,16 +82,17 @@ class Profile 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; @@ -106,6 +107,8 @@ class Profile $this->hrpid = $this->data['hrpid']; if (!S::logged()) { $this->setVisibilityLevel(self::VISIBILITY_PUBLIC); + } else { + $this->setVisibilityLevel(self::VISIBILITY_PRIVATE); } } @@ -366,6 +369,10 @@ class Profile if ($this->addresses == null) { $this->setAddresses($this->getProfileField('ProfileAddresses')); } + + if ($this->addresses == null) { + return PlIteratorUtils::emptyIterator(); + } return $this->addresses->get($flags, $limit); } @@ -393,6 +400,10 @@ class Profile if ($this->educations == null) { $this->setEducations($this->getProfileField('ProfileEducation')); } + + if ($this->educations == null) { + return PlIteratorUtils::emptyIterator(); + } return $this->educations->get($flags, $limit); } @@ -415,6 +426,9 @@ class Profile if ($this->networks == null) { $this->setNetworking($this->getProfileField('ProfileNetworking')); } + if ($this->networks == null) { + return PlIteratorUtils::emptyIterator(); + } return $this->networks->get($flags, $limit); } @@ -444,10 +458,13 @@ class Profile $this->setJobs($this->getProfileField('ProfileJobs')); } + if ($this->jobs == null) { + return PlIteratorUtils::emptyIterator(); + } return $this->jobs->get($flags, $limit); } - public function getMailJob() + public function getMainJob() { $job = $this->getJobs(self::JOBS_MAIN, 1); if ($job->total() != 1) { @@ -464,7 +481,32 @@ class Profile 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() { @@ -503,7 +545,7 @@ class Profile } - $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, @@ -515,6 +557,7 @@ class Profile 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 @@ -814,7 +857,7 @@ class ProfileIterator implements PlIterator $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]);