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