From 2cdea9c7ac06dafaabed86da8853df42e4a00b37 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20Mudr=C3=A1k?= Date: Tue, 2 Sep 2014 20:53:13 +0200 Subject: [PATCH] MDL-47069 admin: Add option to upload required ZIP at the check page The plugins check page displays other plugins that the current one depends on. Previously, we always displayed the other plugin as a link to the plugins directory. This did not work well in two scenarios: * The admin wants/needs to upload the other plugin from the ZIP file (e.g. it is not available in the plugins directory), * the other plugin is actually a standard plugin that is not supposed to be registered with the plugins directory. This patch displays the Install or Upload or Check for updates links next to the required plugin instead, as appropriate. --- admin/renderer.php | 31 ++++++++++++++++++++----------- lang/en/plugin.php | 2 ++ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/admin/renderer.php b/admin/renderer.php index eb3925cfb0f..26afb9062dd 100644 --- a/admin/renderer.php +++ b/admin/renderer.php @@ -1039,19 +1039,28 @@ class core_admin_renderer extends plugin_renderer_base { } foreach ($plugin->get_other_required_plugins() as $component => $requiredversion) { - $ok = true; $otherplugin = $pluginman->get_plugin_info($component); + $actions = array(); if (is_null($otherplugin)) { - $ok = false; + // The required plugin is not installed. + $class = 'requires-failed requires-missing'; + $installurl = new moodle_url('https://moodle.org/plugins/view.php', array('plugin' => $component)); + $uploadurl = new moodle_url('/admin/tool/installaddon/'); + $actions[] = html_writer::link($installurl, get_string('dependencyinstall', 'core_plugin')); + $actions[] = html_writer::link($uploadurl, get_string('dependencyupload', 'core_plugin')); + } else if ($requiredversion != ANY_VERSION and $otherplugin->versiondisk < $requiredversion) { - $ok = false; - } + // The required plugin is installed but needs to be updated. + $class = 'requires-failed requires-outdated'; + if (!$otherplugin->is_standard()) { + $updateurl = new moodle_url($this->page->url, array('sesskey' => sesskey(), 'fetchupdates' => 1)); + $actions[] = html_writer::link($updateurl, get_string('checkforupdates', 'core_plugin')); + } - if ($ok) { - $class = 'requires-ok'; } else { - $class = 'requires-failed'; + // Already installed plugin with sufficient version. + $class = 'requires-ok'; } if ($requiredversion != ANY_VERSION) { @@ -1059,11 +1068,11 @@ class core_admin_renderer extends plugin_renderer_base { } else { $str = 'otherplugin'; } - $componenturl = new moodle_url('https://moodle.org/plugins/view.php?plugin='.$component); - $componenturl = html_writer::tag('a', $component, array('href' => $componenturl->out())); + $requires[] = html_writer::tag('li', - get_string($str, 'core_plugin', - array('component' => $componenturl, 'version' => $requiredversion)), + html_writer::div(get_string($str, 'core_plugin', + array('component' => $component, 'version' => $requiredversion)), 'component'). + html_writer::div(implode(' | ', $actions), 'actions'), array('class' => $class)); } diff --git a/lang/en/plugin.php b/lang/en/plugin.php index ae687b2e109..4216b879f87 100644 --- a/lang/en/plugin.php +++ b/lang/en/plugin.php @@ -30,6 +30,8 @@ $string['availability'] = 'Availability'; $string['checkforupdates'] = 'Check for available updates'; $string['checkforupdateslast'] = 'Last check done on {$a}'; $string['detectedmisplacedplugin'] = 'Plugin "{$a->component}" is installed in incorrect location "{$a->current}", expected location is "{$a->expected}"'; +$string['dependencyinstall'] = 'Install'; +$string['dependencyupload'] = 'Upload'; $string['displayname'] = 'Plugin name'; $string['err_response_curl'] = 'Unable to fetch available updates data - unexpected cURL error.'; $string['err_response_format_version'] = 'Unexpected version of the response format. Please try to re-check for available updates.'; -- 2.43.0