Added an option for custom commands to have their output displayed without any Webmin UI, in a selectable MIME type.
---- Changes since 1.550 ----
A default value for each custom command parameter can now be entered on the Edit Command form. Defaults can also be read from a file or shell command, if this behavior is enabled on the Module Config page. Thanks to Sart Cole for suggesting this feature.
+A command can now be configured to not display any output at all, and instead return to the module index after being run.
push(@opts, [ $j, $text{"edit_type$j"} ]);
}
push(@cols, &ui_select("type_$i", $a[$i]->{'type'}, \@opts)." ".
- &ui_textbox("opts_$i", $a[$i]->{'opts'}, 20));
+ &ui_textbox("opts_$i", $a[$i]->{'opts'}, 40));
if (!$noquote) {
push(@cols, &ui_yesno_radio("quote_$i",
int($a[$i]->{'quote'})));
&ui_yesno_radio("clear", $cmd->{'clear'}));
# Output format
+$fmode = $cmd->{'format'} eq 'redirect' ? 2 :
+ $cmd->{'format'} ? 1 : 0;
print &ui_table_row(&hlink($text{'edit_format'}, "format"),
- &ui_opt_textbox("format", $cmd->{'format'}, 20, $text{'edit_format0'},
- $text{'edit_format1'}));
+ &ui_radio("format_def", $fmode,
+ [ [ 0, $text{'edit_format0'} ],
+ [ 2, $text{'edit_format2'} ],
+ [ 1, $text{'edit_format1'}." ".
+ &ui_textbox("format",
+ $fmode == 1 ? $cmd->{'format'} : "", 20) ] ]));
# Show Webmin servers to run on
@servers = &list_servers();
edit_format=Output style
edit_format0=Show in Webmin UI
edit_format1=Output with MIME type
+edit_format2=Redirect to index
edit_servers=Run on Webmin servers
edit_this=this server
edit_clone=Clone
@servers = &list_servers();
# Run and display output
-if ($cmd->{'format'}) {
- print "Content-type: ",$cmd->{'format'},"\n";
- print "\n";
- }
-else {
- &ui_print_unbuffered_header($cmd->{'desc'}, $text{'run_title'}, "",
- -d "help" ? "run" : undef);
+if ($cmd->{'format'} ne 'redirect') {
+ if ($cmd->{'format'}) {
+ print "Content-type: ",$cmd->{'format'},"\n";
+ print "\n";
+ }
+ else {
+ &ui_print_unbuffered_header($cmd->{'desc'}, $text{'run_title'},
+ "", -d "help" ? "run" : undef);
+ }
}
&remote_error_setup(\&remote_custom_handler);
if ($h == 0) {
# Run locally
($got, $out, $timeout) = &execute_custom_command(
- $cmd, $env, $export, $str, 1);
+ $cmd, $env, $export, $str,
+ $cmd->{'format'} ne 'redirect');
}
else {
# Remote foreign call
&additional_log('exec', undef, $displaystr);
}
if (!$remote_custom_error) {
- print $out if ($h != 0);
+ print $out if ($h != 0 && $cmd->{'format'} ne 'redirect');
if (!$got && !$cmd->{'format'}) {
print "<i>$text{'run_noout'}</i>\n";
}
if (!$cmd->{'format'}) {
&ui_print_footer("", $text{'index_return'});
}
+elsif ($cmd->{'format'} eq 'redirect') {
+ &redirect("");
+ }
sub remote_custom_handler
{
$cmd->{'order'} = $in{'order_def'} ? 0 : int($in{'order'});
$cmd->{'timeout'} = $in{'timeout_def'} ? 0 : int($in{'timeout'});
$cmd->{'clear'} = $in{'clear'};
- if ($in{'format_def'}) {
+ if ($in{'format_def'} == 0) {
delete($cmd->{'format'});
}
+ elsif ($in{'format_def'} == 2) {
+ $cmd->{'format'} = 'redirect';
+ }
else {
$in{'format'} =~ /^[a-z0-9\.\_\-]+\/[a-z0-9\.\_\-]+/i ||
&error($text{'save_eformat'});