Let co-maintainers unflag the package
[aur.git] / web / template / pkg_details.php
blobfb81442da7f7db1391ceb6d4cef3844949163328
1 <?php
3 $pkgbuild_uri = sprintf(config_get('options', 'pkgbuild_uri'), urlencode($row['BaseName']));
4 $log_uri = sprintf(config_get('options', 'log_uri'), urlencode($row['BaseName']));
5 $snapshot_uri = sprintf(config_get('options', 'snapshot_uri'), urlencode($row['BaseName']));
6 $git_clone_uri_anon = sprintf(config_get('options', 'git_clone_uri_anon'), htmlspecialchars($row['BaseName']));
7 $git_clone_uri_priv = sprintf(config_get('options', 'git_clone_uri_priv'), htmlspecialchars($row['BaseName']));
9 $uid = uid_from_sid($SID);
11 $pkgid = intval($row['ID']);
12 $base_id = intval($row['BaseID']);
14 $keywords = pkgbase_get_keywords($base_id);
16 $submitter = username_from_id($row["SubmitterUID"]);
17 $maintainer = username_from_id($row["MaintainerUID"]);
18 $comaintainers = pkgbase_get_comaintainers($base_id);
19 $packager = username_from_id($row["PackagerUID"]);
21 if ($row["MaintainerUID"] !== NULL) {
22 $maintainers = array_merge(array($row["MaintainerUID"]), pkgbase_get_comaintainer_uids(array($base_id)));
23 } else {
24 $maintainers = NULL;
27 $votes = $row['NumVotes'];
29 # In case of wanting to put a custom message
30 $msg = __('unknown');
31 $license = empty($row['License']) ? $msg : $row['License'];
33 # Print the timestamps for last updates
34 $updated_time = ($row["ModifiedTS"] == 0) ? $msg : gmdate("Y-m-d H:i", intval($row["ModifiedTS"]));
35 $submitted_time = ($row["SubmittedTS"] == 0) ? $msg : gmdate("Y-m-d H:i", intval($row["SubmittedTS"]));
36 $out_of_date_time = ($row["OutOfDateTS"] == 0) ? $msg : gmdate("Y-m-d", intval($row["OutOfDateTS"]));
38 $lics = pkg_licenses($row["ID"]);
39 $grps = pkg_groups($row["ID"]);
41 $deps = pkg_dependencies($row["ID"]);
42 $requiredby = pkg_required($row["Name"]);
44 usort($deps, function($x, $y) {
45 if ($x[1] != $y[1]) {
46 if ($x[1] == "depends") {
47 return -1;
48 } elseif ($y[1] == "depends") {
49 return 1;
51 return strcmp($x[1], $y[1]);
52 } elseif ($x[3] != $y[3]) {
53 return strcmp($x[3], $y[3]);
54 } else {
55 return strcmp($x[0], $y[0]);
57 });
59 $rels = pkg_relations($row["ID"]);
61 usort($rels, function($x, $y) {
62 if ($x[3] != $y[3]) {
63 return strcmp($x[3], $y[3]);
64 } else {
65 return strcmp($x[0], $y[0]);
67 });
69 $rels_c = $rels_p = $rels_r = array();
70 foreach ($rels as $rel) {
71 switch ($rel[1]) {
72 case "conflicts":
73 $rels_c[] = $rel;
74 break;
75 case "provides":
76 $rels_p[] = $rel;
77 break;
78 case "replaces":
79 $rels_r[] = $rel;
80 break;
84 # $sources[0] = 'src';
85 $sources = pkg_sources($row["ID"]);
87 <div id="pkgdetails" class="box">
88 <h2><?= __('Package Details') . ': ' . htmlspecialchars($row['Name']) . ' ' . htmlspecialchars($row['Version']) ?></h2>
89 <div id="detailslinks" class="listing">
90 <div id="actionlist">
91 <h4><?= __('Package Actions') ?></h4>
92 <ul class="small">
93 <li>
94 <a href="<?= $pkgbuild_uri ?>"><?= __('View PKGBUILD') ?></a> /
95 <a href="<?= $log_uri ?>"><?= __('View Changes') ?></a>
96 </li>
97 <li><a href="<?= $snapshot_uri ?>"><?= __('Download snapshot') ?></a>
98 <li><a href="https://wiki.archlinux.org/index.php/Special:Search?search=<?= urlencode($row['Name']) ?>"><?= __('Search wiki') ?></a></li>
99 <li><span class="flagged"><?php if ($row["OutOfDateTS"] !== NULL) { echo __('Flagged out-of-date')." (${out_of_date_time})"; } ?></span></li>
100 <?php if ($uid): ?>
101 <?php if ($row["OutOfDateTS"] === NULL): ?>
102 <li>
103 <form action="<?= get_pkgbase_uri($row['BaseName']) . 'flag/'; ?>" method="post">
104 <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
105 <input type="submit" class="button text-button" name="do_Flag" value="<?= __('Flag package out-of-date') ?>" />
106 </form>
107 </li>
108 <?php elseif (($row["OutOfDateTS"] !== NULL) && has_credential(CRED_PKGBASE_UNFLAG, $maintainers)): ?>
109 <li>
110 <form action="<?= get_pkgbase_uri($row['BaseName']) . 'unflag/'; ?>" method="post">
111 <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
112 <input type="submit" class="button text-button" name="do_UnFlag" value="<?= __('Unflag package') ?>" />
113 </form>
114 </li>
115 <?php endif; ?>
116 <?php if (pkgbase_user_voted($uid, $base_id)): ?>
117 <li>
118 <form action="<?= get_pkgbase_uri($row['BaseName']) . 'unvote/'; ?>" method="post">
119 <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
120 <input type="submit" class="button text-button" name="do_UnVote" value="<?= __('Remove vote') ?>" />
121 </form>
122 </li>
123 <?php else: ?>
124 <li>
125 <form action="<?= get_pkgbase_uri($row['BaseName']) . 'vote/'; ?>" method="post">
126 <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
127 <input type="submit" class="button text-button" name="do_Vote" value="<?= __('Vote for this package') ?>" />
128 </form>
129 </li>
130 <?php endif; ?>
131 <?php if (pkgbase_user_notify($uid, $base_id)): ?>
132 <li>
133 <form action="<?= get_pkgbase_uri($row['BaseName']) . 'unnotify/'; ?>" method="post">
134 <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
135 <input type="submit" class="button text-button" name="do_UnNotify" value="<?= __('Disable notifications') ?>" />
136 </form>
137 </li>
138 <?php else: ?>
139 <li>
140 <form action="<?= get_pkgbase_uri($row['BaseName']) . 'notify/'; ?>" method="post">
141 <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
142 <input type="submit" class="button text-button" name="do_Notify" value="<?= __('Notify of new comments') ?>" />
143 </form>
144 </li>
145 <?php endif; ?>
146 <?php if (has_credential(CRED_PKGBASE_EDIT_COMAINTAINERS, array($row["MaintainerUID"]))): ?>
147 <li><a href="<?= get_pkgbase_uri($row['BaseName']) . 'comaintainers/'; ?>"><?= __('Manage Co-Maintainers'); ?></a></li>
148 <?php endif; ?>
149 <li><span class="flagged"><?php if ($row["RequestCount"] > 0) { echo _n('%d pending request', '%d pending requests', $row["RequestCount"]); } ?></span></li>
150 <li><a href="<?= get_pkgbase_uri($row['BaseName']) . 'request/'; ?>"><?= __('File Request'); ?></a></li>
151 <?php if (has_credential(CRED_PKGBASE_DELETE)): ?>
152 <li><a href="<?= get_pkgbase_uri($row['BaseName']) . 'delete/'; ?>"><?= __('Delete Package'); ?></a></li>
153 <li><a href="<?= get_pkgbase_uri($row['BaseName']) . 'merge/'; ?>"><?= __('Merge Package'); ?></a></li>
154 <?php endif; ?>
155 <?php endif; ?>
157 <?php if ($uid && $row["MaintainerUID"] === NULL): ?>
158 <li>
159 <form action="<?= get_pkgbase_uri($row['BaseName']) . 'adopt/'; ?>" method="post">
160 <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
161 <input type="submit" class="button text-button" name="do_Adopt" value="<?= __('Adopt Package') ?>" />
162 </form>
163 </li>
164 <?php elseif (has_credential(CRED_PKGBASE_DISOWN, array($row["MaintainerUID"]))): ?>
165 <li>
166 <form action="<?= get_pkgbase_uri($row['BaseName']) . 'disown/'; ?>" method="post">
167 <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
168 <input type="submit" class="button text-button" name="do_Disown" value="<?= __('Disown Package') ?>" />
169 </form>
170 </li>
171 <?php endif; ?>
172 </ul>
173 </div>
174 </div>
176 <table id="pkginfo">
177 <tr>
178 <th><?= __('Git Clone URL') . ': ' ?></th>
179 <td>
180 <a href="<?= $git_clone_uri_anon ?>"><?= $git_clone_uri_anon ?></a> (<?= __('read-only') ?>)
181 <?php if ($uid == $row["MaintainerUID"]): ?>
182 <br /> <a href="<?= $git_clone_uri_priv ?>"><?= $git_clone_uri_priv ?></a>
183 <?php endif; ?>
184 </td>
185 </tr>
186 <tr>
187 <th><?= __('Package Base') . ': ' ?></th>
188 <td class="wrap"><a href="<?= htmlspecialchars(get_pkgbase_uri($row['BaseName']), ENT_QUOTES); ?>"><?= htmlspecialchars($row['BaseName']); ?></a></td>
189 </tr>
190 <tr>
191 <th><?= __('Description') . ': ' ?></th>
192 <td class="wrap"><?= htmlspecialchars($row['Description']); ?></td>
193 </tr>
194 <tr>
195 <th><?= __('Upstream URL') . ': ' ?></th>
196 <td><a href="<?= htmlspecialchars($row['URL'], ENT_QUOTES) ?>" title="<?= __('Visit the website for') . ' ' . htmlspecialchars( $row['Name'])?>"><?= htmlspecialchars($row['URL'], ENT_QUOTES) ?></a></td>
197 </tr>
198 <?php
199 if (has_credential(CRED_PKGBASE_SET_KEYWORDS, array($row["MaintainerUID"])) || count($keywords) > 0):
201 <tr>
202 <th><?= __('Keywords') . ': ' ?></th>
203 <td>
204 <?php
205 if (has_credential(CRED_PKGBASE_SET_KEYWORDS, array($row["MaintainerUID"]))):
207 <form method="post" action="<?= htmlspecialchars(get_pkgbase_uri($row['BaseName']), ENT_QUOTES); ?>">
208 <div>
209 <input type="hidden" name="action" value="do_SetKeywords" />
210 <?php if ($SID): ?>
211 <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
212 <?php endif; ?>
213 <input type="text" name="keywords" value="<?= htmlspecialchars(implode(" ", $keywords), ENT_QUOTES) ?>"/>
214 <input type="submit" value="<?= __('Update') ?>"/>
215 </div>
216 </form>
217 <?php
218 else:
219 foreach ($keywords as $kw) {
220 echo '<a class="keyword" href="';
221 echo get_uri('/packages/') . '?K=' . urlencode($kw) . '&amp;SB=p';
222 echo '">' . htmlspecialchars($kw) . "</a>\n";
224 endif;
226 </td>
227 </tr>
228 <?php endif; ?>
229 <?php if (count($lics) > 0): ?>
230 <tr>
231 <th><?= __('Licenses') . ': ' ?></th>
232 <td class="wrap">
233 <?php foreach($lics as $lic): ?>
234 <span class="related">
235 <?php if ($lic !== end($lics)): ?>
236 <?= htmlspecialchars($lic) ?>,
237 <?php else: ?>
238 <?= htmlspecialchars($lic) ?>
239 <?php endif; ?>
240 </span>
241 <?php endforeach; ?>
242 </td>
243 </tr>
244 <?php endif; ?>
245 <?php if (count($grps) > 0): ?>
246 <tr>
247 <th><?= __('Groups') . ': ' ?></th>
248 <td class="wrap">
249 <?php foreach($grps as $grp): ?>
250 <span class="related">
251 <?php if ($grp !== end($grps)): ?>
252 <?= htmlspecialchars($grp) ?>,
253 <?php else: ?>
254 <?= htmlspecialchars($grp) ?>
255 <?php endif; ?>
256 </span>
257 <?php endforeach; ?>
258 </td>
259 </tr>
260 <?php endif; ?>
261 <?php if (count($rels_c) > 0): ?>
262 <tr>
263 <th><?= __('Conflicts') . ': ' ?></th>
264 <td class="wrap relatedto">
265 <?php foreach($rels_c as $rarr): ?>
266 <span class="related">
267 <?php if ($rarr !== end($rels_c)): ?>
268 <?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>,
269 <?php else: ?>
270 <?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>
271 <?php endif; ?>
272 </span>
273 <?php endforeach; ?>
274 </td>
275 </tr>
276 <?php endif; ?>
277 <?php if (count($rels_p) > 0): ?>
278 <tr>
279 <th><?= __('Provides') . ': ' ?></th>
280 <td class="wrap relatedto">
281 <?php foreach($rels_p as $rarr): ?>
282 <span class="related">
283 <?php if ($rarr !== end($rels_p)): ?>
284 <?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>,
285 <?php else: ?>
286 <?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>
287 <?php endif; ?>
288 </span>
289 <?php endforeach; ?>
290 </td>
291 </tr>
292 <?php endif; ?>
293 <?php if (count($rels_r) > 0): ?>
294 <tr>
295 <th><?= __('Replaces') . ': ' ?></th>
296 <td class="wrap relatedto">
297 <?php foreach($rels_r as $rarr): ?>
298 <span class="related">
299 <?php if ($rarr !== end($rels_r)): ?>
300 <?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>,
301 <?php else: ?>
302 <?= pkg_rel_html($rarr[0], $rarr[2], $rarr[3]) ?>
303 <?php endif; ?>
304 </span>
305 <?php endforeach; ?>
306 </td>
307 </tr>
308 <?php endif; ?>
309 <tr>
310 <th><?= __('Submitter') .': ' ?></th>
311 <td><?= html_format_username($submitter) ?></td>
312 </tr>
313 <tr>
314 <th><?= __('Maintainer') .': ' ?></th>
315 <td><?= html_format_maintainers($maintainer, $comaintainers) ?></td>
316 </tr>
317 <tr>
318 <th><?= __('Last Packager') .': ' ?></th>
319 <td><?= html_format_username($packager) ?></td>
320 </tr>
321 <tr>
322 <th><?= __('Votes') . ': ' ?></th>
323 <?php if (has_credential(CRED_PKGBASE_LIST_VOTERS)): ?>
324 <td><a href="<?= get_pkgbase_uri($row['BaseName']); ?>voters/"><?= $votes ?></a></td>
325 <?php else: ?>
326 <td><?= $votes ?></td>
327 <?php endif; ?>
328 </tr>
329 <tr>
330 <th><?= __('First Submitted') . ': ' ?></th>
331 <td><?= $submitted_time ?></td>
332 </tr>
333 <tr>
334 <th><?= __('Last Updated') . ': ' ?></th>
335 <td><?= $updated_time ?></td>
336 </tr>
337 </table>
339 <div id="metadata">
340 <div id="pkgdeps" class="listing">
341 <h3><?= __('Dependencies') . " (" . count($deps) . ")"?></h3>
342 <?php if (count($deps) > 0): ?>
343 <ul id="pkgdepslist">
344 <?php while (list($k, $darr) = each($deps)): ?>
345 <li><?= pkg_depend_link($darr[0], $darr[1], $darr[2], $darr[3], $darr[4]); ?></li>
346 <?php endwhile; ?>
347 </ul>
348 <?php endif; ?>
349 </div>
350 <div id="pkgreqs" class="listing">
351 <h3><?= __('Required by') . " (" . count($requiredby) . ")"?></h3>
352 <?php if (count($requiredby) > 0): ?>
353 <ul id="pkgreqslist">
354 <?php
355 # darr: (PackageName, PackageID)
356 while (list($k, $darr) = each($requiredby)):
358 <li><a href="<?= htmlspecialchars(get_pkg_uri($darr[0]), ENT_QUOTES); ?>" title="<?= __('View packages details for').' ' . htmlspecialchars($darr[0]) ?>"><?= htmlspecialchars($darr[0]) ?></a></li>
359 <?php endwhile; ?>
360 </ul>
361 <?php endif; ?>
362 </div>
363 <div id="pkgfiles" class="listing">
364 <h3><?= __('Sources') ?></h3>
365 </div>
366 <?php if (count($sources) > 0): ?>
367 <div>
368 <ul id="pkgsrcslist">
369 <?php while (list($k, $src) = each($sources)): ?>
370 <li><?= pkg_source_link($src[0], $src[1]) ?></li>
371 <?php endwhile; ?>
372 </ul>
373 </div>
374 <?php endif; ?>
375 </div>
376 </div>