File tree 1 file changed +6
-2
lines changed
1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -454,18 +454,22 @@ type FindOrgOptions struct {
454
454
func (opts FindOrgOptions ) toConds () builder.Cond {
455
455
var cond = builder .NewCond ()
456
456
if opts .UserID > 0 {
457
- cond = cond .And (builder.Eq { "`org_user`.uid" : opts .UserID } )
457
+ cond = cond .And (builder .In ( "`user`.`id`" , queryUserOrgIDs ( opts .UserID )) )
458
458
}
459
459
if ! opts .IncludePrivate {
460
460
cond = cond .And (builder.Eq {"`user`.visibility" : structs .VisibleTypePublic })
461
+ } else {
462
+ cond = cond .And (builder.Eq {"`user`.visibility" : structs .VisibleTypePrivate }.Or (
463
+ builder.Eq {"`user`.visibility" : structs .VisibleTypeLimited },
464
+ ))
461
465
}
462
466
return cond
463
467
}
464
468
465
469
// FindOrgs returns a list of organizations according given conditions
466
470
func FindOrgs (opts FindOrgOptions ) ([]* User , error ) {
467
471
orgs := make ([]* User , 0 , 10 )
468
- sess := x .Join ( "INNER" , "`org_user`" , "`org_user`.org_id=`user`.id" ).
472
+ sess := x .
469
473
Where (opts .toConds ()).
470
474
Asc ("`user`.name" )
471
475
if opts .Page > 0 && opts .PageSize > 0 {
You can’t perform that action at this time.
0 commit comments