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);
52 $proj or die "not found project $name, that's really weird!";
54 $escname =~ s/[+]/%2B/g;
56 my $y0 = $cgi->param('y0') || '';
57 if (($y0 eq 'Update' || $y0 eq 'Restart Mirroring') && $cgi->request_method eq 'POST') {
58 # submitted, let's see
59 if ($proj->cgi_fill($gcgi) and $proj->authenticate($gcgi) and $proj->update) {
60 print "<p class=\"updated\">Project successfully updated.</p>\n";
61 if ($proj->{clone_failed
}) {
62 print "<p>Please <a href=\"@{[url_path($Girocco::Config::webadmurl)]}".
63 "/mirrorproj.cgi?name=$escname\">pass onwards</a>.</p>\n";
64 print "<script language=\"javascript\">document.location=".
65 "'@{[url_path($Girocco::Config::webadmurl)]}/mirrorproj.cgi?name=$escname'</script>\n";
71 # $proj may be insane now but that's actually good for us since we'll let the
72 # user fix the invalid values he or she entered
73 my %h = $proj->form_defaults;
76 <p>Here you may adjust the settings of project $h{name}. Go wild.
78 if ($proj->{mirror
}) {
80 Since this is a mirrored project, you may opt to remove it from the site as well.
81 Just <a href="@{[url_path($Girocco::Config::webadmurl)]}/delproj.cgi?name=$escname">remove it</a>.</p>
84 if ($proj->is_empty) {
86 Since this is an empty project, you may opt to remove it from the site as well.
87 Just <a href="@{[url_path($Girocco::Config::webadmurl)]}/delproj.cgi?name=$escname">remove it</a>.</p>
92 <a href="@{[url_path($Girocco::Config::webadmurl)]}/delproj.cgi?name=$escname">request an authorization code</a> in order
93 to remove this project from the site.</p>
97 <p>Use the <b>+</b> button to enable access for more than a single user at a time.</p>
101 my $button_label = $proj->{clone_failed
} ?
'Restart Mirroring' : 'Update';
102 my $showstatusopt = $proj->{mirror
} && !$proj->{clone_failed
} && !$proj->{clone_in_progress
};
103 my $statuschecked = $proj->{statusupdates
} ?
'checked="checked"' : '';
106 <form method="post" action="@{[url_path($Girocco::Config::webadmurl)]}/editproj.cgi">
108 <tr><td class="formlabel">Project name:</td><td class="formdata"><a
109 href="@{[url_path($Girocco::Config::gitweburl)]}/$h{name}.git">$h{name}</a>.git
110 <input type="hidden" name="name" value="$h{name}" /></td></tr>
112 if ($Girocco::Config
::project_passwords
) {
114 <tr><td class="formlabel"><strong>Admin password:</strong></td><td>
115 <input type="password" name="cpwd" /> <sup><a
116 href="@{[url_path($Girocco::Config::webadmurl)]}/pwproj.cgi?name=$escname"
117 class="ctxaction">(forgot password?)</a></sup></td></tr>
118 <tr><td class="formlabel">New admin password (twice):<br />
119 <em>(leave empty to keep it the same)</em></td><td>
120 <input type="password" name="pwd" /><br /><input type="password" name="pwd2" /><br />
124 if ($Girocco::Config
::project_owners
eq 'email') {
126 <tr><td class="formlabel">E-mail contact:</td><td><input type="text" name="email" value="$h{email}" /></td></tr>
130 if ($proj->{mirror
}) {
131 print "<tr><td class=\"formlabel\">Repository URL:</td><td><input type=\"text\" name=\"url\" value=\"$h{url}\" /></td></tr>\n";
134 <tr><td class="formlabel" style="vertical-align:middle">Users:</td><td>
137 $Girocco::Config
::manage_users
and print "<p>Only <a href=\"".
138 "@{[url_path($Girocco::Config::webadmurl)]}/reguser.cgi\">registered users</a> may push.</p>";
139 if ($Girocco::Config
::mob
and not grep { $_ eq $Girocco::Config
::mob
} @
{$h{users
}}) {
140 print "<p><em>(Please consider adding the <tt>$Girocco::Config::mob</tt> user.\n";
141 print "<sup><a href=\"@{[url_path($Girocco::Config::htmlurl)]}/mob.html\">(learn more)</a></sup>)\n";
144 foreach my $user (@
{$h{users
}}) {
146 $mlm = " <sup><a href=\"@{[url_path($Girocco::Config::htmlurl)]}/mob.html\">(learn more)</a></sup>"
147 if $Girocco::Config
::mob
&& $user eq $Girocco::Config
::mob
;
148 print "<li><input type=\"checkbox\" name=\"user\" value=\"$user\" checked=\"1\" /> $user$mlm</li>\n";
151 <li>Add user: <input type="text" name="user" /></li>
152 <button type="button" onclick="adduseritem(this)"><b>+</b></button>
158 print '<tr><td class="formlabel">Default branch:</td><td><select size="1" name="HEAD">';
159 for ($proj->get_heads) {
160 my $selected = $proj->{HEAD
} eq $_ ?
' selected="selected"' : '';
161 print "<option$selected>".Girocco
::CGI
::html_esc
($_)."</option>";
163 print '</select></td></tr>
166 print '<tr><td class="formlabel">Tags (select to delete):</td><td>';
167 print '<select size="6" name="tags" multiple="multiple">';
168 for ($proj->get_ctag_names) {
169 print '<option>'.Girocco
::CGI
::html_esc
($_).'</option>';
171 print '</select></td></tr>
175 $gcgi->print_form_fields($Girocco::Project
::metadata_fields
, \
%h, @Girocco::Config
::project_fields
);
176 print <<EOT if $showstatusopt;
177 <tr><td class="formlabel">Enable status update emails:</td>
178 <td class="formdata" style="padding-left:1ex"
179 ><input type="hidden" name="setstatusupdates" value="1"
180 /><input type="checkbox" name="statusupdates" value="1" $statuschecked /></td></tr>
183 <tr><td class="formlabel"></td><td><input type="submit" name="y0" value="$button_label" /></td></tr>