From: moodler Date: Sun, 13 Aug 2006 09:25:45 +0000 (+0000) Subject: More language-related tidyups and a new get_local_override() function X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=8737be587d5185e48c39808a4c9daf89a8315b7f;p=moodle.git More language-related tidyups and a new get_local_override() function --- diff --git a/admin/roles/manage.html b/admin/roles/manage.html index c07d65e4ef..bf97a1467e 100755 --- a/admin/roles/manage.html +++ b/admin/roles/manage.html @@ -9,55 +9,62 @@

- - - - - component != $component or $capability->contextlevel != $contextlevel) { - echo (''); - } - - // these 2 are used to see to group same mod/core capabilities together - $contextlevel = $capability->contextlevel; - $component = $capability->component; - - // check the capability override for this cap, this role in this context - - $SQL = "select * from {$CFG->prefix}role_capabilities where - roleid = $roleid and capability = '$capability->name' and contextid = $contextid"; - - $localoverride = get_record_sql($SQL); - - if (isset($r_caps[$capability->name])) { - $isallow = $r_caps[$capability->name] > 0; - $isprevent = $r_caps[$capability->name] < 0 && $r_caps[$capability->name] > -500; - $isprohibit = $r_caps[$capability->name] <= -500; - } else { - $isallow = 0; - $isprevent = 0; - $isprohibit = 0; - } - - ?> - - - - - - - - - - -
Capability NameInheritAllowPreventProhibit
'.get_component_string($capability->component, $capability->contextlevel).'
name); ?>permission) || $localoverride->permission==0){ echo 'checked="checked"'; }?>>permission) && $localoverride->permission==1){ echo 'checked="checked"'; }?>>permission) && $localoverride->permission==-1){ echo 'checked="checked"'; }?>>permission) && $localoverride->permission==-1000){ echo 'checked="checked"'; }?>>
+ + + + + + + + + +component != $component or $capability->contextlevel != $contextlevel) { + echo (''); + } + + // these 2 are used to see to group same mod/core capabilities together + $contextlevel = $capability->contextlevel; + $component = $capability->component; + + // check the capability override for this cap, this role in this context + + $SQL = "select * from {$CFG->prefix}role_capabilities where + roleid = $roleid and capability = '$capability->name' and contextid = $contextid"; + get_record_sql($SQL); + + $localoverride = get_local_override($roleid, $contextid, $capability->name); + + if (isset($r_caps[$capability->name])) { + $isallow = $r_caps[$capability->name] > 0; + $isprevent = $r_caps[$capability->name] < 0 && $r_caps[$capability->name] > -500; + $isprohibit = $r_caps[$capability->name] <= -500; + } else { + $isallow = 0; + $isprevent = 0; + $isprohibit = 0; + } + + ?> + + + + + + + + + + +
'. + get_component_string($capability->component, $capability->contextlevel).'
name); ?>permission) || $localoverride->permission==0){ echo 'checked="checked"'; }?>>permission) && $localoverride->permission==1){ echo 'checked="checked"'; }?>>permission) && $localoverride->permission==-1){ echo 'checked="checked"'; }?>>permission) && $localoverride->permission==-1000){ echo 'checked="checked"'; }?>>


diff --git a/lang/en_utf8/role.php b/lang/en_utf8/role.php index ec415fc04d..7c6d8d0b8b 100644 --- a/lang/en_utf8/role.php +++ b/lang/en_utf8/role.php @@ -2,11 +2,16 @@ // role.php $string['assignroles'] = 'Assign roles'; +$string['allow'] = 'Allow'; +$string['capability'] = 'Capability'; $string['currentrole'] = 'Current role'; $string['currentcontext'] = 'Current context'; $string['existingusers'] = '$a existing users'; +$string['inherit'] = 'Inherit'; $string['overrideroles'] = 'Override roles'; $string['potentialusers'] = '$a potential users'; +$string['prevent'] = 'Prevent'; +$string['prohibit'] = 'Prohibit'; $string['site:doanything'] = 'Allowed to do everything'; $string['legacy:guest'] = 'LEGACY ROLE: Guest'; diff --git a/lib/accesslib.php b/lib/accesslib.php index 66cf57bdda..4723cf046c 100755 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -828,6 +828,16 @@ function context_level($contextid) { } +/** + * Get the local override (if any) for a given capability in a role in a context + * @param $roleid + * @param $instance + */ +function get_local_override($roleid, $contextid, $capability) { + return get_record('role_capabilities', 'roleid', $roleid, 'capability', $capability, 'contextid', $contextid); +} + + /************************************ * DB TABLE RELATED FUNCTIONS *