Commit 4423c1e9 authored by Nigel McNie's avatar Nigel McNie
Browse files

Implement result caching in group_user_access.

parent 9c95720a
......@@ -40,7 +40,7 @@ defined('INTERNAL') || die();
* have no role in the group
*/
function group_user_access($groupid, $userid=null) {
// TODO: caching
static $result;
$groupid = (int)$groupid;
......@@ -60,7 +60,11 @@ function group_user_access($groupid, $userid=null) {
throw new InvalidArgumentException("group_user_access: user argument should be an integer");
}
return get_field('group_member', 'role', 'group', $groupid, 'member', $userid);
if (isset($result[$groupid][$userid])) {
return $result[$groupid][$userid];
}
return $result[$groupid][$userid] = get_field('group_member', 'role', 'group', $groupid, 'member', $userid);
}
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment