Skip to content

Commit

Permalink
MDL-35238 Admin renderer method to display the plugin update confirma…
Browse files Browse the repository at this point in the history
…tion page
  • Loading branch information
mudrd8mz committed Nov 8, 2012
1 parent bcc8397 commit 6aa2e28
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
54 changes: 54 additions & 0 deletions admin/renderer.php
Expand Up @@ -234,6 +234,60 @@ public function upgrade_plugin_check_page(plugin_manager $pluginman, available_u
return $output;
}

/**
* Prints a page with a summary of plugin deployment to be confirmed.
*
* @param available_update_deployer $deployer
* @param array $data deployer's data package as returned by {@link available_update_deployer::submitted_data()}
* @return string
*/
public function upgrade_plugin_confirm_deploy_page(available_update_deployer $deployer, array $data) {

if (!$deployer->initialized()) {
throw new coding_exception('Unable to render a page for non-initialized deployer.');
}

if (empty($data['updateinfo'])) {
throw new coding_exception('Missing required data component.');
}

$updateinfo = $data['updateinfo'];

$output = '';
$output .= $this->header();
$output .= $this->container_start('generalbox', 'notice');

$a = new stdClass();
if (get_string_manager()->string_exists('pluginname', $updateinfo->component)) {
$a->name = get_string('pluginname', $updateinfo->component);
} else {
$a->name = $updateinfo->component;
}

if (isset($updateinfo->release)) {
$a->version = $updateinfo->release . ' (' . $updateinfo->version . ')';
} else {
$a->version = $updateinfo->version;
}
$a->url = $updateinfo->download;

$output .= $this->output->heading(get_string('updatepluginconfirm', 'core_plugin'));
$output .= $this->output->container(format_text(
get_string('updatepluginconfirminfo', 'core_plugin', $a) . PHP_EOL . PHP_EOL .
get_string('updatepluginconfirmwarning', 'core_plugin')
));

$widget = $deployer->make_execution_widget($data['updateinfo']);
$output .= $this->output->render($widget);

$output .= $this->output->single_button($data['returnurl'], get_string('cancel', 'core'), 'get');

$output .= $this->container_end();
$output .= $this->footer();

return $output;
}

/**
* Display the admin notifications page.
* @param int $maturity
Expand Down
3 changes: 3 additions & 0 deletions lang/en/plugin.php
Expand Up @@ -131,6 +131,9 @@
$string['updateavailable'] = 'There is a new version {$a} available!';
$string['updateavailable_moreinfo'] = 'More info...';
$string['updateavailable_release'] = 'Release {$a}';
$string['updatepluginconfirm'] = 'Plugin update confirmation';
$string['updatepluginconfirminfo'] = 'You are about to install a new version of the plugin <strong>{$a->name}</strong>. A zip package with version {$a->version} of the plugin will be downloaded from <a href="{$a->url}">{$a->url}</a> and extracted to your Moodle installation so it can upgrade your installation.';
$string['updatepluginconfirmwarning'] = 'Please note that Moodle will not automatically make a backup of your database before the upgrade. We strongly recommend that you make a full snapshot backup now, to cope with the rare case that the new code has bugs that make your site unavailable or even corrupts your database. Proceed at your own risk.';
$string['uninstall'] = 'Uninstall';
$string['version'] = 'Version';
$string['versiondb'] = 'Current version';
Expand Down

0 comments on commit 6aa2e28

Please sign in to comment.