summaryrefslogtreecommitdiffstats
path: root/lib/roles.lua
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2010-10-06 12:57:42 +0000
committerTed Trask <ttrask01@yahoo.com>2010-10-06 12:57:42 +0000
commit25c09923e08f664a0c791f27d521fb13f4d5d74c (patch)
tree6410b0964cdbbd2603b9598f8474b5a9333be520 /lib/roles.lua
parentb202af98292d6d7b5053e5a934b916153ce89af9 (diff)
downloadacf-core-25c09923e08f664a0c791f27d521fb13f4d5d74c.tar.bz2
acf-core-25c09923e08f664a0c791f27d521fb13f4d5d74c.tar.xz
Added home page (action) to user parameters and redirect there after login
Moved get_all_permissions function from acf-util/roles-model to lib/roles
Diffstat (limited to 'lib/roles.lua')
-rw-r--r--lib/roles.lua35
1 files changed, 33 insertions, 2 deletions
diff --git a/lib/roles.lua b/lib/roles.lua
index e5786ba..6c5b8a2 100644
--- a/lib/roles.lua
+++ b/lib/roles.lua
@@ -9,7 +9,7 @@ module (..., package.seeall)
guest_role = "GUEST"
-- Global variables so we don't have to figure out all the roles multiple times
-local defined_roles, default_roles, reverseroles, roles_candidates, role_table
+local defined_roles, default_roles, reverseroles, roles_candidates, role_table, table_perm, array_perm
-- returns a table of the *.roles files
-- startdir should be the app dir
@@ -43,7 +43,7 @@ end
-- Return information about all or specified controller files
get_controllers = function(self,pre,controller)
--we get all the controllers
- local list = roles.list_controllers(self)
+ local list = list_controllers(self)
--we need to grab the directory and name of file
local temp = {}
for k,v in pairs(list) do
@@ -94,6 +94,37 @@ get_controllers_view = function(self,controller_info)
return temp
end
+get_all_permissions = function(self)
+ if not table_perm or not array_perm then
+ -- need to get a list of all the controllers
+ controllers = get_controllers(self)
+ table_perm = {}
+ array_perm = {}
+ for a,b in pairs(controllers) do
+ if nil == table_perm[b.prefix] then
+ table_perm[b.prefix] = {}
+ end
+ if nil == table_perm[b.prefix][b.sname] then
+ table_perm[b.prefix][b.sname] = {}
+ end
+ local temp = get_controllers_func(self,b)
+ for x,y in ipairs(temp) do
+ table_perm[b.prefix][b.sname][y] = {}
+ array_perm[#array_perm + 1] = b.prefix .. b.sname .. "/" .. y
+ end
+ temp = get_controllers_view(self,b)
+ for x,y in ipairs(temp) do
+ if not table_perm[b.prefix][b.sname][y] then
+ table_perm[b.prefix][b.sname][y] = {}
+ array_perm[#array_perm + 1] = b.prefix .. b.sname .. "/" .. y
+ end
+ end
+ end
+ end
+
+ return table_perm, array_perm
+end
+
list_default_roles = function(self)
if not default_roles then
default_roles = {}