diff --git a/common/promotions.go b/common/promotions.go index 38d29b83..94b3465b 100644 --- a/common/promotions.go +++ b/common/promotions.go @@ -45,7 +45,7 @@ func NewDefaultGroupPromotionStore(acc *qgen.Accumulator) (*DefaultGroupPromotio delete: acc.Delete(ugp).Where("pid = ?").Prepare(), create: acc.Insert(ugp).Columns("from_gid, to_gid, two_way, level, posts, minTime").Fields("?,?,?,?,?,?").Prepare(), - getByUser: acc.Select(ugp).Columns("pid, to_gid, two_way, level, posts, minTime").Where("from_gid=? AND level>=? AND posts>=?").Orderby("level DESC").Limit("1").Prepare(), + getByUser: acc.Select(ugp).Columns("pid, to_gid, two_way, level, posts, minTime").Where("from_gid=? AND level<=? AND posts<=?").Orderby("level DESC").Limit("1").Prepare(), updateUser: acc.Update("users").Set("group = ?").Where("level >= ? AND posts >= ?").Prepare(), }, acc.FirstError() } diff --git a/langs/english.json b/langs/english.json index 539da022..37d7b4e2 100644 --- a/langs/english.json +++ b/langs/english.json @@ -884,6 +884,9 @@ "panel_group_update_button":"Update Group", "panel_group_extended_permissions":"Extended Permissions", + "panel_group_promotions_level_prefix":"level ", + "panel_group_promotions_posts_prefix":"posts ", + "panel_group_promotions_delete_button":"Delete", "panel_group_promotions_create_head":"Add Promotion", "panel_group_promotions_from":"From", "panel_group_promotions_to":"To", diff --git a/routes/panel/groups.go b/routes/panel/groups.go index 75898536..4b69798d 100644 --- a/routes/panel/groups.go +++ b/routes/panel/groups.go @@ -197,11 +197,13 @@ func GroupsPromotionsCreateSubmit(w http.ResponseWriter, r *http.Request, user c if err != nil { return c.LocalError("from must be integer", w, r, user) } - to, err := strconv.Atoi(r.FormValue("to")) if err != nil { return c.LocalError("to must be integer", w, r, user) } + if from == to { + return c.LocalError("the from group and to group cannot be the same",w,r,user) + } twoWay := r.FormValue("two-way") == "1" level, err := strconv.Atoi(r.FormValue("level")) diff --git a/routes/panel/word_filters.go b/routes/panel/word_filters.go index dcd2746c..6be12bc7 100644 --- a/routes/panel/word_filters.go +++ b/routes/panel/word_filters.go @@ -19,12 +19,12 @@ func WordFilters(w http.ResponseWriter, r *http.Request, user c.User) c.RouteErr } // TODO: What if this list gets too long? - filterList, err := c.WordFilters.GetAll() + filters, err := c.WordFilters.GetAll() if err != nil { return c.InternalError(err, w, r) } - pi := c.PanelPage{basePage, tList, filterList} + pi := c.PanelPage{basePage, tList, filters} return renderTemplate("panel", w, r, basePage.Header, c.Panel{basePage, "", "", "panel_word_filters", &pi}) } @@ -36,7 +36,7 @@ func WordFiltersCreateSubmit(w http.ResponseWriter, r *http.Request, user c.User if !user.Perms.EditSettings { return c.NoPermissions(w, r, user) } - js := (r.PostFormValue("js") == "1") + js := r.PostFormValue("js") == "1" // ? - We're not doing a full sanitise here, as it would be useful if admins were able to put down rules for replacing things with HTML, etc. find := strings.TrimSpace(r.PostFormValue("find")) @@ -45,7 +45,7 @@ func WordFiltersCreateSubmit(w http.ResponseWriter, r *http.Request, user c.User } // Unlike with find, it's okay if we leave this blank, as this means that the admin wants to remove the word entirely with no replacement - replace := strings.TrimSpace(r.PostFormValue("replacement")) + replace := strings.TrimSpace(r.PostFormValue("replace")) err := c.WordFilters.Create(find, replace) if err != nil { @@ -75,7 +75,7 @@ func WordFiltersEditSubmit(w http.ResponseWriter, r *http.Request, user c.User, if ferr != nil { return ferr } - js := (r.PostFormValue("js") == "1") + js := r.PostFormValue("js") == "1" if !user.Perms.EditSettings { return c.NoPermissionsJSQ(w, r, user, js) } @@ -90,7 +90,7 @@ func WordFiltersEditSubmit(w http.ResponseWriter, r *http.Request, user c.User, return c.LocalErrorJSQ("You need to specify what word you want to match", w, r, user, js) } // Unlike with find, it's okay if we leave this blank, as this means that the admin wants to remove the word entirely with no replacement - replace := strings.TrimSpace(r.PostFormValue("replacement")) + replace := strings.TrimSpace(r.PostFormValue("replace")) err = c.WordFilters.Update(id, find, replace) if err != nil { diff --git a/templates/panel_group_edit_promotions.html b/templates/panel_group_edit_promotions.html index 8c25103a..7135dd16 100644 --- a/templates/panel_group_edit_promotions.html +++ b/templates/panel_group_edit_promotions.html @@ -11,9 +11,10 @@ {{range .Promotions}}