|
|
|
@@ -1045,18 +1045,36 @@ func isCanDelete(ctx *context.Context, modelUserId int64) bool { |
|
|
|
if ctx.User == nil { |
|
|
|
return false |
|
|
|
} |
|
|
|
if ctx.User.IsAdmin || ctx.User.ID == modelUserId { |
|
|
|
if ctx.User.ID == modelUserId { |
|
|
|
return true |
|
|
|
} |
|
|
|
return isAdminRight(ctx) |
|
|
|
} |
|
|
|
|
|
|
|
func isAdminRight(ctx *context.Context) bool { |
|
|
|
if ctx.User.IsAdmin { |
|
|
|
return true |
|
|
|
} |
|
|
|
if ctx.Repo.IsOwner() { |
|
|
|
return true |
|
|
|
} |
|
|
|
isRepoOwnerCollaborator, err := ctx.Repo.Repository.IsOwnerMemberCollaborator(ctx.User.ID) |
|
|
|
if ctx.Repo.Owner.IsOrganization() { |
|
|
|
isOwner, err := ctx.Repo.Owner.IsOwnedBy(ctx.User.ID) |
|
|
|
if err != nil { |
|
|
|
return false |
|
|
|
} else if isOwner { |
|
|
|
return true |
|
|
|
} |
|
|
|
} |
|
|
|
isCollaborator, err := ctx.Repo.Repository.IsCollaborator(ctx.User.ID) |
|
|
|
if err != nil { |
|
|
|
log.Info("query isRepoOwnerCollaborator error." + err.Error()) |
|
|
|
log.Info("query IsCollaborator error." + err.Error()) |
|
|
|
} |
|
|
|
if isRepoOwnerCollaborator { |
|
|
|
return true |
|
|
|
if isCollaborator { |
|
|
|
mode := ctx.Repo.Repository.GetCollaboratorMode(ctx.User.ID) |
|
|
|
if mode >= 3 { |
|
|
|
return true |
|
|
|
} |
|
|
|
} |
|
|
|
return false |
|
|
|
} |
|
|
|
@@ -1068,18 +1086,7 @@ func isOperModifyOrDelete(ctx *context.Context, modelUserId int64) bool { |
|
|
|
if ctx.User.IsAdmin || ctx.User.ID == modelUserId { |
|
|
|
return true |
|
|
|
} |
|
|
|
|
|
|
|
if ctx.Repo.IsOwner() { |
|
|
|
return true |
|
|
|
} |
|
|
|
isRepoOwnerCollaborator, err := ctx.Repo.Repository.IsOwnerMemberCollaborator(ctx.User.ID) |
|
|
|
if err != nil { |
|
|
|
log.Info("query isRepoOwnerCollaborator error." + err.Error()) |
|
|
|
} |
|
|
|
if isRepoOwnerCollaborator { |
|
|
|
return true |
|
|
|
} |
|
|
|
return false |
|
|
|
return isAdminRight(ctx) |
|
|
|
} |
|
|
|
|
|
|
|
func ShowModelPageInfo(ctx *context.Context) { |
|
|
|
|