diff options
author | Unknwon <u@gogs.io> | 2016-02-14 20:34:53 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2016-02-14 20:34:53 -0500 |
commit | d8631b616e41a0dc05db7982bf6b5a569307f622 (patch) | |
tree | 3e4a05a4a09194ca73e4e3e3597bebe05d9a0875 /models/org.go | |
parent | aa5e837c65aa8d9c162e829a46718d7f7129ef6a (diff) | |
parent | 40f9d4f920c481db8dc8bf1a5b29c7005ea06f29 (diff) | |
download | gitea-d8631b616e41a0dc05db7982bf6b5a569307f622.tar.gz gitea-d8631b616e41a0dc05db7982bf6b5a569307f622.zip |
Merge pull request #2578 from exmex/develop
Admins and user itself sees private org relations on profile
Diffstat (limited to 'models/org.go')
-rw-r--r-- | models/org.go | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/models/org.go b/models/org.go index 020284d8d2..8b773b2d04 100644 --- a/models/org.go +++ b/models/org.go @@ -254,24 +254,27 @@ func IsPublicMembership(orgId, uid int64) bool { return has } -func getPublicOrgsByUserID(sess *xorm.Session, userID int64) ([]*User, error) { +func getOrgsByUserID(sess *xorm.Session, userID int64) ([]*User, error) { orgs := make([]*User, 0, 10) - return orgs, sess.Where("`org_user`.uid=?", userID).And("`org_user`.is_public=?", true). + return orgs, sess.Where("`org_user`.uid=?", userID). Join("INNER", "`org_user`", "`org_user`.org_id=`user`.id").Find(&orgs) } // GetPublicOrgsByUserID returns a list of organizations that the given user ID // has joined publicly. -func GetPublicOrgsByUserID(userID int64) ([]*User, error) { +func GetOrgsByUserID(userID int64) ([]*User, error) { sess := x.NewSession() - return getPublicOrgsByUserID(sess, userID) + return getOrgsByUserID(sess, userID) } // GetPublicOrgsByUserID returns a list of organizations that the given user ID // has joined publicly, ordered descending by the given condition. -func GetPublicOrgsByUserIDDesc(userID int64, desc string) ([]*User, error) { +func GetOrgsByUserIDDesc(userID int64, desc string, all bool) ([]*User, error) { sess := x.NewSession() - return getPublicOrgsByUserID(sess.Desc(desc), userID) + if !all { + sess.And("`org_user`.is_public=?", true) + } + return getOrgsByUserID(sess.Desc(desc), userID) } func getOwnedOrgsByUserID(sess *xorm.Session, userID int64) ([]*User, error) { |