diff --git a/controllers/moderator/comments.go b/controllers/moderator/comments.go index 8208182c..26952c8e 100644 --- a/controllers/moderator/comments.go +++ b/controllers/moderator/comments.go @@ -21,6 +21,7 @@ func CommentsListPanel(c *gin.Context) { pagenum := 1 offset := 100 userid := c.Query("userid") + username := c.Query("user") var err error messages := msg.GetMessages(c) deleted := c.Request.URL.Query()["deleted"] @@ -36,14 +37,26 @@ func CommentsListPanel(c *gin.Context) { } var conditions string var values []interface{} - if userid != "" { - conditions = "user_id = ?" - values = append(values, userid) + searchForm := templates.NewSearchForm(c) + // if there is a username in url + if username != "" { + conditions = "user = ?" + values = append(values, username) + searchForm.UserName = username + // else we look if there is a userid + } else if userid != "" { + id, err := strconv.Atoi(userid) + if err == nil { + conditions = "user_id = ?" + values = append(values, id) + searchForm.UserID = uint32(id) + } } + comments, nbComments := comments.FindAll(offset, (pagenum-1)*offset, conditions, values...) nav := templates.Navigation{nbComments, offset, pagenum, "mod/comments/p"} - templates.ModelList(c, "admin/commentlist.jet.html", comments, nav, templates.NewSearchForm(c)) + templates.ModelList(c, "admin/commentlist.jet.html", comments, nav, searchForm) } // CommentDeleteModPanel : Controller for deleting a comment diff --git a/templates/admin/commentlist.jet.html b/templates/admin/commentlist.jet.html index 2b195b1f..11da0aff 100644 --- a/templates/admin/commentlist.jet.html +++ b/templates/admin/commentlist.jet.html @@ -2,7 +2,22 @@ {{block title()}}{{ T("comments_list") }}{{end}} {{block content_body()}}
-

{{ T("comments_list") }}

+

{{ T("comments_list") }}

+ +
+ + + + + + + +
{{T("user_id")}} +
{{T("username")}} +
+ +
+