2 # (c) Petr Baudis <pasky@suse.cz>
14 my $gcgi = Girocco
::CGI
->new('Project Removal');
17 my $name = $cgi->param('name');
19 unless (defined $name) {
20 print "<p>I need the project name as an argument now.</p>\n";
24 if (!Girocco
::Project
::does_exist
($name,1) && !Girocco
::Project
::valid_name
($name)) {
25 print "<p>Invalid project name. Go away, sorcerer.</p>\n";
29 if (!Girocco
::Project
::does_exist
($name,1)) {
30 print "<p>Sorry but this project does not exist. Now, how did you <em>get</em> here?!</p>\n";
34 if (my $romsg=check_readonly
(1)) {
35 print "<p>$romsg</p>\n";
39 my $proj = Girocco
::Project
->load($name);
41 print "<p>not found project $name, that's really weird!</p>\n";
45 $escname =~ s/[+]/%2B/g;
46 $proj->{cpwd
} = $cgi->param('cpwd');
47 my $isempty = !$proj->{mirror
} && $proj->is_empty;
49 if ($proj->has_forks()) {
50 print "<p>Sorry but this project has forks associated. Such projects cannot be removed. Please tell the administrator if you really want to.</p>\n";
54 my $y0 = $cgi->param('y0') || '';
55 if ($y0 && $cgi->request_method eq 'POST' && $proj->authenticate($gcgi)) {
57 if (!$proj->{mirror
} && !$isempty && !$cgi->param('auth')) {
58 if ($y0 ne 'Send authorization code') {
59 print "<p>Invalid data. Go away, sorcerer.</p>\n";
63 valid_email
($proj->{email
}) or die "Sorry, this project cannot be removed.";
65 my $auth = $proj->gen_auth('DEL');
68 defined(my $MAIL = mailer_pipe
'-s', "[$Girocco::Config::name] Project removal authorization", $proj->{email
}) or
69 die "Sorry, could not send authorization code: $!";
73 Somebody requested a project removal authorization code to be sent for
74 project $name on $Girocco::Config::name. Since you are the project admin,
75 you receive the authorization code. If you don't want to actually remove
76 project $name, just ignore this e-mail. Otherwise, use this code
81 In case you did not request the removal authorization code, we apologize.
83 Should you run into any problems, please let us know.
90 <p>The project admin should shortly receive an e-mail containing a project
91 removal authorization code. Please enter this code below to remove project
92 $name from $Girocco::Config::name. The code will expire in 24 hours or after
94 <form method="post" action="@{[url_path($Girocco::Config::webadmurl)]}/delproj.cgi">
95 <input type="hidden" name="name" value="$name" />
96 <input type="hidden" name="cpwd" value="$proj->{cpwd}" />
97 <p>Authorization code: <input name="auth" size="50" /></p>
98 <p><input type="submit" name="y0" value="Remove" /></p>
103 if ($y0 ne "Remove") {
104 print "<p>Invalid data. Go away, sorcerer.</p>\n";
107 if (!$proj->{mirror
} && !$isempty) {
108 $proj->{auth
} && $proj->{authtype
} && $proj->{authtype
} eq 'DEL' or do {
110 <p>There currently isn't any project removal authorization code on file for
111 project $name. Please <a href="@{[url_path($Girocco::Config::webadmurl)]}/delproj.cgi?name=$escname"
112 >generate one</a>.</p>
116 my $auth = $gcgi->wparam('auth');
117 if ($auth ne $proj->{auth
}) {
119 <p>Invalid authorization code, please re-enter or
120 <a href="@{[url_path($Girocco::Config::webadmurl)]}/delproj.cgi?name=$escname"
121 >generate a new one</a>.</p>
122 <form method="post" action="@{[url_path($Girocco::Config::webadmurl)]}/delproj.cgi">
123 <input type="hidden" name="name" value="$name" />
124 <input type="hidden" name="cpwd" value="$proj->{cpwd}" />
125 <p>Authorization code: <input name="auth" size="50" /></p>
126 <p><input type="submit" name="y0" value="Remove" /></p>
133 if (!$proj->{mirror
} && !$isempty) {
134 # archive the non-empty, non-mirror project before calling delete
135 $proj->archive_and_delete;
139 print "<p>Project successfully removed. Have a nice day.</p>\n";
143 my $fetchy = $Girocco::Config
::gitpullurl
|| $Girocco::Config
::httppullurl
||
144 $Girocco::Config
::pushurl
|| $Girocco::Config
::httpspushurl
|| $Girocco::Config
::gitweburl
;
145 my $url = $proj->{mirror
} ?
$proj->{url
} : "$fetchy/$name.git";
146 my $type = $proj->{mirror
} ?
"mirrored " : ($isempty ?
"empty " : "");
147 my $label = ($proj->{mirror
} || $isempty) ?
"Remove" : "Send authorization code";
150 <p>Please confirm that you are going to remove ${type}project
151 $name ($url) from the site.</p>
152 <form method="post" action="@{[url_path($Girocco::Config::webadmurl)]}/delproj.cgi">
153 <input type="hidden" name="name" value="$name" />
155 if ($Girocco::Config
::project_passwords
) {
157 <p>Admin password: <input type="password" name="cpwd" /> <sup class="sup"><span><a
158 href="@{[url_path($Girocco::Config::webadmurl)]}/pwproj.cgi?name=$escname">(forgot password?)</a></span></sup></p>
162 <p><input type="submit" name="y0" value="$label" /></p>