From 4d332c36a0a491a3ed72db7123d5216371555e6c Mon Sep 17 00:00:00 2001 From: Timo Smit Date: Tue, 29 Jan 2019 22:49:20 +0100 Subject: [PATCH] Fixed acl not being able to copy level permissions to levels with existing permissions --- luascripts/wolfadmin/commands/server/acl.lua | 6 ------ luascripts/wolfadmin/db/mysql.lua | 2 +- luascripts/wolfadmin/db/sqlite3.lua | 2 +- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/luascripts/wolfadmin/commands/server/acl.lua b/luascripts/wolfadmin/commands/server/acl.lua index e01ff50..afa356e 100644 --- a/luascripts/wolfadmin/commands/server/acl.lua +++ b/luascripts/wolfadmin/commands/server/acl.lua @@ -161,12 +161,6 @@ function commandAclCopyLevelPermissions(levelId, newLevelId) return true end - if #acl.getLevelPermissions(newLevelId) ~= 0 then - et.G_Print("error: level "..newLevelId.." already has permissions\n") - - return true - end - acl.copyLevelPermissions(levelId, newLevelId) et.G_Print("copied permissions from "..levelId.." to "..newLevelId.."\n") diff --git a/luascripts/wolfadmin/db/mysql.lua b/luascripts/wolfadmin/db/mysql.lua index 97c123c..f117f75 100644 --- a/luascripts/wolfadmin/db/mysql.lua +++ b/luascripts/wolfadmin/db/mysql.lua @@ -178,7 +178,7 @@ function mysql.removeLevelPermission(levelId, permission) end function mysql.copyLevelPermissions(levelId, newLevelId) - cur = assert(con:execute("INSERT INTO `level_permission` (`level_id`, `permission`) SELECT '"..tonumber(newLevelId).."' AS `level_id`, `permission` FROM `level_permission` WHERE `level_id`="..tonumber(levelId))) + cur = assert(con:execute("INSERT INTO `level_permission` (`level_id`, `permission`) SELECT "..tonumber(newLevelId).." AS `level_id`, `permission` FROM `level_permission` WHERE `level_id`="..tonumber(levelId).." EXCEPT SELECT `level_id`, `permission` FROM `level_permission` WHERE `level_id`="..tonumber(newLevelId))) end function mysql.removeLevelPermissions(levelId) diff --git a/luascripts/wolfadmin/db/sqlite3.lua b/luascripts/wolfadmin/db/sqlite3.lua index 61db4f0..2aa9715 100644 --- a/luascripts/wolfadmin/db/sqlite3.lua +++ b/luascripts/wolfadmin/db/sqlite3.lua @@ -178,7 +178,7 @@ function sqlite3.removeLevelPermission(levelId, permission) end function sqlite3.copyLevelPermissions(levelId, newLevelId) - cur = assert(con:execute("INSERT INTO `level_permission` (`level_id`, `permission`) SELECT '"..tonumber(newLevelId).."' AS `level_id`, `permission` FROM `level_permission` WHERE `level_id`="..tonumber(levelId))) + cur = assert(con:execute("INSERT INTO `level_permission` (`level_id`, `permission`) SELECT "..tonumber(newLevelId).." AS `level_id`, `permission` FROM `level_permission` WHERE `level_id`="..tonumber(levelId).." EXCEPT SELECT `level_id`, `permission` FROM `level_permission` WHERE `level_id`="..tonumber(newLevelId))) end function sqlite3.removeLevelPermissions(levelId)