Handle hostnames with upper-case letters
[webmin.git] / postgresql / edit_seq.cgi
1 #!/usr/local/bin/perl
2 # Show a form for creating or editing a sequence
3
4 require './postgresql-lib.pl';
5 &ReadParse();
6 &can_edit_db($in{'db'}) || &error($text{'dbase_ecannot'});
7 $access{'edonly'} && &error($text{'dbase_ecannot'});
8 $access{'seqs'} || &error($text{'seq_ecannot'});
9
10 if ($in{'seq'}) {
11         # Editing a sequence
12         $str = &sequence_structure($in{'db'}, $in{'seq'});
13         }
14 else {
15         $str = { 'increment_by' => 1,
16                  'last_value' => 1 };
17         }
18 $desc = "<tt>$in{'db'}</tt>";
19 &ui_print_header($desc, $in{'seq'} ? $text{'seq_title2'}
20                                    : $text{'seq_title1'}, "");
21
22 print &ui_form_start("save_seq.cgi", "post");
23 print &ui_hidden("db", $in{'db'}),"\n";
24 print &ui_hidden("old", $in{'seq'}),"\n";
25 print &ui_table_start($text{'seq_header1'}, undef, 2);
26
27 # Sequence name
28 print &ui_table_row($text{'seq_name'},
29                     $in{'seq'} ? "<tt>$in{'seq'}</tt>"
30                                : &ui_textbox("name", $str->{'name'}, 20));
31
32 # Current value
33 print &ui_table_row($text{'seq_last'},
34         $in{'seq'} && &supports_sequences() == 1 ?
35    &ui_opt_textbox("last", undef, 20, &text('seq_leave', $str->{'last_value'}))
36    : &ui_textbox("last", $str->{'last_value'}, 20)); 
37
38 # Min and max
39 print &ui_table_row($text{'seq_min'},
40             &ui_opt_textbox("min", $str->{'min_value'}, 20, $text{'seq_none'}));
41 print &ui_table_row($text{'seq_max'},
42             &ui_opt_textbox("max", $str->{'max_value'}, 20, $text{'seq_none'}));
43
44 # Increment
45 print &ui_table_row($text{'seq_inc'},
46             &ui_textbox("inc", $str->{'increment_by'}, 5));
47
48 # Values to cache
49 print &ui_table_row($text{'seq_cache'},
50         !$in{'seq'} ? &ui_opt_textbox("cache", undef, 5, $text{'default'})
51                     : &ui_textbox("cache", $str->{'cache_value'}, 5));
52
53 # Wrap at end of cycle
54 print &ui_table_row($text{'seq_cycle'},
55     &ui_yesno_radio("cycle",
56         $str->{'is_cycled'} eq 't' || $str->{'is_cycled'} eq '1' ? 1 : 0));
57
58 print &ui_table_end();
59 if ($in{'seq'}) {
60         print &ui_form_end([ [ "save", $text{'save'} ],
61                              [ "delete", $text{'delete'} ] ]);
62         }
63 else {
64         print &ui_form_end([ [ "create", $text{'create'} ] ]);
65         }
66
67 &ui_print_footer("edit_dbase.cgi?db=$in{'db'}", $text{'dbase_return'},
68         "", $text{'index_return'});