jobs/clonecheck.sh: Fix permission setup
[girocco.git] / cgi / editproj.cgi
blobd7229b59493da32704feda14651dbc489ded0aec
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 if (!Girocco::Project::available($name)) {
36 print "<p>Sorry but your project has not finished mirroring yet. If it takes inordinate amount of time, please ask the administrator about it.</p>\n";
37 exit;
40 my $proj = Girocco::Project->load($name);
41 $proj or die "not found project $name, that's really weird!";
43 if ($cgi->param('email')) {
44 # submitted, let's see
45 if ($proj->cgi_fill($gcgi) and $proj->authenticate($gcgi) and $proj->update) {
46 print "<p>Project successfuly updated.</p>\n";
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
68 print <<EOT;
69 <form method="post">
70 <table class="form">
71 <tr><td class="formlabel">Project name:</td><td><a href="$Girocco::Config::gitweburl/$h{name}.git">$h{name}</a>.git
72 <input type="hidden" name="name" value="$h{name}" /></td></tr>
73 <tr><td class="formlabel"><strong>Admin password:</strong></td><td>
74 <input type="password" name="cpwd" /> <sup><a href="pwproj.cgi?name=$name" class="ctxaction">(forgot password?)</a></sup></td></tr>
75 <tr><td class="formlabel">New admin password (twice):<br />
76 <em>(leave empty to keep it the same)</em></td><td>
77 <input type="password" name="pwd" /><br /><input type="password" name="pwd2" /><br />
78 </td></tr>
79 <tr><td class="formlabel">E-mail contact:</td><td><input type="text" name="email" value="$h{email}" /></td></tr>
80 EOT
82 if ($proj->{mirror}) {
83 print "<tr><td class=\"formlabel\">Repository URL:</td><td><input type=\"text\" name=\"url\" value=\"$h{url}\" /></td></tr>\n";
84 } else {
85 print <<EOT;
86 <tr><td class="formlabel">Users:</td><td>
87 <ul>
88 EOT
89 $Girocco::Config::manage_users and print "<p>Only <a href=\"reguser.cgi\">registered users</a> can push.</p>";
90 if ($Girocco::Config::mob and not grep { $_ eq $Girocco::Config::mob } @{$h{users}}) {
91 print "<p><em>(Please consider adding the <tt>$Girocco::Config::mob</tt> user.\n";
92 print "<sup><a href=\"$Girocco::Config::htmlurl/mob.html\">(learn more)</a></sup>)\n";
93 print "</em></p>\n";
95 foreach my $user (@{$h{users}}) {
96 print "<li><input type=\"checkbox\" name=\"user\" value=\"$user\" checked=\"1\" /> $user</li>\n";
98 print <<EOT;
99 <li>Add user: <input type="text" name="user" /></li>
100 </ul>
101 </td></tr>
105 print <<EOT;
106 <tr><td class="formlabel">Homepage URL:</td><td><input type="text" name="hp" value="$h{hp}" /></td></tr>
107 <tr><td class="formlabel">Description:</td><td><input type="text" name="desc" value="$h{desc}" size="80" /></td></tr>
108 <tr><td class="formlabel">README (HTML, lt 8kb):</td><td><textarea name="README" rows="5" cols="80">$h{README}</textarea></td></tr>
109 <tr><td></td><td><input type="submit" name="y0" value="Update" /></td></tr>
110 </table>
111 </form>