From fceed6ea036b85ea418d3911f5e33f6d9fabfd0c Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Wed, 29 Sep 2010 14:24:35 +0200 Subject: [PATCH] Add User::isMyProfile($other). Signed-off-by: Florent Bruneau --- classes/user.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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) -- 2.1.4