editproj: improve mirror and password handling
[girocco/ztw.git] / cgi / editproj.cgi
blob5007431502900b25491bbfb58a7f47230fe6eff2
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 # TODO: add config file support, remove hard-coded URLs
12 my $site_repo_url = 'git://repo.or.cz/repo.git';
14 my $repo = Git::RepoCGI->new('Project Settings');
15 my $name = $repo->sparam('name');
17 my $proj = $repo->load_project($name);
19 if ($repo->sparam('email')) {
20 $repo->bye("Form failed. Try again.") unless $proj->cgi_fill($repo);
21 $repo->bye("Authentication failed.") unless $proj->authenticate($repo);
22 my $okay = $proj->update ? "" : ' <span style="color:red">not</span>';
23 print "<p><em>The settings were$okay updated.</em></p>\n";
26 # $proj may be insane now but that's actually good for us since we'll let the
27 # user fix the invalid values she entered
28 my %h = $proj->form_defaults;
30 print <<EOT;
31 <form method="post">
32 <p>Project name: <a href="/w/$h{name}.git">$h{name}</a>.git
33 <input type="hidden" name="name" value="$h{name}" /></p>
34 <h3>Contact/Description </h3>
35 <p>E-mail contact: <input type="text" name="email" value="$h{email}" /></p>
36 <p>Repository URL: <input type="text" name="url" value="$h{url}" /></p>
37 <p>Description: <input type="text" name="desc" value="$h{desc}" /></p>
38 <p>Homepage URL: <input type="text" name="hp" value="$h{hp}" /></p>
39 <p>README (HTML, lt 8kb): <br />
40 <textarea name="README" rows="5" cols="80">$h{README}</textarea></p>
41 EOT
43 if ($proj->{mirror}) {
44 print <<EOT;
45 <h3>Mirror Settings</h3>
46 <p>
47 If no forks have been created, then you can
48 <a href="delproj.cgi?name=$h{name}">remove this project</a> from the site.
49 </p>
50 <p>
51 Since users cannot push changes to this project, the user access
52 list has no practical effect for this type of project.
53 </p>
54 EOT
55 exit
58 print <<EOT;
59 <h3>Users</h3>
60 <p>
61 Currently, you can add access for only one user at a time.
62 If this will be a limitation for you, you may create a patch for
63 <a href="$site_repo_url">the site</a> to improve this functionality,
64 and it will be incorporated in a future revision.
65 </p>
66 EOT
68 print <<EOT unless grep { $_ eq 'mob' } @{$h{users}};
69 <p>
70 <em>Please consider adding the <tt>mob</tt> user to provide
71 <a href=\"/mob.html\">anonymous push access</a> to the mob branch
72 of your project.</em>
73 </p>
74 EOT
76 print "<p>Users:</p>\n<ul>\n";
77 print <<EOT foreach @{$h{users}};
78 <li><input type="checkbox" name="user" value="$_" checked="1" />$_</li>
79 EOT
81 print <<EOT;
82 <li>Add user: <input type="text" name="user" /></li>
83 </ul>
85 <h3>Enter Admin Password</h3>
86 <p>Admin password: <input type="password" name="cpwd" />
87 <sup><a href="pwproj.cgi?name=$name">(forgot password?)</a></sup></p>
88 <p>New password: <input type="password" name="pwd" />
89 (leave empty to keep it at the current value)</p>
90 <p>Verify password: <input type="password" name="pwd2" /></p>
91 <br/>
92 <p><input type="submit" name="y0" value="Change" /></p>
93 </form>
94 EOT