summaryrefslogtreecommitdiffstats
path: root/routers/user/profile.go
diff options
context:
space:
mode:
authorBo-Yi Wu <appleboy.tw@gmail.com>2017-02-08 17:35:59 +0800
committerLunny Xiao <xiaolunwen@gmail.com>2017-02-08 17:35:59 +0800
commita195c3fabeed4136b326ab641460fc30d6feaf01 (patch)
tree4f87f220ec2efc7511c15be26f4e4320f9e3a069 /routers/user/profile.go
parent181c8d9c99f36439f70258dcc17ff8c0c76ad416 (diff)
downloadgitea-a195c3fabeed4136b326ab641460fc30d6feaf01.tar.gz
gitea-a195c3fabeed4136b326ab641460fc30d6feaf01.zip
fix: Admin can also search private user repository. (#869)
Diffstat (limited to 'routers/user/profile.go')
-rw-r--r--routers/user/profile.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/routers/user/profile.go b/routers/user/profile.go
index 1f5acbec0d..cca4391a70 100644
--- a/routers/user/profile.go
+++ b/routers/user/profile.go
@@ -130,6 +130,8 @@ func Profile(ctx *context.Context) {
err error
orderBy string
)
+
+ ctx.Data["SortType"] = ctx.Query("sort")
switch ctx.Query("sort") {
case "newest":
orderBy = "created_unix DESC"
@@ -144,10 +146,17 @@ func Profile(ctx *context.Context) {
case "alphabetically":
orderBy = "name ASC"
default:
+ ctx.Data["SortType"] = "recentupdate"
orderBy = "updated_unix DESC"
}
+ // set default sort value if sort is empty.
+ if ctx.Query("sort") == "" {
+ ctx.Data["SortType"] = "recentupdate"
+ }
+
keyword := ctx.Query("q")
+ ctx.Data["Keyword"] = keyword
if len(keyword) == 0 {
var total int
repos, err = models.GetUserRepositories(ctxUser.ID, showPrivate, page, setting.UI.User.RepoPagingNum, orderBy)
@@ -175,7 +184,7 @@ func Profile(ctx *context.Context) {
Keyword: keyword,
OwnerID: ctxUser.ID,
OrderBy: orderBy,
- Private: ctx.IsSigned && ctx.User.ID == ctxUser.ID,
+ Private: showPrivate,
Page: page,
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["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)