Add User::isMyProfile($other).
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Wed, 29 Sep 2010 12:24:35 +0000 (14:24 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Wed, 29 Sep 2010 12:24:35 +0000 (14:24 +0200)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
classes/user.php

index c265bf0..49f7931 100644 (file)
@@ -327,6 +327,19 @@ class User extends PlUser
         return !is_null($this->profile());
     }
 
+    /** Return true if given a reference to the profile of this user.
+     */
+    public function isMyProfile($other)
+    {
+        if (!$other) {
+            return false;
+        } else if ($other instanceof Profile) {
+            $profile = $this->profile();
+            return $profile && $profile->id() == $other->id();
+        }
+        return false;
+    }
+
     /** Check if the user can edit to given profile.
      */
     public function canEdit(Profile $profile)