From: Raphaël Barrois Date: Mon, 13 Jun 2011 23:41:06 +0000 (+0200) Subject: Use the same 'pub' definition in all tables. X-Git-Tag: xorg/1.1.3~38 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=e4f1d25863b635010a493d733d6d4f22e283eea9;p=platal.git Use the same 'pub' definition in all tables. Signed-off-by: Raphaël Barrois --- diff --git a/classes/profile.php b/classes/profile.php index d004321..b5456fe 100644 --- a/classes/profile.php +++ b/classes/profile.php @@ -387,7 +387,7 @@ class Profile implements PlExportable public function displayEmail() { $o = $this->owner(); - if ($o != null) { + if ($o != null && $this->isVisible(ProfileVisibility::VIS_PRIVATE)) { return $o->bestEmail(); } else { return $this->email_directory; @@ -1107,7 +1107,7 @@ class Profile implements PlExportable if (count($uids) == 0) { return array(); } - return self::getBulkProfilesWithPIDs(self::getPIDsFromUIDs($uids), $fields, ProfileVisibility $visibility); + return self::getBulkProfilesWithPIDs(self::getPIDsFromUIDs($uids), $fields, $visibility); } public static function isDisplayName($name) diff --git a/classes/profilevisibility.php b/classes/profilevisibility.php index 9d870ea..1dd8d6c 100644 --- a/classes/profilevisibility.php +++ b/classes/profilevisibility.php @@ -95,8 +95,6 @@ class ProfileVisibility { if ($level != null && !$this->isVisible($level)) { $level = $this->level(); - } else { - $level = $this->level(); } return new ProfileVisibility($level); diff --git a/classes/userfilter.php b/classes/userfilter.php index bbaceba..d392073 100644 --- a/classes/userfilter.php +++ b/classes/userfilter.php @@ -130,9 +130,16 @@ class UserFilter extends PlFilter return $this->profile_visibility->level(); } + public function getVisibilityLevels() + { + return $this->profile_visibility->levels(); + } + public function getVisibilityCondition($field) { - return XDB::format($field . ' >= {?}', $this->getVisibilityLevel()); + // Fields are ordered as ('hidden', 'private', 'ax', 'public', 'none') + // Which gives 'ax' >= 'private' + return XDB::format($field . ' IN {?}', $this->getVisibilityLevels()); } private function buildQuery() diff --git a/classes/userfilter/conditions.inc.php b/classes/userfilter/conditions.inc.php index ab7503e..9c361c1 100644 --- a/classes/userfilter/conditions.inc.php +++ b/classes/userfilter/conditions.inc.php @@ -668,6 +668,9 @@ class UFC_NameTokens extends UserFilterCondition if ($this->general_type) { $c .= XDB::format(' AND ' . $sub . '.general_type = {?}', $this->general_type); } + if (!$uf->isVisible(ProfileVisibility::VIS_PRIVATE)) { + $c .= XDB::format(' AND ' . $sub . '.general_type != \'nickname\''); + } $conds[] = $c; } diff --git a/upgrade/1.1.2/06_visibility.sql b/upgrade/1.1.2/06_visibility.sql new file mode 100644 index 0000000..f0dbffe --- /dev/null +++ b/upgrade/1.1.2/06_visibility.sql @@ -0,0 +1,5 @@ +ALTER TABLE profile_addresses CHANGE COLUMN pub pub ENUM('hidden', 'private', 'ax', 'public', 'none') NOT NULL DEFAULT 'private'; +ALTER TABLE profile_corps CHANGE COLUMN pub pub ENUM('hidden', 'private', 'ax', 'public', 'none') NOT NULL DEFAULT 'private'; +ALTER TABLE profile_job CHANGE COLUMN pub pub ENUM('hidden', 'private', 'ax', 'public', 'none') NOT NULL DEFAULT 'private'; +ALTER TABLE profile_job CHANGE COLUMN email_pub email_pub ENUM('hidden', 'private', 'ax', 'public', 'none') NOT NULL DEFAULT 'private'; +ALTER TABLE profile_phone CHANGE COLUMN pub pub ENUM('hidden', 'private', 'ax', 'public', 'none') NOT NULL DEFAULT 'private';