| @@ -23,8 +23,8 @@ type CommentType int | |||
| const ( | |||
| // Plain comment, can be associated with a commit (CommitID > 0) and a line (LineNum > 0) | |||
| COMMENT_TYPE_COMMENT CommentType = iota | |||
| COMMENT_TYPE_REOPEN | |||
| CommentTypeComment CommentType = iota | |||
| CommentTypeReopen | |||
| COMMENT_TYPE_CLOSE | |||
| // References. | |||
| @@ -32,7 +32,7 @@ const ( | |||
| // Reference from a commit (not part of a pull request) | |||
| COMMENT_TYPE_COMMIT_REF | |||
| // Reference from a comment | |||
| COMMENT_TYPE_COMMENT_REF | |||
| CommentTypeComment_REF | |||
| // Reference from a pull request | |||
| COMMENT_TYPE_PULL_REF | |||
| ) | |||
| @@ -40,9 +40,9 @@ const ( | |||
| type CommentTag int | |||
| const ( | |||
| COMMENT_TAG_NONE CommentTag = iota | |||
| COMMENT_TAG_POSTER | |||
| COMMENT_TAG_WRITER | |||
| CommentTagNone CommentTag = iota | |||
| CommentTagPoster | |||
| CommentTagWriter | |||
| COMMENT_TAG_OWNER | |||
| ) | |||
| @@ -187,7 +187,7 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err | |||
| // Check comment type. | |||
| switch opts.Type { | |||
| case COMMENT_TYPE_COMMENT: | |||
| case CommentTypeComment: | |||
| act.OpType = ActionCommentIssue | |||
| if _, err = e.Exec("UPDATE `issue` SET num_comments=num_comments+1 WHERE id=?", opts.Issue.ID); err != nil { | |||
| @@ -216,7 +216,7 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err | |||
| } | |||
| } | |||
| case COMMENT_TYPE_REOPEN: | |||
| case CommentTypeReopen: | |||
| act.OpType = ActionReopenIssue | |||
| if opts.Issue.IsPull { | |||
| act.OpType = ActionReopenPullRequest | |||
| @@ -262,7 +262,7 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err | |||
| func createStatusComment(e *xorm.Session, doer *User, repo *Repository, issue *Issue) (*Comment, error) { | |||
| cmtType := COMMENT_TYPE_CLOSE | |||
| if !issue.IsClosed { | |||
| cmtType = COMMENT_TYPE_REOPEN | |||
| cmtType = CommentTypeReopen | |||
| } | |||
| return createComment(e, &CreateCommentOptions{ | |||
| Type: cmtType, | |||
| @@ -304,7 +304,7 @@ func CreateComment(opts *CreateCommentOptions) (comment *Comment, err error) { | |||
| // CreateIssueComment creates a plain issue comment. | |||
| func CreateIssueComment(doer *User, repo *Repository, issue *Issue, content string, attachments []string) (*Comment, error) { | |||
| return CreateComment(&CreateCommentOptions{ | |||
| Type: COMMENT_TYPE_COMMENT, | |||
| Type: CommentTypeComment, | |||
| Doer: doer, | |||
| Repo: repo, | |||
| Issue: issue, | |||
| @@ -403,7 +403,7 @@ func DeleteCommentByID(id int64) error { | |||
| return err | |||
| } | |||
| if comment.Type == COMMENT_TYPE_COMMENT { | |||
| if comment.Type == CommentTypeComment { | |||
| if _, err = sess.Exec("UPDATE `issue` SET num_comments = num_comments - 1 WHERE id = ?", comment.IssueID); err != nil { | |||
| return err | |||
| } | |||
| @@ -28,16 +28,16 @@ type LoginType int | |||
| // Note: new type must append to the end of list to maintain compatibility. | |||
| const ( | |||
| LOGIN_NOTYPE LoginType = iota | |||
| LOGIN_PLAIN // 1 | |||
| LOGIN_LDAP // 2 | |||
| LoginNotype LoginType = iota | |||
| LoginPlain // 1 | |||
| LoginLdap // 2 | |||
| LOGIN_SMTP // 3 | |||
| LOGIN_PAM // 4 | |||
| LOGIN_DLDAP // 5 | |||
| ) | |||
| var LoginNames = map[LoginType]string{ | |||
| LOGIN_LDAP: "LDAP (via BindDN)", | |||
| LoginLdap: "LDAP (via BindDN)", | |||
| LOGIN_DLDAP: "LDAP (simple auth)", // Via direct bind | |||
| LOGIN_SMTP: "SMTP", | |||
| LOGIN_PAM: "PAM", | |||
| @@ -139,7 +139,7 @@ func (source *LoginSource) BeforeSet(colName string, val xorm.Cell) { | |||
| switch colName { | |||
| case "type": | |||
| switch LoginType(Cell2Int64(val)) { | |||
| case LOGIN_LDAP, LOGIN_DLDAP: | |||
| case LoginLdap, LOGIN_DLDAP: | |||
| source.Cfg = new(LDAPConfig) | |||
| case LOGIN_SMTP: | |||
| source.Cfg = new(SMTPConfig) | |||
| @@ -165,7 +165,7 @@ func (source *LoginSource) TypeName() string { | |||
| } | |||
| func (source *LoginSource) IsLDAP() bool { | |||
| return source.Type == LOGIN_LDAP | |||
| return source.Type == LoginLdap | |||
| } | |||
| func (source *LoginSource) IsDLDAP() bool { | |||
| @@ -188,7 +188,7 @@ func (source *LoginSource) HasTLS() bool { | |||
| func (source *LoginSource) UseTLS() bool { | |||
| switch source.Type { | |||
| case LOGIN_LDAP, LOGIN_DLDAP: | |||
| case LoginLdap, LOGIN_DLDAP: | |||
| return source.LDAP().SecurityProtocol != ldap.SECURITY_PROTOCOL_UNENCRYPTED | |||
| case LOGIN_SMTP: | |||
| return source.SMTP().TLS | |||
| @@ -199,7 +199,7 @@ func (source *LoginSource) UseTLS() bool { | |||
| func (source *LoginSource) SkipVerify() bool { | |||
| switch source.Type { | |||
| case LOGIN_LDAP, LOGIN_DLDAP: | |||
| case LoginLdap, LOGIN_DLDAP: | |||
| return source.LDAP().SkipVerify | |||
| case LOGIN_SMTP: | |||
| return source.SMTP().SkipVerify | |||
| @@ -358,11 +358,11 @@ func (auth *smtpLoginAuth) Next(fromServer []byte, more bool) ([]byte, error) { | |||
| } | |||
| const ( | |||
| SMTP_PLAIN = "PLAIN" | |||
| SMTP_LOGIN = "LOGIN" | |||
| SmtpPlain = "PLAIN" | |||
| SmtpLogin = "LOGIN" | |||
| ) | |||
| var SMTPAuths = []string{SMTP_PLAIN, SMTP_LOGIN} | |||
| var SMTPAuths = []string{SmtpPlain, SmtpLogin} | |||
| func SMTPAuth(a smtp.Auth, cfg *SMTPConfig) error { | |||
| c, err := smtp.Dial(fmt.Sprintf("%s:%d", cfg.Host, cfg.Port)) | |||
| @@ -411,9 +411,9 @@ func LoginViaSMTP(user *User, login, password string, sourceID int64, cfg *SMTPC | |||
| } | |||
| var auth smtp.Auth | |||
| if cfg.Auth == SMTP_PLAIN { | |||
| if cfg.Auth == SmtpPlain { | |||
| auth = smtp.PlainAuth("", login, password, cfg.Host) | |||
| } else if cfg.Auth == SMTP_LOGIN { | |||
| } else if cfg.Auth == SmtpLogin { | |||
| auth = &smtpLoginAuth{login, password} | |||
| } else { | |||
| return nil, errors.New("Unsupported SMTP auth type") | |||
| @@ -493,7 +493,7 @@ func ExternalUserLogin(user *User, login, password string, source *LoginSource, | |||
| } | |||
| switch source.Type { | |||
| case LOGIN_LDAP, LOGIN_DLDAP: | |||
| case LoginLdap, LOGIN_DLDAP: | |||
| return LoginViaLDAP(user, login, password, source, autoRegister) | |||
| case LOGIN_SMTP: | |||
| return LoginViaSMTP(user, login, password, source.ID, source.Cfg.(*SMTPConfig), autoRegister) | |||
| @@ -520,7 +520,7 @@ func UserSignIn(username, passowrd string) (*User, error) { | |||
| if hasUser { | |||
| switch user.LoginType { | |||
| case LOGIN_NOTYPE, LOGIN_PLAIN: | |||
| case LoginNotype, LoginPlain: | |||
| if user.ValidatePassword(passowrd) { | |||
| return user, nil | |||
| } | |||
| @@ -20,9 +20,9 @@ import ( | |||
| ) | |||
| const ( | |||
| MAIL_AUTH_ACTIVATE base.TplName = "auth/activate" | |||
| MAIL_AUTH_ACTIVATE_EMAIL base.TplName = "auth/activate_email" | |||
| MAIL_AUTH_RESET_PASSWORD base.TplName = "auth/reset_passwd" | |||
| MailAuthActivate base.TplName = "auth/activate" | |||
| MailAuthActivateEmail base.TplName = "auth/activate_email" | |||
| MailAuthResetPassword base.TplName = "auth/reset_passwd" | |||
| MAIL_AUTH_REGISTER_NOTIFY base.TplName = "auth/register_notify" | |||
| MAIL_ISSUE_COMMENT base.TplName = "issue/comment" | |||
| @@ -77,11 +77,11 @@ func SendUserMail(c *macaron.Context, u *User, tpl base.TplName, code, subject, | |||
| } | |||
| func SendActivateAccountMail(c *macaron.Context, u *User) { | |||
| SendUserMail(c, u, MAIL_AUTH_ACTIVATE, u.GenerateActivateCode(), c.Tr("mail.activate_account"), "activate account") | |||
| SendUserMail(c, u, MailAuthActivate, u.GenerateActivateCode(), c.Tr("mail.activate_account"), "activate account") | |||
| } | |||
| func SendResetPasswordMail(c *macaron.Context, u *User) { | |||
| SendUserMail(c, u, MAIL_AUTH_RESET_PASSWORD, u.GenerateActivateCode(), c.Tr("mail.reset_password"), "reset password") | |||
| SendUserMail(c, u, MailAuthResetPassword, u.GenerateActivateCode(), c.Tr("mail.reset_password"), "reset password") | |||
| } | |||
| // SendActivateAccountMail sends confirmation email. | |||
| @@ -92,7 +92,7 @@ func SendActivateEmailMail(c *macaron.Context, u *User, email *EmailAddress) { | |||
| "Code": u.GenerateEmailActivateCode(email.Email), | |||
| "Email": email.Email, | |||
| } | |||
| body, err := mailRender.HTMLString(string(MAIL_AUTH_ACTIVATE_EMAIL), data) | |||
| body, err := mailRender.HTMLString(string(MailAuthActivateEmail), data) | |||
| if err != nil { | |||
| log.Error(3, "HTMLString: %v", err) | |||
| return | |||
| @@ -140,9 +140,9 @@ func (u *User) APIFormat() *api.User { | |||
| } | |||
| } | |||
| // returns true if user login type is LOGIN_PLAIN. | |||
| // returns true if user login type is LoginPlain. | |||
| func (u *User) IsLocal() bool { | |||
| return u.LoginType <= LOGIN_PLAIN | |||
| return u.LoginType <= LoginPlain | |||
| } | |||
| // HasForkedRepo checks if user has already forked a repository with given ID. | |||
| @@ -48,7 +48,7 @@ type dropdownItem struct { | |||
| var ( | |||
| authSources = []dropdownItem{ | |||
| {models.LoginNames[models.LOGIN_LDAP], models.LOGIN_LDAP}, | |||
| {models.LoginNames[models.LoginLdap], models.LoginLdap}, | |||
| {models.LoginNames[models.LOGIN_DLDAP], models.LOGIN_DLDAP}, | |||
| {models.LoginNames[models.LOGIN_SMTP], models.LOGIN_SMTP}, | |||
| {models.LoginNames[models.LOGIN_PAM], models.LOGIN_PAM}, | |||
| @@ -65,8 +65,8 @@ func NewAuthSource(ctx *context.Context) { | |||
| ctx.Data["PageIsAdmin"] = true | |||
| ctx.Data["PageIsAdminAuthentications"] = true | |||
| ctx.Data["type"] = models.LOGIN_LDAP | |||
| ctx.Data["CurrentTypeName"] = models.LoginNames[models.LOGIN_LDAP] | |||
| ctx.Data["type"] = models.LoginLdap | |||
| ctx.Data["CurrentTypeName"] = models.LoginNames[models.LoginLdap] | |||
| ctx.Data["CurrentSecurityProtocol"] = models.SecurityProtocolNames[ldap.SECURITY_PROTOCOL_UNENCRYPTED] | |||
| ctx.Data["smtp_auth"] = "PLAIN" | |||
| ctx.Data["is_active"] = true | |||
| @@ -125,7 +125,7 @@ func NewAuthSourcePost(ctx *context.Context, form auth.AuthenticationForm) { | |||
| hasTLS := false | |||
| var config core.Conversion | |||
| switch models.LoginType(form.Type) { | |||
| case models.LOGIN_LDAP, models.LOGIN_DLDAP: | |||
| case models.LoginLdap, models.LOGIN_DLDAP: | |||
| config = parseLDAPConfig(form) | |||
| hasTLS = ldap.SecurityProtocol(form.SecurityProtocol) > ldap.SECURITY_PROTOCOL_UNENCRYPTED | |||
| case models.LOGIN_SMTP: | |||
| @@ -208,7 +208,7 @@ func EditAuthSourcePost(ctx *context.Context, form auth.AuthenticationForm) { | |||
| var config core.Conversion | |||
| switch models.LoginType(form.Type) { | |||
| case models.LOGIN_LDAP, models.LOGIN_DLDAP: | |||
| case models.LoginLdap, models.LOGIN_DLDAP: | |||
| config = parseLDAPConfig(form) | |||
| case models.LOGIN_SMTP: | |||
| config = parseSMTPConfig(form) | |||
| @@ -81,7 +81,7 @@ func NewUserPost(ctx *context.Context, form auth.AdminCrateUserForm) { | |||
| Email: form.Email, | |||
| Passwd: form.Password, | |||
| IsActive: true, | |||
| LoginType: models.LOGIN_PLAIN, | |||
| LoginType: models.LoginPlain, | |||
| } | |||
| if len(form.LoginType) > 0 { | |||
| @@ -42,7 +42,7 @@ func CreateUser(ctx *context.APIContext, form api.CreateUserOption) { | |||
| Email: form.Email, | |||
| Passwd: form.Password, | |||
| IsActive: true, | |||
| LoginType: models.LOGIN_PLAIN, | |||
| LoginType: models.LoginPlain, | |||
| } | |||
| parseLoginSource(ctx, u, form.SourceID, form.LoginName) | |||
| @@ -68,7 +68,7 @@ func EditIssueComment(ctx *context.APIContext, form api.EditIssueCommentOption) | |||
| if !ctx.IsSigned || (ctx.User.ID != comment.PosterID && !ctx.Repo.IsAdmin()) { | |||
| ctx.Status(403) | |||
| return | |||
| } else if comment.Type != models.COMMENT_TYPE_COMMENT { | |||
| } else if comment.Type != models.CommentTypeComment { | |||
| ctx.Status(204) | |||
| return | |||
| } | |||
| @@ -599,7 +599,7 @@ func ViewIssue(ctx *context.Context) { | |||
| // Render comments and and fetch participants. | |||
| participants[0] = issue.Poster | |||
| for _, comment = range issue.Comments { | |||
| if comment.Type == models.COMMENT_TYPE_COMMENT { | |||
| if comment.Type == models.CommentTypeComment { | |||
| comment.RenderedContent = string(markdown.Render([]byte(comment.Content), ctx.Repo.RepoLink, | |||
| ctx.Repo.Repository.ComposeMetas())) | |||
| @@ -614,9 +614,9 @@ func ViewIssue(ctx *context.Context) { | |||
| (repo.Owner.IsOrganization() && repo.Owner.IsOwnedBy(comment.PosterID)) { | |||
| comment.ShowTag = models.COMMENT_TAG_OWNER | |||
| } else if comment.Poster.IsWriterOfRepo(repo) { | |||
| comment.ShowTag = models.COMMENT_TAG_WRITER | |||
| comment.ShowTag = models.CommentTagWriter | |||
| } else if comment.PosterID == issue.PosterID { | |||
| comment.ShowTag = models.COMMENT_TAG_POSTER | |||
| comment.ShowTag = models.CommentTagPoster | |||
| } | |||
| marked[comment.PosterID] = comment.ShowTag | |||
| @@ -892,7 +892,7 @@ func UpdateCommentContent(ctx *context.Context) { | |||
| if !ctx.IsSigned || (ctx.User.ID != comment.PosterID && !ctx.Repo.IsAdmin()) { | |||
| ctx.Error(403) | |||
| return | |||
| } else if comment.Type != models.COMMENT_TYPE_COMMENT { | |||
| } else if comment.Type != models.CommentTypeComment { | |||
| ctx.Error(204) | |||
| return | |||
| } | |||
| @@ -924,7 +924,7 @@ func DeleteComment(ctx *context.Context) { | |||
| if !ctx.IsSigned || (ctx.User.ID != comment.PosterID && !ctx.Repo.IsAdmin()) { | |||
| ctx.Error(403) | |||
| return | |||
| } else if comment.Type != models.COMMENT_TYPE_COMMENT { | |||
| } else if comment.Type != models.CommentTypeComment { | |||
| ctx.Error(204) | |||
| return | |||
| } | |||