summaryrefslogtreecommitdiffstats
path: root/core/l10n/th.js
Commit message (Expand)AuthorAgeFilesLines
* [tx-robot] updated from transifexNextcloud bot2018-04-181-2/+2
* [tx-robot] updated from transifexNextcloud bot2018-04-071-1/+1
* [tx-robot] updated from transifexNextcloud bot2018-03-151-2/+2
* [tx-robot] updated from transifexNextcloud bot2018-02-131-0/+187
* [tx-robot] updated from transifexNextcloud bot2017-03-171-285/+0
* [tx-robot] updated from transifexNextcloud bot2017-03-021-0/+285
ass="w"> if err := repo_service.DeleteRepository(ctx.User, ctx.Repo.Repository); err != nil { ctx.ServerError("DeleteRepository", err) return } log.Trace("Repository deleted: %s/%s", ctx.Repo.Owner.Name, repo.Name) ctx.Flash.Success(ctx.Tr("repo.settings.deletion_success")) ctx.Redirect(ctx.Repo.Owner.DashboardLink()) case "delete-wiki": if !ctx.Repo.IsOwner() { ctx.Error(404) return } if repo.Name != form.RepoName { ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_repo_name"), tplSettingsOptions, nil) return } err := repo.DeleteWiki() if err != nil { log.Error("Delete Wiki: %v", err.Error()) } log.Trace("Repository wiki deleted: %s/%s", ctx.Repo.Owner.Name, repo.Name) ctx.Flash.Success(ctx.Tr("repo.settings.wiki_deletion_success")) ctx.Redirect(ctx.Repo.RepoLink + "/settings") case "archive": if !ctx.Repo.IsOwner() { ctx.Error(403) return } if repo.IsMirror { ctx.Flash.Error(ctx.Tr("repo.settings.archive.error_ismirror")) ctx.Redirect(ctx.Repo.RepoLink + "/settings") return } if err := repo.SetArchiveRepoState(true); err != nil { log.Error("Tried to archive a repo: %s", err) ctx.Flash.Error(ctx.Tr("repo.settings.archive.error")) ctx.Redirect(ctx.Repo.RepoLink + "/settings") return } ctx.Flash.Success(ctx.Tr("repo.settings.archive.success")) log.Trace("Repository was archived: %s/%s", ctx.Repo.Owner.Name, repo.Name) ctx.Redirect(ctx.Repo.RepoLink + "/settings") case "unarchive": if !ctx.Repo.IsOwner() { ctx.Error(403) return } if err := repo.SetArchiveRepoState(false); err != nil { log.Error("Tried to unarchive a repo: %s", err) ctx.Flash.Error(ctx.Tr("repo.settings.unarchive.error")) ctx.Redirect(ctx.Repo.RepoLink + "/settings") return } ctx.Flash.Success(ctx.Tr("repo.settings.unarchive.success")) log.Trace("Repository was un-archived: %s/%s", ctx.Repo.Owner.Name, repo.Name) ctx.Redirect(ctx.Repo.RepoLink + "/settings") default: ctx.NotFound("", nil) } } // Collaboration render a repository's collaboration page func Collaboration(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("repo.settings") ctx.Data["PageIsSettingsCollaboration"] = true users, err := ctx.Repo.Repository.GetCollaborators(models.ListOptions{}) if err != nil { ctx.ServerError("GetCollaborators", err) return } ctx.Data["Collaborators"] = users teams, err := ctx.Repo.Repository.GetRepoTeams() if err != nil { ctx.ServerError("GetRepoTeams", err) return } ctx.Data["Teams"] = teams ctx.Data["Repo"] = ctx.Repo.Repository ctx.Data["OrgID"] = ctx.Repo.Repository.OwnerID ctx.Data["OrgName"] = ctx.Repo.Repository.OwnerName ctx.Data["Org"] = ctx.Repo.Repository.Owner ctx.Data["Units"] = models.Units ctx.HTML(200, tplCollaboration) } // CollaborationPost response for actions for a collaboration of a repository func CollaborationPost(ctx *context.Context) { name := utils.RemoveUsernameParameterSuffix(strings.ToLower(ctx.Query("collaborator"))) if len(name) == 0 || ctx.Repo.Owner.LowerName == name { ctx.Redirect(setting.AppSubURL + ctx.Req.URL.Path) return } u, err := models.GetUserByName(name) if err != nil { if models.IsErrUserNotExist(err) { ctx.Flash.Error(ctx.Tr("form.user_not_exist")) ctx.Redirect(setting.AppSubURL + ctx.Req.URL.Path) } else { ctx.ServerError("GetUserByName", err) } return } if !u.IsActive { ctx.Flash.Error(ctx.Tr("repo.settings.add_collaborator_inactive_user")) ctx.Redirect(setting.AppSubURL + ctx.Req.URL.Path) return } // Organization is not allowed to be added as a collaborator. if u.IsOrganization() { ctx.Flash.Error(ctx.Tr("repo.settings.org_not_allowed_to_be_collaborator")) ctx.Redirect(setting.AppSubURL + ctx.Req.URL.Path) return } if got, err := ctx.Repo.Repository.IsCollaborator(u.ID); err == nil && got { ctx.Flash.Error(ctx.Tr("repo.settings.add_collaborator_duplicate")) ctx.Redirect(ctx.Repo.RepoLink + "/settings/collaboration") return } if err = ctx.Repo.Repository.AddCollaborator(u); err != nil { ctx.ServerError("AddCollaborator", err) return } if setting.Service.EnableNotifyMail { mailer.SendCollaboratorMail(u, ctx.User, ctx.Repo.Repository) } ctx.Flash.Success(ctx.Tr("repo.settings.add_collaborator_success")) ctx.Redirect(setting.AppSubURL + ctx.Req.URL.Path) } // ChangeCollaborationAccessMode response for changing access of a collaboration func ChangeCollaborationAccessMode(ctx *context.Context) { if err := ctx.Repo.Repository.ChangeCollaborationAccessMode( ctx.QueryInt64("uid"), models.AccessMode(ctx.QueryInt("mode"))); err != nil { log.Error("ChangeCollaborationAccessMode: %v", err) } } // DeleteCollaboration delete a collaboration for a repository func DeleteCollaboration(ctx *context.Context) { if err := ctx.Repo.Repository.DeleteCollaboration(ctx.QueryInt64("id")); err != nil { ctx.Flash.Error("DeleteCollaboration: " + err.Error()) } else { ctx.Flash.Success(ctx.Tr("repo.settings.remove_collaborator_success")) } ctx.JSON(200, map[string]interface{}{ "redirect": ctx.Repo.RepoLink + "/settings/collaboration", }) } // AddTeamPost response for adding a team to a repository func AddTeamPost(ctx *context.Context) { if !ctx.Repo.Owner.RepoAdminChangeTeamAccess && !ctx.Repo.IsOwner() { ctx.Flash.Error(ctx.Tr("repo.settings.change_team_access_not_allowed")) ctx.Redirect(ctx.Repo.RepoLink + "/settings/collaboration") return } name := utils.RemoveUsernameParameterSuffix(strings.ToLower(ctx.Query("team"))) if len(name) == 0 { ctx.Redirect(ctx.Repo.RepoLink + "/settings/collaboration") return } team, err := ctx.Repo.Owner.GetTeam(name) if err != nil { if models.IsErrTeamNotExist(err) { ctx.Flash.Error(ctx.Tr("form.team_not_exist")) ctx.Redirect(ctx.Repo.RepoLink + "/settings/collaboration") } else { ctx.ServerError("GetTeam", err) } return } if team.OrgID != ctx.Repo.Repository.OwnerID { ctx.Flash.Error(ctx.Tr("repo.settings.team_not_in_organization")) ctx.Redirect(ctx.Repo.RepoLink + "/settings/collaboration") return } if models.HasTeamRepo(ctx.Repo.Repository.OwnerID, team.ID, ctx.Repo.Repository.ID) { ctx.Flash.Error(ctx.Tr("repo.settings.add_team_duplicate")) ctx.Redirect(ctx.Repo.RepoLink + "/settings/collaboration") return } if err = team.AddRepository(ctx.Repo.Repository); err != nil { ctx.ServerError("team.AddRepository", err) return } ctx.Flash.Success(ctx.Tr("repo.settings.add_team_success")) ctx.Redirect(ctx.Repo.RepoLink + "/settings/collaboration") } // DeleteTeam response for deleting a team from a repository func DeleteTeam(ctx *context.Context) { if !ctx.Repo.Owner.RepoAdminChangeTeamAccess && !ctx.Repo.IsOwner() { ctx.Flash.Error(ctx.Tr("repo.settings.change_team_access_not_allowed")) ctx.Redirect(ctx.Repo.RepoLink + "/settings/collaboration") return } team, err := models.GetTeamByID(ctx.QueryInt64("id")) if err != nil { ctx.ServerError("GetTeamByID", err) return } if err = team.RemoveRepository(ctx.Repo.Repository.ID); err != nil { ctx.ServerError("team.RemoveRepositorys", err) return } ctx.Flash.Success(ctx.Tr("repo.settings.remove_team_success")) ctx.JSON(200, map[string]interface{}{ "redirect": ctx.Repo.RepoLink + "/settings/collaboration", }) } // parseOwnerAndRepo get repos by owner func parseOwnerAndRepo(ctx *context.Context) (*models.User, *models.Repository) { owner, err := models.GetUserByName(ctx.Params(":username")) if err != nil { if models.IsErrUserNotExist(err) { ctx.NotFound("GetUserByName", err) } else { ctx.ServerError("GetUserByName", err) } return nil, nil } repo, err := models.GetRepositoryByName(owner.ID, ctx.Params(":reponame")) if err != nil { if models.IsErrRepoNotExist(err) { ctx.NotFound("GetRepositoryByName", err) } else { ctx.ServerError("GetRepositoryByName", err) } return nil, nil } return owner, repo } // GitHooks hooks of a repository func GitHooks(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("repo.settings.githooks") ctx.Data["PageIsSettingsGitHooks"] = true hooks, err := ctx.Repo.GitRepo.Hooks() if err != nil { ctx.ServerError("Hooks", err) return } ctx.Data["Hooks"] = hooks ctx.HTML(200, tplGithooks) } // GitHooksEdit render for editing a hook of repository page func GitHooksEdit(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("repo.settings.githooks") ctx.Data["PageIsSettingsGitHooks"] = true ctx.Data["RequireSimpleMDE"] = true name := ctx.Params(":name") hook, err := ctx.Repo.GitRepo.GetHook(name) if err != nil { if err == git.ErrNotValidHook { ctx.NotFound("GetHook", err) } else { ctx.ServerError("GetHook", err) } return } ctx.Data["Hook"] = hook ctx.HTML(200, tplGithookEdit) } // GitHooksEditPost response for editing a git hook of a repository func GitHooksEditPost(ctx *context.Context) { name := ctx.Params(":name") hook, err := ctx.Repo.GitRepo.GetHook(name) if err != nil { if err == git.ErrNotValidHook { ctx.NotFound("GetHook", err) } else { ctx.ServerError("GetHook", err) } return } hook.Content = ctx.Query("content") if err = hook.Update(); err != nil { ctx.ServerError("hook.Update", err) return } ctx.Redirect(ctx.Repo.RepoLink + "/settings/hooks/git") } // DeployKeys render the deploy keys list of a repository page func DeployKeys(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("repo.settings.deploy_keys") ctx.Data["PageIsSettingsKeys"] = true ctx.Data["DisableSSH"] = setting.SSH.Disabled keys, err := models.ListDeployKeys(ctx.Repo.Repository.ID, models.ListOptions{}) if err != nil { ctx.ServerError("ListDeployKeys", err) return } ctx.Data["Deploykeys"] = keys ctx.HTML(200, tplDeployKeys) } // DeployKeysPost response for adding a deploy key of a repository func DeployKeysPost(ctx *context.Context, form auth.AddKeyForm) { ctx.Data["Title"] = ctx.Tr("repo.settings.deploy_keys") ctx.Data["PageIsSettingsKeys"] = true keys, err := models.ListDeployKeys(ctx.Repo.Repository.ID, models.ListOptions{}) if err != nil { ctx.ServerError("ListDeployKeys", err) return } ctx.Data["Deploykeys"] = keys if ctx.HasError() { ctx.HTML(200, tplDeployKeys) return } content, err := models.CheckPublicKeyString(form.Content) if err != nil { if models.IsErrSSHDisabled(err) { ctx.Flash.Info(ctx.Tr("settings.ssh_disabled")) } else if models.IsErrKeyUnableVerify(err) { ctx.Flash.Info(ctx.Tr("form.unable_verify_ssh_key")) } else { ctx.Data["HasError"] = true ctx.Data["Err_Content"] = true ctx.Flash.Error(ctx.Tr("form.invalid_ssh_key", err.Error())) } ctx.Redirect(ctx.Repo.RepoLink + "/settings/keys") return } key, err := models.AddDeployKey(ctx.Repo.Repository.ID, form.Title, content, !form.IsWritable) if err != nil { ctx.Data["HasError"] = true switch { case models.IsErrDeployKeyAlreadyExist(err): ctx.Data["Err_Content"] = true ctx.RenderWithErr(ctx.Tr("repo.settings.key_been_used"), tplDeployKeys, &form) case models.IsErrKeyAlreadyExist(err): ctx.Data["Err_Content"] = true ctx.RenderWithErr(ctx.Tr("settings.ssh_key_been_used"), tplDeployKeys, &form) case models.IsErrKeyNameAlreadyUsed(err): ctx.Data["Err_Title"] = true ctx.RenderWithErr(ctx.Tr("repo.settings.key_name_used"), tplDeployKeys, &form) default: ctx.ServerError("AddDeployKey", err) } return } log.Trace("Deploy key added: %d", ctx.Repo.Repository.ID) ctx.Flash.Success(ctx.Tr("repo.settings.add_key_success", key.Name)) ctx.Redirect(ctx.Repo.RepoLink + "/settings/keys") } // DeleteDeployKey response for deleting a deploy key func DeleteDeployKey(ctx *context.Context) { if err := models.DeleteDeployKey(ctx.User, ctx.QueryInt64("id")); err != nil { ctx.Flash.Error("DeleteDeployKey: " + err.Error()) } else { ctx.Flash.Success(ctx.Tr("repo.settings.deploy_key_deletion_success")) } ctx.JSON(200, map[string]interface{}{ "redirect": ctx.Repo.RepoLink + "/settings/keys", }) } func init() { var err error validFormAddress, err = xurls.StrictMatchingScheme(`(https?)|(git)://`) if err != nil { panic(err) } } // UpdateAvatarSetting update repo's avatar func UpdateAvatarSetting(ctx *context.Context, form auth.AvatarForm) error { ctxRepo := ctx.Repo.Repository if form.Avatar == nil { // No avatar is uploaded and we not removing it here. // No random avatar generated here. // Just exit, no action. if !com.IsFile(ctxRepo.CustomAvatarPath()) { log.Trace("No avatar was uploaded for repo: %d. Default icon will appear instead.", ctxRepo.ID) } return nil } r, err := form.Avatar.Open() if err != nil { return fmt.Errorf("Avatar.Open: %v", err) } defer r.Close() if form.Avatar.Size > setting.AvatarMaxFileSize { return errors.New(ctx.Tr("settings.uploaded_avatar_is_too_big")) } data, err := ioutil.ReadAll(r) if err != nil { return fmt.Errorf("ioutil.ReadAll: %v", err) } if !base.IsImageFile(data) { return errors.New(ctx.Tr("settings.uploaded_avatar_not_a_image")) } if err = ctxRepo.UploadAvatar(data); err != nil { return fmt.Errorf("UploadAvatar: %v", err) } return nil } // SettingsAvatar save new POSTed repository avatar func SettingsAvatar(ctx *context.Context, form auth.AvatarForm) { form.Source = auth.AvatarLocal if err := UpdateAvatarSetting(ctx, form); err != nil { ctx.Flash.Error(err.Error()) } else { ctx.Flash.Success(ctx.Tr("repo.settings.update_avatar_success")) } ctx.Redirect(ctx.Repo.RepoLink + "/settings") } // SettingsDeleteAvatar delete repository avatar func SettingsDeleteAvatar(ctx *context.Context) { if err := ctx.Repo.Repository.DeleteAvatar(); err != nil { ctx.Flash.Error(fmt.Sprintf("DeleteAvatar: %v", err)) } ctx.Redirect(ctx.Repo.RepoLink + "/settings") }