From 29243cd21aa9c0575bb3c1376d350469e7531804 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 6 Apr 2011 18:12:25 -0400 Subject: [PATCH] make Profile::isMember() and Profile::isAdmin() use caching pkeyGet() --- classes/Profile.php | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/classes/Profile.php b/classes/Profile.php index 9f63980242..d87ace42c5 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -211,31 +211,16 @@ class Profile extends Memcached_DataObject function isMember($group) { - $mem = new Group_member(); - - $mem->group_id = $group->id; - $mem->profile_id = $this->id; - - if ($mem->find()) { - return true; - } else { - return false; - } + $gm = Group_member::pkeyGet(array('profile_id' => $this->id, + 'group_id' => $group->id)); + return (!empty($gm)); } function isAdmin($group) { - $mem = new Group_member(); - - $mem->group_id = $group->id; - $mem->profile_id = $this->id; - $mem->is_admin = 1; - - if ($mem->find()) { - return true; - } else { - return false; - } + $gm = Group_member::pkeyGet(array('profile_id' => $this->id, + 'group_id' => $group->id)); + return (!empty($gm) && $gm->is_admin); } function isPendingMember($group) -- 2.39.5