Adminlogs: More user edit logs, groups, and group promotions.
Shorten the group form field names. Add group_unknown phrase. Add panel_logs_administration_action_group_create phrase. Add panel_logs_administration_action_group_edit phrase. Add panel_logs_administration_action_group_promotion_create phrase. Add panel_logs_administration_action_group_promotion_delete phrase.
This commit is contained in:
parent
6e8c241d8b
commit
20984f7ea3
|
@ -1019,9 +1019,14 @@
|
|||
|
||||
"user_unknown":"Unknown",
|
||||
"topic_unknown":"Unknown",
|
||||
"group_unknown":"Unknown",
|
||||
|
||||
"panel_logs_administration_head":"Admin Action Logs",
|
||||
"panel_logs_administration_action_user_edit":"User <a href='%s'>%s</a> was modified by <a href='%s'>%s</a>",
|
||||
"panel_logs_administration_action_group_create":"Group <a href='%s'>%s</a> was created by <a href='%s'>%s</a>",
|
||||
"panel_logs_administration_action_group_edit":"Group <a href='%s'>%s</a> was modified by <a href='%s'>%s</a>",
|
||||
"panel_logs_administration_action_group_promotion_create":"A group promotion was created by <a href='%s'>%s</a>",
|
||||
"panel_logs_administration_action_group_promotion_delete":"A group promotion was deleted by <a href='%s'>%s</a>",
|
||||
"panel_logs_administration_action_unknown":"Unknown action '%s' on elementType '%s' by <a href='%s'>%s</a>",
|
||||
"panel_logs_administration_no_logs":"There aren't any events logged.",
|
||||
|
||||
|
|
|
@ -225,7 +225,11 @@ func GroupsPromotionsCreateSubmit(w http.ResponseWriter, r *http.Request, user c
|
|||
if err != nil {
|
||||
return ferr
|
||||
}
|
||||
_, err = c.GroupPromotions.Create(from, to, twoWay, level, posts)
|
||||
pid, err := c.GroupPromotions.Create(from, to, twoWay, level, posts)
|
||||
if err != nil {
|
||||
return c.InternalError(err, w, r)
|
||||
}
|
||||
err = c.AdminLogs.Create("create", pid, "group_promotion", user.LastIP, user.ID)
|
||||
if err != nil {
|
||||
return c.InternalError(err, w, r)
|
||||
}
|
||||
|
@ -272,6 +276,10 @@ func GroupsPromotionsDeleteSubmit(w http.ResponseWriter, r *http.Request, user c
|
|||
if err != nil {
|
||||
return c.InternalError(err, w, r)
|
||||
}
|
||||
err = c.AdminLogs.Create("delete", pid, "group_promotion", user.LastIP, user.ID)
|
||||
if err != nil {
|
||||
return c.InternalError(err, w, r)
|
||||
}
|
||||
|
||||
http.Redirect(w, r, "/panel/groups/edit/promotions/"+strconv.Itoa(gid), http.StatusSeeOther)
|
||||
return nil
|
||||
|
@ -378,12 +386,12 @@ func GroupsEditSubmit(w http.ResponseWriter, r *http.Request, user c.User, sgid
|
|||
return ferr
|
||||
}
|
||||
|
||||
gname := r.FormValue("group-name")
|
||||
gname := r.FormValue("name")
|
||||
if gname == "" {
|
||||
return c.LocalError(p.GetErrorPhrase("panel_groups_need_name"), w, r, user)
|
||||
}
|
||||
gtag := r.FormValue("group-tag")
|
||||
rank := r.FormValue("group-type")
|
||||
gtag := r.FormValue("tag")
|
||||
rank := r.FormValue("type")
|
||||
|
||||
var originalRank string
|
||||
// TODO: Use a switch for this
|
||||
|
@ -403,7 +411,6 @@ func GroupsEditSubmit(w http.ResponseWriter, r *http.Request, user c.User, sgid
|
|||
if !user.Perms.EditGroupGlobalPerms {
|
||||
return c.LocalError(p.GetErrorPhrase("panel_groups_cannot_edit_group_type"), w, r, user)
|
||||
}
|
||||
|
||||
switch rank {
|
||||
case "Admin":
|
||||
if !user.Perms.EditGroupAdmin {
|
||||
|
@ -433,6 +440,10 @@ func GroupsEditSubmit(w http.ResponseWriter, r *http.Request, user c.User, sgid
|
|||
if err != nil {
|
||||
return c.InternalError(err, w, r)
|
||||
}
|
||||
err = c.AdminLogs.Create("edit", group.ID, "group", user.LastIP, user.ID)
|
||||
if err != nil {
|
||||
return c.InternalError(err, w, r)
|
||||
}
|
||||
|
||||
http.Redirect(w, r, "/panel/groups/edit/"+strconv.Itoa(gid), http.StatusSeeOther)
|
||||
return nil
|
||||
|
@ -466,7 +477,7 @@ func GroupsEditPermsSubmit(w http.ResponseWriter, r *http.Request, user c.User,
|
|||
pCheck := func(hasPerm bool, perms []string) {
|
||||
if hasPerm {
|
||||
for _, perm := range perms {
|
||||
pvalue := r.PostFormValue("group-perm-" + perm)
|
||||
pvalue := r.PostFormValue("perm-" + perm)
|
||||
pmap[perm] = (pvalue == "1")
|
||||
}
|
||||
}
|
||||
|
@ -478,6 +489,10 @@ func GroupsEditPermsSubmit(w http.ResponseWriter, r *http.Request, user c.User,
|
|||
if err != nil {
|
||||
return c.InternalError(err, w, r)
|
||||
}
|
||||
err = c.AdminLogs.Create("edit", group.ID, "group", user.LastIP, user.ID)
|
||||
if err != nil {
|
||||
return c.InternalError(err, w, r)
|
||||
}
|
||||
|
||||
http.Redirect(w, r, "/panel/groups/edit/perms/"+strconv.Itoa(gid), http.StatusSeeOther)
|
||||
return nil
|
||||
|
@ -492,15 +507,15 @@ func GroupsCreateSubmit(w http.ResponseWriter, r *http.Request, user c.User) c.R
|
|||
return c.NoPermissions(w, r, user)
|
||||
}
|
||||
|
||||
groupName := r.PostFormValue("group-name")
|
||||
groupName := r.PostFormValue("name")
|
||||
if groupName == "" {
|
||||
return c.LocalError(p.GetErrorPhrase("panel_groups_need_name"), w, r, user)
|
||||
}
|
||||
groupTag := r.PostFormValue("group-tag")
|
||||
groupTag := r.PostFormValue("tag")
|
||||
|
||||
var isAdmin, isMod, isBanned bool
|
||||
if user.Perms.EditGroupGlobalPerms {
|
||||
switch r.PostFormValue("group-type") {
|
||||
switch r.PostFormValue("type") {
|
||||
case "Admin":
|
||||
if !user.Perms.EditGroupAdmin {
|
||||
return c.LocalError(p.GetErrorPhrase("panel_groups_create_cannot_designate_admin"), w, r, user)
|
||||
|
@ -521,6 +536,11 @@ func GroupsCreateSubmit(w http.ResponseWriter, r *http.Request, user c.User) c.R
|
|||
if err != nil {
|
||||
return c.InternalError(err, w, r)
|
||||
}
|
||||
err = c.AdminLogs.Create("create", gid, "group", user.LastIP, user.ID)
|
||||
if err != nil {
|
||||
return c.InternalError(err, w, r)
|
||||
}
|
||||
|
||||
http.Redirect(w, r, "/panel/groups/edit/"+strconv.Itoa(gid), http.StatusSeeOther)
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -106,6 +106,14 @@ func adminlogsElementType(action string, elementType string, elementID int, acto
|
|||
case "user":
|
||||
targetUser := handleUnknownUser(c.Users.Get(elementID))
|
||||
out = p.GetTmplPhrasef("panel_logs_administration_action_user_"+action, targetUser.Link, targetUser.Name, actor.Link, actor.Name)
|
||||
case "group":
|
||||
g, err := c.Groups.Get(elementID)
|
||||
if err != nil {
|
||||
g = &c.Group{Name: p.GetTmplPhrase("group_unknown")}
|
||||
}
|
||||
out = p.GetTmplPhrasef("panel_logs_administration_action_group_"+action, "/panel/groups/edit/"+strconv.Itoa(g.ID), g.Name, actor.Link, actor.Name)
|
||||
case "group_promotion":
|
||||
out = p.GetTmplPhrasef("panel_logs_administration_action_group_promotion_"+action, actor.Link, actor.Name)
|
||||
}
|
||||
if out == "" {
|
||||
out = p.GetTmplPhrasef("panel_logs_administration_action_unknown", action, elementType, actor.Link, actor.Name)
|
||||
|
|
|
@ -209,6 +209,11 @@ func UsersAvatarSubmit(w http.ResponseWriter, r *http.Request, user c.User, suid
|
|||
return c.InternalError(err, w, r)
|
||||
}
|
||||
|
||||
err = c.AdminLogs.Create("edit", targetUser.ID, "user", user.LastIP, user.ID)
|
||||
if err != nil {
|
||||
return c.InternalError(err, w, r)
|
||||
}
|
||||
|
||||
var se string
|
||||
if r.PostFormValue("show-email") == "1" {
|
||||
se = "&show-email=1"
|
||||
|
@ -244,6 +249,11 @@ func UsersAvatarRemoveSubmit(w http.ResponseWriter, r *http.Request, user c.User
|
|||
return ferr
|
||||
}
|
||||
|
||||
err = c.AdminLogs.Create("edit", targetUser.ID, "user", user.LastIP, user.ID)
|
||||
if err != nil {
|
||||
return c.InternalError(err, w, r)
|
||||
}
|
||||
|
||||
var se string
|
||||
if r.PostFormValue("show-email") == "1" {
|
||||
se = "&show-email=1"
|
||||
|
|
|
@ -10,13 +10,13 @@
|
|||
<form action="/panel/groups/edit/submit/{{.ID}}?s={{.CurrentUser.Session}}" method="post">
|
||||
<div class="formrow">
|
||||
<div class="formitem formlabel"><a>{{lang "panel_group_name"}}</a></div>
|
||||
<div class="formitem"><input name="group-name" type="text" value="{{.Name}}" placeholder="{{lang "panel_group_name_placeholder"}}" /></div>
|
||||
<div class="formitem"><input name="name" type="text" value="{{.Name}}" placeholder="{{lang "panel_group_name_placeholder"}}" /></div>
|
||||
</div>
|
||||
{{if .CurrentUser.Perms.EditGroup}}
|
||||
<div class="formrow">
|
||||
<div class="formitem formlabel"><a>{{lang "panel_group_type"}}</a></div>
|
||||
<div class="formitem">
|
||||
<select name="group-type"{{if .DisableRank}} disabled{{end}}>
|
||||
<select name="type"{{if .DisableRank}} disabled{{end}}>
|
||||
<option value="Guest"{{if eq .Rank "Guest"}} selected{{end}} disabled>{{lang "panel_groups_rank_guest"}}</option>
|
||||
<option value="Member"{{if eq .Rank "Member"}} selected{{end}}>{{lang "panel_groups_rank_member"}}</option>
|
||||
<option value="Mod"{{if eq .Rank "Mod"}} selected{{end}}{{if not .CurrentUser.Perms.EditGroupSuperMod}} disabled{{end}}>{{lang "panel_groups_rank_mod"}}</option>
|
||||
|
@ -27,7 +27,7 @@
|
|||
</div>{{end}}
|
||||
<div class="formrow">
|
||||
<div class="formitem formlabel"><a>{{lang "panel_group_tag"}}</a></div>
|
||||
<div class="formitem"><input name="group-tag" type="text" value="{{.Tag}}" placeholder="{{lang "panel_group_tag_placeholder"}}" /></div>
|
||||
<div class="formitem"><input name="tag" type="text" value="{{.Tag}}" placeholder="{{lang "panel_group_tag_placeholder"}}" /></div>
|
||||
</div>
|
||||
<div class="formrow form_button_row">
|
||||
<div class="formitem"><button name="panel-button" class="formbutton">{{lang "panel_group_update_button"}}</button></div>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<div class="formitem">
|
||||
<a>{{.LangStr}}</a>
|
||||
<div class="to_right">
|
||||
<select name="group-perm-{{.Name}}">
|
||||
<select name="perm-{{.Name}}">
|
||||
<option{{if .Toggle}} selected{{end}} value=1>{{lang "option_yes"}}</option>
|
||||
<option{{if not .Toggle}} selected{{end}} value=0>{{lang "option_no"}}</option>
|
||||
</select>
|
||||
|
@ -37,7 +37,7 @@
|
|||
<div class="formitem">
|
||||
<a>{{.LangStr}}</a>
|
||||
<div class="to_right">
|
||||
<select name="group-perm-{{.Name}}">
|
||||
<select name="perm-{{.Name}}">
|
||||
<option{{if .Toggle}} selected{{end}} value=1>{{lang "option_yes"}}</option>
|
||||
<option{{if not .Toggle}} selected{{end}} value=0>{{lang "option_no"}}</option>
|
||||
</select>
|
||||
|
|
|
@ -24,12 +24,12 @@
|
|||
<form action="/panel/groups/create/?s={{.CurrentUser.Session}}" method="post">
|
||||
<div class="formrow">
|
||||
<div class="formitem formlabel"><a>{{lang "panel_groups_create_name"}}</a></div>
|
||||
<div class="formitem"><input name="group-name" type="text" placeholder="{{lang "panel_groups_create_name_placeholder"}}" /></div>
|
||||
<div class="formitem"><input name="name" type="text" placeholder="{{lang "panel_groups_create_name_placeholder"}}" /></div>
|
||||
</div>
|
||||
<div class="formrow">
|
||||
<div class="formitem formlabel"><a>{{lang "panel_groups_create_type"}}</a></div>
|
||||
<div class="formitem">
|
||||
<select name="group-type"{{if not .CurrentUser.Perms.EditGroupGlobalPerms}} disabled{{end}}>
|
||||
<select name="type"{{if not .CurrentUser.Perms.EditGroupGlobalPerms}} disabled{{end}}>
|
||||
<option selected>Member</option>
|
||||
<option{{if not .CurrentUser.Perms.EditGroupSuperMod}} disabled{{end}}>Mod</option>
|
||||
<option{{if not .CurrentUser.Perms.EditGroupAdmin}} disabled{{end}}>Admin</option>
|
||||
|
@ -39,7 +39,7 @@
|
|||
</div>
|
||||
<div class="formrow">
|
||||
<div class="formitem formlabel"><a>{{lang "panel_groups_create_tag"}}</a></div>
|
||||
<div class="formitem"><input name="group-tag" type="text" /></div>
|
||||
<div class="formitem"><input name="tag" type="text" /></div>
|
||||
</div>
|
||||
<div class="formrow form_button_row">
|
||||
<div class="formitem"><button name="panel-button" class="formbutton">{{lang "panel_groups_create_button"}}</button></div>
|
||||
|
|
Loading…
Reference in New Issue