aboutsummaryrefslogtreecommitdiff
path: root/models
diff options
context:
space:
mode:
authorFlorian Kaiser <florian.kaiser@fnkr.net>2016-01-30 21:51:11 +0000
committerFlorian Kaiser <florian.kaiser@fnkr.net>2016-01-30 21:53:58 +0000
commit295de51b9958703fe1b8da49aa1c13421b318190 (patch)
tree7361d7392659a8e3893a93be33f538a084ab71b2 /models
parent6e03f6161777b38c0c185793e8f0294851796e46 (diff)
Show all orgs on user profile, except the private one's
Diffstat (limited to 'models')
-rw-r--r--models/org.go22
1 files changed, 21 insertions, 1 deletions
diff --git a/models/org.go b/models/org.go
index b8836c34..3de89e4b 100644
--- a/models/org.go
+++ b/models/org.go
@@ -253,6 +253,26 @@ func IsPublicMembership(orgId, uid int64) bool {
return has
}
+func getPublicOrgsByUserID(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).
+ 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) {
+ sess := x.NewSession()
+ return getPublicOrgsByUserID(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) {
+ sess := x.NewSession()
+ return getPublicOrgsByUserID(sess.Desc(desc), userID)
+}
+
func getOwnedOrgsByUserID(sess *xorm.Session, userID int64) ([]*User, error) {
orgs := make([]*User, 0, 10)
return orgs, sess.Where("`org_user`.uid=?", userID).And("`org_user`.is_owner=?", true).
@@ -266,7 +286,7 @@ func GetOwnedOrgsByUserID(userID int64) ([]*User, error) {
}
// GetOwnedOrganizationsByUserIDDesc returns a list of organizations are owned by
-// given user ID and descring order by given condition.
+// given user ID, ordered descending by the given condition.
func GetOwnedOrgsByUserIDDesc(userID int64, desc string) ([]*User, error) {
sess := x.NewSession()
return getOwnedOrgsByUserID(sess.Desc(desc), userID)