Permalink
Browse files

BUGFIX: RequestHandler needs some tricks to make sure it knows when a…

…llowed_actions hasnt been provided on a class when it has been provided on an extension, now that statics from extensions isnt a feature specific hack
  • Loading branch information...
1 parent bc3f5ac commit 5ff095e56100997e2c0e7b2bf50610379aeaed78 Hamish Friedlander committed Mar 9, 2012
Showing with 5 additions and 5 deletions.
  1. +5 −5 control/RequestHandler.php
View
10 control/RequestHandler.php
@@ -216,7 +216,7 @@ function handleRequest(SS_HTTPRequest $request, DataModel $model) {
public function allowedActions() {
$actions = Config::inst()->get(get_class($this), 'allowed_actions');
-
+
if($actions) {
// convert all keys and values to lowercase to
// allow for easier comparison, unless it is a permission code
@@ -225,7 +225,7 @@ public function allowedActions() {
foreach($actions as $key => $value) {
if(is_numeric($key)) $actions[$key] = strtolower($value);
}
-
+
return $actions;
}
}
@@ -253,7 +253,7 @@ public function hasAction($action) {
if($isKey || $isValue) return true;
}
- if(!is_array($actions) || !$this->uninherited('allowed_actions')) {
+ if(!is_array($actions) || !$this->config()->get('allowed_actions', Config::UNINHERITED | Config::EXCLUDE_EXTRA_SOURCES)) {
if($action != 'init' && $action != 'run' && method_exists($this, $action)) return true;
}
@@ -286,7 +286,7 @@ function checkAccessAction($action) {
return Permission::check($test);
}
- } elseif((($key = array_search($actionOrAll, $allowedActions)) !== false) && is_numeric($key)) {
+ } elseif((($key = array_search($actionOrAll, $allowedActions, true)) !== false) && is_numeric($key)) {
// Case 4: Allow numeric array notation (search for array value as action instead of key)
return true;
}
@@ -297,7 +297,7 @@ function checkAccessAction($action) {
// it should be allowed.
if($action == 'index' || empty($action)) return true;
- if($allowedActions === null || !$this->uninherited('allowed_actions')) {
+ if($allowedActions === null || !$this->config()->get('allowed_actions', Config::UNINHERITED | Config::EXCLUDE_EXTRA_SOURCES)) {
// If no allowed_actions are provided, then we should only let through actions that aren't handled by magic methods
// we test this by calling the unmagic method_exists.
if(method_exists($this, $action)) {

0 comments on commit 5ff095e

Please sign in to comment.