-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.cgi
executable file
·161 lines (147 loc) · 4.01 KB
/
index.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/usr/local/bin/perl
# Show all repositories for this user
use strict;
use warnings;
our (%access, %text, %in, %config);
our $module_name;
require './virtualmin-svn-lib.pl';
&ReadParse();
my $showd;
if ($in{'show'}) {
$showd = &virtual_server::get_domain_by("dom", $in{'show'});
$showd || &error($text{'index_eshow'});
}
&ui_print_header($showd ? &virtual_server::domain_in($showd) : undef,
$text{'index_title'}, "", undef, 1, 1);
# Check if subversion is installed
my $err = &svn_check();
if ($err) {
&ui_print_endpage($err);
}
# Check if plugin is enabled
no warnings "once";
if (&indexof($module_name, @virtual_server::plugins) < 0) {
if (&virtual_server::can_edit_templates()) {
&ui_print_endpage(&text('index_eplugin',
"../virtual-server/edit_newfeatures.cgi"));
}
else {
&ui_print_endpage($text{'index_eplugin2'});
}
}
use warnings "once";
# Show repositories for Virtualmin domains visible to the current user
my ($domcount, $accesscount, $svncount);
my (@reps, @mydoms);
foreach my $d ($in{'show'} ? ( $showd ) : &virtual_server::list_domains()) {
$domcount++;
next if (!&can_edit_domain($d));
$accesscount++;
next if (!$d->{$module_name});
$svncount++;
push(@reps, &list_reps($d));
push(@mydoms, $d);
}
if (!@mydoms) {
&ui_print_endpage(!$domcount ? $text{'index_edoms2'} :
!$accesscount ? $text{'index_edoms'} :
$text{'index_edoms3'});
}
# Build table of repositories
my @table;
foreach my $r (@reps) {
my $dom = $r->{'dom'}->{'dom'};
my @actions = (
&ui_submit($text{'delete'},
$r->{'rep'}."\@".$r->{'dom'}->{'id'}),
);
if ($config{'cannotify'}) {
push(@actions, &ui_submit($text{'index_email'},
$r->{'rep'}."\@".$r->{'dom'}->{'id'}));
}
push(@actions, &ui_submit($text{'index_perms'},
$r->{'rep'}."\@".$r->{'dom'}->{'id'}));
if ($config{'candump'}) {
push(@actions, &ui_submit($text{'index_dump'},
$r->{'rep'}."\@".$r->{'dom'}->{'id'}));
}
if ($config{'canload'}) {
push(@actions, &ui_submit($text{'index_load'},
$r->{'rep'}."\@".$r->{'dom'}->{'id'}));
}
push(@actions, &ui_submit($text{'index_anon'},
$r->{'rep'}."\@".$r->{'dom'}->{'id'}));
push(@table, [ $r->{'rep'}, $dom, $r->{'dir'}, join(" ", @actions) ]);
}
# Show table of repos
if ($access{'max'} && $access{'max'} > @reps) {
print "<b>",&text('index_canadd0', $access{'max'}-@reps),
"</b><p>\n";
}
print &ui_form_columns_table(
"delete.cgi",
undef,
0,
undef,
[ [ 'show', $in{'show'} ] ],
[ $text{'index_rep'}, $text{'index_dom'},
$text{'index_dir'}, $text{'index_action'} ],
100,
\@table,
undef,
0,
undef,
$text{'index_none'});
print "<p>\n";
if ($access{'max'} && @reps >= $access{'max'}) {
# Cannot add any more
print $text{'index_max'},"<p>\n";
}
else {
# Show form to add a repository
print &ui_form_start("add.cgi");
print &ui_hidden("show", $in{'show'});
print &ui_table_start($text{'index_header'}, undef, 2,
[ "width=30% nowrap" ]);
# Repo name
print &ui_table_row($text{'index_rep'},
&ui_textbox("rep", undef, 20), 1);
# In domain
print &ui_table_row($text{'index_dom'},
&ui_select("dom", undef,
[ map { [ $_->{'id'}, $_->{'dom'} ] } @mydoms ]));
# Users to grant
my @unames;
if ($showd) {
foreach my $u (&virtual_server::list_domain_users(
$showd, 0, 1, 1, 1)) {
push(@unames, &virtual_server::remove_userdom(
$u->{'user'}, $showd));
}
}
if (@unames) {
print &ui_table_row($text{'index_grant'},
&ui_multi_select(
"users",
[ ],
[ map { [ $_, $_ ] } @unames ],
5, 0, 0,
$text{'index_allusers'},
$text{'index_grantusers'},
));
}
# SVN filesystem type
if (&supports_fs_type()) {
print &ui_table_row($text{'index_type'},
&ui_select("type", "fsfs",
[ [ "fsfs", "Versioned Filesystem (FSFS)" ],
[ "bdb", "Berkeley DB" ] ]));
}
# Readonly?
print &ui_table_row($text{'index_ro'},
&ui_yesno_radio("ro", 0));
print &ui_table_end();
print &ui_submit($text{'create'});
print &ui_form_end();
}
&ui_print_footer("/", $text{'index'});