groundwork for generating member export (unfinished)
This commit is contained in:
+27
-10
@@ -91,16 +91,17 @@ type CfgPermission struct {
|
||||
|
||||
// CfgSecurityDefs is the master structure for security definitions.
|
||||
type CfgSecurityDefs struct {
|
||||
Scopes []CfgScope `yaml:"scopes"`
|
||||
Roles []CfgRole `yaml:"roles"`
|
||||
Defaults []CfgDefault `yaml:"defaults"`
|
||||
Lists []CfgRoleList `yaml:"lists"`
|
||||
Permissions []CfgPermission `yaml:"permissions"`
|
||||
scopeMap map[string]*CfgScope
|
||||
roleMap map[string]*CfgRole
|
||||
defaultsMap map[string]*CfgDefault
|
||||
listsMap map[string]*CfgRoleList
|
||||
permsMap map[string]*CfgPermission
|
||||
Scopes []CfgScope `yaml:"scopes"`
|
||||
Roles []CfgRole `yaml:"roles"`
|
||||
Defaults []CfgDefault `yaml:"defaults"`
|
||||
Lists []CfgRoleList `yaml:"lists"`
|
||||
Permissions []CfgPermission `yaml:"permissions"`
|
||||
scopeMap map[string]*CfgScope
|
||||
roleMap map[string]*CfgRole
|
||||
roleMapReverse map[uint16]*CfgRole
|
||||
defaultsMap map[string]*CfgDefault
|
||||
listsMap map[string]*CfgRoleList
|
||||
permsMap map[string]*CfgPermission
|
||||
}
|
||||
|
||||
//go:embed securitydefs.yaml
|
||||
@@ -153,10 +154,12 @@ func init() {
|
||||
securityRoot.scopeMap[sc.Name] = &(securityRoot.Scopes[i])
|
||||
}
|
||||
securityRoot.roleMap = make(map[string]*CfgRole)
|
||||
securityRoot.roleMapReverse = make(map[uint16]*CfgRole)
|
||||
for i, ro := range securityRoot.Roles {
|
||||
scope := securityRoot.scopeMap[ro.Scope]
|
||||
securityRoot.Roles[i].level = parseLevelValue(scope.bounds, ro.Value)
|
||||
securityRoot.roleMap[ro.Internal] = &(securityRoot.Roles[i])
|
||||
securityRoot.roleMapReverse[securityRoot.Roles[i].level] = &(securityRoot.Roles[i])
|
||||
}
|
||||
securityRoot.defaultsMap = make(map[string]*CfgDefault)
|
||||
for i, def := range securityRoot.Defaults {
|
||||
@@ -247,6 +250,20 @@ func AmRole(id string) Role {
|
||||
return rc
|
||||
}
|
||||
|
||||
/* AmRoleForLevel returns a Role given an integer level.
|
||||
* Parameters:
|
||||
* level - Level of the Role to look up.
|
||||
* Returns:
|
||||
* The specified role.
|
||||
*/
|
||||
func AmRoleForLevel(level uint16) Role {
|
||||
rc, ok := securityRoot.roleMapReverse[level]
|
||||
if !ok {
|
||||
log.Errorf("AmRoleForLevel('%d') - role not found!", level)
|
||||
}
|
||||
return rc
|
||||
}
|
||||
|
||||
/* AmDefaultRole returns a Role given a default ID.
|
||||
* Parameters:
|
||||
* id - ID of the default to look up.
|
||||
|
||||
@@ -123,6 +123,14 @@ lists:
|
||||
- "Global.Normal"
|
||||
- "UnrestrictedUser"
|
||||
- "Global.PFY"
|
||||
- name: "Global.AllUserLevels"
|
||||
roles:
|
||||
- "Global.Anonymous"
|
||||
- "Global.Unverified"
|
||||
- "Global.Normal"
|
||||
- "UnrestrictedUser"
|
||||
- "Global.PFY"
|
||||
- "Global.BOFH"
|
||||
- name: "Global.CreateCommunity"
|
||||
default: "Global.Normal"
|
||||
roles:
|
||||
|
||||
@@ -121,6 +121,22 @@ func (p *UserPrefs) Location() *time.Location {
|
||||
return rc
|
||||
}
|
||||
|
||||
// LocationISO8601Offset returns an offset value for the user's time location.
|
||||
func (p *UserPrefs) LocationISO8601Offset() string {
|
||||
loc := p.Location()
|
||||
_, secondsOut := time.Now().In(loc).Zone()
|
||||
if secondsOut == 0 {
|
||||
return "Z"
|
||||
}
|
||||
minutesOut := secondsOut / 60
|
||||
if minutesOut < 0 {
|
||||
minutesOut = -minutesOut
|
||||
return fmt.Sprintf("-%02d:%02d", minutesOut/60, minutesOut%60)
|
||||
} else {
|
||||
return fmt.Sprintf("+%02d:%02d", minutesOut/60, minutesOut%60)
|
||||
}
|
||||
}
|
||||
|
||||
// User represents a user in the Amsterdam database.
|
||||
type User struct {
|
||||
Mutex sync.RWMutex
|
||||
|
||||
Reference in New Issue
Block a user