diff options
-rw-r--r-- | app/acf-util/roles-model.lua | 9 | ||||
-rw-r--r-- | lib/roles.lua | 11 |
2 files changed, 18 insertions, 2 deletions
diff --git a/app/acf-util/roles-model.lua b/app/acf-util/roles-model.lua index f064536..9149ba2 100644 --- a/app/acf-util/roles-model.lua +++ b/app/acf-util/roles-model.lua @@ -14,11 +14,18 @@ local get_all_permissions = function(self) if nil == table_perm[b.sname] then table_perm[b.sname] = {} end - temp = roles.get_controllers_func(self,b) + local temp = roles.get_controllers_func(self,b) for x,y in ipairs(temp) do table_perm[b.sname][y] = {} array_perm[#array_perm + 1] = b.sname .. ":" .. y end + temp = roles.get_controllers_view(self,b) + for x,y in ipairs(temp) do + if not table_perm[b.sname][y] then + table_perm[b.sname][y] = {} + array_perm[#array_perm + 1] = b.sname .. ":" .. y + end + end end return table_perm, array_perm diff --git a/lib/roles.lua b/lib/roles.lua index 201e2a9..b90ecea 100644 --- a/lib/roles.lua +++ b/lib/roles.lua @@ -63,7 +63,7 @@ get_controllers_func = function(self,controller_info) temp = require (controller_info.name) temp1 = {} for a,b in pairs(temp) do - local c = string.match(a,"mvc") or string.match(a,"^_") + local c = string.match(a,"^mvc") or string.match(a,"^_") if c == nil and type(temp[a])=="function" then temp1[#temp1 +1] = a end @@ -74,6 +74,15 @@ get_controllers_func = function(self,controller_info) end end +-- Find all views for a controller +get_controllers_view = function(self,controller_info) + local temp = {} + for file in fs.find(controller_info.sname.."%-[^%.]+%-html%.lsp", controller_info.path) do + temp[#temp + 1] = string.match(file, controller_info.sname.."%-([^%./]+)%-html%.lsp") + end + return temp +end + list_default_roles = function() return default_roles end |