summaryrefslogtreecommitdiffstats
path: root/app/acf_www-controller.lua
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2009-12-17 10:15:51 +0000
committerTed Trask <ttrask01@yahoo.com>2009-12-17 10:15:51 +0000
commit1b8a047f7d1c71a1efd0bd34b5f887086a857b20 (patch)
tree1c9eb5f130d13f06f76a17d7e0cdce03416bafc0 /app/acf_www-controller.lua
parentb2b8ac87e45257215fa9642858a3bc5903b160e6 (diff)
downloadacf-core-1b8a047f7d1c71a1efd0bd34b5f887086a857b20.tar.bz2
acf-core-1b8a047f7d1c71a1efd0bd34b5f887086a857b20.tar.xz
Added a check-permission function to viewlibrary to abstract permissions.
Diffstat (limited to 'app/acf_www-controller.lua')
-rw-r--r--app/acf_www-controller.lua17
1 files changed, 14 insertions, 3 deletions
diff --git a/app/acf_www-controller.lua b/app/acf_www-controller.lua
index 9e92e0e..e71ba4f 100644
--- a/app/acf_www-controller.lua
+++ b/app/acf_www-controller.lua
@@ -69,6 +69,17 @@ local check_permission = function(self, controller, action)
return true
end
+local check_permission_string = function (self, str)
+ local prefix, controller, action = self.parse_path_info("/" .. (str or ""))
+ if prefix == "/" then prefix = self.conf.prefix end
+ if controller == "" then controller = self.conf.controller end
+
+ if "" == action then
+ action = rawget(self.worker, "default_action") or ""
+ end
+ return check_permission(self, controller, action)
+end
+
-- look for a template
-- ctlr-action-view, then ctlr-view, then action-view, then view
-- cannot be local function because of recursion
@@ -124,9 +135,8 @@ local has_view = function(self)
end
-- This function is made available within the view to allow loading of components
-local dispatch_component = function(str, clientdata, suppress_view)
+local dispatch_component = function(self, str, clientdata, suppress_view)
-- Before we call dispatch, we have to set up conf and clientdata like it was really called for this component
- self = APP
local tempconf = self.conf
self.conf = {}
for x,y in pairs(tempconf) do
@@ -163,7 +173,8 @@ local create_helper_library = function ( self )
end
end
--]]
- library.dispatch_component = dispatch_component
+ library.dispatch_component = function(...) return dispatch_component(self, ...) end
+ library.check_permission = function(...) return check_permission_string(self, ...) end
return library
end