add AutoLink permission
eliminate pointless arithmetic in the parser possible fix for creating group promotions add AutoLink phrase
This commit is contained in:
parent
de2221f243
commit
f2adb7dfac
|
@ -127,6 +127,7 @@ func seedTables(a qgen.Adapter) error {
|
||||||
UseConvosOnlyWithMod
|
UseConvosOnlyWithMod
|
||||||
CreateProfileReply
|
CreateProfileReply
|
||||||
AutoEmbed
|
AutoEmbed
|
||||||
|
AutoLink
|
||||||
// CreateConvo ?
|
// CreateConvo ?
|
||||||
// CreateConvoReply ?
|
// CreateConvoReply ?
|
||||||
|
|
||||||
|
@ -144,7 +145,7 @@ func seedTables(a qgen.Adapter) error {
|
||||||
MoveTopic
|
MoveTopic
|
||||||
*/
|
*/
|
||||||
|
|
||||||
p := func(perms c.Perms) string {
|
p := func(perms *c.Perms) string {
|
||||||
jBytes, err := json.Marshal(perms)
|
jBytes, err := json.Marshal(perms)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
@ -162,7 +163,7 @@ func seedTables(a qgen.Adapter) error {
|
||||||
if banned {
|
if banned {
|
||||||
bi = "1"
|
bi = "1"
|
||||||
}
|
}
|
||||||
qgen.Install.SimpleInsert("users_groups", "name, permissions, plugin_perms, is_mod, is_admin, is_banned, tag", `'`+name+`','`+p(perms)+`','{}',`+mi+`,`+ai+`,`+bi+`,"`+tag+`"`)
|
qgen.Install.SimpleInsert("users_groups", "name, permissions, plugin_perms, is_mod, is_admin, is_banned, tag", `'`+name+`','`+p(&perms)+`','{}',`+mi+`,`+ai+`,`+bi+`,"`+tag+`"`)
|
||||||
}
|
}
|
||||||
|
|
||||||
perms := c.AllPerms
|
perms := c.AllPerms
|
||||||
|
@ -170,10 +171,10 @@ func seedTables(a qgen.Adapter) error {
|
||||||
perms.EditGroupAdmin = false
|
perms.EditGroupAdmin = false
|
||||||
addGroup("Administrator", perms, true, true, false, "Admin")
|
addGroup("Administrator", perms, true, true, false, "Admin")
|
||||||
|
|
||||||
perms = c.Perms{BanUsers: true, ActivateUsers: true, EditUser: true, EditUserEmail: false, EditUserGroup: true, ViewIPs: true, UploadFiles: true, UploadAvatars: true, UseConvos: true, UseConvosOnlyWithMod: true, CreateProfileReply: true, AutoEmbed: true, ViewTopic: true, LikeItem: true, CreateTopic: true, EditTopic: true, DeleteTopic: true, CreateReply: true, EditReply: true, DeleteReply: true, PinTopic: true, CloseTopic: true, MoveTopic: true}
|
perms = c.Perms{BanUsers: true, ActivateUsers: true, EditUser: true, EditUserEmail: false, EditUserGroup: true, ViewIPs: true, UploadFiles: true, UploadAvatars: true, UseConvos: true, UseConvosOnlyWithMod: true, CreateProfileReply: true, AutoEmbed: true, AutoLink: true, ViewTopic: true, LikeItem: true, CreateTopic: true, EditTopic: true, DeleteTopic: true, CreateReply: true, EditReply: true, DeleteReply: true, PinTopic: true, CloseTopic: true, MoveTopic: true}
|
||||||
addGroup("Moderator", perms, true, false, false, "Mod")
|
addGroup("Moderator", perms, true, false, false, "Mod")
|
||||||
|
|
||||||
perms = c.Perms{UploadFiles: true, UploadAvatars: true, UseConvos: true, UseConvosOnlyWithMod: true, CreateProfileReply: true, AutoEmbed: true, ViewTopic: true, LikeItem: true, CreateTopic: true, CreateReply: true}
|
perms = c.Perms{UploadFiles: true, UploadAvatars: true, UseConvos: true, UseConvosOnlyWithMod: true, CreateProfileReply: true, AutoEmbed: true, AutoLink: true, ViewTopic: true, LikeItem: true, CreateTopic: true, CreateReply: true}
|
||||||
addGroup("Member", perms, false, false, false, "")
|
addGroup("Member", perms, false, false, false, "")
|
||||||
|
|
||||||
perms = c.Perms{ViewTopic: true}
|
perms = c.Perms{ViewTopic: true}
|
||||||
|
@ -190,6 +191,10 @@ func seedTables(a qgen.Adapter) error {
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
|
/*var addForumPerm = func(gid, fid int, permStr string) {
|
||||||
|
qgen.Install.SimpleInsert("forums_permissions", "gid, fid, permissions", strconv.Itoa(gid)+`,`+strconv.Itoa(fid)+`,'`+permStr+`'`)
|
||||||
|
}*/
|
||||||
|
|
||||||
qgen.Install.SimpleInsert("forums_permissions", "gid, fid, permissions", `1,1,'{"ViewTopic":true,"CreateReply":true,"CreateTopic":true,"PinTopic":true,"CloseTopic":true}'`)
|
qgen.Install.SimpleInsert("forums_permissions", "gid, fid, permissions", `1,1,'{"ViewTopic":true,"CreateReply":true,"CreateTopic":true,"PinTopic":true,"CloseTopic":true}'`)
|
||||||
qgen.Install.SimpleInsert("forums_permissions", "gid, fid, permissions", `2,1,'{"ViewTopic":true,"CreateReply":true,"CloseTopic":true}'`)
|
qgen.Install.SimpleInsert("forums_permissions", "gid, fid, permissions", `2,1,'{"ViewTopic":true,"CreateReply":true,"CloseTopic":true}'`)
|
||||||
qgen.Install.SimpleInsert("forums_permissions", "gid, fid, permissions", "3,1,'{}'")
|
qgen.Install.SimpleInsert("forums_permissions", "gid, fid, permissions", "3,1,'{}'")
|
||||||
|
@ -257,9 +262,6 @@ func seedTables(a qgen.Adapter) error {
|
||||||
fSet = append(fSet, "'"+table+"'")
|
fSet = append(fSet, "'"+table+"'")
|
||||||
}
|
}
|
||||||
qgen.Install.SimpleBulkInsert("tables", "name", fSet)*/
|
qgen.Install.SimpleBulkInsert("tables", "name", fSet)*/
|
||||||
/*for _, table := range tables {
|
|
||||||
qgen.Install.SimpleInsert("tables", "name", "'"+table+"'")
|
|
||||||
}*/
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -324,7 +326,7 @@ func writeDeletes(a qgen.Adapter) error {
|
||||||
|
|
||||||
//b.Delete("deleteForumPermsByForum").Table("forums_permissions").Where("fid=?").Parse()
|
//b.Delete("deleteForumPermsByForum").Table("forums_permissions").Where("fid=?").Parse()
|
||||||
|
|
||||||
b.Delete("deleteActivityStreamMatch").Table("activity_stream_matches").Where("watcher = ? AND asid = ?").Parse()
|
b.Delete("deleteActivityStreamMatch").Table("activity_stream_matches").Where("watcher=? AND asid=?").Parse()
|
||||||
//b.Delete("deleteActivityStreamMatchesByWatcher").Table("activity_stream_matches").Where("watcher=?").Parse()
|
//b.Delete("deleteActivityStreamMatchesByWatcher").Table("activity_stream_matches").Where("watcher=?").Parse()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -632,7 +632,8 @@ func ParseMessage2(msg string, sectionID int, sectionType string, settings *Pars
|
||||||
i--
|
i--
|
||||||
case 'h', 'f', 'g', '/':
|
case 'h', 'f', 'g', '/':
|
||||||
//fmt.Println("s3")
|
//fmt.Println("s3")
|
||||||
if len(msg) > i+5 && msg[i+1] == 't' && msg[i+2] == 't' && msg[i+3] == 'p' {
|
fch := msg[i+1]
|
||||||
|
if len(msg) > i+5 && fch == 't' && msg[i+2] == 't' && msg[i+3] == 'p' {
|
||||||
if len(msg) > i+6 && msg[i+4] == 's' && msg[i+5] == ':' && msg[i+6] == '/' {
|
if len(msg) > i+6 && msg[i+4] == 's' && msg[i+5] == ':' && msg[i+6] == '/' {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
} else if msg[i+4] == ':' && msg[i+5] == '/' {
|
} else if msg[i+4] == ':' && msg[i+5] == '/' {
|
||||||
|
@ -641,7 +642,6 @@ func ParseMessage2(msg string, sectionID int, sectionType string, settings *Pars
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
} else if len(msg) > i+4 {
|
} else if len(msg) > i+4 {
|
||||||
fch := msg[i+1]
|
|
||||||
if fch == 't' && msg[i+2] == 'p' && msg[i+3] == ':' && msg[i+4] == '/' {
|
if fch == 't' && msg[i+2] == 'p' && msg[i+3] == ':' && msg[i+4] == '/' {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
} else if fch == 'i' && msg[i+2] == 't' && msg[i+3] == ':' && msg[i+4] == '/' {
|
} else if fch == 'i' && msg[i+2] == 't' && msg[i+3] == ':' && msg[i+4] == '/' {
|
||||||
|
@ -651,11 +651,14 @@ func ParseMessage2(msg string, sectionID int, sectionType string, settings *Pars
|
||||||
} else {
|
} else {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
} else if msg[i+1] == '/' {
|
} else if fch == '/' {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
} else {
|
} else {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if !user.Perms.AutoLink {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
//fmt.Println("p1:",i)
|
//fmt.Println("p1:",i)
|
||||||
sb.WriteString(msg[lastItem:i])
|
sb.WriteString(msg[lastItem:i])
|
||||||
|
|
|
@ -43,6 +43,7 @@ var GlobalPermList = []string{
|
||||||
"UseConvosOnlyWithMod",
|
"UseConvosOnlyWithMod",
|
||||||
"CreateProfileReply",
|
"CreateProfileReply",
|
||||||
"AutoEmbed",
|
"AutoEmbed",
|
||||||
|
"AutoLink",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Permission Structure: ActionComponent[Subcomponent]Flag
|
// Permission Structure: ActionComponent[Subcomponent]Flag
|
||||||
|
@ -69,12 +70,13 @@ type Perms struct {
|
||||||
ViewIPs bool `json:",omitempty"`
|
ViewIPs bool `json:",omitempty"`
|
||||||
|
|
||||||
// Global non-staff permissions
|
// Global non-staff permissions
|
||||||
UploadFiles bool `json:",omitempty"`
|
UploadFiles bool `json:",omitempty"`
|
||||||
UploadAvatars bool `json:",omitempty"`
|
UploadAvatars bool `json:",omitempty"`
|
||||||
UseConvos bool `json:",omitempty"`
|
UseConvos bool `json:",omitempty"`
|
||||||
UseConvosOnlyWithMod bool `json:",omitempty"`
|
UseConvosOnlyWithMod bool `json:",omitempty"`
|
||||||
CreateProfileReply bool `json:",omitempty"`
|
CreateProfileReply bool `json:",omitempty"`
|
||||||
AutoEmbed bool `json:",omitempty"`
|
AutoEmbed bool `json:",omitempty"`
|
||||||
|
AutoLink bool `json:",omitempty"`
|
||||||
|
|
||||||
// Forum permissions
|
// Forum permissions
|
||||||
ViewTopic bool `json:",omitempty"`
|
ViewTopic bool `json:",omitempty"`
|
||||||
|
@ -128,12 +130,13 @@ func init() {
|
||||||
ViewAdminLogs: true,
|
ViewAdminLogs: true,
|
||||||
ViewIPs: true,
|
ViewIPs: true,
|
||||||
|
|
||||||
UploadFiles: true,
|
UploadFiles: true,
|
||||||
UploadAvatars: true,
|
UploadAvatars: true,
|
||||||
UseConvos: true,
|
UseConvos: true,
|
||||||
UseConvosOnlyWithMod: true,
|
UseConvosOnlyWithMod: true,
|
||||||
CreateProfileReply: true,
|
CreateProfileReply: true,
|
||||||
AutoEmbed: true,
|
AutoEmbed: true,
|
||||||
|
AutoLink: true,
|
||||||
|
|
||||||
ViewTopic: true,
|
ViewTopic: true,
|
||||||
LikeItem: true,
|
LikeItem: true,
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
"UseConvosOnlyWithMod":"Can use conversations only to contact global mods",
|
"UseConvosOnlyWithMod":"Can use conversations only to contact global mods",
|
||||||
"CreateProfileReply": "Can create profile replies",
|
"CreateProfileReply": "Can create profile replies",
|
||||||
"AutoEmbed":"Automatically embed media they post",
|
"AutoEmbed":"Automatically embed media they post",
|
||||||
|
"AutoLink":"Linkify their links",
|
||||||
|
|
||||||
"ViewTopic": "Can view topics",
|
"ViewTopic": "Can view topics",
|
||||||
"LikeItem": "Can like items",
|
"LikeItem": "Can like items",
|
||||||
|
|
|
@ -183,58 +183,58 @@ func groupCheck(w http.ResponseWriter, r *http.Request, u *c.User, g *c.Group, e
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GroupsPromotionsCreateSubmit(w http.ResponseWriter, r *http.Request, user *c.User, sgid string) c.RouteError {
|
func GroupsPromotionsCreateSubmit(w http.ResponseWriter, r *http.Request, u *c.User, sgid string) c.RouteError {
|
||||||
if !user.Perms.EditGroup {
|
if !u.Perms.EditGroup {
|
||||||
return c.NoPermissions(w, r, user)
|
return c.NoPermissions(w, r, u)
|
||||||
}
|
}
|
||||||
gid, err := strconv.Atoi(sgid)
|
gid, err := strconv.Atoi(sgid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.LocalError(p.GetErrorPhrase("url_id_must_be_integer"), w, r, user)
|
return c.LocalError(p.GetErrorPhrase("url_id_must_be_integer"), w, r, u)
|
||||||
}
|
}
|
||||||
|
|
||||||
from, err := strconv.Atoi(r.FormValue("from"))
|
from, err := strconv.Atoi(r.FormValue("from"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.LocalError("from must be integer", w, r, user)
|
return c.LocalError("from must be integer", w, r, u)
|
||||||
}
|
}
|
||||||
to, err := strconv.Atoi(r.FormValue("to"))
|
to, err := strconv.Atoi(r.FormValue("to"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.LocalError("to must be integer", w, r, user)
|
return c.LocalError("to must be integer", w, r, u)
|
||||||
}
|
}
|
||||||
if from == to {
|
if from == to {
|
||||||
return c.LocalError("the from group and to group cannot be the same", w, r, user)
|
return c.LocalError("the from group and to group cannot be the same", w, r, u)
|
||||||
}
|
}
|
||||||
twoWay := r.FormValue("two-way") == "1"
|
twoWay := r.FormValue("two-way") == "1"
|
||||||
|
|
||||||
level, err := strconv.Atoi(r.FormValue("level"))
|
level, err := strconv.Atoi(r.FormValue("level"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.LocalError("level must be integer", w, r, user)
|
return c.LocalError("level must be integer", w, r, u)
|
||||||
}
|
}
|
||||||
posts, err := strconv.Atoi(r.FormValue("posts"))
|
posts, err := strconv.Atoi(r.FormValue("posts"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.LocalError("posts must be integer", w, r, user)
|
return c.LocalError("posts must be integer", w, r, u)
|
||||||
}
|
}
|
||||||
|
|
||||||
regHours, err := strconv.Atoi(r.FormValue("registered_hours"))
|
regHours, err := strconv.Atoi(r.FormValue("reg_hours"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.LocalError("registered_hours must be integer", w, r, user)
|
return c.LocalError("reg_hours must be integer", w, r, u)
|
||||||
}
|
}
|
||||||
regDays, err := strconv.Atoi(r.FormValue("registered_days"))
|
regDays, err := strconv.Atoi(r.FormValue("reg_days"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.LocalError("registered_days must be integer", w, r, user)
|
return c.LocalError("reg_days must be integer", w, r, u)
|
||||||
}
|
}
|
||||||
regMonths, err := strconv.Atoi(r.FormValue("registered_months"))
|
regMonths, err := strconv.Atoi(r.FormValue("reg_months"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.LocalError("registered_months must be integer", w, r, user)
|
return c.LocalError("reg_months must be integer", w, r, u)
|
||||||
}
|
}
|
||||||
regMinutes := (regHours * 60) + (regDays * 24 * 60) + (regMonths * 30 * 24 * 60)
|
regMinutes := (regHours * 60) + (regDays * 24 * 60) + (regMonths * 30 * 24 * 60)
|
||||||
|
|
||||||
g, err := c.Groups.Get(from)
|
g, err := c.Groups.Get(from)
|
||||||
ferr := groupCheck(w, r, user, g, err)
|
ferr := groupCheck(w, r, u, g, err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ferr
|
return ferr
|
||||||
}
|
}
|
||||||
g, err = c.Groups.Get(to)
|
g, err = c.Groups.Get(to)
|
||||||
ferr = groupCheck(w, r, user, g, err)
|
ferr = groupCheck(w, r, u, g, err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ferr
|
return ferr
|
||||||
}
|
}
|
||||||
|
@ -242,7 +242,7 @@ func GroupsPromotionsCreateSubmit(w http.ResponseWriter, r *http.Request, user *
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.InternalError(err, w, r)
|
return c.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
err = c.AdminLogs.Create("create", pid, "group_promotion", user.GetIP(), user.ID)
|
err = c.AdminLogs.Create("create", pid, "group_promotion", u.GetIP(), u.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.InternalError(err, w, r)
|
return c.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
|
@ -251,37 +251,37 @@ func GroupsPromotionsCreateSubmit(w http.ResponseWriter, r *http.Request, user *
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GroupsPromotionsDeleteSubmit(w http.ResponseWriter, r *http.Request, user *c.User, sspl string) c.RouteError {
|
func GroupsPromotionsDeleteSubmit(w http.ResponseWriter, r *http.Request, u *c.User, sspl string) c.RouteError {
|
||||||
if !user.Perms.EditGroup {
|
if !u.Perms.EditGroup {
|
||||||
return c.NoPermissions(w, r, user)
|
return c.NoPermissions(w, r, u)
|
||||||
}
|
}
|
||||||
spl := strings.Split(sspl, "-")
|
spl := strings.Split(sspl, "-")
|
||||||
if len(spl) < 2 {
|
if len(spl) < 2 {
|
||||||
return c.LocalError("need two params", w, r, user)
|
return c.LocalError("need two params", w, r, u)
|
||||||
}
|
}
|
||||||
gid, err := strconv.Atoi(spl[0])
|
gid, err := strconv.Atoi(spl[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.LocalError(p.GetErrorPhrase("url_id_must_be_integer"), w, r, user)
|
return c.LocalError(p.GetErrorPhrase("url_id_must_be_integer"), w, r, u)
|
||||||
}
|
}
|
||||||
pid, err := strconv.Atoi(spl[1])
|
pid, err := strconv.Atoi(spl[1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.LocalError(p.GetErrorPhrase("url_id_must_be_integer"), w, r, user)
|
return c.LocalError(p.GetErrorPhrase("url_id_must_be_integer"), w, r, u)
|
||||||
}
|
}
|
||||||
|
|
||||||
pro, err := c.GroupPromotions.Get(pid)
|
pro, err := c.GroupPromotions.Get(pid)
|
||||||
if err == sql.ErrNoRows {
|
if err == sql.ErrNoRows {
|
||||||
return c.LocalError("That group promotion doesn't exist", w, r, user)
|
return c.LocalError("That group promotion doesn't exist", w, r, u)
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return c.InternalError(err, w, r)
|
return c.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
g, err := c.Groups.Get(pro.From)
|
g, err := c.Groups.Get(pro.From)
|
||||||
ferr := groupCheck(w, r, user, g, err)
|
ferr := groupCheck(w, r, u, g, err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ferr
|
return ferr
|
||||||
}
|
}
|
||||||
g, err = c.Groups.Get(pro.To)
|
g, err = c.Groups.Get(pro.To)
|
||||||
ferr = groupCheck(w, r, user, g, err)
|
ferr = groupCheck(w, r, u, g, err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ferr
|
return ferr
|
||||||
}
|
}
|
||||||
|
@ -289,7 +289,7 @@ func GroupsPromotionsDeleteSubmit(w http.ResponseWriter, r *http.Request, user *
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.InternalError(err, w, r)
|
return c.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
err = c.AdminLogs.Create("delete", pid, "group_promotion", user.GetIP(), user.ID)
|
err = c.AdminLogs.Create("delete", pid, "group_promotion", u.GetIP(), u.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.InternalError(err, w, r)
|
return c.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
|
@ -298,17 +298,17 @@ func GroupsPromotionsDeleteSubmit(w http.ResponseWriter, r *http.Request, user *
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GroupsEditPerms(w http.ResponseWriter, r *http.Request, user *c.User, sgid string) c.RouteError {
|
func GroupsEditPerms(w http.ResponseWriter, r *http.Request, u *c.User, sgid string) c.RouteError {
|
||||||
basePage, ferr := buildBasePage(w, r, user, "edit_group", "groups")
|
basePage, ferr := buildBasePage(w, r, u, "edit_group", "groups")
|
||||||
if ferr != nil {
|
if ferr != nil {
|
||||||
return ferr
|
return ferr
|
||||||
}
|
}
|
||||||
if !user.Perms.EditGroup {
|
if !u.Perms.EditGroup {
|
||||||
return c.NoPermissions(w, r, user)
|
return c.NoPermissions(w, r, u)
|
||||||
}
|
}
|
||||||
gid, err := strconv.Atoi(sgid)
|
gid, err := strconv.Atoi(sgid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.LocalError(p.GetErrorPhrase("url_id_must_be_integer"), w, r, user)
|
return c.LocalError(p.GetErrorPhrase("url_id_must_be_integer"), w, r, u)
|
||||||
}
|
}
|
||||||
|
|
||||||
g, err := c.Groups.Get(gid)
|
g, err := c.Groups.Get(gid)
|
||||||
|
@ -318,11 +318,11 @@ func GroupsEditPerms(w http.ResponseWriter, r *http.Request, user *c.User, sgid
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return c.InternalError(err, w, r)
|
return c.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
if g.IsAdmin && !user.Perms.EditGroupAdmin {
|
if g.IsAdmin && !u.Perms.EditGroupAdmin {
|
||||||
return c.LocalError(p.GetErrorPhrase("panel_groups_cannot_edit_admin"), w, r, user)
|
return c.LocalError(p.GetErrorPhrase("panel_groups_cannot_edit_admin"), w, r, u)
|
||||||
}
|
}
|
||||||
if g.IsMod && !user.Perms.EditGroupSuperMod {
|
if g.IsMod && !u.Perms.EditGroupSuperMod {
|
||||||
return c.LocalError(p.GetErrorPhrase("panel_groups_cannot_edit_supermod"), w, r, user)
|
return c.LocalError(p.GetErrorPhrase("panel_groups_cannot_edit_supermod"), w, r, u)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Load the phrases in bulk for efficiency?
|
// TODO: Load the phrases in bulk for efficiency?
|
||||||
|
@ -355,6 +355,7 @@ func GroupsEditPerms(w http.ResponseWriter, r *http.Request, user *c.User, sgid
|
||||||
addPerm("UseConvosOnlyWithMod", g.Perms.UseConvosOnlyWithMod)
|
addPerm("UseConvosOnlyWithMod", g.Perms.UseConvosOnlyWithMod)
|
||||||
addPerm("CreateProfileReply", g.Perms.CreateProfileReply)
|
addPerm("CreateProfileReply", g.Perms.CreateProfileReply)
|
||||||
addPerm("AutoEmbed", g.Perms.AutoEmbed)
|
addPerm("AutoEmbed", g.Perms.AutoEmbed)
|
||||||
|
addPerm("AutoLink", g.Perms.AutoLink)
|
||||||
|
|
||||||
var modPerms []c.NameLangToggle
|
var modPerms []c.NameLangToggle
|
||||||
addPerm = func(permStr string, perm bool) {
|
addPerm = func(permStr string, perm bool) {
|
||||||
|
|
|
@ -7,9 +7,9 @@ INSERT INTO [settings] ([name],[content],[type]) VALUES ('rapid_loading','1','bo
|
||||||
INSERT INTO [settings] ([name],[content],[type]) VALUES ('google_site_verify','','html-attribute');
|
INSERT INTO [settings] ([name],[content],[type]) VALUES ('google_site_verify','','html-attribute');
|
||||||
INSERT INTO [themes] ([uname],[default]) VALUES ('cosora',1);
|
INSERT INTO [themes] ([uname],[default]) VALUES ('cosora',1);
|
||||||
INSERT INTO [emails] ([email],[uid],[validated]) VALUES ('admin@localhost',1,1);
|
INSERT INTO [emails] ([email],[uid],[validated]) VALUES ('admin@localhost',1,1);
|
||||||
INSERT INTO [users_groups] ([name],[permissions],[plugin_perms],[is_mod],[is_admin],[is_banned],[tag]) VALUES ('Administrator','{"BanUsers":true,"ActivateUsers":true,"EditUser":true,"EditUserEmail":true,"EditUserPassword":true,"EditUserGroup":true,"EditUserGroupSuperMod":true,"EditGroup":true,"EditGroupLocalPerms":true,"EditGroupGlobalPerms":true,"EditGroupSuperMod":true,"ManageForums":true,"EditSettings":true,"ManageThemes":true,"ManagePlugins":true,"ViewAdminLogs":true,"ViewIPs":true,"UploadFiles":true,"UploadAvatars":true,"UseConvos":true,"UseConvosOnlyWithMod":true,"CreateProfileReply":true,"AutoEmbed":true,"ViewTopic":true,"LikeItem":true,"CreateTopic":true,"EditTopic":true,"DeleteTopic":true,"CreateReply":true,"EditReply":true,"DeleteReply":true,"PinTopic":true,"CloseTopic":true,"MoveTopic":true}','{}',1,1,0,'Admin');
|
INSERT INTO [users_groups] ([name],[permissions],[plugin_perms],[is_mod],[is_admin],[is_banned],[tag]) VALUES ('Administrator','{"BanUsers":true,"ActivateUsers":true,"EditUser":true,"EditUserEmail":true,"EditUserPassword":true,"EditUserGroup":true,"EditUserGroupSuperMod":true,"EditGroup":true,"EditGroupLocalPerms":true,"EditGroupGlobalPerms":true,"EditGroupSuperMod":true,"ManageForums":true,"EditSettings":true,"ManageThemes":true,"ManagePlugins":true,"ViewAdminLogs":true,"ViewIPs":true,"UploadFiles":true,"UploadAvatars":true,"UseConvos":true,"UseConvosOnlyWithMod":true,"CreateProfileReply":true,"AutoEmbed":true,"AutoLink":true,"ViewTopic":true,"LikeItem":true,"CreateTopic":true,"EditTopic":true,"DeleteTopic":true,"CreateReply":true,"EditReply":true,"DeleteReply":true,"PinTopic":true,"CloseTopic":true,"MoveTopic":true}','{}',1,1,0,'Admin');
|
||||||
INSERT INTO [users_groups] ([name],[permissions],[plugin_perms],[is_mod],[is_admin],[is_banned],[tag]) VALUES ('Moderator','{"BanUsers":true,"ActivateUsers":true,"EditUser":true,"EditUserGroup":true,"ViewIPs":true,"UploadFiles":true,"UploadAvatars":true,"UseConvos":true,"UseConvosOnlyWithMod":true,"CreateProfileReply":true,"AutoEmbed":true,"ViewTopic":true,"LikeItem":true,"CreateTopic":true,"EditTopic":true,"DeleteTopic":true,"CreateReply":true,"EditReply":true,"DeleteReply":true,"PinTopic":true,"CloseTopic":true,"MoveTopic":true}','{}',1,0,0,'Mod');
|
INSERT INTO [users_groups] ([name],[permissions],[plugin_perms],[is_mod],[is_admin],[is_banned],[tag]) VALUES ('Moderator','{"BanUsers":true,"ActivateUsers":true,"EditUser":true,"EditUserGroup":true,"ViewIPs":true,"UploadFiles":true,"UploadAvatars":true,"UseConvos":true,"UseConvosOnlyWithMod":true,"CreateProfileReply":true,"AutoEmbed":true,"AutoLink":true,"ViewTopic":true,"LikeItem":true,"CreateTopic":true,"EditTopic":true,"DeleteTopic":true,"CreateReply":true,"EditReply":true,"DeleteReply":true,"PinTopic":true,"CloseTopic":true,"MoveTopic":true}','{}',1,0,0,'Mod');
|
||||||
INSERT INTO [users_groups] ([name],[permissions],[plugin_perms],[is_mod],[is_admin],[is_banned],[tag]) VALUES ('Member','{"UploadFiles":true,"UploadAvatars":true,"UseConvos":true,"UseConvosOnlyWithMod":true,"CreateProfileReply":true,"AutoEmbed":true,"ViewTopic":true,"LikeItem":true,"CreateTopic":true,"CreateReply":true}','{}',0,0,0,"");
|
INSERT INTO [users_groups] ([name],[permissions],[plugin_perms],[is_mod],[is_admin],[is_banned],[tag]) VALUES ('Member','{"UploadFiles":true,"UploadAvatars":true,"UseConvos":true,"UseConvosOnlyWithMod":true,"CreateProfileReply":true,"AutoEmbed":true,"AutoLink":true,"ViewTopic":true,"LikeItem":true,"CreateTopic":true,"CreateReply":true}','{}',0,0,0,"");
|
||||||
INSERT INTO [users_groups] ([name],[permissions],[plugin_perms],[is_mod],[is_admin],[is_banned],[tag]) VALUES ('Banned','{"ViewTopic":true}','{}',0,0,1,"");
|
INSERT INTO [users_groups] ([name],[permissions],[plugin_perms],[is_mod],[is_admin],[is_banned],[tag]) VALUES ('Banned','{"ViewTopic":true}','{}',0,0,1,"");
|
||||||
INSERT INTO [users_groups] ([name],[permissions],[plugin_perms],[is_mod],[is_admin],[is_banned],[tag]) VALUES ('Awaiting Activation','{"UseConvosOnlyWithMod":true,"ViewTopic":true}','{}',0,0,0,"");
|
INSERT INTO [users_groups] ([name],[permissions],[plugin_perms],[is_mod],[is_admin],[is_banned],[tag]) VALUES ('Awaiting Activation','{"UseConvosOnlyWithMod":true,"ViewTopic":true}','{}',0,0,0,"");
|
||||||
INSERT INTO [users_groups] ([name],[permissions],[plugin_perms],[is_mod],[is_admin],[is_banned],[tag]) VALUES ('Not Loggedin','{"ViewTopic":true}','{}',0,0,0,'Guest');
|
INSERT INTO [users_groups] ([name],[permissions],[plugin_perms],[is_mod],[is_admin],[is_banned],[tag]) VALUES ('Not Loggedin','{"ViewTopic":true}','{}',0,0,0,'Guest');
|
||||||
|
|
|
@ -15,9 +15,9 @@ INSERT INTO `settings`(`name`,`content`,`type`) VALUES ('rapid_loading','1','boo
|
||||||
INSERT INTO `settings`(`name`,`content`,`type`) VALUES ('google_site_verify','','html-attribute');
|
INSERT INTO `settings`(`name`,`content`,`type`) VALUES ('google_site_verify','','html-attribute');
|
||||||
INSERT INTO `themes`(`uname`,`default`) VALUES ('cosora',1);
|
INSERT INTO `themes`(`uname`,`default`) VALUES ('cosora',1);
|
||||||
INSERT INTO `emails`(`email`,`uid`,`validated`) VALUES ('admin@localhost',1,1);
|
INSERT INTO `emails`(`email`,`uid`,`validated`) VALUES ('admin@localhost',1,1);
|
||||||
INSERT INTO `users_groups`(`name`,`permissions`,`plugin_perms`,`is_mod`,`is_admin`,`is_banned`,`tag`) VALUES ('Administrator','{"BanUsers":true,"ActivateUsers":true,"EditUser":true,"EditUserEmail":true,"EditUserPassword":true,"EditUserGroup":true,"EditUserGroupSuperMod":true,"EditGroup":true,"EditGroupLocalPerms":true,"EditGroupGlobalPerms":true,"EditGroupSuperMod":true,"ManageForums":true,"EditSettings":true,"ManageThemes":true,"ManagePlugins":true,"ViewAdminLogs":true,"ViewIPs":true,"UploadFiles":true,"UploadAvatars":true,"UseConvos":true,"UseConvosOnlyWithMod":true,"CreateProfileReply":true,"AutoEmbed":true,"ViewTopic":true,"LikeItem":true,"CreateTopic":true,"EditTopic":true,"DeleteTopic":true,"CreateReply":true,"EditReply":true,"DeleteReply":true,"PinTopic":true,"CloseTopic":true,"MoveTopic":true}','{}',1,1,0,'Admin');
|
INSERT INTO `users_groups`(`name`,`permissions`,`plugin_perms`,`is_mod`,`is_admin`,`is_banned`,`tag`) VALUES ('Administrator','{"BanUsers":true,"ActivateUsers":true,"EditUser":true,"EditUserEmail":true,"EditUserPassword":true,"EditUserGroup":true,"EditUserGroupSuperMod":true,"EditGroup":true,"EditGroupLocalPerms":true,"EditGroupGlobalPerms":true,"EditGroupSuperMod":true,"ManageForums":true,"EditSettings":true,"ManageThemes":true,"ManagePlugins":true,"ViewAdminLogs":true,"ViewIPs":true,"UploadFiles":true,"UploadAvatars":true,"UseConvos":true,"UseConvosOnlyWithMod":true,"CreateProfileReply":true,"AutoEmbed":true,"AutoLink":true,"ViewTopic":true,"LikeItem":true,"CreateTopic":true,"EditTopic":true,"DeleteTopic":true,"CreateReply":true,"EditReply":true,"DeleteReply":true,"PinTopic":true,"CloseTopic":true,"MoveTopic":true}','{}',1,1,0,'Admin');
|
||||||
INSERT INTO `users_groups`(`name`,`permissions`,`plugin_perms`,`is_mod`,`is_admin`,`is_banned`,`tag`) VALUES ('Moderator','{"BanUsers":true,"ActivateUsers":true,"EditUser":true,"EditUserGroup":true,"ViewIPs":true,"UploadFiles":true,"UploadAvatars":true,"UseConvos":true,"UseConvosOnlyWithMod":true,"CreateProfileReply":true,"AutoEmbed":true,"ViewTopic":true,"LikeItem":true,"CreateTopic":true,"EditTopic":true,"DeleteTopic":true,"CreateReply":true,"EditReply":true,"DeleteReply":true,"PinTopic":true,"CloseTopic":true,"MoveTopic":true}','{}',1,0,0,'Mod');
|
INSERT INTO `users_groups`(`name`,`permissions`,`plugin_perms`,`is_mod`,`is_admin`,`is_banned`,`tag`) VALUES ('Moderator','{"BanUsers":true,"ActivateUsers":true,"EditUser":true,"EditUserGroup":true,"ViewIPs":true,"UploadFiles":true,"UploadAvatars":true,"UseConvos":true,"UseConvosOnlyWithMod":true,"CreateProfileReply":true,"AutoEmbed":true,"AutoLink":true,"ViewTopic":true,"LikeItem":true,"CreateTopic":true,"EditTopic":true,"DeleteTopic":true,"CreateReply":true,"EditReply":true,"DeleteReply":true,"PinTopic":true,"CloseTopic":true,"MoveTopic":true}','{}',1,0,0,'Mod');
|
||||||
INSERT INTO `users_groups`(`name`,`permissions`,`plugin_perms`,`is_mod`,`is_admin`,`is_banned`,`tag`) VALUES ('Member','{"UploadFiles":true,"UploadAvatars":true,"UseConvos":true,"UseConvosOnlyWithMod":true,"CreateProfileReply":true,"AutoEmbed":true,"ViewTopic":true,"LikeItem":true,"CreateTopic":true,"CreateReply":true}','{}',0,0,0,"");
|
INSERT INTO `users_groups`(`name`,`permissions`,`plugin_perms`,`is_mod`,`is_admin`,`is_banned`,`tag`) VALUES ('Member','{"UploadFiles":true,"UploadAvatars":true,"UseConvos":true,"UseConvosOnlyWithMod":true,"CreateProfileReply":true,"AutoEmbed":true,"AutoLink":true,"ViewTopic":true,"LikeItem":true,"CreateTopic":true,"CreateReply":true}','{}',0,0,0,"");
|
||||||
INSERT INTO `users_groups`(`name`,`permissions`,`plugin_perms`,`is_mod`,`is_admin`,`is_banned`,`tag`) VALUES ('Banned','{"ViewTopic":true}','{}',0,0,1,"");
|
INSERT INTO `users_groups`(`name`,`permissions`,`plugin_perms`,`is_mod`,`is_admin`,`is_banned`,`tag`) VALUES ('Banned','{"ViewTopic":true}','{}',0,0,1,"");
|
||||||
INSERT INTO `users_groups`(`name`,`permissions`,`plugin_perms`,`is_mod`,`is_admin`,`is_banned`,`tag`) VALUES ('Awaiting Activation','{"UseConvosOnlyWithMod":true,"ViewTopic":true}','{}',0,0,0,"");
|
INSERT INTO `users_groups`(`name`,`permissions`,`plugin_perms`,`is_mod`,`is_admin`,`is_banned`,`tag`) VALUES ('Awaiting Activation','{"UseConvosOnlyWithMod":true,"ViewTopic":true}','{}',0,0,0,"");
|
||||||
INSERT INTO `users_groups`(`name`,`permissions`,`plugin_perms`,`is_mod`,`is_admin`,`is_banned`,`tag`) VALUES ('Not Loggedin','{"ViewTopic":true}','{}',0,0,0,'Guest');
|
INSERT INTO `users_groups`(`name`,`permissions`,`plugin_perms`,`is_mod`,`is_admin`,`is_banned`,`tag`) VALUES ('Not Loggedin','{"ViewTopic":true}','{}',0,0,0,'Guest');
|
||||||
|
|
|
@ -7,9 +7,9 @@ INSERT INTO "settings"("name","content","type") VALUES ('rapid_loading','1','boo
|
||||||
INSERT INTO "settings"("name","content","type") VALUES ('google_site_verify','','html-attribute');
|
INSERT INTO "settings"("name","content","type") VALUES ('google_site_verify','','html-attribute');
|
||||||
INSERT INTO "themes"("uname","default") VALUES ('cosora',1);
|
INSERT INTO "themes"("uname","default") VALUES ('cosora',1);
|
||||||
INSERT INTO "emails"("email","uid","validated") VALUES ('admin@localhost',1,1);
|
INSERT INTO "emails"("email","uid","validated") VALUES ('admin@localhost',1,1);
|
||||||
INSERT INTO "users_groups"("name","permissions","plugin_perms","is_mod","is_admin","is_banned","tag") VALUES ('Administrator','{"BanUsers":true,"ActivateUsers":true,"EditUser":true,"EditUserEmail":true,"EditUserPassword":true,"EditUserGroup":true,"EditUserGroupSuperMod":true,"EditGroup":true,"EditGroupLocalPerms":true,"EditGroupGlobalPerms":true,"EditGroupSuperMod":true,"ManageForums":true,"EditSettings":true,"ManageThemes":true,"ManagePlugins":true,"ViewAdminLogs":true,"ViewIPs":true,"UploadFiles":true,"UploadAvatars":true,"UseConvos":true,"UseConvosOnlyWithMod":true,"CreateProfileReply":true,"AutoEmbed":true,"ViewTopic":true,"LikeItem":true,"CreateTopic":true,"EditTopic":true,"DeleteTopic":true,"CreateReply":true,"EditReply":true,"DeleteReply":true,"PinTopic":true,"CloseTopic":true,"MoveTopic":true}','{}',1,1,0,'Admin');
|
INSERT INTO "users_groups"("name","permissions","plugin_perms","is_mod","is_admin","is_banned","tag") VALUES ('Administrator','{"BanUsers":true,"ActivateUsers":true,"EditUser":true,"EditUserEmail":true,"EditUserPassword":true,"EditUserGroup":true,"EditUserGroupSuperMod":true,"EditGroup":true,"EditGroupLocalPerms":true,"EditGroupGlobalPerms":true,"EditGroupSuperMod":true,"ManageForums":true,"EditSettings":true,"ManageThemes":true,"ManagePlugins":true,"ViewAdminLogs":true,"ViewIPs":true,"UploadFiles":true,"UploadAvatars":true,"UseConvos":true,"UseConvosOnlyWithMod":true,"CreateProfileReply":true,"AutoEmbed":true,"AutoLink":true,"ViewTopic":true,"LikeItem":true,"CreateTopic":true,"EditTopic":true,"DeleteTopic":true,"CreateReply":true,"EditReply":true,"DeleteReply":true,"PinTopic":true,"CloseTopic":true,"MoveTopic":true}','{}',1,1,0,'Admin');
|
||||||
INSERT INTO "users_groups"("name","permissions","plugin_perms","is_mod","is_admin","is_banned","tag") VALUES ('Moderator','{"BanUsers":true,"ActivateUsers":true,"EditUser":true,"EditUserGroup":true,"ViewIPs":true,"UploadFiles":true,"UploadAvatars":true,"UseConvos":true,"UseConvosOnlyWithMod":true,"CreateProfileReply":true,"AutoEmbed":true,"ViewTopic":true,"LikeItem":true,"CreateTopic":true,"EditTopic":true,"DeleteTopic":true,"CreateReply":true,"EditReply":true,"DeleteReply":true,"PinTopic":true,"CloseTopic":true,"MoveTopic":true}','{}',1,0,0,'Mod');
|
INSERT INTO "users_groups"("name","permissions","plugin_perms","is_mod","is_admin","is_banned","tag") VALUES ('Moderator','{"BanUsers":true,"ActivateUsers":true,"EditUser":true,"EditUserGroup":true,"ViewIPs":true,"UploadFiles":true,"UploadAvatars":true,"UseConvos":true,"UseConvosOnlyWithMod":true,"CreateProfileReply":true,"AutoEmbed":true,"AutoLink":true,"ViewTopic":true,"LikeItem":true,"CreateTopic":true,"EditTopic":true,"DeleteTopic":true,"CreateReply":true,"EditReply":true,"DeleteReply":true,"PinTopic":true,"CloseTopic":true,"MoveTopic":true}','{}',1,0,0,'Mod');
|
||||||
INSERT INTO "users_groups"("name","permissions","plugin_perms","is_mod","is_admin","is_banned","tag") VALUES ('Member','{"UploadFiles":true,"UploadAvatars":true,"UseConvos":true,"UseConvosOnlyWithMod":true,"CreateProfileReply":true,"AutoEmbed":true,"ViewTopic":true,"LikeItem":true,"CreateTopic":true,"CreateReply":true}','{}',0,0,0,"");
|
INSERT INTO "users_groups"("name","permissions","plugin_perms","is_mod","is_admin","is_banned","tag") VALUES ('Member','{"UploadFiles":true,"UploadAvatars":true,"UseConvos":true,"UseConvosOnlyWithMod":true,"CreateProfileReply":true,"AutoEmbed":true,"AutoLink":true,"ViewTopic":true,"LikeItem":true,"CreateTopic":true,"CreateReply":true}','{}',0,0,0,"");
|
||||||
INSERT INTO "users_groups"("name","permissions","plugin_perms","is_mod","is_admin","is_banned","tag") VALUES ('Banned','{"ViewTopic":true}','{}',0,0,1,"");
|
INSERT INTO "users_groups"("name","permissions","plugin_perms","is_mod","is_admin","is_banned","tag") VALUES ('Banned','{"ViewTopic":true}','{}',0,0,1,"");
|
||||||
INSERT INTO "users_groups"("name","permissions","plugin_perms","is_mod","is_admin","is_banned","tag") VALUES ('Awaiting Activation','{"UseConvosOnlyWithMod":true,"ViewTopic":true}','{}',0,0,0,"");
|
INSERT INTO "users_groups"("name","permissions","plugin_perms","is_mod","is_admin","is_banned","tag") VALUES ('Awaiting Activation','{"UseConvosOnlyWithMod":true,"ViewTopic":true}','{}',0,0,0,"");
|
||||||
INSERT INTO "users_groups"("name","permissions","plugin_perms","is_mod","is_admin","is_banned","tag") VALUES ('Not Loggedin','{"ViewTopic":true}','{}',0,0,0,'Guest');
|
INSERT INTO "users_groups"("name","permissions","plugin_perms","is_mod","is_admin","is_banned","tag") VALUES ('Not Loggedin','{"ViewTopic":true}','{}',0,0,0,'Guest');
|
||||||
|
|
Loading…
Reference in New Issue