Support canonical links to packages

This is more user-friendly than supporting package IDs only and can be
used as a basis to support direct links to AUR packages in places where
links are computer-produced (e.g. Wiki templates).

Addresses FS#21600 and FS#28839.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
This commit is contained in:
Lukas Fleischer 2012-03-22 09:38:18 +01:00
parent 132856a938
commit cf2f667512
3 changed files with 22 additions and 2 deletions

View file

@ -10,6 +10,8 @@ check_sid(); # see if they're still logged in
# Set the title to the current query if required # Set the title to the current query if required
if (isset($_GET['ID']) && ($pkgname = pkgname_from_id($_GET['ID']))) { if (isset($_GET['ID']) && ($pkgname = pkgname_from_id($_GET['ID']))) {
$title = $pkgname; $title = $pkgname;
} else if (isset($_GET['N'])) {
$title = $pkgname = $_GET['N'];
} else if (!empty($_GET['K'])) { } else if (!empty($_GET['K'])) {
$title = __("Search Criteria") . ": " . $_GET['K']; $title = __("Search Criteria") . ": " . $_GET['K'];
} else { } else {
@ -98,6 +100,18 @@ if (isset($_GET['ID'])) {
package_details($_GET['ID'], null); package_details($_GET['ID'], null);
} }
} }
} else if (isset($_GET['N'])) {
include('pkg_search_form.php');
if (!$pkgid = pkgid_from_name($_GET['N'])) {
print __("Error trying to retrieve package details.")."<br />\n";
} else {
if (isset($_COOKIE["AURSID"])) {
package_details($pkgid, $_COOKIE["AURSID"]);
}
else {
package_details($pkgid, null);
}
}
} else { } else {
if (!isset($_GET['K']) && !isset($_GET['SB'])) { if (!isset($_GET['K']) && !isset($_GET['SB'])) {
$_GET['SB'] = 'v'; $_GET['SB'] = 'v';

View file

@ -36,7 +36,7 @@ while (list($indx, $carr) = each($comments)) { ?>
</div> </div>
<?php <?php
$count = package_comments_count($_GET['ID']); $count = package_comments_count(isset($_GET['ID']) ? $_GET['ID'] : pkgid_from_name($_GET['N']));
if ($count > 10 && !isset($_GET['comments'])) { if ($count > 10 && !isset($_GET['comments'])) {
echo '<div class="pgbox">'; echo '<div class="pgbox">';
echo '<a href="'. $_SERVER['REQUEST_URI'] . '&comments=all">'. __('Show all %s comments', $count) . '</a>'; echo '<a href="'. $_SERVER['REQUEST_URI'] . '&comments=all">'. __('Show all %s comments', $count) . '</a>';

View file

@ -2,7 +2,13 @@
$atype = account_from_sid($SID); $atype = account_from_sid($SID);
$uid = uid_from_sid($SID); $uid = uid_from_sid($SID);
$pkgid = intval($_REQUEST['ID']); if (isset($_REQUEST['ID'])) {
$pkgid = intval($_REQUEST['ID']);
}
else {
$pkgid = pkgid_from_name($_REQUEST['N']);
}
if ($uid == $row["MaintainerUID"] or if ($uid == $row["MaintainerUID"] or
($atype == "Developer" or $atype == "Trusted User")) { ($atype == "Developer" or $atype == "Trusted User")) {