AclSetRight: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m (Added "resource" as the ACL rights type) |
||
(8 intermediate revisions by 7 users not shown) | |||
Line 7: | Line 7: | ||
bool aclSetRight ( acl theAcl, string rightName, bool hasAccess ) | bool aclSetRight ( acl theAcl, string rightName, bool hasAccess ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[acl]]:setRight||aclGetRight}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
*'''theAcl:''' The ACL to change the right of | *'''theAcl:''' The ACL to change the right of | ||
*'''rightName:''' The right to add/change the access property of | *'''rightName:''' The right to add/change the access property of. It '''must''' be prefixed with "'''function.'''" or "'''command.'''" or "'''general.'''" or "'''resource.'''" | ||
*'''hasAccess:''' Whether the access should be set to true or false | *'''hasAccess:''' Whether the access should be set to true or false | ||
Line 31: | Line 31: | ||
if not (access == "true" or access == "false") then | if not (access == "true" or access == "false") then | ||
-- print out error message to debug window | -- print out error message to debug window | ||
outputDebugString ( "Invalid access; true and false are only accepted", 1 ) | return outputDebugString ( "Invalid access; true and false are only accepted", 1 ) | ||
end | end | ||
Line 41: | Line 39: | ||
else | else | ||
access = false | access = false | ||
end | |||
-- and finally let's set the right | -- and finally let's set the right | ||
Line 52: | Line 51: | ||
==See Also== | ==See Also== | ||
{{ACL_functions}} | {{ACL_functions}} | ||
[[zh-cn:aclSetRight]] |
Latest revision as of 16:21, 1 March 2023
This functions changes or adds the given right in the given ACL. The access can be true or false and specifies whether the ACL gives access to the right or not.
Syntax
bool aclSetRight ( acl theAcl, string rightName, bool hasAccess )
OOP Syntax Help! I don't understand this!
- Method: acl:setRight(...)
- Counterpart: aclGetRight
Required Arguments
- theAcl: The ACL to change the right of
- rightName: The right to add/change the access property of. It must be prefixed with "function." or "command." or "general." or "resource."
- hasAccess: Whether the access should be set to true or false
Returns
Returns true if the access was successfully changed, false or nil if it failed for some reason, ie. invalid ACL or the rightname is invalid.
Example
This example adds a command setaclright with which you can easily add new rights to specified access control lists.
function setACLRight ( thePlayer, commandName, aclName, rightName, access ) local ourACL = aclGet ( aclName ) -- if there is no previous ACL with this name, we need to create one if not ourACL then ourACL = aclCreate ( aclName ) end -- turn the boolean string to lower case access = string.lower ( access ) -- access has to be either true or false (booleans) if not (access == "true" or access == "false") then -- print out error message to debug window return outputDebugString ( "Invalid access; true and false are only accepted", 1 ) end -- change the access to boolean if access == "true" then access = true else access = false end -- and finally let's set the right aclSetRight ( ourACL, rightName, access ) -- don't forget to save the ACL after it has been modified aclSave () end addCommandHandler ( "setaclright", setACLRight )
See Also
- aclCreate
- aclCreateGroup
- aclDestroy
- aclDestroyGroup
- aclGet
- aclGetGroup
- aclGetName
- aclGetRight
- aclGroupAddACL
- aclGroupAddObject
- aclGroupGetName
- aclGroupList
- aclGroupListACL
- aclGroupListObjects
- aclGroupRemoveACL
- aclGroupRemoveObject
- aclList
- aclListRights
- aclReload
- aclRemoveRight
- aclSave
- aclSetRight
- hasObjectPermissionTo
- isObjectInACLGroup