Commit 9137a89a authored by David Mudrák's avatar David Mudrák
Browse files

MDL-49329 admin: Improve the UI for installing dependencies

parent 2f29cf6e
......@@ -106,7 +106,8 @@ $agreelicense = optional_param('agreelicense', 0, PARAM_BOOL);
$fetchupdates = optional_param('fetchupdates', 0, PARAM_BOOL);
$newaddonreq = optional_param('installaddonrequest', null, PARAM_RAW);
$upgradekeyhash = optional_param('upgradekeyhash', null, PARAM_ALPHANUM);
$installalldeps = optional_param('installalldeps', false, PARAM_BOOL);
$installdep = optional_param('installdep', null, PARAM_COMPONENT);
$installdepx = optional_param('installdepx', false, PARAM_BOOL);
$abortinstall = optional_param('abortinstall', null, PARAM_COMPONENT);
$abortinstallx = optional_param('abortinstallx', null, PARAM_BOOL);
......
......@@ -1138,18 +1138,30 @@ class core_admin_renderer extends plugin_renderer_base {
if ($available) {
$out .= $this->output->heading(get_string('misdepsavail', 'core_plugin'));
$out .= $this->available_missing_dependencies_list($pluginman, $available);
$installable = array();
foreach ($available as $component => $remoteinfo) {
if ($pluginman->is_remote_plugin_installable($component, $remoteinfo->version->version)) {
$installable[$component] = $remoteinfo;
}
}
$out .= $this->output->container_start('plugins-check-dependencies-actions');
// TODO implement the button functionality.
$out .= html_writer::link(
new moodle_url($this->page->url, array('installalldeps' => 1, 'sesskey' => sesskey())),
get_string('dependencyinstallmissing', 'core_plugin'),
array('class' => 'btn')
);
$out.= ' | '.html_writer::link(new moodle_url('/admin/tool/installaddon/'),
get_string('dependencyuploadmissing', 'core_plugin'));
if ($installable) {
$out .= $this->output->single_button(
new moodle_url($this->page->url, array('installdepx' => 1)),
get_string('dependencyinstallmissing', 'core_plugin', count($installable)),
'post',
array('class' => 'singlebutton dependencyinstallmissing')
);
}
$out.= html_writer::div(html_writer::link(new moodle_url('/admin/tool/installaddon/'),
get_string('dependencyuploadmissing', 'core_plugin')), 'dependencyuploadmissing');
$out .= $this->output->container_end(); // .plugins-check-dependencies-actions
$out .= $this->available_missing_dependencies_list($pluginman, $available);
}
$out .= $this->output->container_end(); // .plugins-check-dependencies
......@@ -1206,24 +1218,32 @@ class core_admin_renderer extends plugin_renderer_base {
$info = '';
}
$info .= html_writer::span(
$info .= $this->output->container_start('actions');
$info .= html_writer::div(
html_writer::link('https://moodle.org/plugins/view.php?plugin='.$plugin->component,
get_string('misdepinfoplugin', 'core_plugin')),
'misdepinfoplugin'
);
$info .= ' | '.html_writer::span(
$info .= html_writer::div(
html_writer::link('https://moodle.org/plugins/pluginversion.php?id='.$plugin->version->id,
get_string('misdepinfoversion', 'core_plugin')),
'misdepinfoversion'
);
$info .= ' | '.html_writer::link($plugin->version->downloadurl, get_string('download'),
array('class' => 'btn btn-small'));
$info .= html_writer::div(html_writer::link($plugin->version->downloadurl, get_string('download')), 'misdepdownload');
if ($pluginman->is_remote_plugin_installable($plugin->component, $plugin->version->version)) {
$info .= $this->output->single_button(
new moodle_url($this->page->url, array('installdep' => $plugin->component)),
get_string('dependencyinstall', 'core_plugin'),
'post',
array('class' => 'singlebutton dependencyinstall')
);
}
// TODO Implement the button functionality.
$info .= ' | '.html_writer::link($plugin->version->downloadurl, get_string('dependencyinstall', 'core_plugin'),
array('class' => 'btn btn-small'));
$info .= $this->output->container_end(); // .actions
$table->data[] = array(
html_writer::div($plugin->name, 'name').' '.html_writer::div($plugin->component, 'component'),
......
......@@ -449,11 +449,13 @@ $CFG->admin = 'admin';
//
// Use the following flag to completely disable the Automatic updates deployment
// feature and hide it from the server administration UI.
// TODO: drop this flag and use disableonclickaddoninstall instead.
//
// $CFG->disableupdateautodeploy = true;
//
// Use the following flag to completely disable the On-click add-on installation
// feature and hide it from the server administration UI.
// Use the following flag to completely disable the installation of plugins
// (new plugins, available updates and missing dependencies) via the server
// administration UI.
//
// $CFG->disableonclickaddoninstall = true;
//
......
......@@ -35,7 +35,7 @@ $string['detectedmisplacedplugin'] = 'Plugin "{$a->component}" is installed in i
$string['dependencyavailable'] = 'Available';
$string['dependencyfails'] = 'Fails';
$string['dependencyinstall'] = 'Install';
$string['dependencyinstallmissing'] = 'Install all missing dependencies';
$string['dependencyinstallmissing'] = 'Install missing dependencies ({$a})';
$string['dependencymissing'] = 'Missing';
$string['dependencyunavailable'] = 'Unavailable';
$string['dependencyupload'] = 'Upload';
......
......@@ -915,6 +915,51 @@ class core_plugin_manager {
return true;
}
/**
* Can the given plugin remote plugin be installed via the admin UI?
*
* @param string $component
* @param string|int $requiredversion ANY_VERSION or the version number
* @return boolean
*/
public function is_remote_plugin_installable($component, $requiredversion) {
global $CFG;
// Make sure the feature is not disabled.
if (!empty($CFG->disableonclickaddoninstall)) {
return false;
}
// Make sure we know there is some version available.
if (!$this->is_remote_plugin_available($component, $requiredversion)) {
return false;
}
// Make sure the plugin type root directory is writable.
list($plugintype, $pluginname) = core_component::normalize_component($component);
if (!$this->is_plugintype_writable($plugintype)) {
return false;
}
$remoteinfo = $this->get_remote_plugin_info($component, $requiredversion);
$localinfo = $this->get_plugin_info($component);
if ($localinfo) {
// If the plugin is already present, prevent downgrade.
if ($current->versiondb > $remoteinfo->version->version) {
return false;
}
// Make sure we have write access to all the existing code.
if (!$this->is_plugin_folder_removable($component)) {
return false;
}
}
// Looks like it could work.
return true;
}
/**
* Returns information about a plugin in the plugins directory.
*
......
......@@ -656,12 +656,40 @@ img.iconsmall {
}
}
// Available dependencies on the plugins check page.
.plugins-check-dependencies-actions {
> div {
display: inline-block;
margin-right: 1em;
}
.singlebutton {
margin: 5px 0;
padding: 0;
input {
margin: 0;
}
}
}
// List of available dependencies on the plugins check page.
#plugins-check-available-dependencies {
.displayname .component {
font-size: @fontSizeSmall;
.muted
}
.info .actions {
> div {
display: inline-block;
margin-right: 1em;
}
.singlebutton {
display: block;
margin: 5px 0;
padding: 0;
input {
margin: 0;
}
}
}
}
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment