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