[aur-dev] [PATCH 0/2] Support canonical links to packages/accounts
Resubmission of two patches I submitted to aur-dev about one and a half years ago. Not sure how I managed not to merge these into master :) Lukas Fleischer (2): Support canonical links to packages Support canonical links to accounts web/html/account.php | 6 +++++- web/html/packages.php | 14 ++++++++++++++ web/template/pkg_comments.php | 2 +- web/template/pkg_details.php | 8 +++++++- 4 files changed, 27 insertions(+), 3 deletions(-) -- 1.7.9.4
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> --- web/html/packages.php | 14 ++++++++++++++ web/template/pkg_comments.php | 2 +- web/template/pkg_details.php | 8 +++++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/web/html/packages.php b/web/html/packages.php index dc06c7e..8f3b143 100644 --- a/web/html/packages.php +++ b/web/html/packages.php @@ -10,6 +10,8 @@ check_sid(); # see if they're still logged in # Set the title to the current query if required if (isset($_GET['ID']) && ($pkgname = pkgname_from_id($_GET['ID']))) { $title = $pkgname; +} else if (isset($_GET['N'])) { + $title = $pkgname = $_GET['N']; } else if (!empty($_GET['K'])) { $title = __("Search Criteria") . ": " . $_GET['K']; } else { @@ -98,6 +100,18 @@ if (isset($_GET['ID'])) { 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 { if (!isset($_GET['K']) && !isset($_GET['SB'])) { $_GET['SB'] = 'v'; diff --git a/web/template/pkg_comments.php b/web/template/pkg_comments.php index aed9ca8..ac6e1de 100644 --- a/web/template/pkg_comments.php +++ b/web/template/pkg_comments.php @@ -36,7 +36,7 @@ while (list($indx, $carr) = each($comments)) { ?> </div> <?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'])) { echo '<div class="pgbox">'; echo '<a href="'. $_SERVER['REQUEST_URI'] . '&comments=all">'. __('Show all %s comments', $count) . '</a>'; diff --git a/web/template/pkg_details.php b/web/template/pkg_details.php index 046f836..230cc2c 100644 --- a/web/template/pkg_details.php +++ b/web/template/pkg_details.php @@ -2,7 +2,13 @@ $atype = account_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 ($atype == "Developer" or $atype == "Trusted User")) { -- 1.7.9.4
Addresses FS#9582 and FS#21600. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- web/html/account.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/web/html/account.php b/web/html/account.php index 339316b..f17ba48 100644 --- a/web/html/account.php +++ b/web/html/account.php @@ -75,7 +75,11 @@ if (isset($_COOKIE["AURSID"])) { $q = "SELECT Users.*, AccountTypes.AccountType "; $q.= "FROM Users, AccountTypes "; $q.= "WHERE AccountTypes.ID = Users.AccountTypeID "; - $q.= "AND Users.ID = ".intval(in_request("ID")); + if (isset($_REQUEST["ID"])) { + $q.= "AND Users.ID = ".intval(in_request("ID")); + } else { + $q.= "AND Users.Username = '".db_escape_string(in_request("U")) . "'"; + } $result = db_query($q, $dbh); if (!mysql_num_rows($result)) { print __("Could not retrieve information for the specified user."); -- 1.7.9.4
participants (1)
-
Lukas Fleischer