diff options
author | Lukas Fleischer <archlinux@cryptocrack.de> | 2012-07-17 18:18:19 +0200 |
---|---|---|
committer | Lukas Fleischer <archlinux@cryptocrack.de> | 2012-07-17 22:19:07 +0200 |
commit | c349cb2feafa1c2009e8f41c039edc661ef6e0be (patch) | |
tree | c3e8b4deb58458472a7c6bfec0764f107558cae4 | |
parent | fc657af7f6c52aabbb40b1da922672c554f72438 (diff) |
Add virtual path support for package actions
This allows for using following URLs:
* /package/$pkg_name/flag: Flag a package out-of-date
* /package/$pkg_name/unflag: Unflag a package
* /package/$pkg_name/notify: Enable comment notifications
* /package/$pkg_name/unnotify: Disable comment notifications
* /package/$pkg_name/vote: Vote for the package
* /package/$pkg_name/unvote: Remove vote
Note that this code is very hackish and should be refactored once we
drop support for legacy URLs.
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
-rw-r--r-- | web/html/index.php | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/web/html/index.php b/web/html/index.php index de38178..0af3f2d 100644 --- a/web/html/index.php +++ b/web/html/index.php @@ -3,14 +3,44 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib'); include_once("config.inc.php"); include_once("routing.inc.php"); +include_once("aur.inc.php"); +include_once("pkgfuncs.inc.php"); $path = rtrim($_SERVER['PATH_INFO'], '/'); $tokens = explode('/', $path); -if (isset($tokens[1]) &&'/' . $tokens[1] == get_pkg_route()) { +if (isset($tokens[1]) && '/' . $tokens[1] == get_pkg_route()) { if (isset($tokens[2])) { unset($_GET['ID']); $_GET['N'] = $tokens[2]; + + if (isset($tokens[3])) { + /* TODO: Remove support for legacy URIs and move these + * actions to separate modules. */ + switch ($tokens[3]) { + case "vote": + $_POST['do_Vote'] = __('Vote'); + break; + case "unvote": + $_POST['do_UnVote'] = __('UnVote'); + break; + case "notify": + $_POST['do_Notify'] = __('Notify'); + break; + case "unnotify": + $_POST['do_UnNotify'] = __('UnNotify'); + break; + case "flag": + $_POST['do_Flag'] = __('Flag'); + break; + case "unflag": + $_POST['do_UnFlag'] = __('UnFlag'); + break; + } + + $_POST['token'] = $_COOKIE['AURSID']; + $_POST['IDs'] = array(pkgid_from_name($tokens[2]) => '1'); + } } include get_route('/' . $tokens[1]); |