Username search for admin comment list, inputs for userid & username search in said comment list (#1713)
* Update comments.go * Update commentlist.jet.html * Update comments.go When you search a username and you have a userid in the url, the conditions string doesn't have "AND" in it. I made the username search a priority and if there is not username provided, it falls back to userid in url.
Cette révision appartient à :
Parent
98af64a4e2
révision
ca271e2ac6
|
@ -21,6 +21,7 @@ func CommentsListPanel(c *gin.Context) {
|
||||||
pagenum := 1
|
pagenum := 1
|
||||||
offset := 100
|
offset := 100
|
||||||
userid := c.Query("userid")
|
userid := c.Query("userid")
|
||||||
|
username := c.Query("user")
|
||||||
var err error
|
var err error
|
||||||
messages := msg.GetMessages(c)
|
messages := msg.GetMessages(c)
|
||||||
deleted := c.Request.URL.Query()["deleted"]
|
deleted := c.Request.URL.Query()["deleted"]
|
||||||
|
@ -36,14 +37,26 @@ func CommentsListPanel(c *gin.Context) {
|
||||||
}
|
}
|
||||||
var conditions string
|
var conditions string
|
||||||
var values []interface{}
|
var values []interface{}
|
||||||
if userid != "" {
|
searchForm := templates.NewSearchForm(c)
|
||||||
conditions = "user_id = ?"
|
// if there is a username in url
|
||||||
values = append(values, userid)
|
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...)
|
comments, nbComments := comments.FindAll(offset, (pagenum-1)*offset, conditions, values...)
|
||||||
nav := templates.Navigation{nbComments, offset, pagenum, "mod/comments/p"}
|
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
|
// CommentDeleteModPanel : Controller for deleting a comment
|
||||||
|
|
|
@ -2,7 +2,22 @@
|
||||||
{{block title()}}{{ T("comments_list") }}{{end}}
|
{{block title()}}{{ T("comments_list") }}{{end}}
|
||||||
{{block content_body()}}
|
{{block content_body()}}
|
||||||
<div class="results box">
|
<div class="results box">
|
||||||
<h1>{{ T("comments_list") }}</h1>
|
<h1 style="margin-bottom: 0;">{{ T("comments_list") }}</h1>
|
||||||
|
|
||||||
|
<form action="/mod/comments">
|
||||||
|
<table style="margin-left: 5px; max-width: 30%; min-width: 100px;text-align:left;">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>{{T("user_id")}}</td><td><input type="text" name="userid" class="form-input" placeholder="{{T("user_id")}}" value="{{if Search.UserID > 0}}{{Search.UserID}}{{end}}"><td/>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{{T("username")}}</td><td><input type="text" name="username" class="form-input" placeholder="{{T("username")}}" value="{{Search.UserName}}"><td/>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<button style="display: none;"></button>
|
||||||
|
</form>
|
||||||
|
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead class="torrent-info">
|
<thead class="torrent-info">
|
||||||
<tr>
|
<tr>
|
||||||
|
|
Référencer dans un nouveau ticket