mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
MDL-49329 admin: Improve the UI for installing dependencies
This commit is contained in:
parent
2f29cf6e63
commit
9137a89a1a
7 changed files with 118 additions and 22 deletions
|
@ -106,7 +106,8 @@ $agreelicense = optional_param('agreelicense', 0, PARAM_BOOL);
|
||||||
$fetchupdates = optional_param('fetchupdates', 0, PARAM_BOOL);
|
$fetchupdates = optional_param('fetchupdates', 0, PARAM_BOOL);
|
||||||
$newaddonreq = optional_param('installaddonrequest', null, PARAM_RAW);
|
$newaddonreq = optional_param('installaddonrequest', null, PARAM_RAW);
|
||||||
$upgradekeyhash = optional_param('upgradekeyhash', null, PARAM_ALPHANUM);
|
$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);
|
$abortinstall = optional_param('abortinstall', null, PARAM_COMPONENT);
|
||||||
$abortinstallx = optional_param('abortinstallx', null, PARAM_BOOL);
|
$abortinstallx = optional_param('abortinstallx', null, PARAM_BOOL);
|
||||||
|
|
||||||
|
|
|
@ -1138,18 +1138,30 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||||
|
|
||||||
if ($available) {
|
if ($available) {
|
||||||
$out .= $this->output->heading(get_string('misdepsavail', 'core_plugin'));
|
$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');
|
$out .= $this->output->container_start('plugins-check-dependencies-actions');
|
||||||
|
|
||||||
// TODO implement the button functionality.
|
if ($installable) {
|
||||||
$out .= html_writer::link(
|
$out .= $this->output->single_button(
|
||||||
new moodle_url($this->page->url, array('installalldeps' => 1, 'sesskey' => sesskey())),
|
new moodle_url($this->page->url, array('installdepx' => 1)),
|
||||||
get_string('dependencyinstallmissing', 'core_plugin'),
|
get_string('dependencyinstallmissing', 'core_plugin', count($installable)),
|
||||||
array('class' => 'btn')
|
'post',
|
||||||
|
array('class' => 'singlebutton dependencyinstallmissing')
|
||||||
);
|
);
|
||||||
$out.= ' | '.html_writer::link(new moodle_url('/admin/tool/installaddon/'),
|
}
|
||||||
get_string('dependencyuploadmissing', 'core_plugin'));
|
|
||||||
|
$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->output->container_end(); // .plugins-check-dependencies-actions
|
||||||
|
|
||||||
|
$out .= $this->available_missing_dependencies_list($pluginman, $available);
|
||||||
}
|
}
|
||||||
|
|
||||||
$out .= $this->output->container_end(); // .plugins-check-dependencies
|
$out .= $this->output->container_end(); // .plugins-check-dependencies
|
||||||
|
@ -1206,24 +1218,32 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||||
$info = '';
|
$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,
|
html_writer::link('https://moodle.org/plugins/view.php?plugin='.$plugin->component,
|
||||||
get_string('misdepinfoplugin', 'core_plugin')),
|
get_string('misdepinfoplugin', 'core_plugin')),
|
||||||
'misdepinfoplugin'
|
'misdepinfoplugin'
|
||||||
);
|
);
|
||||||
|
|
||||||
$info .= ' | '.html_writer::span(
|
$info .= html_writer::div(
|
||||||
html_writer::link('https://moodle.org/plugins/pluginversion.php?id='.$plugin->version->id,
|
html_writer::link('https://moodle.org/plugins/pluginversion.php?id='.$plugin->version->id,
|
||||||
get_string('misdepinfoversion', 'core_plugin')),
|
get_string('misdepinfoversion', 'core_plugin')),
|
||||||
'misdepinfoversion'
|
'misdepinfoversion'
|
||||||
);
|
);
|
||||||
|
|
||||||
$info .= ' | '.html_writer::link($plugin->version->downloadurl, get_string('download'),
|
$info .= html_writer::div(html_writer::link($plugin->version->downloadurl, get_string('download')), 'misdepdownload');
|
||||||
array('class' => 'btn btn-small'));
|
|
||||||
|
|
||||||
// TODO Implement the button functionality.
|
if ($pluginman->is_remote_plugin_installable($plugin->component, $plugin->version->version)) {
|
||||||
$info .= ' | '.html_writer::link($plugin->version->downloadurl, get_string('dependencyinstall', 'core_plugin'),
|
$info .= $this->output->single_button(
|
||||||
array('class' => 'btn btn-small'));
|
new moodle_url($this->page->url, array('installdep' => $plugin->component)),
|
||||||
|
get_string('dependencyinstall', 'core_plugin'),
|
||||||
|
'post',
|
||||||
|
array('class' => 'singlebutton dependencyinstall')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$info .= $this->output->container_end(); // .actions
|
||||||
|
|
||||||
$table->data[] = array(
|
$table->data[] = array(
|
||||||
html_writer::div($plugin->name, 'name').' '.html_writer::div($plugin->component, 'component'),
|
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
|
// Use the following flag to completely disable the Automatic updates deployment
|
||||||
// feature and hide it from the server administration UI.
|
// feature and hide it from the server administration UI.
|
||||||
|
// TODO: drop this flag and use disableonclickaddoninstall instead.
|
||||||
//
|
//
|
||||||
// $CFG->disableupdateautodeploy = true;
|
// $CFG->disableupdateautodeploy = true;
|
||||||
//
|
//
|
||||||
// Use the following flag to completely disable the On-click add-on installation
|
// Use the following flag to completely disable the installation of plugins
|
||||||
// feature and hide it from the server administration UI.
|
// (new plugins, available updates and missing dependencies) via the server
|
||||||
|
// administration UI.
|
||||||
//
|
//
|
||||||
// $CFG->disableonclickaddoninstall = true;
|
// $CFG->disableonclickaddoninstall = true;
|
||||||
//
|
//
|
||||||
|
|
|
@ -35,7 +35,7 @@ $string['detectedmisplacedplugin'] = 'Plugin "{$a->component}" is installed in i
|
||||||
$string['dependencyavailable'] = 'Available';
|
$string['dependencyavailable'] = 'Available';
|
||||||
$string['dependencyfails'] = 'Fails';
|
$string['dependencyfails'] = 'Fails';
|
||||||
$string['dependencyinstall'] = 'Install';
|
$string['dependencyinstall'] = 'Install';
|
||||||
$string['dependencyinstallmissing'] = 'Install all missing dependencies';
|
$string['dependencyinstallmissing'] = 'Install missing dependencies ({$a})';
|
||||||
$string['dependencymissing'] = 'Missing';
|
$string['dependencymissing'] = 'Missing';
|
||||||
$string['dependencyunavailable'] = 'Unavailable';
|
$string['dependencyunavailable'] = 'Unavailable';
|
||||||
$string['dependencyupload'] = 'Upload';
|
$string['dependencyupload'] = 'Upload';
|
||||||
|
|
|
@ -915,6 +915,51 @@ class core_plugin_manager {
|
||||||
return true;
|
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.
|
* 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 {
|
#plugins-check-available-dependencies {
|
||||||
.displayname .component {
|
.displayname .component {
|
||||||
font-size: @fontSizeSmall;
|
font-size: @fontSizeSmall;
|
||||||
.muted
|
.muted
|
||||||
}
|
}
|
||||||
|
.info .actions {
|
||||||
|
> div {
|
||||||
|
display: inline-block;
|
||||||
|
margin-right: 1em;
|
||||||
|
}
|
||||||
|
.singlebutton {
|
||||||
|
display: block;
|
||||||
|
margin: 5px 0;
|
||||||
|
padding: 0;
|
||||||
|
input {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue