Documentation ¶
Index ¶
- Constants
- func AddOrgUser(orgID, uid int64) error
- func AddTeamRepo(ctx context.Context, orgID, teamID, repoID int64) error
- func CanCreateOrgRepo(orgID, uid int64) (bool, error)
- func ChangeOrgUserStatus(orgID, uid int64, public bool) error
- func CountOrgMembers(opts *FindOrgMembersOpts) (int64, error)
- func CountOrgs(opts FindOrgOptions) (int64, error)
- func CreateOrganization(org *Organization, owner *user_model.User) (err error)
- func DeleteOrganization(ctx context.Context, org *Organization) error
- func FindOrgMembers(opts *FindOrgMembersOpts) (user_model.UserList, map[int64]bool, error)
- func GetOrganizationCount(ctx context.Context, u *user_model.User) (int64, error)
- func GetTeamIDsByNames(orgID int64, names []string, ignoreNonExistent bool) ([]int64, error)
- func GetTeamMembers(ctx context.Context, opts *SearchMembersOptions) ([]*user_model.User, error)
- func GetTeamNamesByID(teamIDs []int64) ([]string, error)
- func GetTeamRepositories(ctx context.Context, opts *SearchTeamRepoOptions) ([]*repo_model.Repository, error)
- func GetUsersWhoCanCreateOrgRepo(ctx context.Context, orgID int64) ([]*user_model.User, error)
- func HasOrgOrUserVisible(ctx context.Context, orgOrUser, user *user_model.User) bool
- func HasOrgsVisible(orgs []*Organization, user *user_model.User) bool
- func HasTeamRepo(ctx context.Context, orgID, teamID, repoID int64) bool
- func IsErrLastOrgOwner(err error) bool
- func IsErrOrgNotExist(err error) bool
- func IsErrTeamAlreadyExist(err error) bool
- func IsErrTeamNotExist(err error) bool
- func IsErrUserNotAllowedCreateOrg(err error) bool
- func IsOrganizationMember(ctx context.Context, orgID, uid int64) (bool, error)
- func IsOrganizationOwner(ctx context.Context, orgID, uid int64) (bool, error)
- func IsPublicMembership(orgID, uid int64) (bool, error)
- func IsTeamMember(ctx context.Context, orgID, teamID, userID int64) (bool, error)
- func IsUsableTeamName(name string) error
- func IsUserInTeams(ctx context.Context, userID int64, teamIDs []int64) (bool, error)
- func IsUserOrgOwner(users user_model.UserList, orgID int64) map[int64]bool
- func RemoveOrgRepo(ctx context.Context, orgID, repoID int64) error
- func RemoveTeamRepo(ctx context.Context, teamID, repoID int64) error
- func UpdateTeamUnits(team *Team, units []TeamUnit) (err error)
- func UsersInTeamsCount(userIDs, teamIDs []int64) (int64, error)
- type AccessibleReposEnvironment
- type ErrLastOrgOwner
- type ErrOrgNotExist
- type ErrTeamAlreadyExist
- type ErrTeamNotExist
- type ErrUserNotAllowedCreateOrg
- type FindOrgMembersOpts
- type FindOrgOptions
- type OrgUser
- type Organization
- func FindOrgs(opts FindOrgOptions) ([]*Organization, error)
- func GetOrgByID(ctx context.Context, id int64) (*Organization, error)
- func GetOrgByName(name string) (*Organization, error)
- func GetOrgsCanCreateRepoByUserID(userID int64) ([]*Organization, error)
- func OrgFromUser(user *user_model.User) *Organization
- func (org *Organization) AccessibleTeamReposEnv(team *Team) AccessibleReposEnvironment
- func (org *Organization) AsUser() *user_model.User
- func (org *Organization) AvatarLink() string
- func (org *Organization) CanCreateOrgRepo(uid int64) (bool, error)
- func (org *Organization) CanCreateRepo() bool
- func (org *Organization) CustomAvatarRelativePath() string
- func (org *Organization) DisplayName() string
- func (org *Organization) GetMembers() (user_model.UserList, map[int64]bool, error)
- func (org *Organization) GetOrgUserMaxAuthorizeLevel(uid int64) (perm.AccessMode, error)
- func (org *Organization) GetOwnerTeam() (*Team, error)
- func (org *Organization) GetTeam(name string) (*Team, error)
- func (org *Organization) GetUserTeamIDs(userID int64) ([]int64, error)
- func (org *Organization) GetUserTeams(userID int64) ([]*Team, error)
- func (org *Organization) HTMLURL() string
- func (org *Organization) HasMemberWithUserID(userID int64) bool
- func (org *Organization) HomeLink() string
- func (org *Organization) IsOrgMember(uid int64) (bool, error)
- func (org *Organization) IsOwnedBy(uid int64) (bool, error)
- func (org *Organization) LoadTeams() ([]*Team, error)
- func (org *Organization) OrganisationLink() string
- func (org *Organization) ShortName(length int) string
- func (Organization) TableName() string
- func (org *Organization) TeamsWithAccessToRepo(repoID int64, mode perm.AccessMode) ([]*Team, error)
- type SearchMembersOptions
- type SearchOrganizationsOptions
- type SearchTeamOptions
- type SearchTeamRepoOptions
- type Team
- func FindOrgTeams(ctx context.Context, orgID int64) ([]*Team, error)
- func GetOwnerTeam(ctx context.Context, orgID int64) (*Team, error)
- func GetRepoTeams(ctx context.Context, repo *repo_model.Repository) (teams []*Team, err error)
- func GetTeam(ctx context.Context, orgID int64, name string) (*Team, error)
- func GetTeamByID(ctx context.Context, teamID int64) (*Team, error)
- func GetTeamsWithAccessToRepo(ctx context.Context, orgID, repoID int64, mode perm.AccessMode) ([]*Team, error)
- func GetUserOrgTeams(ctx context.Context, orgID, userID int64) (teams []*Team, err error)
- func GetUserRepoTeams(ctx context.Context, orgID, userID, repoID int64) (teams []*Team, err error)
- func SearchTeam(opts *SearchTeamOptions) ([]*Team, int64, error)
- func (t *Team) ColorFormat(s fmt.State)
- func (t *Team) GetMembersCtx(ctx context.Context) (err error)
- func (t *Team) GetRepositoriesCtx(ctx context.Context) (err error)
- func (t *Team) GetUnitNames() (res []string)
- func (t *Team) GetUnits() error
- func (t *Team) GetUnitsMap() map[string]string
- func (t *Team) IsMember(userID int64) bool
- func (t *Team) IsOwnerTeam() bool
- func (t *Team) UnitAccessMode(tp unit.Type) perm.AccessMode
- func (t *Team) UnitAccessModeCtx(ctx context.Context, tp unit.Type) perm.AccessMode
- func (t *Team) UnitEnabled(tp unit.Type) bool
- type TeamRepo
- type TeamUnit
- type TeamUser
Constants ¶
const OwnerTeamName = "Owners"
OwnerTeamName return the owner team name
Variables ¶
This section is empty.
Functions ¶
func AddOrgUser ¶
AddOrgUser adds new user to given organization.
func AddTeamRepo ¶
AddTeamRepo addes a repo for an organization's team
func CanCreateOrgRepo ¶
CanCreateOrgRepo returns true if user can create repo in organization
func ChangeOrgUserStatus ¶
ChangeOrgUserStatus changes public or private membership status.
func CountOrgMembers ¶
func CountOrgMembers(opts *FindOrgMembersOpts) (int64, error)
CountOrgMembers counts the organization's members
func CountOrgs ¶
func CountOrgs(opts FindOrgOptions) (int64, error)
CountOrgs returns total count organizations according options
func CreateOrganization ¶
func CreateOrganization(org *Organization, owner *user_model.User) (err error)
CreateOrganization creates record of a new organization.
func DeleteOrganization ¶
func DeleteOrganization(ctx context.Context, org *Organization) error
DeleteOrganization deletes models associated to an organization.
func FindOrgMembers ¶
func FindOrgMembers(opts *FindOrgMembersOpts) (user_model.UserList, map[int64]bool, error)
FindOrgMembers loads organization members according conditions
func GetOrganizationCount ¶
GetOrganizationCount returns count of membership of organization of the user.
func GetTeamIDsByNames ¶
GetTeamIDsByNames returns a slice of team ids corresponds to names.
func GetTeamMembers ¶
func GetTeamMembers(ctx context.Context, opts *SearchMembersOptions) ([]*user_model.User, error)
GetTeamMembers returns all members in given team of organization.
func GetTeamNamesByID ¶
GetTeamNamesByID returns team's lower name from a list of team ids.
func GetTeamRepositories ¶
func GetTeamRepositories(ctx context.Context, opts *SearchTeamRepoOptions) ([]*repo_model.Repository, error)
GetRepositories returns paginated repositories in team of organization.
func GetUsersWhoCanCreateOrgRepo ¶
GetUsersWhoCanCreateOrgRepo returns users which are able to create repo in organization
func HasOrgOrUserVisible ¶
func HasOrgOrUserVisible(ctx context.Context, orgOrUser, user *user_model.User) bool
HasOrgOrUserVisible tells if the given user can see the given org or user
func HasOrgsVisible ¶
func HasOrgsVisible(orgs []*Organization, user *user_model.User) bool
HasOrgsVisible tells if the given user can see at least one of the orgs provided
func HasTeamRepo ¶
HasTeamRepo returns true if given repository belongs to team.
func IsErrLastOrgOwner ¶
IsErrLastOrgOwner checks if an error is a ErrLastOrgOwner.
func IsErrOrgNotExist ¶
IsErrOrgNotExist checks if an error is a ErrOrgNotExist.
func IsErrTeamAlreadyExist ¶
IsErrTeamAlreadyExist checks if an error is a ErrTeamAlreadyExist.
func IsErrTeamNotExist ¶
IsErrTeamNotExist checks if an error is a ErrTeamNotExist.
func IsErrUserNotAllowedCreateOrg ¶
IsErrUserNotAllowedCreateOrg checks if an error is an ErrUserNotAllowedCreateOrg.
func IsOrganizationMember ¶
IsOrganizationMember returns true if given user is member of organization.
func IsOrganizationOwner ¶
IsOrganizationOwner returns true if given user is in the owner team.
func IsPublicMembership ¶
IsPublicMembership returns true if the given user's membership of given org is public.
func IsTeamMember ¶
IsTeamMember returns true if given user is a member of team.
func IsUsableTeamName ¶
IsUsableTeamName tests if a name could be as team name
func IsUserInTeams ¶
IsUserInTeams returns if a user in some teams
func IsUserOrgOwner ¶
func IsUserOrgOwner(users user_model.UserList, orgID int64) map[int64]bool
IsUserOrgOwner returns true if user is in the owner team of given organization.
func RemoveOrgRepo ¶
RemoveOrgRepo removes all team-repository relations of organization.
func RemoveTeamRepo ¶
RemoveTeamRepo remove repository from team
func UpdateTeamUnits ¶
UpdateTeamUnits updates a teams's units
func UsersInTeamsCount ¶
UsersInTeamsCount counts the number of users which are in userIDs and teamIDs
Types ¶
type AccessibleReposEnvironment ¶
type AccessibleReposEnvironment interface { CountRepos() (int64, error) RepoIDs(page, pageSize int) ([]int64, error) Repos(page, pageSize int) ([]*repo_model.Repository, error) MirrorRepos() ([]*repo_model.Repository, error) AddKeyword(keyword string) SetSort(db.SearchOrderBy) }
AccessibleReposEnvironment operations involving the repositories that are accessible to a particular user
func AccessibleReposEnv ¶
func AccessibleReposEnv(ctx context.Context, org *Organization, userID int64) (AccessibleReposEnvironment, error)
AccessibleReposEnv builds an AccessibleReposEnvironment for the repositories in `org` that are accessible to the specified user.
type ErrLastOrgOwner ¶
type ErrLastOrgOwner struct {
UID int64
}
ErrLastOrgOwner represents a "LastOrgOwner" kind of error.
func (ErrLastOrgOwner) Error ¶
func (err ErrLastOrgOwner) Error() string
type ErrOrgNotExist ¶
ErrOrgNotExist represents a "OrgNotExist" kind of error.
func (ErrOrgNotExist) Error ¶
func (err ErrOrgNotExist) Error() string
type ErrTeamAlreadyExist ¶
ErrTeamAlreadyExist represents a "TeamAlreadyExist" kind of error.
func (ErrTeamAlreadyExist) Error ¶
func (err ErrTeamAlreadyExist) Error() string
type ErrTeamNotExist ¶
ErrTeamNotExist represents a "TeamNotExist" error
func (ErrTeamNotExist) Error ¶
func (err ErrTeamNotExist) Error() string
type ErrUserNotAllowedCreateOrg ¶
type ErrUserNotAllowedCreateOrg struct{}
ErrUserNotAllowedCreateOrg represents a "UserNotAllowedCreateOrg" kind of error.
func (ErrUserNotAllowedCreateOrg) Error ¶
func (err ErrUserNotAllowedCreateOrg) Error() string
type FindOrgMembersOpts ¶
type FindOrgMembersOpts struct { db.ListOptions OrgID int64 PublicOnly bool }
FindOrgMembersOpts represensts find org members conditions
type FindOrgOptions ¶
type FindOrgOptions struct { db.ListOptions UserID int64 IncludePrivate bool }
FindOrgOptions finds orgs options
type OrgUser ¶
type OrgUser struct { ID int64 `xorm:"pk autoincr"` UID int64 `xorm:"INDEX UNIQUE(s)"` OrgID int64 `xorm:"INDEX UNIQUE(s)"` IsPublic bool `xorm:"INDEX"` }
OrgUser represents an organization-user relation.
func GetOrgUsersByOrgID ¶
func GetOrgUsersByOrgID(ctx context.Context, opts *FindOrgMembersOpts) ([]*OrgUser, error)
GetOrgUsersByOrgID returns all organization-user relations by organization ID.
func GetOrgUsersByUserID ¶
func GetOrgUsersByUserID(uid int64, opts *SearchOrganizationsOptions) ([]*OrgUser, error)
GetOrgUsersByUserID returns all organization-user relations by user ID.
type Organization ¶
type Organization user_model.User
Organization represents an organization
func FindOrgs ¶
func FindOrgs(opts FindOrgOptions) ([]*Organization, error)
FindOrgs returns a list of organizations according given conditions
func GetOrgByID ¶
func GetOrgByID(ctx context.Context, id int64) (*Organization, error)
GetOrgByID returns the user object by given ID if exists.
func GetOrgByName ¶
func GetOrgByName(name string) (*Organization, error)
GetOrgByName returns organization by given name.
func GetOrgsCanCreateRepoByUserID ¶
func GetOrgsCanCreateRepoByUserID(userID int64) ([]*Organization, error)
GetOrgsCanCreateRepoByUserID returns a list of organizations where given user ID are allowed to create repos.
func OrgFromUser ¶
func OrgFromUser(user *user_model.User) *Organization
OrgFromUser converts user to organization
func (*Organization) AccessibleTeamReposEnv ¶
func (org *Organization) AccessibleTeamReposEnv(team *Team) AccessibleReposEnvironment
AccessibleTeamReposEnv an AccessibleReposEnvironment for the repositories in `org` that are accessible to the specified team.
func (*Organization) AsUser ¶
func (org *Organization) AsUser() *user_model.User
AsUser returns the org as user object
func (*Organization) AvatarLink ¶
func (org *Organization) AvatarLink() string
AvatarLink returns the full avatar link with http host
func (*Organization) CanCreateOrgRepo ¶
func (org *Organization) CanCreateOrgRepo(uid int64) (bool, error)
CanCreateOrgRepo returns true if given user can create repo in organization
func (*Organization) CanCreateRepo ¶
func (org *Organization) CanCreateRepo() bool
CanCreateRepo returns if user login can create a repository NOTE: functions calling this assume a failure due to repository count limit; if new checks are added, those functions should be revised
func (*Organization) CustomAvatarRelativePath ¶
func (org *Organization) CustomAvatarRelativePath() string
CustomAvatarRelativePath returns user custom avatar relative path.
func (*Organization) DisplayName ¶
func (org *Organization) DisplayName() string
DisplayName returns full name if it's not empty, returns username otherwise.
func (*Organization) GetMembers ¶
func (org *Organization) GetMembers() (user_model.UserList, map[int64]bool, error)
GetMembers returns all members of organization.
func (*Organization) GetOrgUserMaxAuthorizeLevel ¶
func (org *Organization) GetOrgUserMaxAuthorizeLevel(uid int64) (perm.AccessMode, error)
GetOrgUserMaxAuthorizeLevel returns highest authorize level of user in an organization
func (*Organization) GetOwnerTeam ¶
func (org *Organization) GetOwnerTeam() (*Team, error)
GetOwnerTeam returns owner team of organization.
func (*Organization) GetTeam ¶
func (org *Organization) GetTeam(name string) (*Team, error)
GetTeam returns named team of organization.
func (*Organization) GetUserTeamIDs ¶
func (org *Organization) GetUserTeamIDs(userID int64) ([]int64, error)
GetUserTeamIDs returns of all team IDs of the organization that user is member of.
func (*Organization) GetUserTeams ¶
func (org *Organization) GetUserTeams(userID int64) ([]*Team, error)
GetUserTeams returns all teams that belong to user, and that the user has joined.
func (*Organization) HTMLURL ¶
func (org *Organization) HTMLURL() string
HTMLURL returns the organization's full link.
func (*Organization) HasMemberWithUserID ¶
func (org *Organization) HasMemberWithUserID(userID int64) bool
HasMemberWithUserID returns true if user with userID is part of the u organisation.
func (*Organization) HomeLink ¶
func (org *Organization) HomeLink() string
HomeLink returns the user or organization home page link.
func (*Organization) IsOrgMember ¶
func (org *Organization) IsOrgMember(uid int64) (bool, error)
IsOrgMember returns true if given user is member of organization.
func (*Organization) IsOwnedBy ¶
func (org *Organization) IsOwnedBy(uid int64) (bool, error)
IsOwnedBy returns true if given user is in the owner team.
func (*Organization) LoadTeams ¶
func (org *Organization) LoadTeams() ([]*Team, error)
LoadTeams load teams if not loaded.
func (*Organization) OrganisationLink ¶
func (org *Organization) OrganisationLink() string
OrganisationLink returns the organization sub page link.
func (*Organization) ShortName ¶
func (org *Organization) ShortName(length int) string
ShortName ellipses username to length
func (Organization) TableName ¶
func (Organization) TableName() string
TableName represents the real table name of Organization
func (*Organization) TeamsWithAccessToRepo ¶
func (org *Organization) TeamsWithAccessToRepo(repoID int64, mode perm.AccessMode) ([]*Team, error)
TeamsWithAccessToRepo returns all teams that have given access level to the repository.
type SearchMembersOptions ¶
type SearchMembersOptions struct { db.ListOptions TeamID int64 }
SearchMembersOptions holds the search options
func (SearchMembersOptions) ToConds ¶
func (opts SearchMembersOptions) ToConds() builder.Cond
type SearchOrganizationsOptions ¶
type SearchOrganizationsOptions struct { db.ListOptions All bool }
SearchOrganizationsOptions options to filter organizations
type SearchTeamOptions ¶
type SearchTeamOptions struct { db.ListOptions UserID int64 Keyword string OrgID int64 IncludeDesc bool }
SearchTeamOptions holds the search options
type SearchTeamRepoOptions ¶
type SearchTeamRepoOptions struct { db.ListOptions TeamID int64 }
type Team ¶
type Team struct { ID int64 `xorm:"pk autoincr"` OrgID int64 `xorm:"INDEX"` LowerName string Name string Description string AccessMode perm.AccessMode `xorm:"'authorize'"` Repos []*repo_model.Repository `xorm:"-"` Members []*user_model.User `xorm:"-"` NumRepos int NumMembers int Units []*TeamUnit `xorm:"-"` IncludesAllRepositories bool `xorm:"NOT NULL DEFAULT false"` CanCreateOrgRepo bool `xorm:"NOT NULL DEFAULT false"` }
Team represents a organization team.
func FindOrgTeams ¶
FindOrgTeams returns all teams of a given organization
func GetOwnerTeam ¶
GetOwnerTeam returns team by given team name and organization.
func GetRepoTeams ¶
func GetRepoTeams(ctx context.Context, repo *repo_model.Repository) (teams []*Team, err error)
GetRepoTeams gets the list of teams that has access to the repository
func GetTeamByID ¶
GetTeamByID returns team by given ID.
func GetTeamsWithAccessToRepo ¶
func GetTeamsWithAccessToRepo(ctx context.Context, orgID, repoID int64, mode perm.AccessMode) ([]*Team, error)
GetTeamsWithAccessToRepo returns all teams in an organization that have given access level to the repository.
func GetUserOrgTeams ¶
GetUserOrgTeams returns all teams that user belongs to in given organization.
func GetUserRepoTeams ¶
GetUserRepoTeams returns user repo's teams
func SearchTeam ¶
func SearchTeam(opts *SearchTeamOptions) ([]*Team, int64, error)
SearchTeam search for teams. Caller is responsible to check permissions.
func (*Team) ColorFormat ¶
ColorFormat provides a basic color format for a Team
func (*Team) GetMembersCtx ¶
GetMembersCtx returns paginated members in team of organization.
func (*Team) GetRepositoriesCtx ¶
GetRepositoriesCtx returns paginated repositories in team of organization.
func (*Team) GetUnitNames ¶
GetUnitNames returns the team units names
func (*Team) GetUnitsMap ¶
GetUnitsMap returns the team units permissions
func (*Team) IsOwnerTeam ¶
IsOwnerTeam returns true if team is owner team.
func (*Team) UnitAccessMode ¶
func (t *Team) UnitAccessMode(tp unit.Type) perm.AccessMode
UnitAccessMode returns if the team has the given unit type enabled it is called in templates, should not be replaced by `UnitAccessModeCtx(ctx ...)`
func (*Team) UnitAccessModeCtx ¶
UnitAccessModeCtx returns if the team has the given unit type enabled
type TeamRepo ¶
type TeamRepo struct { ID int64 `xorm:"pk autoincr"` OrgID int64 `xorm:"INDEX"` TeamID int64 `xorm:"UNIQUE(s)"` RepoID int64 `xorm:"UNIQUE(s)"` }
TeamRepo represents an team-repository relation.
type TeamUnit ¶
type TeamUnit struct { ID int64 `xorm:"pk autoincr"` OrgID int64 `xorm:"INDEX"` TeamID int64 `xorm:"UNIQUE(s)"` Type unit.Type `xorm:"UNIQUE(s)"` AccessMode perm.AccessMode }
TeamUnit describes all units of a repository