Handle hostnames with upper-case letters
[webmin.git] / cluster-cron / edit.cgi
1 #!/usr/local/bin/perl
2 # edit.cgi
3 # Edit an existing or new cluster cron job
4
5 require './cluster-cron-lib.pl';
6 &ReadParse();
7
8 if (!$in{'new'}) {
9         @jobs = &list_cluster_jobs();
10         ($job) = grep { $_->{'cluster_id'} eq $in{'id'} } @jobs;
11         &ui_print_header(undef, $text{'edit_title'}, "");
12         }
13 else {
14         &ui_print_header(undef, $text{'create_title'}, "");
15         $job = { 'mins' => '*',
16                  'hours' => '*',
17                  'days' => '*',
18                  'months' => '*',
19                  'weekdays' => '*',
20                  'active' => 1 };
21         }
22
23 print "<form action=save.cgi>\n";
24 print "<input type=hidden name=new value='$in{'new'}'>\n";
25 print "<input type=hidden name=id value='$in{'id'}'>\n";
26 print "<table border width=100%>\n";
27 print "<tr $tb> <td><b>$cron::text{'edit_details'}</b></td> </tr>\n";
28 print "<tr $cb> <td><table width=100%>\n";
29
30 print "<tr> <td><b>$cron::text{'edit_user'}</b></td>\n";
31 print "<td><input name=user size=8 value=\"$job->{'cluster_user'}\"> ",
32         &user_chooser_button("user", 0),"</td>\n";
33
34 %serv = map { $_, 1 } split(/ /, $job->{'cluster_server'});
35 print "<td rowspan=4 valign=top><b>$text{'edit_servers'}</b></td>\n";
36 print "<td rowspan=4 valign=top><select multiple size=8 name=server>\n";
37 printf "<option value=ALL %s>%s\n",
38         $serv{'ALL'} ? 'selected' : '', $text{'edit_all'};
39 printf "<option value=* %s>%s\n",
40         $serv{'*'} ? 'selected' : '', $text{'edit_this'};
41 foreach $s (grep { $_->{'user'} } &servers::list_servers()) {
42         printf "<option value=%s %s>%s\n",
43                 $s->{'host'}, $serv{$s->{'host'}} ? "selected" : "",
44                 $s->{'desc'} || $s->{'host'};
45         }
46 foreach $g (&servers::list_all_groups()) {
47         $gn = "group_".$g->{'name'};
48         printf "<option value=%s %s>%s\n",
49                 $gn, $serv{$gn} ? "selected" : "",
50                 &text('edit_group', $g->{'name'});
51         }
52 print "</select></td> </tr>\n";
53
54 print "<tr> <td> <b>$cron::text{'edit_active'}</b></td>\n";
55 printf "<td><input type=radio name=active value=1 %s> $text{'yes'}\n",
56         $job->{'active'} ? "checked" : "";
57 printf "<input type=radio name=active value=0 %s> $text{'no'}</td> </tr>\n",
58         $job->{'active'} ? "" : "checked";
59
60 # Normal cron job.. can edit command
61 print "<tr> <td><b>$cron::text{'edit_command'}</b></td>\n";
62 print "<td><input name=cmd size=30 ",
63       "value='",&html_escape($job->{'cluster_command'}),"'></td> </tr>\n";
64
65 if ($cron::config{'cron_input'}) {
66         @lines = split(/%/ , $job->{'cluster_input'});
67         print "<tr> <td valign=top><b>$cron::text{'edit_input'}</b></td>\n";
68         print "<td><textarea name=input rows=3 cols=30>",
69               join("\n" , @lines),"</textarea></td> </tr>\n";
70         }
71
72 print "</table></td></tr></table><p>\n";
73
74 print "<table border width=100%>\n";
75 print "<tr $tb> <td colspan=5><b>$cron::text{'edit_when'}</b></td> </tr>\n";
76 &cron::show_times_input($job, 1);
77 print "</table>\n";
78
79 if (!$in{'new'}) {
80         print "<table width=100%>\n";
81         print "<tr> <td align=left><input type=submit value=\"$text{'save'}\"></td>\n";
82
83         print "</form><form action=\"exec.cgi\">\n";
84         print "<input type=hidden name=id value=\"$in{'id'}\">\n";
85         print "<td align=center>",
86               "<input type=submit value=\"$cron::text{'edit_run'}\"></td>\n";
87
88         print "</form><form action=\"delete.cgi\">\n";
89         print "<input type=hidden name=id value=\"$in{'id'}\">\n";
90         print "<td align=right><input type=submit value=\"$cron::text{'delete'}\"></td> </tr>\n";
91         print "</form></table><p>\n";
92         }
93 else {
94         print "<input type=submit value=\"$text{'create'}\"></form><p>\n";
95         }
96
97 &ui_print_footer("", $text{'index_return'});
98