]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
make Profile::isMember() and Profile::isAdmin() use caching pkeyGet()
authorEvan Prodromou <evan@status.net>
Wed, 6 Apr 2011 22:12:25 +0000 (18:12 -0400)
committerEvan Prodromou <evan@status.net>
Wed, 6 Apr 2011 22:12:25 +0000 (18:12 -0400)
classes/Profile.php

index 9f6398024291e8e3a75725b81e735852dda63e0d..d87ace42c5a77760574699f680850f0746a3efdd 100644 (file)
@@ -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)