Skip to content

Commit

Permalink
feat: Require URL for plugin installation and remove plugin name option
Browse files Browse the repository at this point in the history
  • Loading branch information
erseco committed Oct 19, 2024
1 parent 314d79d commit 047c51a
Showing 1 changed file with 2 additions and 24 deletions.
26 changes: 2 additions & 24 deletions rootfs/var/www/html/admin/cli/install_plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
Options:
-h --help Print this help.
--plugin=<pluginname> The name of the plugin to install.
--url=<pluginurl> The URL to download the plugin from.
--type=<plugintype> The type of the plugin (e.g., mod, block, filter, theme, local). Defaults to mod.
--run Execute install. If this option is not set, the script will run in dry mode.
Expand Down Expand Up @@ -67,8 +66,8 @@
$DB->set_debug(true);
}

if (!$options['plugin'] && !$options['url']) {
cli_writeln('You must specify either a plugin name or a URL.');
if (!$options['url']) {
cli_writeln('You must specify a URL to download the plugin.');
cli_writeln($help);
exit(0);
}
Expand Down Expand Up @@ -119,27 +118,6 @@
'component' => $pluginname,
'zipfilepath' => $tempfile,
];
} else {
$pluginDir = $CFG->dirroot . '/mod/' . $options['plugin'];

$plugininfo = get_plugin_info_from_version_file($pluginDir);
if (!$plugininfo) {
cli_error('Invalid plugin directory: ' . $pluginDir);
}

$pluginname = $plugininfo->component;
cli_writeln("Preparing to install plugin: $pluginname");

// Check if the plugin is already installed, unless forced
if ($pluginman->get_plugin_info($pluginname) && !$options['force']) {
cli_error("Plugin $pluginname is already installed. Use --force to reinstall.");
}

$plugins[] = (object)[
'component' => $pluginname,
'zipfilepath' => null,
];
}

if ($options['run']) {
cli_writeln('Installing plugin...');
Expand Down

0 comments on commit 047c51a

Please sign in to comment.