cgi/*proj.cgi: Rearrange the retype-password inputs horizontally
[girocco/mytab.git] / cgi / editproj.cgi
blob879265ff863ef2117d278bd847ff1f82bf45af11
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 Though you can currently enable access only for a single user at a time
57 so perhaps you will need to click a lot. Sorry! (Patches welcome.)</p>
58 EOT
59 if ($proj->{mirror}) {
60 print <<EOT;
61 <p>Since this is a mirrored project, you can opt to remove it from the site as well.
62 Just <a href="delproj.cgi?name=$h{name}">delete it</a>.</p>
63 EOT
65 print <<EOT;
66 <form method="post">
67 <p>Project name: <a href="$Girocco::Config::gitweburl/$h{name}.git">$h{name}</a>.git <input type="hidden" name="name" value="$h{name}" /></p>
68 <p>Admin password: <input type="password" name="cpwd" /> <sup><a href="pwproj.cgi?name=$name">(forgot password?)</a></sup></p>
69 <p>New admin password (twice): <input type="password" name="pwd" /> <input type="password" name="pwd2" /><br />
70 <em>(leave empty to keep it at the current value)</em></p>
71 <p>E-mail contact: <input type="text" name="email" value="$h{email}" /></p>
72 <p>Description: <input type="text" name="desc" value="$h{desc}" /></p>
73 <p>Homepage URL: <input type="text" name="hp" value="$h{hp}" /></p>
74 <p>README (HTML, lt 8kb): <textarea name="README" rows="5" cols="80">$h{README}</textarea></p>
75 EOT
77 if ($proj->{mirror}) {
78 print "<p>Repository URL: <input type=\"text\" name=\"url\" value=\"$h{url}\" /></p>\n";
79 } else {
80 print <<EOT;
81 <p>Users:</p>
82 <ul>
83 EOT
84 $Girocco::Config::manage_users and print "<p>Only <a href=\"reguser.cgi\">registered users</a> can push.</p>";
85 if ($Girocco::Config::mob and not grep { $_ eq $Girocco::Config::mob } @{$h{users}}) {
86 print "<p><em>(Please consider adding the <tt>$Girocco::Config::mob</tt> user.\n";
87 print "<sup><a href=\"$Girocco::Config::htmlurl/mob.html\">(learn more)</a></sup>)\n";
88 print "</em></p>\n";
90 foreach my $user (@{$h{users}}) {
91 print "<li><input type=\"checkbox\" name=\"user\" value=\"$user\" checked=\"1\" /> $user</li>\n";
93 print <<EOT;
94 <li>Add user: <input type="text" name="user" /></li>
95 </ul>
96 EOT
99 print <<EOT;
100 <p><input type="submit" name="y0" value="Update" /></p>
101 </form>