Use the same 'pub' definition in all tables.
authorRaphaël Barrois <raphael.barrois@polytechnique.org>
Mon, 13 Jun 2011 23:41:06 +0000 (01:41 +0200)
committerRaphaël Barrois <raphael.barrois@polytechnique.org>
Sat, 23 Jul 2011 15:05:37 +0000 (17:05 +0200)
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
classes/profile.php
classes/profilevisibility.php
classes/userfilter.php
classes/userfilter/conditions.inc.php
upgrade/1.1.2/06_visibility.sql [new file with mode: 0644]

index d004321..b5456fe 100644 (file)
@@ -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)
index 9d870ea..1dd8d6c 100644 (file)
@@ -95,8 +95,6 @@ class ProfileVisibility
     {
         if ($level != null && !$this->isVisible($level)) {
             $level = $this->level();
-        } else {
-            $level = $this->level();
         }
 
         return new ProfileVisibility($level);
index bbaceba..d392073 100644 (file)
@@ -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()
index ab7503e..9c361c1 100644 (file)
@@ -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 (file)
index 0000000..f0dbffe
--- /dev/null
@@ -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';