Handle hostnames with upper-case letters
[webmin.git] / samba / edit_pshare.cgi
1 #!/usr/local/bin/perl
2 # edit_pshare.cgi
3 # Display a form for editing or creating a new printer share
4
5 require './samba-lib.pl';
6 &ReadParse();
7 $s = $in{'share'};
8 # check acls
9
10 &error_setup("<blink><font color=red>$text{'eacl_aviol'}</font></blink>");
11 if(!$s) {
12         &error("$text{'eacl_np'} $text{'eacl_pcps'}")
13         unless $access{'c_ps'};
14         }
15 else {
16         &error("$text{'eacl_np'} $text{'eacl_paps'}")
17         unless &can('r', \%access, $in{'share'});
18         }
19 # display
20 if ($s) {
21         &ui_print_header(undef, $s eq 'global' ? $text{'pshare_title1'} : $text{'pshare_title2'}, "");
22         &get_share($s);
23         }
24 else {
25         &ui_print_header(undef, $text{'pshare_title3'}, "");
26         }
27
28 print "<form action=save_pshare.cgi>\n";
29 if ($s) { print "<input type=hidden name=old_name value=\"$s\">\n"; }
30
31 # Vital share options..
32 print "<table border width=100%>\n";
33 print "<tr $tb> <td><b>$text{'pshare_info'}</b></td> </tr>\n";
34 print "<tr $cb> <td><table>\n";
35 if ($s ne "global") {
36         if ($copy = &getval("copy")) {
37                 print "<tr> <td colspan=4><b>", &text('share_copy',$copy),"</b></td> </tr>\n";
38                 }
39         print "<tr> <td><b>$text{'pshare_name'}</b></td>\n";
40         printf "<td colspan=3><input type=radio name=printers value=0 %s>\n",
41                 $s eq "printers" ? "" : "checked";
42         printf "<input size=10 name=share value=\"%s\">&nbsp;&nbsp;&nbsp;\n",
43                 $s eq "printers" ? "" : $s;
44         printf "<input type=radio name=printers value=1 %s> $text{'pshare_all'}\n",
45                 $s eq "printers" ? "checked" : "";
46         print "</td> </tr>\n";
47         }
48
49 print "<tr> <td><b>$text{'pshare_unixprn'}</b></td>\n";
50 if (&foreign_check("lpadmin")) {
51         &foreign_require("lpadmin", "lpadmin-lib.pl");
52         @plist = &foreign_call("lpadmin", "list_printers");
53         }
54 elsif ($config{'list_printers_command'}) {
55         @plist = split(/\s+/ , `$config{'list_printers_command'}`);
56         }
57 if (@plist) {
58         local $printer = &getval("printer");
59         push(@plist, $printer)
60                 if ($printer && &indexof($printer, @plist) == -1);
61         print "<td><select name=printer>\n";
62         printf "<option value=\"\" %s> %s\n",
63                 $printer eq "" ? "selected" : "",
64                 $s eq "global" ? $text{'config_none'} : $text{'default'};
65         foreach $p (@plist) {
66                 printf "<option value=\"$p\" %s> $p\n",
67                         $p eq $printer ? "selected" : "";
68                 }
69         print "</select></td>\n";
70         }
71 else {
72         print "<td><input name=printer size=8></td>\n";
73         }
74
75 print "<td><b>$text{'pshare_spool'}</b></td>\n";
76 printf "<td><input name=path size=35 value=\"%s\">\n",
77         &getval("path");
78 print &file_chooser_button("path", 1);
79 print "</td> </tr>\n";
80
81 print "<tr> <td><b>$text{'share_available'}</b></td>\n";
82 print "<td>",&yesno_input("available"),"</td>\n";
83
84 print "<td><b>$text{'share_browseable'}</b></td>\n";
85 print "<td>",&yesno_input("browseable"),"</td> </tr>\n";
86
87 print "<td align=right><b>$text{'share_comment'}</b></td>\n";
88 printf "<td colspan=3 align=left>\n";
89 printf "<input size=40 name=comment value=\"%s\"></td> </tr>\n",
90         &getval("comment");
91
92 print "<tr> <td colspan=4 align=center>$text{'share_samedesc1'}</td> </tr>\n"
93         if ($s eq "global");
94
95 print "</table> </td></tr></table><p>\n";
96
97 if ($s eq "global") {
98         print "<input type=submit value=$text{'save'}> </form><p>\n";
99         }
100 elsif ($s) {
101         print "<table width=100%> <tr>\n";
102         print "<td align=left><input type=submit value=$text{'save'}></td>\n"
103                 if &can('rw', \%access, $s);
104         print "</form><form action=view_users.cgi>\n";
105         print "<input type=hidden name=share value=\"$s\">\n";
106         print "<input type=hidden name=printer value=1>\n";
107         print "<td align=center><input type=submit value=\"$text{'index_view'}\"></td>\n"
108                 if &can('rv', \%access, $s);
109         print "</form><form action=delete_share.cgi>\n";
110         print "<input type=hidden name=share value=\"$s\">\n";
111         print "<input type=hidden name=type value=pshare>\n";
112         print "<td align=right><input type=submit value=$text{'delete'}></td>\n"
113                 if &can('rw', \%access, $s);
114         print "</form> </tr> </table> <p>\n";
115         }
116 else {
117         print "<input type=submit value=$text{'create'}> </form><p>\n";
118         }
119
120 if ($s) {
121         # Icons for other share options
122     $us = "share=".&urlize($s)."&printer=1";
123     local (@url, @text, @icon, $disp);
124     if (&can('rs',\%access, $s)) {
125         push(@url,  "edit_sec.cgi?$us");
126         push(@text, $text{'share_security'});
127         push(@icon, "images/icon_2.gif");
128         $disp++;
129         }
130     if (&can('ro',\%access, $s)) {
131         push(@url,  "edit_popts.cgi?$us");
132         push(@text, $text{'print_option'});
133         push(@icon, "images/icon_3.gif");
134         $disp++;
135         }
136     if ($disp) {
137         print &ui_hr();
138         print &ui_subheading($text{'share_option'});
139         &icons_table(\@url, \@text, \@icon);
140         }
141         }
142
143 &ui_print_footer("", $text{'index_sharelist'});