New parameter types
authorJamie Cameron <jcameron@webmin.com>
Fri, 2 Sep 2011 21:24:22 +0000 (14:24 -0700)
committerJamie Cameron <jcameron@webmin.com>
Fri, 2 Sep 2011 21:24:22 +0000 (14:24 -0700)
custom/CHANGELOG
custom/custom-lib.pl
custom/lang/en

index 0e3a687..da61b99 100644 (file)
@@ -37,3 +37,4 @@ A default value for each custom command parameter can now be entered on the Edit
 A command can now be configured to not display any output at all, and instead return to the module index after being run.
 ---- Changes since 1.560 ----
 Added an option to the file editor to run a command before the file is displayed, thanks to a suggestion from Sart Cole.
+Added new date and left-right menu parameter types.
index c5bfb2a..da57682 100755 (executable)
@@ -436,8 +436,14 @@ foreach my $a (@{$cmd->{'args'}}) {
                chown($uinfo->[2], $uinfo->[3], $rv);
                push(@unlink, $rv);
                }
-       elsif ($a->{'type'} == 12) {
-               local @vals = split(/\0/, $setin->{$n});
+       elsif ($a->{'type'} == 12 || $a->{'type'} == 13 || $a->{'type'} == 14) {
+               local @vals;
+               if ($a->{'type'} == 14) {
+                       @vals = split(/\r?\n/, $setin->{$n});
+                       }
+               else {
+                       @vals = split(/\0/, $setin->{$n});
+                       }
                local @opts = &read_opts_file($a->{'opts'});
                foreach my $v (@vals) {
                        local $found;
@@ -448,7 +454,7 @@ foreach my $a (@{$cmd->{'args'}}) {
                        }
                $rv = join(" ", @vals);
                }
-       elsif ($a->{'type'} == 13) {
+       elsif ($a->{'type'} == 15) {
                $rv = $setin->{$n."_year"}."-".
                      $setin->{$n."_month"}."-".
                      $setin->{$n."_day"};
@@ -547,7 +553,8 @@ sub show_parameter_input
 local ($a, $form) = @_;
 local $n = $a->{'name'};
 local $v = $a->{'opts'};
-if ($a->{'type'} != 9 && $a->{'type'} != 12) {
+if ($a->{'type'} != 9 && $a->{'type'} != 12 &&
+    $a->{'type'} != 13 && $a->{'type'} != 14) {
        if ($v =~ /^"(.*)"$/ || $v =~ /^'(.*)'$/) {
                # Quoted default
                $v = $1;
@@ -600,6 +607,14 @@ elsif ($a->{'type'} == 12) {
                          5, 1);
        }
 elsif ($a->{'type'} == 13) {
+       my @opts = &read_opts_file($a->{'opts'});
+       return &ui_select($n, undef, \@opts, scalar(@opts), 1);
+       }
+elsif ($a->{'type'} == 14) {
+       my @opts = &read_opts_file($a->{'opts'});
+       return &ui_multi_select($n, [ ], \@opts, 5);
+       }
+elsif ($a->{'type'} == 15) {
        my ($year, $month, $day) = split(/\-/, $v);
        return &ui_date_input($day, $month, $year,
                              $n."_day", $n."_month", $n."_year")."&nbsp;".
index 82348d2..440384a 100644 (file)
@@ -47,7 +47,9 @@ edit_type9=Menu..
 edit_type10=Upload
 edit_type11=Text box
 edit_type12=Multi menu..
-edit_type13=Date
+edit_type13=Large multi menu..
+edit_type14=Left-right menu..
+edit_type15=Date
 edit_noshow=Hide command when executing?
 edit_usermin=Available in Usermin?
 edit_timeout=Maximum time to wait for command?