Skip to content
Browse files

MDL-25316 capabilities defined in subplugins are available when overr…

…iding the module permissions
  • Loading branch information...
1 parent e6f6fa1 commit 61869c550f1c298d27f9a5638664d306d946c411 @mudrd8mz mudrd8mz committed Dec 2, 2010
Showing with 17 additions and 0 deletions.
  1. +17 −0 lib/accesslib.php
View
17 lib/accesslib.php
@@ -3765,6 +3765,20 @@ function fetch_context_capabilities($context) {
$cm = $DB->get_record('course_modules', array('id'=>$context->instanceid));
$module = $DB->get_record('modules', array('id'=>$cm->module));
+ $subcaps = array();
+ $subpluginsfile = "$CFG->dirroot/mod/$module->name/db/subplugins.php";
+ if (file_exists($subpluginsfile)) {
+ $subplugins = array(); // should be redefined in the file
+ include($subpluginsfile);
+ if (!empty($subplugins)) {
+ foreach (array_keys($subplugins) as $subplugintype) {
+ foreach (array_keys(get_plugin_list($subplugintype)) as $subpluginname) {
+ $subcaps = array_merge($subcaps, array_keys(load_capability_def($subplugintype.'_'.$subpluginname)));
+ }
+ }
+ }
+ }
+
$modfile = "$CFG->dirroot/mod/$module->name/lib.php";
if (file_exists($modfile)) {
include_once($modfile);
@@ -3777,6 +3791,8 @@ function fetch_context_capabilities($context) {
$extracaps = array();
}
+ $extracaps = array_merge($subcaps, $extracaps);
+
// All modules allow viewhiddenactivities. This is so you can hide
// the module then override to allow specific roles to see it.
// The actual check is in course page so not module-specific
@@ -4220,6 +4236,7 @@ function get_component_string($component, $contextlevel) {
}
switch ($type) {
+ // TODO this is really hacky
case 'quiz': return get_string($name.':componentname', $component);// insane hack!!!
case 'repository': return get_string('repository', 'repository').': '.get_string('pluginname', $component);
case 'gradeimport': return get_string('gradeimport', 'grades').': '.get_string('pluginname', $component);

0 comments on commit 61869c5

Please sign in to comment.
Something went wrong with that request. Please try again.