Details
-
Type:
New Feature
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 1.9, 2.0
-
Fix Version/s: None
-
Component/s: Roles / Access
-
Labels:None
-
Difficulty:Difficult
-
Affected Branches:MOODLE_19_STABLE, MOODLE_20_STABLE
Description
This issue is in reference to http://moodle.org/mod/forum/discuss.php?d=111362.
In brief, one of our Moodle extensions would benefit greatly from being able to use Moodle's roles and contexts system, and we would need to define our own context levels. However, we would like to be able to do this without having to differ from core in unmaintainable ways.
We believe that this would be helpful to many other Moodle partners and plugin developers, and some of our proposed changes may help to improve the maintainability and readability of core Moodle code.
remove_switch_statements.diff adds removes some of the huge switch statements, and does some other reorganizing of context level-specific functions into classes, as outlined in http://moodle.org/mod/forum/discuss.php?d=111362#p561990 . It also replaces the array in get_context_instance with the context_levels array defined in the patch.
This applies against Moodle 1.9, and so is missing changes to get_context_url and get_contextlevel_name which are only in Moodle 2.0, but they can be easily added once this patch is reviewed.
We did not change create_contexts – it is only used for upgrading from Moodle 1.6, or for the grade letter upgrade.