diff --git a/langs/english.json b/langs/english.json index 09b3acf5..c4ea46e8 100644 --- a/langs/english.json +++ b/langs/english.json @@ -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 %s was modified by %s", + "panel_logs_administration_action_group_create":"Group %s was created by %s", + "panel_logs_administration_action_group_edit":"Group %s was modified by %s", + "panel_logs_administration_action_group_promotion_create":"A group promotion was created by %s", + "panel_logs_administration_action_group_promotion_delete":"A group promotion was deleted by %s", "panel_logs_administration_action_unknown":"Unknown action '%s' on elementType '%s' by %s", "panel_logs_administration_no_logs":"There aren't any events logged.", diff --git a/routes/panel/groups.go b/routes/panel/groups.go index 3aee3c4f..e1709097 100644 --- a/routes/panel/groups.go +++ b/routes/panel/groups.go @@ -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 } diff --git a/routes/panel/logs.go b/routes/panel/logs.go index 9313828d..c8003ab9 100644 --- a/routes/panel/logs.go +++ b/routes/panel/logs.go @@ -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) diff --git a/routes/panel/users.go b/routes/panel/users.go index bac4225c..97a1d821 100644 --- a/routes/panel/users.go +++ b/routes/panel/users.go @@ -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" diff --git a/templates/panel_group_edit.html b/templates/panel_group_edit.html index c084da6b..b994458b 100644 --- a/templates/panel_group_edit.html +++ b/templates/panel_group_edit.html @@ -10,13 +10,13 @@