Only show reply button if user is logged in.

This commit is contained in:
Dominik Picheta 2014-12-07 14:26:59 +00:00
commit 4ba9de012c
2 changed files with 12 additions and 6 deletions

View file

@ -479,6 +479,10 @@ proc login(c: var TForumData, name, pass: string): bool =
proc hasReplyBtn(c: var TForumData): bool =
result = c.req.pathInfo != "/donewthread" and c.req.pathInfo != "/doreply"
result = result and c.req.params["action"] != "reply"
# If the user is not logged in and there are no page numbers then we shouldn't
# generate the div.
let pages = ceil(c.totalPosts / PostsPerPage).int
result = result and (pages > 1 or c.loggedIn)
return c.threadId >= 0 and result
proc genActionMenu(c: var TForumData): string =

View file

@ -72,12 +72,14 @@
</div>
</div>
<div class="user-post">
#let replyUri = c.req.makeUri(c.req.path & "?action=reply#reply")
<a href="$replyUri">
<div>
<span class="reply">Reply</span>
</div>
</a>
#if c.loggedIn():
#let replyUri = c.req.makeUri(c.req.path & "?action=reply#reply")
<a href="$replyUri">
<div>
<span class="reply">Reply</span>
</div>
</a>
#end if
</div>
</div>
#end if