From: Florent Bruneau Date: Wed, 29 Sep 2010 12:24:35 +0000 (+0200) Subject: Add User::isMyProfile($other). X-Git-Tag: xorg/1.0.1~138 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=fceed6ea036b85ea418d3911f5e33f6d9fabfd0c;p=platal.git Add User::isMyProfile($other). Signed-off-by: Florent Bruneau --- diff --git a/classes/user.php b/classes/user.php index c265bf0..49f7931 100644 --- a/classes/user.php +++ b/classes/user.php @@ -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)