Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion [admin]/admin/client/gui/admin_acl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ function aManageACL ()
aACLOk = guiCreateButton ( 0.55, 0.40, 0.19, 0.04, "Ok", true, aAclForm )
aACLCancel = guiCreateButton ( 0.76, 0.40, 0.19, 0.04, "Cancel", true, aAclForm )

aACLAddRight = guiCreateButton ( 0.55, 0.30, 0.40, 0.04, "Add Right", true, aAclForm )
aACLAddRight = guiCreateButton ( 0.55, 0.35, 0.40, 0.04, "Add Right", true, aAclForm )
aACLSetRight = guiCreateButton ( 0.55, 0.40, 0.40, 0.04, "Set Right", true, aAclForm )
aACLRemoveRight = guiCreateButton ( 0.55, 0.45, 0.40, 0.04, "Remove Right", true, aAclForm )
aACLDeleteRight = guiCreateButton ( 0.55, 0.55, 0.40, 0.04, "Delete Right", true, aAclForm )

aACLExit = guiCreateButton ( 0.75, 0.90, 0.27, 0.04, "Close", true, aAclForm )
aclDisplayOptions ( "", "" )

Expand Down Expand Up @@ -205,6 +209,15 @@ function aClientACLDoubleClick ( button )
end
end

local function getSelectedRight()
local row = guiGridListGetSelectedItem ( aACLList )
if ( row ~= -1 ) then
local state = guiGridListGetItemText ( aACLList, row, 2 )
return state:gsub("^%s*(.-)%s*$", "%1")
end
return false
end

function aClientACLClick ( button )
if ( source ~= aACLDropList ) then guiSetVisible ( aACLDropList, false ) end
if ( button == "left" ) then
Expand All @@ -218,6 +231,15 @@ function aClientACLClick ( button )
aInputBox ( "Create ACL Group", "Enter object name:", "", "aclAddObject", aAclData["current"] )
elseif ( source == aACLAddRight ) then
aInputBox ( "Create ACL", "Enter right name:", "", "aclAddRight", aAclData["current"] )
elseif ( source == aACLSetRight ) then
local right = getSelectedRight()
triggerServerEvent ( "aAdmin", localPlayer, "acladd", "right", aAclData["current"], right )
elseif ( source == aACLRemoveRight ) then
local right = getSelectedRight()
triggerServerEvent ( "aAdmin", localPlayer, "acladd", "right", aAclData["current"], right, false )
elseif ( source == aACLDeleteRight ) then
local right = getSelectedRight()
triggerServerEvent ( "aAdmin", localPlayer, "aclremove", "right", aAclData["current"], right )
elseif ( source == aACLDestroyGroup ) then
aMessageBox ( "warning", "Are you sure to destroy "..aAclData["current"].." group?", "aclDestroyGroup", aAclData["current"])
elseif ( source == aACLDestroyACL ) then
Expand Down Expand Up @@ -278,6 +300,9 @@ function aclDisplayOptions ( state, name )
guiSetVisible ( aACLAddACL, false )
guiSetVisible ( aACLRemoveACL, false )
guiSetVisible ( aACLAddRight, false )
guiSetVisible ( aACLSetRight, false )
guiSetVisible ( aACLRemoveRight, false )
guiSetVisible ( aACLDeleteRight, false )
guiSetVisible ( aACLDropCurrent, false )
guiSetVisible ( aACLDropList, false )
guiSetVisible ( aACLDropDown, false )
Expand All @@ -287,6 +312,9 @@ function aclDisplayOptions ( state, name )
if ( state == "ACL" ) then
guiSetVisible ( aACLDestroyACL, true )
guiSetVisible ( aACLAddRight, true )
guiSetVisible ( aACLSetRight, true )
guiSetVisible ( aACLRemoveRight, true )
guiSetVisible ( aACLDeleteRight, true )
elseif ( state == "Group" ) then
guiSetVisible ( aACLDestroyGroup, true )
guiSetVisible ( aACLAddObject, true )
Expand Down
9 changes: 7 additions & 2 deletions [admin]/admin/server/admin_server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -830,9 +830,14 @@ addEventHandler ( "aAdmin", root, function ( action, ... )
elseif ( arg[1] == "right" ) then
local acl = aclGet ( arg[2] )
local right = arg[3]
local enabled = true
local enabled = arg[4]
if enabled == nil then
enabled = true
end
local verb = enabled and "adding" or "removing"
local prep = enabled and "to" or "from"
if ( not aclSetRight ( acl, right, enabled ) ) then
outputChatBox ( "Error adding right '"..tostring ( arg[3] ).."' to group '"..tostring ( arg[2] ).."'", source, 255, 0, 0 )
outputChatBox ( "Error "..verb.." right '"..tostring(arg[3]).."' "..prep.." group '"..tostring(arg[2]).."'", source, 255, 0, 0)
else
mdata2 = "Right '"..arg[3].."'"
triggerEvent ( "aAdmin", source, "sync", "aclrights", arg[2] )
Expand Down