summaryrefslogtreecommitdiffstats
path: root/web/lib
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@archlinux.org>2015-06-26 12:06:21 +0200
committerLukas Fleischer <lfleischer@archlinux.org>2015-06-27 13:04:03 +0200
commit4bc990f9c0a5da9e42f5ed58917cf051e1eacc0f (patch)
tree8b140080cc315652c893611f06a4140c98aa3008 /web/lib
parent3dbaee80b4fcc99cd236f76e60a1572377946123 (diff)
downloadaurweb-4bc990f9c0a5da9e42f5ed58917cf051e1eacc0f.tar.xz
Split out code to generate action links
Add (and use) two new helper functions html_account_link() and html_account_form() to generate the links in the package actions box. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'web/lib')
-rw-r--r--web/lib/aur.inc.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/web/lib/aur.inc.php b/web/lib/aur.inc.php
index 7f923d7..95f72ce 100644
--- a/web/lib/aur.inc.php
+++ b/web/lib/aur.inc.php
@@ -222,6 +222,43 @@ function html_format_maintainers($maintainer, $comaintainers) {
}
/**
+ * Format a link in the package actions box
+ *
+ * @param string $uri The link target
+ * @param string $desc The link label
+ *
+ * @return string The generated HTML code for the action link
+ */
+function html_action_link($uri, $desc) {
+ $code = '<a href="' . htmlspecialchars($uri, ENT_QUOTES) . '">';
+ $code .= htmlspecialchars($desc) . '</a>';
+
+ return $code;
+}
+
+/**
+ * Format a form in the package actions box
+ *
+ * @param string $uri The link target
+ * @param string $action The action name (passed as HTTP POST parameter)
+ * @param string $desc The link label
+ *
+ * @return string The generated HTML code for the action link
+ */
+function html_action_form($uri, $action, $desc) {
+ $code = '<form action="' . htmlspecialchars($uri, ENT_QUOTES) . '" ';
+ $code .= 'method="post">';
+ $code .= '<input type="hidden" name="token" value="';
+ $code .= htmlspecialchars($_COOKIE['AURSID'], ENT_QUOTES) . '" />';
+ $code .= '<input type="submit" class="button text-button" name="';
+ $code .= htmlspecialchars($action, ENT_QUOTES) . '" ';
+ $code .= 'value="' . htmlspecialchars($desc, ENT_QUOTES) . '" />';
+ $code .= '</form>';
+
+ return $code;
+}
+
+/**
* Determine the user's e-mail address in the database using a session ID
*
* @param string $sid User's session ID