mirror of
https://github.com/go-gitea/gitea.git
synced 2024-12-04 14:46:57 -05:00
fix: Admin can also search private user repository. (#869)
This commit is contained in:
parent
181c8d9c99
commit
a195c3fabe
@ -130,6 +130,8 @@ func Profile(ctx *context.Context) {
|
|||||||
err error
|
err error
|
||||||
orderBy string
|
orderBy string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ctx.Data["SortType"] = ctx.Query("sort")
|
||||||
switch ctx.Query("sort") {
|
switch ctx.Query("sort") {
|
||||||
case "newest":
|
case "newest":
|
||||||
orderBy = "created_unix DESC"
|
orderBy = "created_unix DESC"
|
||||||
@ -144,10 +146,17 @@ func Profile(ctx *context.Context) {
|
|||||||
case "alphabetically":
|
case "alphabetically":
|
||||||
orderBy = "name ASC"
|
orderBy = "name ASC"
|
||||||
default:
|
default:
|
||||||
|
ctx.Data["SortType"] = "recentupdate"
|
||||||
orderBy = "updated_unix DESC"
|
orderBy = "updated_unix DESC"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set default sort value if sort is empty.
|
||||||
|
if ctx.Query("sort") == "" {
|
||||||
|
ctx.Data["SortType"] = "recentupdate"
|
||||||
|
}
|
||||||
|
|
||||||
keyword := ctx.Query("q")
|
keyword := ctx.Query("q")
|
||||||
|
ctx.Data["Keyword"] = keyword
|
||||||
if len(keyword) == 0 {
|
if len(keyword) == 0 {
|
||||||
var total int
|
var total int
|
||||||
repos, err = models.GetUserRepositories(ctxUser.ID, showPrivate, page, setting.UI.User.RepoPagingNum, orderBy)
|
repos, err = models.GetUserRepositories(ctxUser.ID, showPrivate, page, setting.UI.User.RepoPagingNum, orderBy)
|
||||||
@ -175,7 +184,7 @@ func Profile(ctx *context.Context) {
|
|||||||
Keyword: keyword,
|
Keyword: keyword,
|
||||||
OwnerID: ctxUser.ID,
|
OwnerID: ctxUser.ID,
|
||||||
OrderBy: orderBy,
|
OrderBy: orderBy,
|
||||||
Private: ctx.IsSigned && ctx.User.ID == ctxUser.ID,
|
Private: showPrivate,
|
||||||
Page: page,
|
Page: page,
|
||||||
PageSize: setting.UI.User.RepoPagingNum,
|
PageSize: setting.UI.User.RepoPagingNum,
|
||||||
})
|
})
|
||||||
@ -188,15 +197,6 @@ func Profile(ctx *context.Context) {
|
|||||||
ctx.Data["Page"] = paginater.New(int(count), setting.UI.User.RepoPagingNum, page, 5)
|
ctx.Data["Page"] = paginater.New(int(count), setting.UI.User.RepoPagingNum, page, 5)
|
||||||
ctx.Data["Total"] = count
|
ctx.Data["Total"] = count
|
||||||
}
|
}
|
||||||
|
|
||||||
// set default sort value.
|
|
||||||
if ctx.Query("sort") == "" {
|
|
||||||
ctx.Data["SortType"] = "recentupdate"
|
|
||||||
} else {
|
|
||||||
ctx.Data["SortType"] = ctx.Query("sort")
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.Data["Keyword"] = keyword
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.HTML(200, tplProfile)
|
ctx.HTML(200, tplProfile)
|
||||||
|
Loading…
Reference in New Issue
Block a user