summaryrefslogtreecommitdiffstats
path: root/web/lib
diff options
context:
space:
mode:
authorLukas Fleischer <archlinux@cryptocrack.de>2012-07-14 01:57:19 +0200
committerLukas Fleischer <archlinux@cryptocrack.de>2012-07-15 22:48:32 +0200
commit03486c3b6feafb18f00b0e0c092a1bd4ac2f3903 (patch)
treef91bbdf64c725e35c7f08ac930e7fcd2a1f066c6 /web/lib
parent2425f963f8ad45292c217914b5fee1ed18104c26 (diff)
downloadaurweb-03486c3b6feafb18f00b0e0c092a1bd4ac2f3903.tar.xz
Use virtual paths for package details
Extend the routing front/back ends to allow for using "/package/$pkgname/" for individual packages. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'web/lib')
-rw-r--r--web/lib/pkgfuncs.inc.php7
-rw-r--r--web/lib/routing.inc.php18
2 files changed, 21 insertions, 4 deletions
diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php
index bdf8976..0610617 100644
--- a/web/lib/pkgfuncs.inc.php
+++ b/web/lib/pkgfuncs.inc.php
@@ -238,8 +238,7 @@ function add_package_comment($pkgid, $uid, $comment, $dbh=NULL) {
# Simply making these strings translatable won't work, users would be
# getting emails in the language that the user who posted the comment was in
$body =
- 'from ' . $AUR_LOCATION . '/' . get_uri('/packages/') . '?ID='
- . $pkgid . "\n"
+ 'from ' . $AUR_LOCATION . '/' . get_pkg_uri($row['Name']) . "\n"
. username_from_sid($_COOKIE['AURSID'], $dbh) . " wrote:\n\n"
. $comment
. "\n\n---\nIf you no longer wish to receive notifications about this package, please go the the above package page and click the UnNotify button.";
@@ -744,7 +743,7 @@ function pkg_flag ($atype, $ids, $action=true, $dbh=NULL) {
if (mysql_num_rows($result)) {
while ($row = mysql_fetch_assoc($result)) {
# construct email
- $body = "Your package " . $row['Name'] . " has been flagged out of date by " . $f_name . " [1]. You may view your package at:\n" . $AUR_LOCATION . "/" . get_uri('/packages/') . "?ID=" . $row['ID'] . "\n\n[1] - " . $AUR_LOCATION . "/" . get_uri('/accounts/') . "?Action=AccountInfo&ID=" . $f_uid;
+ $body = "Your package " . $row['Name'] . " has been flagged out of date by " . $f_name . " [1]. You may view your package at:\n" . $AUR_LOCATION . "/" . get_pkg_uri($row['Name']) . "\n\n[1] - " . $AUR_LOCATION . "/" . get_uri('/accounts/') . "?Action=AccountInfo&ID=" . $f_uid;
$body = wordwrap($body, 70);
$headers = "Reply-to: nobody@archlinux.org\nFrom:aur-notify@archlinux.org\nX-Mailer: PHP\nX-MimeOLE: Produced By AUR\n";
@mail($row['Email'], "AUR Out-of-date Notification for ".$row['Name'], $body, $headers);
@@ -813,7 +812,7 @@ function pkg_delete ($atype, $ids, $mergepkgid, $dbh=NULL) {
$body = "";
if ($mergepkgid) {
$body .= username_from_sid($_COOKIE['AURSID']) . " merged \"".$pkgname."\" into \"$mergepkgname\".\n\n";
- $body .= "You will no longer receive notifications about this package, please go to https://aur.archlinux.org/" . get_uri('/packages/') . "?ID=".$mergepkgid." and click the Notify button if you wish to recieve them again.";
+ $body .= "You will no longer receive notifications about this package, please go to https://aur.archlinux.org/" . get_pkg_uri($mergepkgname) . " and click the Notify button if you wish to recieve them again.";
} else {
$body .= username_from_sid($_COOKIE['AURSID']) . " deleted \"".$pkgname."\".\n\n";
$body .= "You will no longer receive notifications about this package.";
diff --git a/web/lib/routing.inc.php b/web/lib/routing.inc.php
index 0d940a2..e8a2deb 100644
--- a/web/lib/routing.inc.php
+++ b/web/lib/routing.inc.php
@@ -17,6 +17,8 @@ $ROUTES = array(
'/addvote' => 'addvote.php',
);
+$PKG_PATH = '/packages';
+
function get_route($path) {
global $ROUTES;
@@ -37,3 +39,19 @@ function get_uri($path) {
return get_route($path);
}
}
+
+function get_pkg_route() {
+ global $PKG_PATH;
+ return $PKG_PATH;
+}
+
+function get_pkg_uri($pkgname) {
+ global $USE_VIRTUAL_URLS;
+ global $PKG_PATH;
+
+ if ($USE_VIRTUAL_URLS) {
+ return $PKG_PATH . '/' . urlencode($pkgname) . '/';
+ } else {
+ return get_route($PKG_PATH) . '?N=' . urlencode($pkgname);
+ }
+}