Double password entering in editproj as well
[girocco/mytab.git] / cgi / editproj.cgi
blobc494bcb721f961013db5cd68e9f0b6cadc2c5ea0
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>New admin password (retype): <input type="password" name="pwd2" /></p>
67 <p>E-mail contact: <input type="text" name="email" value="$h{email}" /></p>
68 <p>Repository URL: <input type="text" name="url" value="$h{url}" /></p>
69 <p>Description: <input type="text" name="desc" value="$h{desc}" /></p>
70 <p>Homepage URL: <input type="text" name="hp" value="$h{hp}" /></p>
71 <p>README (HTML, lt 8kb): <textarea name="README" rows="5" cols="80">$h{README}</textarea></p>
72 <p>Users:</p>
73 <ul>
74 EOT
75 if ($proj->{mirror}) {
76 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";
77 } elsif (not grep { $_ eq 'mob' } @{$h{users}}) {
78 print "<p><em>(Please consider adding the <tt>mob</tt> user.<sup><a href=\"/mob.html\">(learn more)</a></sup>)</em></p>\n";
80 foreach my $user (@{$h{users}}) {
81 print "<li><input type=\"checkbox\" name=\"user\" value=\"$user\" checked=\"1\" /> $user</li>\n";
83 print <<EOT;
84 <li>Add user: <input type="text" name="user" /></li>
85 </ul>
86 <p><input type="submit" name="y0" value="Update" /></p>
87 </form>
88 EOT