Localised the errors in /routes/panel/groups.go

Fixed a typo in a group manager phrase.
This commit is contained in:
Azareal 2018-10-03 20:10:55 +10:00
parent f6ab754743
commit b02175d7ae
2 changed files with 19 additions and 11 deletions

View File

@ -98,8 +98,16 @@
"register_username_too_long_prefix":"The username is too long, max: ", "register_username_too_long_prefix":"The username is too long, max: ",
"register_email_fail":"We were unable to send the email for you to confirm that this email address belongs to you. You may not have access to some functionality until you do so. Please ask an administrator for assistance.", "register_email_fail":"We were unable to send the email for you to confirm that this email address belongs to you. You may not have access to some functionality until you do so. Please ask an administrator for assistance.",
"panel_groups_need_name":"The group name can't be left blank.",
"panel_groups_cannot_edit_admin":"You need the EditGroupAdmin permission to edit an admin group.", "panel_groups_cannot_edit_admin":"You need the EditGroupAdmin permission to edit an admin group.",
"panel_groups_cannot_edit_supermod":"You need the EditGroupSuperMod permission to edit a super-mod group." "panel_groups_cannot_edit_supermod":"You need the EditGroupSuperMod permission to edit a super-mod group.",
"panel_groups_cannot_edit_group_type":"You need the EditGroupGlobalPerms permission to change the group type.",
"panel_groups_edit_cannot_designate_admin":"You need the EditGroupAdmin permission to designate this group as an admin group.",
"panel_groups_edit_cannot_designate_supermod":"You need the EditGroupSuperMod permission to designate this group as a super-mod group.",
"panel_groups_create_cannot_designate_admin":"You need the EditGroupAdmin permission to create admin groups",
"panel_groups_create_cannot_designate_supermod":"You need the EditGroupSuperMod permission to create super-mod groups",
"panel_groups_cannot_be_guest":"You can't designate a group as a guest group.",
"panel_groups_invalid_group_type":"Invalid group type."
}, },
"PageTitles": { "PageTitles": {

View File

@ -223,7 +223,7 @@ func GroupsEditSubmit(w http.ResponseWriter, r *http.Request, user common.User,
gname := r.FormValue("group-name") gname := r.FormValue("group-name")
if gname == "" { if gname == "" {
return common.LocalError("The group name can't be left blank.", w, r, user) return common.LocalError(common.GetErrorPhrase("panel_groups_need_name"), w, r, user)
} }
gtag := r.FormValue("group-tag") gtag := r.FormValue("group-tag")
rank := r.FormValue("group-type") rank := r.FormValue("group-type")
@ -242,30 +242,30 @@ func GroupsEditSubmit(w http.ResponseWriter, r *http.Request, user common.User,
originalRank = "Member" originalRank = "Member"
} }
if rank != originalRank { if rank != originalRank && originalRank != "Guest" {
if !user.Perms.EditGroupGlobalPerms { if !user.Perms.EditGroupGlobalPerms {
return common.LocalError("You need the EditGroupGlobalPerms permission to change the group type.", w, r, user) return common.LocalError(common.GetErrorPhrase("panel_groups_cannot_edit_group_type"), w, r, user)
} }
switch rank { switch rank {
case "Admin": case "Admin":
if !user.Perms.EditGroupAdmin { if !user.Perms.EditGroupAdmin {
return common.LocalError("You need the EditGroupAdmin permission to designate this group as an admin group.", w, r, user) return common.LocalError(common.GetErrorPhrase("panel_groups_edit_cannot_designate_admin"), w, r, user)
} }
err = group.ChangeRank(true, true, false) err = group.ChangeRank(true, true, false)
case "Mod": case "Mod":
if !user.Perms.EditGroupSuperMod { if !user.Perms.EditGroupSuperMod {
return common.LocalError("You need the EditGroupSuperMod permission to designate this group as a super-mod group.", w, r, user) return common.LocalError(common.GetErrorPhrase("panel_groups_edit_cannot_designate_supermod"), w, r, user)
} }
err = group.ChangeRank(false, true, false) err = group.ChangeRank(false, true, false)
case "Banned": case "Banned":
err = group.ChangeRank(false, false, true) err = group.ChangeRank(false, false, true)
case "Guest": case "Guest":
return common.LocalError("You can't designate a group as a guest group.", w, r, user) return common.LocalError(common.GetErrorPhrase("panel_groups_cannot_be_guest"), w, r, user)
case "Member": case "Member":
err = group.ChangeRank(false, false, false) err = group.ChangeRank(false, false, false)
default: default:
return common.LocalError("Invalid group type.", w, r, user) return common.LocalError(common.GetErrorPhrase("panel_groups_invalid_group_type"), w, r, user)
} }
if err != nil { if err != nil {
return common.InternalError(err, w, r) return common.InternalError(err, w, r)
@ -348,7 +348,7 @@ func GroupsCreateSubmit(w http.ResponseWriter, r *http.Request, user common.User
groupName := r.PostFormValue("group-name") groupName := r.PostFormValue("group-name")
if groupName == "" { if groupName == "" {
return common.LocalError("You need a name for this group!", w, r, user) return common.LocalError(common.GetErrorPhrase("panel_groups_need_name"), w, r, user)
} }
groupTag := r.PostFormValue("group-tag") groupTag := r.PostFormValue("group-tag")
@ -357,13 +357,13 @@ func GroupsCreateSubmit(w http.ResponseWriter, r *http.Request, user common.User
groupType := r.PostFormValue("group-type") groupType := r.PostFormValue("group-type")
if groupType == "Admin" { if groupType == "Admin" {
if !user.Perms.EditGroupAdmin { if !user.Perms.EditGroupAdmin {
return common.LocalError("You need the EditGroupAdmin permission to create admin groups", w, r, user) return common.LocalError(common.GetErrorPhrase("panel_groups_create_cannot_designate_admin"), w, r, user)
} }
isAdmin = true isAdmin = true
isMod = true isMod = true
} else if groupType == "Mod" { } else if groupType == "Mod" {
if !user.Perms.EditGroupSuperMod { if !user.Perms.EditGroupSuperMod {
return common.LocalError("You need the EditGroupSuperMod permission to create admin groups", w, r, user) return common.LocalError(common.GetErrorPhrase("panel_groups_create_cannot_designate_supermod"), w, r, user)
} }
isMod = true isMod = true
} else if groupType == "Banned" { } else if groupType == "Banned" {