Fix name passing
[girocco/ztw.git] / cgi / editproj.cgi
blob0933815473dd2e211b4656795cdd07fb78a24439
1 #!/usr/bin/perl
2 # (c) Petr Baudis <pasky@suse.cz>
3 # GPLv2
5 use strict;
6 use warnings;
8 use lib qw(/home/repo/repomgr/cgi);
9 use Git::RepoCGI;
11 my $repo = Git::RepoCGI->new('Project Settings');
12 my $cgi = $repo->cgi;
14 my $name = $cgi->param('name');
16 unless (defined $name) {
17 print "<p>I need the project name as an argument now.</p>\n";
18 exit;
21 if (!valid_proj_name($name)) {
22 print "<p>Invalid project name. Go away, sorcerer.</p>\n";
23 exit;
26 if (!Git::RepoCGI::Project::does_exist($name)) {
27 print "<p>Sorry but the project $name does not exist. Now, how did you <em>get</em> here?!</p>\n";
28 exit;
31 if (!Git::RepoCGI::Project::available($name)) {
32 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";
33 exit;
36 my $proj = Git::RepoCGI::Project->load($name);
37 $proj or die "not found project $name, that's really weird!";
39 if ($cgi->param('email')) {
40 # submitted, let's see
41 if ($proj->cgi_fill($repo) and $proj->authenticate($repo) and $proj->update) {
42 print "<p>Project successfuly updated.</p>\n";
46 # $proj may be insane now but that's actually good for us since we'll let the
47 # user fix the invalid values she entered
48 my %h = $proj->form_defaults;
50 print <<EOT;
51 <p>Here you can adjust the settings of project $h{name}. Go wild.
52 Though you can currently enable access only for a single user at a time
53 so perhaps you will need to click a lot. Sorry! (Patches welcome.)</p>
54 EOT
55 if ($proj->{mirror}) {
56 print <<EOT;
57 <p>Since this is a mirrored project, you can opt to remove it from the site as well.
58 Just <a href="delproj.cgi?name=$h{name}">delete it</a>.</p>
59 EOT
61 print <<EOT;
62 <form method="post">
63 <p>Project name: <a href="/w/$h{name}.git">$h{name}</a>.git <input type="hidden" name="name" value="$h{name}" /></p>
64 <p>Admin password: <input type="password" name="cpwd" /></p>
65 <p>New admin password: <input type="password" name="pwd" /> (leave empty to keep it at the current value)</p>
66 <p>E-mail contact: <input type="text" name="email" value="$h{email}" /></p>
67 <p>Repository URL: <input type="text" name="url" value="$h{url}" /></p>
68 <p>Description: <input type="text" name="desc" value="$h{desc}" /></p>
69 <p>Homepage URL: <input type="text" name="hp" value="$h{hp}" /></p>
70 <p>README (HTML, lt 8kb): <textarea name="README" rows="5" cols="80">$h{README}</textarea></p>
71 <p>Users:</p>
72 <ul>
73 EOT
74 if ($proj->{mirror}) {
75 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";
76 } elsif (not grep { $_ eq 'mob' } @{$h{users}}) {
77 print "<p><em>(Please consider adding the <tt>mob</tt> user.<sup><a href=\"/mob.html\">(learn more)</a></sup>)</em></p>\n";
79 foreach my $user (@{$h{users}}) {
80 print "<li><input type=\"checkbox\" name=\"user\" value=\"$user\" checked=\"1\" /> $user</li>\n";
82 print <<EOT;
83 <li>Add user: <input type="text" name="user" /></li>
84 </ul>
85 <p><input type="submit" name="y0" value="Update" /></p>
86 </form>
87 EOT