Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
5fb3ede1
Commit
5fb3ede1
authored
Aug 21, 2008
by
Nigel McNie
Browse files
Implement caching in group_is_only_admin.
parent
4423c1e9
Changes
1
Hide whitespace changes
Inline
Side-by-side
htdocs/lib/group.php
View file @
5fb3ede1
...
...
@@ -78,7 +78,7 @@ function group_user_access($groupid, $userid=null) {
* @returns boolean
*/
function
group_is_only_admin
(
$groupid
,
$userid
=
null
)
{
// TODO: caching
static
$result
;
$groupid
=
(
int
)
$groupid
;
...
...
@@ -98,8 +98,12 @@ function group_is_only_admin($groupid, $userid=null) {
throw
new
InvalidArgumentException
(
"group_is_only_admin: user argument should be an integer"
);
}
return
group_user_access
(
$groupid
,
$userid
)
==
'admin'
&&
count_records
(
'group_member'
,
'group'
,
$groupid
,
'role'
,
'admin'
)
==
1
;
if
(
isset
(
$result
[
$groupid
][
$userid
]))
{
return
$result
[
$groupid
][
$userid
];
}
return
$result
[
$groupid
][
$userid
]
=
(
group_user_access
(
$groupid
,
$userid
)
==
'admin'
&&
count_records
(
'group_member'
,
'group'
,
$groupid
,
'role'
,
'admin'
)
==
1
);
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment