@@ -440,24 +440,6 @@ func getUsersWhoCanCreateOrgRepo(e db.Engine, orgID int64) ([]*User, error) {
440
440
And ("team_user.org_id = ?" , orgID ).Asc ("`user`.name" ).Find (& users )
441
441
}
442
442
443
- func getOrgsByUserID (e db.Engine , userID int64 , showAll bool ) ([]* Organization , error ) {
444
- orgs := make ([]* Organization , 0 , 10 )
445
- sess := e .Where ("`org_user`.uid=?" , userID )
446
- if ! showAll {
447
- sess = sess .And ("`org_user`.is_public=?" , true )
448
- }
449
- return orgs , sess .
450
- Join ("INNER" , "`org_user`" , "`org_user`.org_id=`user`.id" ).
451
- Asc ("`user`.name" ).
452
- Find (& orgs )
453
- }
454
-
455
- // GetOrgsByUserID returns a list of organizations that the given user ID
456
- // has joined.
457
- func GetOrgsByUserID (userID int64 , showAll bool ) ([]* Organization , error ) {
458
- return getOrgsByUserID (db .GetEngine (db .DefaultContext ), userID , showAll )
459
- }
460
-
461
443
// MinimalOrg represents a simple orgnization with only needed columns
462
444
type MinimalOrg = Organization
463
445
@@ -526,17 +508,18 @@ type FindOrgOptions struct {
526
508
IncludePrivate bool
527
509
}
528
510
529
- func queryUserOrgIDs (userID int64 ) * builder.Builder {
530
- return builder .Select ("org_id" ).From ("org_user" ).
531
- Where (builder.Eq {
532
- "uid" : userID ,
533
- })
511
+ func queryUserOrgIDs (userID int64 , includePrivate bool ) * builder.Builder {
512
+ var cond = builder.Eq {"uid" : userID }
513
+ if ! includePrivate {
514
+ cond ["is_public" ] = true
515
+ }
516
+ return builder .Select ("org_id" ).From ("org_user" ).Where (cond )
534
517
}
535
518
536
519
func (opts FindOrgOptions ) toConds () builder.Cond {
537
520
var cond = builder .NewCond ()
538
521
if opts .UserID > 0 {
539
- cond = cond .And (builder .In ("`user`.`id`" , queryUserOrgIDs (opts .UserID )))
522
+ cond = cond .And (builder .In ("`user`.`id`" , queryUserOrgIDs (opts .UserID , opts . IncludePrivate )))
540
523
}
541
524
if ! opts .IncludePrivate {
542
525
cond = cond .And (builder.Eq {"`user`.visibility" : structs .VisibleTypePublic })
0 commit comments