forked from virtualmin/virtualmin-dav
-
Notifications
You must be signed in to change notification settings - Fork 0
/
list_shares.cgi
executable file
·64 lines (59 loc) · 1.62 KB
/
list_shares.cgi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/local/bin/perl
# Show a list of DAV sub-directories to which users can be granted access
use strict;
use warnings;
our (%in, %text);
our $module_name;
require './virtualmin-dav-lib.pl';
&ReadParse();
$in{'dom'} || &error($text{'index_edom'});
my $d = &virtual_server::get_domain($in{'dom'});
$d || &error($text{'index_edom2'});
$d->{$module_name} || &error($text{'index_edav'});
my $digest = $d->{'dav_auth'} ne 'Digest' ? 0 : 1;
my $ddesc = &virtual_server::domain_in($d);
&ui_print_header($ddesc, $text{'shares_title'}, "");
my @shares = &list_dav_shares($d);
my @links = ( "<a href='edit_share.cgi?dom=$in{'dom'}&new=1'>".
$text{'shares_add'}."</a>" );
if (@shares) {
# Show list of shares
print &ui_links_row(\@links);
print &ui_columns_start([ $text{'shares_dir'},
$text{'shares_relpath'},
$digest ? ( ) : ( $text{'shares_realm'} ),
$text{'shares_users'},
$text{'shares_rwusers'},
], 100);
foreach my $s (@shares) {
print &ui_columns_row([
"<a href='edit_share.cgi?dom=$in{'dom'}&".
"dir=$s->{'dir'}'>$s->{'fulldir'}</a>",
$s->{'relpath'},
$digest ? ( ) : ( $s->{'realm'} ),
&make_nice_users($s->{'users'}),
&make_nice_users($s->{'rwusers'}),
]);
}
print &ui_columns_end();
}
else {
print "<b>$text{'shares_none'}</b> <p>\n";
}
print &ui_links_row(\@links);
&ui_print_footer(&virtual_server::domain_footer_link($d));
sub make_nice_users
{
my ($ulist) = @_;
if (!$ulist) {
return "<i>$text{'shares_all'}</i>";
}
else {
my @users = @$ulist;
if (@users > 4) {
@users = ( @users[0..3],
&text('shares_uc', scalar(@users)-4) );
}
return join(" , ", @users);
}
}