Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ucl = ULib.ucl -- Make it easier for us to refer to
- local function reloadGroups()
- -- Try to read from the safest locations first
- local noMount = true
- local path = ULib.UCL_GROUPS
- local needsBackup = false
- local err
- ucl.groups, err = ULib.parseKeyValues( ULib.removeCommentHeader( ULib.fileRead( path, noMount ) or "", "/" ) )
- if not ucl.groups or not ucl.groups[ ULib.ACCESS_ALL ] then
- needsBackup = false
- -- Totally messed up! Clear it.
- local err2
- ucl.groups, err2 = ULib.parseKeyValues( ULib.removeCommentHeader( defaultGroupsText, "/" ) )
- else
- -- Check to make sure it passes a basic validity test
- ucl.groups[ ULib.ACCESS_ALL ].inherit_from = nil -- Ensure this is the case
- for groupName, groupInfo in pairs( ucl.groups ) do
- if type( groupName ) ~= "string" then
- needsBackup = true
- ucl.groups[ groupName ] = nil
- else
- if type( groupInfo ) ~= "table" then
- needsBackup = true
- groupInfo = {}
- ucl.groups[ groupName ] = groupInfo
- end
- if type( groupInfo.allow ) ~= "table" then
- needsBackup = true
- groupInfo.allow = {}
- end
- local inherit_from = groupInfo.inherit_from
- if inherit_from and inherit_from ~= "" and not ucl.groups[ groupInfo.inherit_from ] then
- needsBackup = true
- groupInfo.inherit_from = nil
- end
- -- Check for cycles
- local group = ucl.groupInheritsFrom( groupName )
- while group do
- if group == groupName then
- needsBackup = false
- groupInfo.inherit_from = nil -- nil
- end
- group = ucl.groupInheritsFrom( group )
- end
- if groupName ~= ULib.ACCESS_ALL and not groupInfo.inherit_from or groupInfo.inherit_from == "" then
- groupInfo.inherit_from = ULib.ACCESS_SUPERADMIN -- Clean :)
- end
- -- Lower case'ify
- for k, v in pairs( groupInfo.allow ) do
- if type( k ) == "string" and k:lower() ~= k then
- groupInfo.allow[ k:lower() ] = v
- groupInfo.allow[ k ] = nil
- else
- groupInfo.allow[ k ] = v
- end
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement