post-receive-hook: Display possible reply from taskd
[girocco.git] / cgi / editproj.cgi
blob55cc0e22d92aa7b5fd70824e054670a8c571f895
1 #!/usr/bin/perl
2 # (c) Petr Baudis <pasky@suse.cz>
3 # GPLv2
5 use strict;
6 use warnings;
8 use lib ".";
9 use Girocco::CGI;
10 use Girocco::Config;
11 use Girocco::Project;
12 use Girocco::Util;
14 my $gcgi = Girocco::CGI->new('Project Settings');
15 my $cgi = $gcgi->cgi;
17 my $name = $cgi->param('name');
18 $name =~ s#\.git$## if $name; #
20 unless (defined $name) {
21 print "<p>I need the project name as an argument now.</p>\n";
22 exit;
25 if (!Girocco::Project::valid_name($name)) {
26 print "<p>Invalid project name. Go away, sorcerer.</p>\n";
27 exit;
30 if (!Girocco::Project::does_exist($name)) {
31 print "<p>Sorry but the project $name does not exist. Now, how did you <em>get</em> here?!</p>\n";
32 exit;
35 my $proj = Girocco::Project->load($name);
36 $proj or die "not found project $name, that's really weird!";
38 if ($cgi->param('y0')) {
39 # submitted, let's see
40 if ($proj->cgi_fill($gcgi) and $proj->authenticate($gcgi) and $proj->update) {
41 print "<p>Project successfuly updated.</p>\n";
42 if ($proj->{clone_failed}) {
43 print "<p>Please <a href=\"mirrorproj.cgi?name=$name\">pass onwards</a>.</p>\n";
44 print "<script language=\"javascript\">document.location='mirrorproj.cgi?name=$name'</script>\n";
45 exit;
50 # $proj may be insane now but that's actually good for us since we'll let the
51 # user fix the invalid values she entered
52 my %h = $proj->form_defaults;
54 print <<EOT;
55 <p>Here you can adjust the settings of project $h{name}. Go wild.
56 EOT
57 if ($proj->{mirror}) {
58 print <<EOT;
59 Since this is a mirrored project, you can opt to remove it from the site as well.
60 Just <a href="delproj.cgi?name=$h{name}">delete it</a>.</p>
61 EOT
62 } else {
63 print <<EOT;
64 Though you can currently enable access only for a single user at a time
65 so perhaps you will need to click a lot. Sorry! (Patches welcome.)</p>
66 EOT
69 my $button_label = $proj->{clone_failed} ? 'Restart Mirroring' : 'Update';
71 print <<EOT;
72 <form method="post">
73 <table class="form">
74 <tr><td class="formlabel">Project name:</td><td><a href="$Girocco::Config::gitweburl/$h{name}.git">$h{name}</a>.git
75 <input type="hidden" name="name" value="$h{name}" /></td></tr>
76 EOT
77 if ($Girocco::Config::project_passwords) {
78 print <<EOT;
79 <tr><td class="formlabel"><strong>Admin password:</strong></td><td>
80 <input type="password" name="cpwd" /> <sup><a href="pwproj.cgi?name=$name" class="ctxaction">(forgot password?)</a></sup></td></tr>
81 <tr><td class="formlabel">New admin password (twice):<br />
82 <em>(leave empty to keep it the same)</em></td><td>
83 <input type="password" name="pwd" /><br /><input type="password" name="pwd2" /><br />
84 </td></tr>
85 EOT
87 if ($Girocco::Config::project_owners eq 'email') {
88 print <<EOT;
89 <tr><td class="formlabel">E-mail contact:</td><td><input type="text" name="email" value="$h{email}" /></td></tr>
90 EOT
93 if ($proj->{mirror}) {
94 print "<tr><td class=\"formlabel\">Repository URL:</td><td><input type=\"text\" name=\"url\" value=\"$h{url}\" /></td></tr>\n";
95 } else {
96 print <<EOT;
97 <tr><td class="formlabel">Users:</td><td>
98 <ul>
99 EOT
100 $Girocco::Config::manage_users and print "<p>Only <a href=\"reguser.cgi\">registered users</a> can push.</p>";
101 if ($Girocco::Config::mob and not grep { $_ eq $Girocco::Config::mob } @{$h{users}}) {
102 print "<p><em>(Please consider adding the <tt>$Girocco::Config::mob</tt> user.\n";
103 print "<sup><a href=\"$Girocco::Config::htmlurl/mob.html\">(learn more)</a></sup>)\n";
104 print "</em></p>\n";
106 foreach my $user (@{$h{users}}) {
107 print "<li><input type=\"checkbox\" name=\"user\" value=\"$user\" checked=\"1\" /> $user</li>\n";
109 print <<EOT;
110 <li>Add user: <input type="text" name="user" /></li>
111 </ul>
112 </td></tr>
116 $gcgi->print_form_fields($Girocco::Project::metadata_fields, \%h, @Girocco::Config::project_fields);
118 print <<EOT;
119 <tr><td></td><td><input type="submit" name="y0" value="$button_label" /></td></tr>
120 </table>
121 </form>