Handle hostnames with upper-case letters
[webmin.git] / mysql / edit_index.cgi
1 #!/usr/local/bin/perl
2 # Show a form for creating or editing index on a table
3
4 require './mysql-lib.pl';
5 &ReadParse();
6 &can_edit_db($in{'db'}) || &error($text{'dbase_ecannot'});
7 $access{'edonly'} && &error($text{'dbase_ecannot'});
8 $access{'indexes'} || &error($text{'index_ecannot'});
9
10 if ($in{'index'}) {
11         # Editing an index
12         $str = &index_structure($in{'db'}, $in{'index'});
13         $table = $str->{'table'};
14         }
15 else {
16         # Creating an index
17         $table = $in{'table'};
18         }
19 $desc = &text('table_header', "<tt>$table</tt>", "<tt>$in{'db'}</tt>");
20 &ui_print_header($desc, $in{'index'} ? $text{'index_title2'}
21                                      : $text{'index_title1'}, "");
22
23 print &ui_form_start("save_index.cgi", "post");
24 print &ui_hidden("db", $in{'db'}),"\n";
25 print &ui_hidden("table", $table),"\n";
26 print &ui_hidden("old", $in{'index'}),"\n";
27 print &ui_table_start($text{'index_header1'}, undef, 2);
28
29 # Index name
30 print &ui_table_row($text{'index_name'},
31                     &ui_textbox("name", $str->{'name'}, 20));
32
33 # Fields in index
34 @str = &table_structure($in{'db'}, $table);
35 @cols = map { $_->{'field'} } @str;
36 print &ui_table_row($text{'index_fields'},
37    &ui_select("cols", $str->{'cols'},
38       [ map { [ $_->{'field'},
39                 "$_->{'field'} - $_->{'type'}" ] } @str ], 5, 1));
40
41 # Index type
42 print &ui_table_row($text{'index_type'},
43                     &ui_select("type", $str->{'type'},
44                         [ !$in{'index'} ? ( [ "", "&lt;$text{'default'}&gt;" ] )
45                                         : ( ),
46                           [ "unique", $text{'index_unique'} ],
47                           [ "fulltext", $text{'index_fulltext'} ],
48                           [ "spatial", $text{'index_spatial'} ] ]));
49
50 print &ui_table_end();
51 if ($in{'index'}) {
52         print &ui_form_end([ [ "save", $text{'save'} ],
53                              [ "delete", $text{'delete'} ] ]);
54         }
55 else {
56         print &ui_form_end([ [ "create", $text{'create'} ] ]);
57         }
58
59 &ui_print_footer("edit_dbase.cgi?db=$in{'db'}", $text{'dbase_return'},
60         "", $text{'index_return'});