MDL-39249 Return to the correct page after successful update deployment
authorDavid Mudrák <david@moodle.com>
Fri, 19 Apr 2013 23:51:16 +0000 (01:51 +0200)
committerDavid Mudrák <david@moodle.com>
Sat, 20 Apr 2013 01:00:19 +0000 (03:00 +0200)
The method available_update_deployer::make_execution_widget() used to
have hard-coded return URL. Now it accepts the return URL as the second
parameter and passes it to the mdeploy.php utility.

The callerurl parameter is now correctly passed and used.

admin/plugins.php
admin/renderer.php
lib/pluginlib.php

index 972bf51..08157df 100644 (file)
@@ -152,7 +152,7 @@ if ($fetchremote) {
 $deployer = available_update_deployer::instance();
 if ($deployer->enabled()) {
     $myurl = new moodle_url($PAGE->url, array('updatesonly' => $updatesonly, 'contribonly' => $contribonly));
-    $deployer->initialize($myurl, $myurl);
+    $deployer->initialize($myurl, new moodle_url('/admin'));
 
     $deploydata = $deployer->submitted_data();
     if (!empty($deploydata)) {
index 5f96325..7108823 100644 (file)
@@ -279,10 +279,10 @@ class core_admin_renderer extends plugin_renderer_base {
             $output .= $this->output->container(get_string('updatepluginconfirmexternal', 'core_plugin', $repotype), 'updatepluginconfirmexternal');
         }
 
-        $widget = $deployer->make_execution_widget($data['updateinfo']);
+        $widget = $deployer->make_execution_widget($data['updateinfo'], $data['returnurl']);
         $output .= $this->output->render($widget);
 
-        $output .= $this->output->single_button($data['returnurl'], get_string('cancel', 'core'), 'get');
+        $output .= $this->output->single_button($data['callerurl'], get_string('cancel', 'core'), 'get');
 
         $output .= $this->container_end();
         $output .= $this->footer();
index c426414..fe3aa73 100644 (file)
@@ -2003,9 +2003,10 @@ class available_update_deployer {
      * Prepares a renderable widget to execute installation of an available update.
      *
      * @param available_update_info $info component version to deploy
+     * @param moodle_url $returnurl URL to return after the installation execution
      * @return renderable
      */
-    public function make_execution_widget(available_update_info $info) {
+    public function make_execution_widget(available_update_info $info, moodle_url $returnurl = null) {
         global $CFG;
 
         if (!$this->initialized()) {
@@ -2022,7 +2023,11 @@ class available_update_deployer {
 
         list($passfile, $password) = $this->prepare_authorization();
 
-        $upgradeurl = new moodle_url('/admin');
+        if (is_null($returnurl)) {
+            $returnurl = new moodle_url('/admin');
+        } else {
+            $returnurl = $returnurl;
+        }
 
         $params = array(
             'upgrade' => true,
@@ -2035,7 +2040,7 @@ class available_update_deployer {
             'dirroot' => $CFG->dirroot,
             'passfile' => $passfile,
             'password' => $password,
-            'returnurl' => $upgradeurl->out(true),
+            'returnurl' => $returnurl->out(false),
         );
 
         if (!empty($CFG->proxyhost)) {