@@ -25,13 +25,6 @@ import (
2525 "xorm.io/xorm"
2626)
2727
28- // ________ .__ __ .__
29- // \_____ \_______ _________ ____ |__|____________ _/ |_|__| ____ ____
30- // / | \_ __ \/ ___\__ \ / \| \___ /\__ \\ __\ |/ _ \ / \
31- // / | \ | \/ /_/ > __ \| | \ |/ / / __ \| | | ( <_> ) | \
32- // \_______ /__| \___ (____ /___| /__/_____ \(____ /__| |__|\____/|___| /
33- // \/ /_____/ \/ \/ \/ \/ \/
34-
3528// ErrOrgNotExist represents a "OrgNotExist" kind of error.
3629type ErrOrgNotExist struct {
3730 ID int64
@@ -465,42 +458,6 @@ func GetUsersWhoCanCreateOrgRepo(ctx context.Context, orgID int64) (map[int64]*u
465458 And ("team_user.org_id = ?" , orgID ).Find (& users )
466459}
467460
468- // SearchOrganizationsOptions options to filter organizations
469- type SearchOrganizationsOptions struct {
470- db.ListOptions
471- All bool
472- }
473-
474- // FindOrgOptions finds orgs options
475- type FindOrgOptions struct {
476- db.ListOptions
477- UserID int64
478- IncludePrivate bool
479- }
480-
481- func queryUserOrgIDs (userID int64 , includePrivate bool ) * builder.Builder {
482- cond := builder.Eq {"uid" : userID }
483- if ! includePrivate {
484- cond ["is_public" ] = true
485- }
486- return builder .Select ("org_id" ).From ("org_user" ).Where (cond )
487- }
488-
489- func (opts FindOrgOptions ) ToConds () builder.Cond {
490- var cond builder.Cond = builder.Eq {"`user`.`type`" : user_model .UserTypeOrganization }
491- if opts .UserID > 0 {
492- cond = cond .And (builder .In ("`user`.`id`" , queryUserOrgIDs (opts .UserID , opts .IncludePrivate )))
493- }
494- if ! opts .IncludePrivate {
495- cond = cond .And (builder.Eq {"`user`.visibility" : structs .VisibleTypePublic })
496- }
497- return cond
498- }
499-
500- func (opts FindOrgOptions ) ToOrders () string {
501- return "`user`.name ASC"
502- }
503-
504461// HasOrgOrUserVisible tells if the given user can see the given org or user
505462func HasOrgOrUserVisible (ctx context.Context , orgOrUser , user * user_model.User ) bool {
506463 // If user is nil, it's an anonymous user/request.
@@ -533,20 +490,6 @@ func HasOrgsVisible(ctx context.Context, orgs []*Organization, user *user_model.
533490 return false
534491}
535492
536- // GetOrgsCanCreateRepoByUserID returns a list of organizations where given user ID
537- // are allowed to create repos.
538- func GetOrgsCanCreateRepoByUserID (ctx context.Context , userID int64 ) ([]* Organization , error ) {
539- orgs := make ([]* Organization , 0 , 10 )
540-
541- return orgs , db .GetEngine (ctx ).Where (builder .In ("id" , builder .Select ("`user`.id" ).From ("`user`" ).
542- Join ("INNER" , "`team_user`" , "`team_user`.org_id = `user`.id" ).
543- Join ("INNER" , "`team`" , "`team`.id = `team_user`.team_id" ).
544- Where (builder.Eq {"`team_user`.uid" : userID }).
545- And (builder.Eq {"`team`.authorize" : perm .AccessModeOwner }.Or (builder.Eq {"`team`.can_create_org_repo" : true })))).
546- Asc ("`user`.name" ).
547- Find (& orgs )
548- }
549-
550493// GetOrgUsersByOrgID returns all organization-user relations by organization ID.
551494func GetOrgUsersByOrgID (ctx context.Context , opts * FindOrgMembersOpts ) ([]* OrgUser , error ) {
552495 sess := db .GetEngine (ctx ).Where ("org_id=?" , opts .OrgID )
0 commit comments