MDL-43635: Further support custom contexts

Reading from config DB table and reset method for after plugin install
Add PHPUnit test for custom context changes
This commit is contained in:
Brent Boghosian
2014-01-14 11:25:10 -05:00
committed by Damyon Wiese
parent 93881b8011
commit 00dabc896b
2 changed files with 155 additions and 1 deletions

View File

@@ -5787,6 +5787,13 @@ class context_helper extends context {
protected function __construct() {
}
/**
* Reset internal context levels array.
*/
public static function reset_levels() {
self::$alllevels = null;
}
/**
* Initialise context levels, call before using self::$alllevels.
*/
@@ -5809,8 +5816,17 @@ class context_helper extends context {
return;
}
$levels = $CFG->custom_context_classes;
if (!is_array($levels)) {
$levels = @unserialize($levels);
}
if (!is_array($levels)) {
debugging('Invalid $CFG->custom_context_classes detected, value ignored.', DEBUG_DEVELOPER);
return;
}
// Unsupported custom levels, use with care!!!
foreach ($CFG->custom_context_classes as $level => $classname) {
foreach ($levels as $level => $classname) {
self::$alllevels[$level] = $classname;
}
ksort(self::$alllevels);