MDL-30789 add new update_status() method to enrol plugins and improve enrol cache invalidation

This commit is contained in:
Petr Skoda 2011-12-18 17:02:16 +01:00
parent f89a83b87b
commit af7177dbcb
2 changed files with 30 additions and 9 deletions

View file

@ -98,7 +98,6 @@ if ($canconfig and $action and confirm_sesskey()) {
if ($confirm) {
$plugin->delete_instance($instance);
$context->mark_dirty(); // invalidate all enrol caches
redirect($PAGE->url);
}
@ -113,19 +112,17 @@ if ($canconfig and $action and confirm_sesskey()) {
} else if ($action === 'disable') {
$instance = $instances[$instanceid];
if ($instance->status == ENROL_INSTANCE_ENABLED) {
$instance->status = ENROL_INSTANCE_DISABLED;
$DB->update_record('enrol', $instance);
$context->mark_dirty(); // invalidate all enrol caches
$plugin = $plugins[$instance->enrol];
if ($instance->status != ENROL_INSTANCE_DISABLED) {
$plugin->update_status($instance, ENROL_INSTANCE_DISABLED);
redirect($PAGE->url);
}
} else if ($action === 'enable') {
$instance = $instances[$instanceid];
if ($instance->status == ENROL_INSTANCE_DISABLED) {
$instance->status = ENROL_INSTANCE_ENABLED;
$DB->update_record('enrol', $instance);
$context->mark_dirty(); // invalidate all enrol caches
$plugin = $plugins[$instance->enrol];
if ($instance->status != ENROL_INSTANCE_ENABLED) {
$plugin->update_status($instance, ENROL_INSTANCE_ENABLED);
redirect($PAGE->url);
}
}