One more thing I changed in your module
I wanted the srbac autodiscovery, that actually checks the action* methods in controllers could discover widget actions declared in method actions(), so I changed in method _getControllerInfo the last part (from "// $action == "actions"… process the method" on) to process such case
It’s working for me right now but it’s not tested, please check it!
private function _getControllerInfo($controller, $getAll = false) {
$actions = array();
$allowed = array();
$auth = Yii::app()->authManager;
//Check if it's a module controller
if(substr_count($controller, "/")) {
$c = explode("/", $controller);
$controller = $c[1];
$module = $c[0]."/";
$contPath = Yii::app()->getModule($c[0])->getControllerPath();
$control = $contPath.DIRECTORY_SEPARATOR.str_replace(".", DIRECTORY_SEPARATOR, $controller).".php";
} else {
$module = "";
$contPath = Yii::app()->getControllerPath();
$control = $contPath.DIRECTORY_SEPARATOR.str_replace(".", DIRECTORY_SEPARATOR, $controller).".php";
}
$task =$module.str_replace("Controller", "", $controller);
$taskViewingExists = $auth->getAuthItem($task."Viewing")!==null ? true : false;
$taskAdministratingExists = $auth->getAuthItem($task."Administrating")!==null ? true : false;
$delete = Yii::app()->request->getParam('delete');
$h = file($control);
for ($i = 0 ; $i < count($h) ; $i++) {
$line = trim($h[$i]);
if(preg_match("/^(.+)function( +)action*/", $line)) {
$action = trim(substr($line, strpos($line, "action")));
$patterns[0] = '/\s*/m';
$patterns[1] = '/\(/m';
$patterns[2] = '/\)/m';
$patterns[3] = '/\{/m';
$replacements[2] = '';
$replacements[1] = '';
$replacements[0] = '';
$action = preg_replace($patterns, $replacements, trim($action));
$itemId = $module.str_replace("Controller","",$controller).
str_replace("action", "", $action);
if($action !="actions" ) {
if($getAll) {
$actions[$module.$action] = $itemId;
if(in_array($itemId, $this->allowedAccess())) {
$allowed[] = $itemId;
}
} else {
if(in_array($itemId, $this->allowedAccess())) {
$allowed[] = $itemId;
} else {
if($auth->getAuthItem($itemId) === null && !$delete) {
if(!in_array($itemId, $this->allowedAccess())) {
$actions[$module.$action] = $itemId;
}
} else if($auth->getAuthItem($itemId)!==null && $delete) {
if(!in_array($itemId, $this->allowedAccess())) {
$actions[$module.$action] = $itemId;
}
}
}
}
} else { // $action == "actions"... process the method
if (is_file($control)) {
if(!class_exists($controller,false)) require($control);
if(class_exists($controller,false) && is_subclass_of($controller,'CController')) {
$tmp = array();
$controller_obj = new $controller($controller, $module);
$controller_actions = $controller_obj->actions();
foreach ($controller_actions as $prefix=>$act) {
$act_class_name = is_array($act) ? $act['class'] : $act;
$act_class=Yii::import($act_class_name,true);
$subaction_obj = new $act_class($controller_obj, ''); // Id not needed to invoke actions()
if ($act_class && method_exists($subaction_obj, 'actions')) {
$map=call_user_func(array($subaction_obj,'actions'));
if ($map) {
foreach ($map as $key=>$item) {
$subaction = $itemId.ucfirst($prefix.$key);
$actions[$module.'action'.$subaction] = $subaction;
if(in_array($subaction, $this->allowedAccess())) {
$allowed[] = $subaction;
}
}
}
}
}
}
}
}
}
}
return array($actions,$allowed, $delete , $task, $taskViewingExists, $taskAdministratingExists);
}
Hope it helps!
Hwangar