From 5d7a4bab3f25b3f24418df07dede7ca04060cd71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mudr=C3=A1k?= Date: Sat, 20 Apr 2013 01:51:16 +0200 Subject: [PATCH 1/2] MDL-39249 Return to the correct page after successful update deployment 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 | 2 +- admin/renderer.php | 4 ++-- lib/pluginlib.php | 11 ++++++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/admin/plugins.php b/admin/plugins.php index 972bf518d5a..08157df89d6 100644 --- a/admin/plugins.php +++ b/admin/plugins.php @@ -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)) { diff --git a/admin/renderer.php b/admin/renderer.php index 5f96325f6e4..7108823adfe 100644 --- a/admin/renderer.php +++ b/admin/renderer.php @@ -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(); diff --git a/lib/pluginlib.php b/lib/pluginlib.php index c426414a2b7..fe3aa73eb5e 100644 --- a/lib/pluginlib.php +++ b/lib/pluginlib.php @@ -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)) { From 7b1e0645c17a320971e8fc5eeeec87715ed3deba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mudr=C3=A1k?= Date: Sat, 20 Apr 2013 01:54:01 +0200 Subject: [PATCH 2/2] MDL-39249 Fix typo in available_update_deployer class I have accidentally spotted this typo while working on this branch. It has never caused any harm as both parameters callerurl and returnurl are always passed. Blame copy/pasting of code blocks. --- lib/pluginlib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pluginlib.php b/lib/pluginlib.php index fe3aa73eb5e..a9ad0358f4a 100644 --- a/lib/pluginlib.php +++ b/lib/pluginlib.php @@ -2211,7 +2211,7 @@ class available_update_deployer { if (!empty($this->callerurl)) { $data['callerurl'] = $this->callerurl->out(false); } - if (!empty($this->callerurl)) { + if (!empty($this->returnurl)) { $data['returnurl'] = $this->returnurl->out(false); }