mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-78346 tool_langimport: Print any notifications before redirect
This commit is contained in:
parent
68122a9d89
commit
cc193bd7a6
2 changed files with 24 additions and 3 deletions
|
@ -24,6 +24,8 @@
|
||||||
|
|
||||||
namespace tool_langimport;
|
namespace tool_langimport;
|
||||||
|
|
||||||
|
use moodle_url;
|
||||||
|
|
||||||
defined('MOODLE_INTERNAL') || die();
|
defined('MOODLE_INTERNAL') || die();
|
||||||
require_once($CFG->libdir.'/filelib.php');
|
require_once($CFG->libdir.'/filelib.php');
|
||||||
require_once($CFG->libdir.'/componentlib.class.php');
|
require_once($CFG->libdir.'/componentlib.class.php');
|
||||||
|
@ -59,6 +61,25 @@ class controller {
|
||||||
$this->availablelangs = $this->installer->get_remote_list_of_languages();
|
$this->availablelangs = $this->installer->get_remote_list_of_languages();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redirect to the specified url, outputting any required messages.
|
||||||
|
*
|
||||||
|
* @param moodle_url $url
|
||||||
|
*/
|
||||||
|
public function redirect(moodle_url $url): void {
|
||||||
|
if ($this->info) {
|
||||||
|
$info = implode('<br />', $this->info);
|
||||||
|
\core\notification::success($info);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->errors) {
|
||||||
|
$info = implode('<br />', $this->errors);
|
||||||
|
\core\notification::error($info);
|
||||||
|
}
|
||||||
|
|
||||||
|
redirect($url);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Install language packs provided
|
* Install language packs provided
|
||||||
*
|
*
|
||||||
|
|
|
@ -76,12 +76,12 @@ if (($mode == INSTALLATION_OF_SELECTED_LANG) and confirm_sesskey() and !empty($p
|
||||||
if (is_array($pack) && count($pack) > 1) {
|
if (is_array($pack) && count($pack) > 1) {
|
||||||
// Installing multiple languages can take a while - perform it asynchronously in the background.
|
// Installing multiple languages can take a while - perform it asynchronously in the background.
|
||||||
$controller->schedule_languagepacks_installation($pack);
|
$controller->schedule_languagepacks_installation($pack);
|
||||||
redirect($PAGE->url);
|
$controller->redirect($PAGE->url);
|
||||||
} else {
|
} else {
|
||||||
// Single language pack to be installed synchronously. It should be reasonably quick and can be used for debugging, too.
|
// Single language pack to be installed synchronously. It should be reasonably quick and can be used for debugging, too.
|
||||||
core_php_time_limit::raise();
|
core_php_time_limit::raise();
|
||||||
$controller->install_languagepacks($pack);
|
$controller->install_languagepacks($pack);
|
||||||
redirect($PAGE->url);
|
$controller->redirect($PAGE->url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ if ($mode == DELETION_OF_SELECTED_LANG and (!empty($uninstalllang) or !empty($co
|
||||||
foreach ($uninstalllang as $ulang) {
|
foreach ($uninstalllang as $ulang) {
|
||||||
$controller->uninstall_language($ulang);
|
$controller->uninstall_language($ulang);
|
||||||
}
|
}
|
||||||
redirect($PAGE->url);
|
$controller->redirect($PAGE->url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue