Handle hostnames with upper-case letters
[webmin.git] / cluster-copy / edit.cgi
1 #!/usr/local/bin/perl
2 # Edit or create a scheduled cluster copy
3
4 require './cluster-copy-lib.pl';
5 &ReadParse();
6 &foreign_require("servers", "servers-lib.pl");
7
8 if (!$in{'new'}) {
9         $copy = &get_copy($in{'id'});
10         $job = &find_cron_job($copy);
11         &ui_print_header(undef, $text{'edit_title'}, "");
12         }
13 else {
14         &ui_print_header(undef, $text{'create_title'}, "");
15         $copy = { 'mins' => '0',
16                   'hours' => '0',
17                   'days' => '*',
18                   'months' => '*',
19                   'weekdays' => '*',
20                   'sched' => 1,
21                   'dest' => '/' };
22         }
23
24 print &ui_form_start("save.cgi", "post");
25 print &ui_hidden("new", $in{'new'});
26 print &ui_hidden("id", $in{'id'});
27 print &ui_table_start($text{'edit_header'}, "width=100%", 2);
28
29 # Files to copy
30 print &ui_table_row($text{'edit_files'},
31                     &ui_textarea("files",
32                         join("\n", split(/\t+/, $copy->{'files'})), 5, 60)." ".
33                     &file_chooser_button("files", 0, undef, undef, 1));
34
35 # Destination directory
36 print &ui_table_row($text{'edit_dest'},
37                     &ui_textbox("dest", $copy->{'dest'}, 50));
38 print &ui_table_row(" ",
39                     &ui_radio("dmode", $copy->{'dmode'} || 0,
40                               [ [ 0, $text{'edit_dmode0'} ],
41                                 [ 1, $text{'edit_dmode1'} ] ]));
42
43 # Command to run before copy
44 print &ui_table_row($text{'edit_before'},
45                     &ui_textbox("before", $copy->{'before'}, 60)." ".
46                     &ui_checkbox("beforeremote", 1, $text{'edit_remote'},
47                                  !$copy->{'beforelocal'}));
48
49 # Command to run after copy
50 print &ui_table_row($text{'edit_cmd'},
51                     &ui_textbox("cmd", $copy->{'cmd'}, 60)." ".
52                     &ui_checkbox("cmdremote", 1, $text{'edit_remote'},
53                                  !$copy->{'cmdlocal'}));
54
55 # Target servers
56 @sel = split(/\s+/, $copy->{'servers'});
57 push(@opts, [ "ALL", $text{'edit_all'} ]);
58 push(@opts, [ "*", $text{'edit_this'} ]);
59 foreach $s (grep { $_->{'user'} } &servers::list_servers()) {
60         push(@opts, [ $s->{'host'}, $s->{'desc'} || $s->{'host'} ]);
61         }
62 foreach $g (&servers::list_all_groups()) {
63         push(@opts, [ "group_".$g->{'name'},
64                       &text('edit_group', $g->{'name'}) ]);
65         }
66 print &ui_table_row($text{'edit_servers'},
67                     &ui_select("servers", \@sel, \@opts, 8, 1));
68
69 # Cron enabled
70 print &ui_table_row($text{'edit_sched'},
71                     &ui_radio("sched", $job || $in{'new'} ? 1 : 0,
72                               [ [ 0, $text{'no'} ],
73                                 [ 1, $text{'edit_schedyes'} ] ]));
74
75 # Send email to
76 print &ui_table_row($text{'edit_email'},
77             &ui_opt_textbox("email", $copy->{'email'}, 50, $text{'edit_none'}));
78
79 # Cron times
80 print "<tr> <td colspan=2><table border width=100%>\n";
81 &cron::show_times_input($copy);
82 print "</table></td> </tr>\n";
83
84 print &ui_table_end();
85 if ($in{'new'}) {
86         print &ui_form_end([ [ 'create', $text{'create'} ] ], "100%");
87         }
88 else {
89         print &ui_form_end([ [ 'save', $text{'save'} ],
90                              [ 'run', $text{'edit_run'} ],
91                              [ 'delete', $text{'delete'} ] ], "100%");
92         }
93
94 &ui_print_footer("", $text{'index_return'});
95