Skip to content

Commit

Permalink
Merge branch 'MDL-78346-400' of https://github.com/andrewnicols/moodle
Browse files Browse the repository at this point in the history
…into MOODLE_400_STABLE
  • Loading branch information
junpataleta committed May 25, 2023
2 parents 723c26a + fbc7ce0 commit fcf1329
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
21 changes: 21 additions & 0 deletions admin/tool/langimport/classes/controller.php
Expand Up @@ -24,6 +24,8 @@

namespace tool_langimport;

use moodle_url;

defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir.'/filelib.php');
require_once($CFG->libdir.'/componentlib.class.php');
Expand Down Expand Up @@ -59,6 +61,25 @@ public function __construct() {
$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
*
Expand Down
6 changes: 3 additions & 3 deletions admin/tool/langimport/index.php
Expand Up @@ -76,12 +76,12 @@
if (is_array($pack) && count($pack) > 1) {
// Installing multiple languages can take a while - perform it asynchronously in the background.
$controller->schedule_languagepacks_installation($pack);
redirect($PAGE->url);
$controller->redirect($PAGE->url);
} else {
// Single language pack to be installed synchronously. It should be reasonably quick and can be used for debugging, too.
core_php_time_limit::raise();
$controller->install_languagepacks($pack);
redirect($PAGE->url);
$controller->redirect($PAGE->url);
}
}

Expand Down Expand Up @@ -110,7 +110,7 @@
foreach ($uninstalllang as $ulang) {
$controller->uninstall_language($ulang);
}
redirect($PAGE->url);
$controller->redirect($PAGE->url);
}
}

Expand Down

0 comments on commit fcf1329

Please sign in to comment.