Skip to content

Commit 839b1d1

Browse files
authored
Admin: ACL Rights improvement (#711)
* Update admin_acl.lua * Update admin_server.lua * Update admin_server.lua * Clarify the purposes of the buttons
1 parent 4c2a6ae commit 839b1d1

2 files changed

Lines changed: 36 additions & 3 deletions

File tree

[admin]/admin/client/gui/admin_acl.lua

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ function aManageACL ()
4545
aACLOk = guiCreateButton ( 0.55, 0.40, 0.19, 0.04, "Ok", true, aAclForm )
4646
aACLCancel = guiCreateButton ( 0.76, 0.40, 0.19, 0.04, "Cancel", true, aAclForm )
4747

48-
aACLAddRight = guiCreateButton ( 0.55, 0.30, 0.40, 0.04, "Add Right", true, aAclForm )
48+
aACLAddRight = guiCreateButton ( 0.55, 0.35, 0.40, 0.04, "Add Right", true, aAclForm )
49+
aACLSetRight = guiCreateButton ( 0.55, 0.40, 0.40, 0.04, "Enable Selected Right", true, aAclForm )
50+
aACLRemoveRight = guiCreateButton ( 0.55, 0.45, 0.40, 0.04, "Disable Selected Right", true, aAclForm )
51+
aACLDeleteRight = guiCreateButton ( 0.55, 0.55, 0.40, 0.04, "Delete Right", true, aAclForm )
52+
4953
aACLExit = guiCreateButton ( 0.75, 0.90, 0.27, 0.04, "Close", true, aAclForm )
5054
aclDisplayOptions ( "", "" )
5155

@@ -205,6 +209,15 @@ function aClientACLDoubleClick ( button )
205209
end
206210
end
207211

212+
local function getSelectedRight()
213+
local row = guiGridListGetSelectedItem ( aACLList )
214+
if ( row ~= -1 ) then
215+
local state = guiGridListGetItemText ( aACLList, row, 2 )
216+
return state:gsub("^%s*(.-)%s*$", "%1")
217+
end
218+
return false
219+
end
220+
208221
function aClientACLClick ( button )
209222
if ( source ~= aACLDropList ) then guiSetVisible ( aACLDropList, false ) end
210223
if ( button == "left" ) then
@@ -218,6 +231,15 @@ function aClientACLClick ( button )
218231
aInputBox ( "Create ACL Group", "Enter object name:", "", "aclAddObject", aAclData["current"] )
219232
elseif ( source == aACLAddRight ) then
220233
aInputBox ( "Create ACL", "Enter right name:", "", "aclAddRight", aAclData["current"] )
234+
elseif ( source == aACLSetRight ) then
235+
local right = getSelectedRight()
236+
triggerServerEvent ( "aAdmin", localPlayer, "acladd", "right", aAclData["current"], right )
237+
elseif ( source == aACLRemoveRight ) then
238+
local right = getSelectedRight()
239+
triggerServerEvent ( "aAdmin", localPlayer, "acladd", "right", aAclData["current"], right, false )
240+
elseif ( source == aACLDeleteRight ) then
241+
local right = getSelectedRight()
242+
triggerServerEvent ( "aAdmin", localPlayer, "aclremove", "right", aAclData["current"], right )
221243
elseif ( source == aACLDestroyGroup ) then
222244
aMessageBox ( "warning", "Are you sure to destroy "..aAclData["current"].." group?", "aclDestroyGroup", aAclData["current"])
223245
elseif ( source == aACLDestroyACL ) then
@@ -278,6 +300,9 @@ function aclDisplayOptions ( state, name )
278300
guiSetVisible ( aACLAddACL, false )
279301
guiSetVisible ( aACLRemoveACL, false )
280302
guiSetVisible ( aACLAddRight, false )
303+
guiSetVisible ( aACLSetRight, false )
304+
guiSetVisible ( aACLRemoveRight, false )
305+
guiSetVisible ( aACLDeleteRight, false )
281306
guiSetVisible ( aACLDropCurrent, false )
282307
guiSetVisible ( aACLDropList, false )
283308
guiSetVisible ( aACLDropDown, false )
@@ -287,6 +312,9 @@ function aclDisplayOptions ( state, name )
287312
if ( state == "ACL" ) then
288313
guiSetVisible ( aACLDestroyACL, true )
289314
guiSetVisible ( aACLAddRight, true )
315+
guiSetVisible ( aACLSetRight, true )
316+
guiSetVisible ( aACLRemoveRight, true )
317+
guiSetVisible ( aACLDeleteRight, true )
290318
elseif ( state == "Group" ) then
291319
guiSetVisible ( aACLDestroyGroup, true )
292320
guiSetVisible ( aACLAddObject, true )

[admin]/admin/server/admin_server.lua

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -830,9 +830,14 @@ addEventHandler ( "aAdmin", root, function ( action, ... )
830830
elseif ( arg[1] == "right" ) then
831831
local acl = aclGet ( arg[2] )
832832
local right = arg[3]
833-
local enabled = true
833+
local enabled = arg[4]
834+
if enabled == nil then
835+
enabled = true
836+
end
837+
local verb = enabled and "adding" or "removing"
838+
local prep = enabled and "to" or "from"
834839
if ( not aclSetRight ( acl, right, enabled ) ) then
835-
outputChatBox ( "Error adding right '"..tostring ( arg[3] ).."' to group '"..tostring ( arg[2] ).."'", source, 255, 0, 0 )
840+
outputChatBox ( "Error "..verb.." right '"..tostring(arg[3]).."' "..prep.." group '"..tostring(arg[2]).."'", source, 255, 0, 0)
836841
else
837842
mdata2 = "Right '"..arg[3].."'"
838843
triggerEvent ( "aAdmin", source, "sync", "aclrights", arg[2] )

0 commit comments

Comments
 (0)