role_context_capabilities should handle current context too and role override simply use parent context

This commit is contained in:
skodak
2006-09-20 06:24:55 +00:00
parent bcaa8d9322
commit 8521d83aff
2 changed files with 12 additions and 9 deletions
+3 -8
View File
@@ -1971,13 +1971,8 @@ function fetch_context_capabilities($context) {
function role_context_capabilities($roleid, $context, $cap='') {
global $CFG;
$sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
if ($sitecontext->id == $context->id) {
$contexts = array($sitecontext->id);
} else {
// first of all, figure out all parental contexts
$contexts = array_reverse(get_parent_contexts($context));
}
$contexts = get_parent_contexts($context);
$contexts[] = $context->id;
$contexts = '('.implode(',', $contexts).')';
if ($cap) {
@@ -2579,4 +2574,4 @@ function get_user_capability_course($capability, $userid='') {
}
return $usercourses;
}
?>
?>