Skip to content

Commit 8679183

Browse files
committed
Remove legacy 'Restrictions' functionality
1 parent 84f6df1 commit 8679183

File tree

3 files changed

+9
-144
lines changed

3 files changed

+9
-144
lines changed

lua/blobsprofiler/client/cl_blobsprofiler.lua

Lines changed: 5 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ local function popupSourceView(sourceContent, frameTitle)
186186
end
187187

188188
local function killAllSourcePopups()
189-
for k,v in ipairs(blobsProfiler.sourceFrames) do
189+
for k,v in pairs(blobsProfiler.sourceFrames) do
190190
if IsValid(v) then
191191
v:Remove()
192192
end
@@ -244,8 +244,7 @@ blobsProfiler.Menu.RCFunctions_DEFAULT = {
244244
print(ref.value)
245245
print(node.GlobalPath)
246246
end,
247-
icon = "icon16/application_osx_terminal.png",
248-
requiredAccess = "Read"
247+
icon = "icon16/application_osx_terminal.png"
249248
}
250249
},
251250
["number"] = {
@@ -255,8 +254,7 @@ blobsProfiler.Menu.RCFunctions_DEFAULT = {
255254
print(ref.value)
256255
print(node.GlobalPath)
257256
end,
258-
icon = "icon16/application_osx_terminal.png",
259-
requiredAccess = "Read"
257+
icon = "icon16/application_osx_terminal.png"
260258
}
261259
},
262260
["boolean"] = {
@@ -266,8 +264,7 @@ blobsProfiler.Menu.RCFunctions_DEFAULT = {
266264
print(ref.value)
267265
print(node.GlobalPath)
268266
end,
269-
icon = "icon16/application_osx_terminal.png",
270-
requiredAccess = "Read"
267+
icon = "icon16/application_osx_terminal.png"
271268
}
272269
},
273270
["table"] = {
@@ -276,11 +273,8 @@ blobsProfiler.Menu.RCFunctions_DEFAULT = {
276273
func = function(ref, node)
277274
PrintTable(ref.value)
278275
print("Global Path:", node.GlobalPath)
279-
print("Restrictions:")
280-
PrintTable(node.Restrictions)
281276
end,
282-
icon = "icon16/application_osx_terminal.png",
283-
requiredAccess = "Read"
277+
icon = "icon16/application_osx_terminal.png"
284278
}
285279
},
286280
["function"] = {
@@ -427,9 +421,6 @@ local function addDTreeNode(parentNode, nodeData, specialType, isRoot, varType,
427421
local RCTable = blobsProfiler.GetRCFunctionsTable(varType)
428422
if RCTable and RCTable[dataType] then
429423
for k,v in ipairs(RCTable[dataType]) do
430-
if v.requiredAccess and childNode.Restrictions[v.requiredAccess] then
431-
continue
432-
end
433424
if v.condition and not v.condition(nodeData, childNode, luaState) then
434425
continue
435426
end
@@ -471,7 +462,6 @@ local function addDTreeNode(parentNode, nodeData, specialType, isRoot, varType,
471462
end
472463

473464
childNode.GlobalPath = childNode.GlobalPath || ""
474-
childNode.Restrictions = childNode.Restrictions || {}
475465

476466
if not nodeData.special then
477467
if isRoot then
@@ -483,21 +473,6 @@ local function addDTreeNode(parentNode, nodeData, specialType, isRoot, varType,
483473

484474
varType = varType or "Lua.Globals"
485475

486-
if parentNode.Restrictions then
487-
childNode.Restrictions = parentNode.Restrictions
488-
end
489-
490-
if blobsProfiler.Restrictions[varType] and blobsProfiler.Restrictions[varType][childNode.GlobalPath] then
491-
childNode.Restrictions = blobsProfiler.Restrictions[varType][childNode.GlobalPath].Restrict
492-
end
493-
494-
if childNode.Restrictions and (childNode.Restrictions["Read"] or childNode.Restrictions["Write"] or childNode.Restrictions["Delete"]) then
495-
childNode.Label:SetTextColor(Color(200,190,0))
496-
497-
local toolTipStr = "Read: ".. (childNode.Restrictions["Read"] and "NO" or "YES") .."\nWrite: ".. (childNode.Restrictions["Write"] and "NO" or "YES") .."\nDelete: ".. (childNode.Restrictions["Delete"] and "NO" or "YES")
498-
childNode:SetTooltip(toolTipStr)
499-
end
500-
501476
childNode.DoRightClick = function()
502477
childNode:InternalDoClick()
503478

@@ -507,9 +482,6 @@ local function addDTreeNode(parentNode, nodeData, specialType, isRoot, varType,
507482
local RCMenu = blobsProfiler.Menu.RCMenu
508483

509484
for _, rcM in ipairs(RCTable[visualDataType]) do
510-
if rcM.requiredAccess and childNode.Restrictions[rcM.requiredAccess] then
511-
continue
512-
end
513485
if rcM.condition and not rcM.condition(nodeData, childNode, luaState) then
514486
continue
515487
end
@@ -529,9 +501,6 @@ local function addDTreeNode(parentNode, nodeData, specialType, isRoot, varType,
529501
if useIcon then rcParent:SetIcon(useIcon) end
530502

531503
for _, rcMS in ipairs(rcM.submenu) do
532-
if rcMS.requiredAccess and childNode.Restrictions[rcMS.requiredAccess] then
533-
continue
534-
end
535504
if rcMS.condition and not rcMS.condition(nodeData, childNode, luaState) then
536505
continue
537506
end
@@ -579,9 +548,6 @@ local function addDTreeNode(parentNode, nodeData, specialType, isRoot, varType,
579548
local RCTable = blobsProfiler.GetRCFunctionsTable(varType)
580549
if RCTable and RCTable[visualDataType] then
581550
for k,v in ipairs(RCTable[visualDataType]) do
582-
if v.requiredAccess and childNode.Restrictions[v.requiredAccess] then
583-
continue
584-
end
585551
if v.condition and not v.condition(nodeData, childNode, luaState) then
586552
continue
587553
end
@@ -640,9 +606,6 @@ local function addDTreeNode(parentNode, nodeData, specialType, isRoot, varType,
640606
childNode:SetExpanded(not childNode:GetExpanded())
641607
elseif RCTable and RCTable[visualDataType] then
642608
for _, rcM in ipairs(RCTable[visualDataType]) do
643-
if rcM.requiredAccess and childNode.Restrictions[rcM.requiredAccess] then
644-
continue
645-
end
646609
if rcM.condition and not rcM.condition(nodeData, childNode, luaState) then
647610
continue
648611
end

lua/blobsprofiler/shared/modules/bp_timers.lua

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ blobsProfiler.RegisterModule("Timers", {
4242
print(ref.value)
4343
print(node.GlobalPath)
4444
end,
45-
icon = "icon16/application_osx_terminal.png",
46-
requiredAccess = "Read"
45+
icon = "icon16/application_osx_terminal.png"
4746
},
4847
{ -- Pause/Resume timer
4948
name = function(ref, node)
@@ -83,8 +82,7 @@ blobsProfiler.RegisterModule("Timers", {
8382
else
8483
return "icon16/clock_play.png"
8584
end
86-
end,
87-
requiredAccess = "Write"
85+
end
8886
},
8987
{ -- Delete timer
9088
name = function(ref, node)
@@ -102,8 +100,7 @@ blobsProfiler.RegisterModule("Timers", {
102100
node.Icon:SetImage("icon16/clock_delete.png")
103101
end
104102
end,
105-
icon = "icon16/clock_delete.png",
106-
requiredAccess = "Delete"
103+
icon = "icon16/clock_delete.png"
107104
},
108105
{ -- Remove timer reference
109106
name = function(ref, node)
@@ -113,8 +110,7 @@ blobsProfiler.RegisterModule("Timers", {
113110
blobsProfiler.createdTimers[node.GlobalPath] = nil
114111
node:Remove()
115112
end,
116-
icon = "icon16/clock_red.png",
117-
requiredAccess = "Delete"
113+
icon = "icon16/clock_red.png"
118114
}
119115
}
120116
}

lua/blobsprofiler/shared/sh_blobsprofiler.lua

Lines changed: 0 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
blobsProfiler = blobsProfiler or {}
22

3-
blobsProfiler.Restrictions = blobsProfiler.Restrictions or {}
4-
blobsProfiler.Restrictions.Global = blobsProfiler.Restrictions.Global or {}
5-
blobsProfiler.Restrictions.Function = blobsProfiler.Restrictions.Function or {}
6-
blobsProfiler.Restrictions.Hook = blobsProfiler.Restrictions.Hook or {}
7-
blobsProfiler.Restrictions.Concommand = blobsProfiler.Restrictions.Concommand or {}
8-
93
blobsProfiler.Client = blobsProfiler.Client or {}
104
blobsProfiler.Server = blobsProfiler.Server or {}
115

@@ -79,94 +73,6 @@ blobsProfiler.Log = function(lLevel, lMessage, lSendToServer, lErrStack) -- TODO
7973
end
8074
end
8175

82-
-- TODO:
83-
-- Complete todo list
84-
-- Prevent blobsProfiler.Restrictions modification outside of this file
85-
86-
blobsProfiler.RestrictAccess = function(rType, rValue, rMethod) -- Legacy?
87-
-- STRING rType = Global, Function, Hook, Concommand
88-
-- STRING rValue = "functionName (or path i.e myGlobal.functionName)"
89-
-- STRING or TABLE rMethod = Type of method to restrict (Read, Write, Delete) - * can be used in place of a table containing all methods
90-
91-
--[[
92-
'Read'
93-
READ: Deny
94-
WRITE: Deny
95-
DELETE: Deny
96-
'Write'
97-
READ: Allow
98-
WRITE: Deny
99-
DELETE: Deny
100-
'Delete'
101-
READ: Allow
102-
WRITE: Allow
103-
DELETE: Deny
104-
]]
105-
106-
if not rType or type(rType) ~= "string" or not table.HasValue({"Globals", "Function", "Hook", "Concommand"}, rType) then
107-
error("blobsProfiler.RestrictAccess: Invalid rType provided '".. rType .."'\nAllowed string values: Global, Function, Hook, Concommand")
108-
end
109-
if not rMethod then -- Type is checked later on
110-
error("blobsProfiler.RestrictAccess: rMethod not provided")
111-
end
112-
if not rValue or type(rValue) ~= "string" then
113-
error("blobsProfiler.RestrictAccess: Invalid rValue provided")
114-
end
115-
116-
local restrictMethods = {}
117-
restrictMethods["Read"] = false
118-
restrictMethods["Write"] = false
119-
restrictMethods["Delete"] = false
120-
121-
if type(rMethod) == "string" then
122-
rMethod = string.lower(rMethod)
123-
124-
if rMethod == "*" then
125-
restrictMethods["Read"] = true
126-
restrictMethods["Write"] = true
127-
restrictMethods["Delete"] = true
128-
elseif rMethod == "read" then
129-
restrictMethods["Read"] = true
130-
elseif rMethod == "write" then
131-
restrictMethods["Write"] = true
132-
elseif rMethod == "delete" then
133-
restrictMethods["Delete"] = true
134-
else
135-
error("blobsProfiler.RestrictAccess: rMethod invalid string provided\nAllowed string values: Read, Write, Delete, *")
136-
end
137-
elseif type(rMethod) == "table" then
138-
for _, rM in ipairs(rMethod) do
139-
local rM = string.lower(rM)
140-
141-
if rM == "read" then
142-
restrictMethods["Read"] = true
143-
end
144-
if rM == "write" then
145-
restrictMethods["Write"] = true
146-
end
147-
if rM == "read" then
148-
restrictMethods["Delete"] = true
149-
end
150-
end
151-
else
152-
error("blobsProfiler.RestrictAccess: Invalid rMethod type provided")
153-
end
154-
155-
if blobsProfiler.Restrictions[rType][rValue] then
156-
print("blobsProfiler.RestrictAccess: rValue is already restricted")
157-
-- return
158-
end
159-
160-
local dgiSource = debug.getinfo(2, "Sl")
161-
blobsProfiler.Restrictions[rType][rValue] = {
162-
Value = rValue,
163-
Restrict = restrictMethods,
164-
Restriction_Source = (dgiSource.short_src or "UNKNOWN_SOURCE") .. ":" .. (dgiSource.currentline or "UNKNOWN_LINE")
165-
}
166-
167-
return true
168-
end
169-
17076
blobsProfiler.CanAccess = function(cPly, cArea, cRealm)
17177
return cPly:IsUserGroup("superadmin") -- TODO
17278
end

0 commit comments

Comments
 (0)