2 # (c) Petr Baudis <pasky@suse.cz>
15 <script type="text/javascript">
17 function adduseritem(elem)
19 var inp = document.createElement('input');
22 var li = document.createElement('li');
23 li.appendChild(document.createTextNode('Add user: '));
25 elem.parentNode.insertBefore(li, elem);
30 my $gcgi = Girocco
::CGI
->new('Project Settings', undef, $script);
33 my $name = $cgi->param('name');
34 $name =~ s
#\.git$## if $name; #
36 unless (defined $name) {
37 print "<p>I need the project name as an argument now.</p>\n";
41 if (!Girocco
::Project
::valid_name
($name)) {
42 print "<p>Invalid project name. Go away, sorcerer.</p>\n";
46 if (!Girocco
::Project
::does_exist
($name)) {
47 print "<p>Sorry but the project $name does not exist. Now, how did you <em>get</em> here?!</p>\n";
51 my $proj = Girocco
::Project
->load($name);
52 $proj or die "not found project $name, that's really weird!";
54 if ($cgi->param('y0')) {
55 # submitted, let's see
56 if ($proj->cgi_fill($gcgi) and $proj->authenticate($gcgi) and $proj->update) {
57 print "<p>Project successfully updated.</p>\n";
58 if ($proj->{clone_failed
}) {
59 print "<p>Please <a href=\"mirrorproj.cgi?name=$name\">pass onwards</a>.</p>\n";
60 print "<script language=\"javascript\">document.location='mirrorproj.cgi?name=$name'</script>\n";
66 # $proj may be insane now but that's actually good for us since we'll let the
67 # user fix the invalid values she entered
68 my %h = $proj->form_defaults;
71 <p>Here you can adjust the settings of project $h{name}. Go wild.
73 if ($proj->{mirror
}) {
75 Since this is a mirrored project, you can opt to remove it from the site as well.
76 Just <a href="delproj.cgi?name=$h{name}">delete it</a>.</p>
79 if ($proj->is_empty) {
81 Since this is an empty project, you can opt to remove it from the site as well.
82 Just <a href="delproj.cgi?name=$h{name}">delete it</a>.</p>
86 Use the <b>+</b> button to enable access for more than a single user at a time.</p>
90 my $button_label = $proj->{clone_failed
} ?
'Restart Mirroring' : 'Update';
95 <tr><td class="formlabel">Project name:</td><td class="formdata"><a href="$Girocco::Config::gitweburl/$h{name}.git">$h{name}</a>.git
96 <input type="hidden" name="name" value="$h{name}" /></td></tr>
98 if ($Girocco::Config
::project_passwords
) {
100 <tr><td class="formlabel"><strong>Admin password:</strong></td><td>
101 <input type="password" name="cpwd" /> <sup><a href="pwproj.cgi?name=$name" class="ctxaction">(forgot password?)</a></sup></td></tr>
102 <tr><td class="formlabel">New admin password (twice):<br />
103 <em>(leave empty to keep it the same)</em></td><td>
104 <input type="password" name="pwd" /><br /><input type="password" name="pwd2" /><br />
108 if ($Girocco::Config
::project_owners
eq 'email') {
110 <tr><td class="formlabel">E-mail contact:</td><td><input type="text" name="email" value="$h{email}" /></td></tr>
114 if ($proj->{mirror
}) {
115 print "<tr><td class=\"formlabel\">Repository URL:</td><td><input type=\"text\" name=\"url\" value=\"$h{url}\" /></td></tr>\n";
118 <tr><td class="formlabel" style="vertical-align:middle">Users:</td><td>
121 $Girocco::Config
::manage_users
and print "<p>Only <a href=\"reguser.cgi\">registered users</a> can push.</p>";
122 if ($Girocco::Config
::mob
and not grep { $_ eq $Girocco::Config
::mob
} @
{$h{users
}}) {
123 print "<p><em>(Please consider adding the <tt>$Girocco::Config::mob</tt> user.\n";
124 print "<sup><a href=\"$Girocco::Config::htmlurl/mob.html\">(learn more)</a></sup>)\n";
127 foreach my $user (@
{$h{users
}}) {
129 $mlm = " <sup><a href=\"$Girocco::Config::htmlurl/mob.html\">(learn more)</a></sup>"
130 if $Girocco::Config
::mob
&& $user eq $Girocco::Config
::mob
;
131 print "<li><input type=\"checkbox\" name=\"user\" value=\"$user\" checked=\"1\" /> $user$mlm</li>\n";
134 <li>Add user: <input type="text" name="user" /></li>
135 <button type="button" onclick="adduseritem(this)"><b>+</b></button>
141 print '<tr><td class="formlabel">Default branch:</td><td><select size="1" name="HEAD">';
142 for ($proj->get_heads) {
143 my $selected = $proj->{HEAD
} eq $_ ?
' selected="selected"' : '';
144 print "<option$selected>".Girocco
::CGI
::html_esc
($_)."</option>";
146 print '</select></td></tr>
149 print '<tr><td class="formlabel">Tags (select to delete):</td><td>';
150 print '<select size="6" name="tags" multiple="multiple">';
151 for ($proj->get_ctag_names) {
152 print '<option>'.Girocco
::CGI
::html_esc
($_).'</option>';
154 print '</select></td></tr>
158 $gcgi->print_form_fields($Girocco::Project
::metadata_fields
, \
%h, @Girocco::Config
::project_fields
);
161 <tr><td></td><td><input type="submit" name="y0" value="$button_label" /></td></tr>