make Profile::isMember() and Profile::isAdmin() use caching pkeyGet()
This commit is contained in:
parent
402c0654ea
commit
29243cd21a
|
@ -211,31 +211,16 @@ class Profile extends Memcached_DataObject
|
||||||
|
|
||||||
function isMember($group)
|
function isMember($group)
|
||||||
{
|
{
|
||||||
$mem = new Group_member();
|
$gm = Group_member::pkeyGet(array('profile_id' => $this->id,
|
||||||
|
'group_id' => $group->id));
|
||||||
$mem->group_id = $group->id;
|
return (!empty($gm));
|
||||||
$mem->profile_id = $this->id;
|
|
||||||
|
|
||||||
if ($mem->find()) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isAdmin($group)
|
function isAdmin($group)
|
||||||
{
|
{
|
||||||
$mem = new Group_member();
|
$gm = Group_member::pkeyGet(array('profile_id' => $this->id,
|
||||||
|
'group_id' => $group->id));
|
||||||
$mem->group_id = $group->id;
|
return (!empty($gm) && $gm->is_admin);
|
||||||
$mem->profile_id = $this->id;
|
|
||||||
$mem->is_admin = 1;
|
|
||||||
|
|
||||||
if ($mem->find()) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isPendingMember($group)
|
function isPendingMember($group)
|
||||||
|
|
Loading…
Reference in New Issue