diff options
Diffstat (limited to 'models')
-rw-r--r-- | models/org.go | 11 | ||||
-rw-r--r-- | models/user.go | 4 |
2 files changed, 10 insertions, 5 deletions
diff --git a/models/org.go b/models/org.go index 6cc951bef0..fa26b59e66 100644 --- a/models/org.go +++ b/models/org.go @@ -274,10 +274,15 @@ func GetOwnedOrgsByUserIDDesc(userID int64, desc string) ([]*User, error) { return getOwnedOrgsByUserID(sess.Desc(desc), userID) } -// GetOrgUsersByUserId returns all organization-user relations by user ID. -func GetOrgUsersByUserId(uid int64) ([]*OrgUser, error) { +// GetOrgUsersByUserID returns all organization-user relations by user ID. +func GetOrgUsersByUserID(uid int64, all bool) ([]*OrgUser, error) { ous := make([]*OrgUser, 0, 10) - err := x.Where("uid=?", uid).Find(&ous) + sess := x.Where("uid=?", uid) + if !all { + // Only show public organizations + sess.And("is_public=?", true) + } + err := sess.Find(&ous) return ous, err } diff --git a/models/user.go b/models/user.go index 71729a4e3e..ebdc3c47fe 100644 --- a/models/user.go +++ b/models/user.go @@ -376,8 +376,8 @@ func (u *User) GetOwnedOrganizations() (err error) { } // GetOrganizations returns all organizations that user belongs to. -func (u *User) GetOrganizations() error { - ous, err := GetOrgUsersByUserId(u.Id) +func (u *User) GetOrganizations(all bool) error { + ous, err := GetOrgUsersByUserID(u.Id, all) if err != nil { return err } |