From: Evan Prodromou Date: Wed, 6 Apr 2011 22:12:25 +0000 (-0400) Subject: make Profile::isMember() and Profile::isAdmin() use caching pkeyGet() X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=29243cd21aa9c0575bb3c1376d350469e7531804;p=quix0rs-gnu-social.git make Profile::isMember() and Profile::isAdmin() use caching pkeyGet() --- 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)