$repo -> $gcgi for Girocco::CGI instances
[girocco.git] / cgi / editproj.cgi
bloba9fdbae5f769f5afdd1fb5dbd861e8fbebf5976b
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;
11 my $gcgi = Girocco::CGI->new('Project Settings');
12 my $cgi = $gcgi->cgi;
14 my $name = $cgi->param('name');
15 $name =~ s#.git$##;
17 unless (defined $name) {
18 print "<p>I need the project name as an argument now.</p>\n";
19 exit;
22 if (!valid_proj_name($name)) {
23 print "<p>Invalid project name. Go away, sorcerer.</p>\n";
24 exit;
27 if (!Girocco::Project::does_exist($name)) {
28 print "<p>Sorry but the project $name does not exist. Now, how did you <em>get</em> here?!</p>\n";
29 exit;
32 if (!Girocco::Project::available($name)) {
33 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";
34 exit;
37 my $proj = Girocco::Project->load($name);
38 $proj or die "not found project $name, that's really weird!";
40 if ($cgi->param('email')) {
41 # submitted, let's see
42 if ($proj->cgi_fill($gcgi) and $proj->authenticate($gcgi) and $proj->update) {
43 print "<p>Project successfuly updated.</p>\n";
47 # $proj may be insane now but that's actually good for us since we'll let the
48 # user fix the invalid values she entered
49 my %h = $proj->form_defaults;
51 print <<EOT;
52 <p>Here you can adjust the settings of project $h{name}. Go wild.
53 Though you can currently enable access only for a single user at a time
54 so perhaps you will need to click a lot. Sorry! (Patches welcome.)</p>
55 EOT
56 if ($proj->{mirror}) {
57 print <<EOT;
58 <p>Since this is a mirrored project, you can opt to remove it from the site as well.
59 Just <a href="delproj.cgi?name=$h{name}">delete it</a>.</p>
60 EOT
62 print <<EOT;
63 <form method="post">
64 <p>Project name: <a href="$Girocco::Config::gitweburl/$h{name}.git">$h{name}</a>.git <input type="hidden" name="name" value="$h{name}" /></p>
65 <p>Admin password: <input type="password" name="cpwd" /> <sup><a href="pwproj.cgi?name=$name">(forgot password?)</a></sup></p>
66 <p>New admin password: <input type="password" name="pwd" /> (leave empty to keep it at the current value)</p>
67 <p>New admin password (retype): <input type="password" name="pwd2" /></p>
68 <p>E-mail contact: <input type="text" name="email" value="$h{email}" /></p>
69 <p>Repository URL: <input type="text" name="url" value="$h{url}" /></p>
70 <p>Description: <input type="text" name="desc" value="$h{desc}" /></p>
71 <p>Homepage URL: <input type="text" name="hp" value="$h{hp}" /></p>
72 <p>README (HTML, lt 8kb): <textarea name="README" rows="5" cols="80">$h{README}</textarea></p>
73 <p>Users:</p>
74 <ul>
75 EOT
76 if ($proj->{mirror}) {
77 print "<p><em>Warning: This is a mirrored repository, thus you cannot push into it. Changing the user set will have no practical effect.</em></p>\n";
78 } elsif ($Girocco::Config::mob and not grep { $_ eq $Girocco::Config::mob } @{$h{users}}) {
79 print "<p><em>(Please consider adding the <tt>$Girocco::Config::mob</tt> user.";
80 print "<sup><a href=\"$Girocco::Config::moburl\">(learn more)</a></sup>)" if $Girocco::Config::moburl;
81 print "</em></p>\n";
83 foreach my $user (@{$h{users}}) {
84 print "<li><input type=\"checkbox\" name=\"user\" value=\"$user\" checked=\"1\" /> $user</li>\n";
86 print <<EOT;
87 <li>Add user: <input type="text" name="user" /></li>
88 </ul>
89 <p><input type="submit" name="y0" value="Update" /></p>
90 </form>
91 EOT