mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
MDL-77269 licencemanager: show notification instead of an exception
This commit is contained in:
parent
8503f2cfd8
commit
3236bf8e11
@ -95,7 +95,7 @@ class manager {
|
||||
}
|
||||
|
||||
$viewmanager = true;
|
||||
|
||||
$message = null;
|
||||
switch ($action) {
|
||||
case self::ACTION_DISABLE:
|
||||
license_manager::disable($license);
|
||||
@ -106,7 +106,12 @@ class manager {
|
||||
break;
|
||||
|
||||
case self::ACTION_DELETE:
|
||||
try {
|
||||
license_manager::delete($license);
|
||||
} catch (\moodle_exception $e) {
|
||||
$message = $e->getMessage();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case self::ACTION_CREATE:
|
||||
@ -124,7 +129,7 @@ class manager {
|
||||
break;
|
||||
}
|
||||
if ($viewmanager) {
|
||||
$this->view_license_manager();
|
||||
$this->view_license_manager($message);
|
||||
}
|
||||
}
|
||||
|
||||
@ -229,8 +234,8 @@ class manager {
|
||||
/**
|
||||
* View the license manager.
|
||||
*/
|
||||
private function view_license_manager() : void {
|
||||
global $PAGE;
|
||||
private function view_license_manager(string $message = null) : void {
|
||||
global $PAGE, $OUTPUT;
|
||||
|
||||
$PAGE->requires->js_call_amd('tool_licensemanager/delete_license');
|
||||
|
||||
@ -238,6 +243,10 @@ class manager {
|
||||
$html = $renderer->header();
|
||||
$html .= $renderer->heading(get_string('licensemanager', 'tool_licensemanager'));
|
||||
|
||||
if (!empty($message)) {
|
||||
$html .= $OUTPUT->notification($message);
|
||||
}
|
||||
|
||||
$table = new \tool_licensemanager\output\table();
|
||||
$html .= $renderer->render($table);
|
||||
$html .= $renderer->footer();
|
||||
|
Loading…
x
Reference in New Issue
Block a user