From 98b6ba94795b27b098276b30ca9fd61b28b2b110 Mon Sep 17 00:00:00 2001 From: canyonknight Date: Wed, 12 Sep 2012 18:21:22 -0400 Subject: Use URL rewriting for user info page Navigation to the "AccountInfo" page should only require a user to know the username of the account they are looking for. Update all AUR links that use the user info page to reflect the new URL. Before: AUR_URL/account/?Action=AccountInfo&U=userfoo After: AUR_URL/account/userfoo Signed-off-by: canyonknight Signed-off-by: Lukas Fleischer --- web/html/index.php | 6 ++++++ web/html/voters.php | 2 +- web/lib/acctfuncs.inc.php | 2 +- web/lib/pkgfuncs.inc.php | 2 +- web/lib/routing.inc.php | 17 +++++++++++++++++ web/template/pkg_comments.php | 2 +- 6 files changed, 27 insertions(+), 4 deletions(-) (limited to 'web') diff --git a/web/html/index.php b/web/html/index.php index 7c4eb47..e6f3771 100644 --- a/web/html/index.php +++ b/web/html/index.php @@ -47,6 +47,12 @@ if (isset($tokens[1]) && '/' . $tokens[1] == get_pkg_route()) { } } + include get_route('/' . $tokens[1]); +} elseif (isset($tokens[1]) && '/' . $tokens[1] == get_user_route()) { + if (isset($tokens[2])) { + $_REQUEST['U'] = $tokens[2]; + $_REQUEST['Action'] = "AccountInfo"; + } include get_route('/' . $tokens[1]); } elseif (get_route($path) !== NULL) { include get_route($path); diff --git a/web/html/voters.php b/web/html/voters.php index 0ec77ec..41c9d6f 100644 --- a/web/html/voters.php +++ b/web/html/voters.php @@ -19,7 +19,7 @@ if ($atype == 'Trusted User' || $atype== 'Developer'):
    -
  • +
diff --git a/web/lib/acctfuncs.inc.php b/web/lib/acctfuncs.inc.php index e7dcb10..7471d06 100644 --- a/web/lib/acctfuncs.inc.php +++ b/web/lib/acctfuncs.inc.php @@ -827,7 +827,7 @@ function voter_list($voteid, $dbh=NULL) { $result = $dbh->query($q); if ($result) { while ($row = $result->fetch(PDO::FETCH_ASSOC)) { - $whovoted.= ''.$row['Username'].' '; + $whovoted.= ''.$row['Username'].' '; } } return $whovoted; diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php index 6cdab0f..b2daf0e 100644 --- a/web/lib/pkgfuncs.inc.php +++ b/web/lib/pkgfuncs.inc.php @@ -764,7 +764,7 @@ function pkg_flag ($atype, $ids, $action=true, $dbh=NULL) { if ($result) { while ($row = $result->fetch(PDO::FETCH_ASSOC)) { # 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_pkg_uri($row['Name']) . "\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_user_uri($f_name); $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); diff --git a/web/lib/routing.inc.php b/web/lib/routing.inc.php index 4ca1150..dfd6942 100644 --- a/web/lib/routing.inc.php +++ b/web/lib/routing.inc.php @@ -18,6 +18,7 @@ $ROUTES = array( ); $PKG_PATH = '/packages'; +$USER_PATH = '/account'; function get_route($path) { global $ROUTES; @@ -56,3 +57,19 @@ function get_pkg_uri($pkgname) { return get_route($PKG_PATH) . '?N=' . urlencode($pkgname); } } + +function get_user_route() { + global $USER_PATH; + return $USER_PATH; +} + +function get_user_uri($username) { + global $USE_VIRTUAL_URLS; + global $USER_PATH; + + if ($USE_VIRTUAL_URLS) { + return $USER_PATH . '/' . urlencode($username) . '/'; + } else { + return get_route($USER_PATH) . '?U=' . urlencode($username); + } +} diff --git a/web/template/pkg_comments.php b/web/template/pkg_comments.php index 46c1ef3..d0bd4f8 100644 --- a/web/template/pkg_comments.php +++ b/web/template/pkg_comments.php @@ -11,7 +11,7 @@ $pkgname = $row['Name']; {$row['UserName']}"; + $row['UserName'] = "{$row['UserName']}"; endif; ?>

-- cgit v1.2.3-70-g09d2