mirror of
https://github.com/moodle/moodle.git
synced 2025-07-25 08:11:39 +02:00
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:
committed by
Damyon Wiese
parent
93881b8011
commit
00dabc896b
@@ -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);
|
||||
|
Reference in New Issue
Block a user