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
::does_exist
($name,1) && !Girocco
::Project
::valid_name
($name)) {
42 print "<p>Invalid project name. Go away, sorcerer.</p>\n";
46 if (!Girocco
::Project
::does_exist
($name,1)) {
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);
53 print "<p>not found project $name, that's really weird!</p>\n";
57 $escname =~ s/[+]/%2B/g;
59 my $y0 = $cgi->param('y0') || '';
60 if (($y0 eq 'Update' || $y0 eq 'Restart Mirroring') && $cgi->request_method eq 'POST') {
61 # submitted, let's see
62 if ($proj->cgi_fill($gcgi) and $proj->authenticate($gcgi) and $proj->update) {
63 print "<p class=\"updated\">Project successfully updated.</p>\n";
64 if ($proj->{clone_failed
}) {
66 print "<p>Please <a href=\"@{[url_path($Girocco::Config::webadmurl)]}".
67 "/mirrorproj.cgi?name=$escname\">pass onwards</a>.</p>\n";
68 print "<script language=\"javascript\">document.location=".
69 "'@{[url_path($Girocco::Config::webadmurl)]}/mirrorproj.cgi?name=$escname'</script>\n";
75 # $proj may be insane now but that's actually good for us since we'll let the
76 # user fix the invalid values he or she entered
77 my %h = $proj->form_defaults;
80 <p>Here you may adjust the settings of project $h{name}. Go wild.
82 if ($proj->{mirror
}) {
84 Since this is a mirrored project, you may opt to remove it from the site as well.
85 Just <a href="@{[url_path($Girocco::Config::webadmurl)]}/delproj.cgi?name=$escname">remove it</a>.</p>
88 if ($proj->is_empty) {
90 Since this is an empty project, you may opt to remove it from the site as well.
91 Just <a href="@{[url_path($Girocco::Config::webadmurl)]}/delproj.cgi?name=$escname">remove it</a>.</p>
96 <a href="@{[url_path($Girocco::Config::webadmurl)]}/delproj.cgi?name=$escname">request an authorization code</a> in order
97 to remove this project from the site.</p>
101 <p>Use the <b>+</b> button to enable access for more than a single user at a time.</p>
105 my $button_label = $proj->{clone_failed
} ?
'Restart Mirroring' : 'Update';
106 my $showstatusopt = $proj->{mirror
} && !$proj->{clone_failed
} && !$proj->{clone_in_progress
};
107 my $statuschecked = $proj->{statusupdates
} ?
'checked="checked"' : '';
110 <form method="post" action="@{[url_path($Girocco::Config::webadmurl)]}/editproj.cgi">
112 <tr><td class="formlabel">Project name:</td><td class="formdata"><a
113 href="@{[url_path($Girocco::Config::gitweburl)]}/$h{name}.git">$h{name}</a>.git
114 <input type="hidden" name="name" value="$h{name}" /></td></tr>
116 if ($Girocco::Config
::project_passwords
) {
118 <tr><td class="formlabel"><strong>Admin password:</strong></td><td>
119 <input type="password" name="cpwd" /> <sup><a
120 href="@{[url_path($Girocco::Config::webadmurl)]}/pwproj.cgi?name=$escname"
121 class="ctxaction">(forgot password?)</a></sup></td></tr>
122 <tr><td class="formlabel">New admin password (twice):<br />
123 <em>(leave empty to keep it the same)</em></td><td>
124 <input type="password" name="pwd" /><br /><input type="password" name="pwd2" /><br />
128 if ($Girocco::Config
::project_owners
eq 'email') {
130 <tr><td class="formlabel">E-mail contact:</td><td><input type="text" name="email" value="$h{email}" /></td></tr>
134 if ($proj->{mirror
}) {
135 print "<tr><td class=\"formlabel\">Repository URL:</td><td><input type=\"text\" name=\"url\" value=\"$h{url}\" /></td></tr>\n";
138 <tr><td class="formlabel" style="vertical-align:middle">Users:</td><td>
141 $Girocco::Config
::manage_users
and print "<p>Only <a href=\"".
142 "@{[url_path($Girocco::Config::webadmurl)]}/reguser.cgi\">registered users</a> may push.</p>";
143 if ($Girocco::Config
::mob
and not grep { $_ eq $Girocco::Config
::mob
} @
{$h{users
}}) {
144 print "<p><em>(Please consider adding the <tt>$Girocco::Config::mob</tt> user.\n";
145 print "<sup><a href=\"@{[url_path($Girocco::Config::htmlurl)]}/mob.html\">(learn more)</a></sup>)\n";
148 foreach my $user (@
{$h{users
}}) {
150 $mlm = " <sup><a href=\"@{[url_path($Girocco::Config::htmlurl)]}/mob.html\">(learn more)</a></sup>"
151 if $Girocco::Config
::mob
&& $user eq $Girocco::Config
::mob
;
152 print "<li><input type=\"checkbox\" name=\"user\" value=\"$user\" checked=\"1\" /> $user$mlm</li>\n";
155 <li>Add user: <input type="text" name="user" /></li>
156 <button type="button" onclick="adduseritem(this)"><b>+</b></button>
162 print '<tr><td class="formlabel">Default branch:</td><td><select size="1" name="HEAD">';
163 for ($proj->get_heads) {
164 my $selected = $proj->{HEAD
} eq $_ ?
' selected="selected"' : '';
165 print "<option$selected>".Girocco
::CGI
::html_esc
($_)."</option>";
167 print '</select></td></tr>
170 print '<tr><td class="formlabel">Tags (select to delete):</td><td>';
171 print '<select size="6" name="tags" multiple="multiple">';
172 for ($proj->get_ctag_names) {
173 print '<option>'.Girocco
::CGI
::html_esc
($_).'</option>';
175 print '</select></td></tr>
179 $gcgi->print_form_fields($Girocco::Project
::metadata_fields
, \
%h, @Girocco::Config
::project_fields
);
180 print <<EOT if $showstatusopt;
181 <tr><td class="formlabel">Enable status update emails:</td>
182 <td class="formdata" style="padding-left:1ex"
183 ><input type="hidden" name="setstatusupdates" value="1"
184 /><input type="checkbox" name="statusupdates" value="1" $statuschecked /></td></tr>
187 <tr><td class="formlabel"></td><td><input type="submit" name="y0" value="$button_label" /></td></tr>