2016-12-04 06:16:59 +00:00
|
|
|
package main
|
2016-12-21 02:30:32 +00:00
|
|
|
import "fmt"
|
|
|
|
|
|
|
|
var GuestPerms Perms
|
|
|
|
var AllPerms Perms
|
2016-12-04 06:16:59 +00:00
|
|
|
|
|
|
|
type Group struct
|
|
|
|
{
|
|
|
|
ID int
|
|
|
|
Name string
|
2016-12-21 02:30:32 +00:00
|
|
|
Perms Perms
|
|
|
|
PermissionsText []byte
|
2016-12-07 13:46:14 +00:00
|
|
|
Is_Mod bool
|
2016-12-04 06:16:59 +00:00
|
|
|
Is_Admin bool
|
|
|
|
Is_Banned bool
|
2016-12-07 09:34:09 +00:00
|
|
|
Tag string
|
2016-12-04 06:16:59 +00:00
|
|
|
}
|
2016-12-21 02:30:32 +00:00
|
|
|
|
2016-12-23 12:35:22 +00:00
|
|
|
// Permission Structure: ActionComponent[Subcomponent]Flag
|
2016-12-21 02:30:32 +00:00
|
|
|
type Perms struct
|
|
|
|
{
|
|
|
|
// Global Permissions
|
|
|
|
BanUsers bool
|
|
|
|
ActivateUsers bool
|
2016-12-23 12:35:22 +00:00
|
|
|
EditUser bool
|
|
|
|
EditUserEmail bool
|
|
|
|
EditUserPassword bool
|
|
|
|
EditUserGroup bool
|
|
|
|
EditUserGroupSuperMod bool
|
|
|
|
EditUserGroupAdmin bool
|
2016-12-21 02:30:32 +00:00
|
|
|
ManageForums bool // This could be local, albeit limited for per-forum managers
|
|
|
|
EditSettings bool
|
|
|
|
ManagePlugins bool
|
|
|
|
ViewIPs bool
|
|
|
|
|
|
|
|
// Forum permissions
|
|
|
|
ViewTopic bool
|
|
|
|
CreateTopic bool
|
|
|
|
EditTopic bool
|
|
|
|
DeleteTopic bool
|
|
|
|
CreateReply bool
|
|
|
|
//CreateReplyToOwn bool
|
|
|
|
EditReply bool
|
|
|
|
//EditOwnReply bool
|
|
|
|
DeleteReply bool
|
|
|
|
PinTopic bool
|
|
|
|
CloseTopic bool
|
|
|
|
//CloseOwnTopic bool
|
|
|
|
|
|
|
|
ExtData interface{}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Inherit from group permissions for ones we don't have */
|
|
|
|
type ForumPerms struct
|
|
|
|
{
|
|
|
|
ViewTopic bool
|
|
|
|
CreateTopic bool
|
|
|
|
EditTopic bool
|
|
|
|
DeleteTopic bool
|
|
|
|
CreateReply bool
|
|
|
|
//CreateReplyToOwn bool
|
|
|
|
EditReply bool
|
|
|
|
//EditOwnReply bool
|
|
|
|
DeleteReply bool
|
|
|
|
PinTopic bool
|
|
|
|
CloseTopic bool
|
|
|
|
//CloseOwnTopic bool
|
|
|
|
|
|
|
|
ExtData map[string]bool
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
GuestPerms = Perms{
|
|
|
|
ViewTopic: true,
|
|
|
|
ExtData: make(map[string]bool),
|
|
|
|
}
|
|
|
|
|
|
|
|
AllPerms = Perms{
|
|
|
|
BanUsers: true,
|
|
|
|
ActivateUsers: true,
|
2016-12-23 12:35:22 +00:00
|
|
|
EditUser: true,
|
|
|
|
EditUserEmail: true,
|
|
|
|
EditUserPassword: true,
|
|
|
|
EditUserGroup: true,
|
|
|
|
EditUserGroupSuperMod: true,
|
|
|
|
EditUserGroupAdmin: true,
|
2016-12-21 02:30:32 +00:00
|
|
|
ManageForums: true,
|
|
|
|
EditSettings: true,
|
|
|
|
ManagePlugins: true,
|
|
|
|
ViewIPs: true,
|
|
|
|
|
|
|
|
ViewTopic: true,
|
|
|
|
CreateTopic: true,
|
|
|
|
EditTopic: true,
|
|
|
|
DeleteTopic: true,
|
|
|
|
CreateReply: true,
|
|
|
|
EditReply: true,
|
|
|
|
DeleteReply: true,
|
|
|
|
PinTopic: true,
|
|
|
|
CloseTopic: true,
|
|
|
|
|
|
|
|
ExtData: make(map[string]bool),
|
|
|
|
}
|
|
|
|
|
|
|
|
if debug {
|
|
|
|
fmt.Printf("Guest Perms: ")
|
|
|
|
fmt.Printf("%+v\n", GuestPerms)
|
|
|
|
fmt.Printf("All Perms: ")
|
|
|
|
fmt.Printf("%+v\n", AllPerms)
|
|
|
|
}
|
|
|
|
}
|