summaryrefslogtreecommitdiffstats
path: root/web/lib/aur.inc.php
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@archlinux.org>2015-06-14 09:49:17 +0200
committerLukas Fleischer <lfleischer@archlinux.org>2015-06-14 17:58:56 +0200
commita2f79eb2e1ff74e7d2403bf194a52b41cc7f3c0c (patch)
treee3ee9cea28d8a8a8b28eadef3b86e314690b2b81 /web/lib/aur.inc.php
parent19ee268935de2befc68fc245555cfc5ba7951062 (diff)
downloadaurweb-a2f79eb2e1ff74e7d2403bf194a52b41cc7f3c0c.tar.xz
Refactor code for printing account links
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'web/lib/aur.inc.php')
-rw-r--r--web/lib/aur.inc.php13
1 files changed, 11 insertions, 2 deletions
diff --git a/web/lib/aur.inc.php b/web/lib/aur.inc.php
index c4a1705..2d06fc8 100644
--- a/web/lib/aur.inc.php
+++ b/web/lib/aur.inc.php
@@ -181,10 +181,19 @@ function username_from_sid($sid="") {
*
* @param string $username The user name to format
*
- * @return void
+ * @return string The generated HTML code for the account link
*/
function html_format_username($username) {
- return $username ? htmlspecialchars($username) : __("None");
+ $username_fmt = $username ? htmlspecialchars($username, ENT_QUOTES) : __("None");
+
+ if ($username && $_COOKIE["AURSID"]) {
+ $link = '<a href="' . get_uri('/account/') . $username_fmt;
+ $link .= '" title="' . __('View account information for %s', $username_fmt);
+ $link .= '">' . $username_fmt . '</a>';
+ return $link;
+ } else {
+ return $username_fmt;
+ }
}
/**