From: Raphaël Barrois Date: Fri, 2 Apr 2010 08:23:53 +0000 (+0200) Subject: Set visibility for section and binets to private X-Git-Tag: xorg/1.0.0~323 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=875a88d34072686e9deb802692280c8883d07c30;p=platal.git Set visibility for section and binets to private Signed-off-by: Raphaël Barrois --- diff --git a/classes/profile.php b/classes/profile.php index a397da7..834667b 100644 --- a/classes/profile.php +++ b/classes/profile.php @@ -637,16 +637,24 @@ class Profile */ public function getBinets() { - return XDB::fetchColumn('SELECT binet_id - FROM profile_binets - WHERE pid = {?}', $this->id()); + if ($this->visibility->isVisible(ProfileVisibility::VIS_PRIVATE)) { + return XDB::fetchColumn('SELECT binet_id + FROM profile_binets + WHERE pid = {?}', $this->id()); + } else { + return array(); + } } 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()); + if ($this->visibility->isVisible(ProfileVisibility::VIS_PRIVATE)) { + 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()); + } else { + return array(); + } } /* Medals @@ -701,7 +709,8 @@ class Profile $visibility = new ProfileVisibility($visibility); - $it = XDB::Iterator('SELECT p.*, p.sex = \'female\' AS sex, pe.entry_year, pe.grad_year, pse.text AS section, + $it = XDB::Iterator('SELECT p.*, p.sex = \'female\' AS sex, pe.entry_year, pe.grad_year, + IF ({?} IN {?}, pse.text, NULL) 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, @@ -732,7 +741,7 @@ class Profile LEFT JOIN account_profiles AS ap ON (ap.pid = p.pid AND FIND_IN_SET(\'owner\', ap.perms)) WHERE p.pid IN ' . XDB::formatArray($pids) . ' GROUP BY p.pid - ' . $order, $visibility->levels(), $visibility->levels()); + ' . $order, ProfileVisibility::VIS_PRIVATE, $visibility->levels(), $visibility->levels(), $visibility->levels()); return new ProfileIterator($it, $pids, $fields, $visibility); }