11 private $_authManager;
26 $this->_authManager = Yii::app()->getAuthManager();
27 $this->db = $this->_authManager->db;
36 $authManager = $this->_authManager;
37 $itemTable = $authManager->itemTable;
40 $txn = $this->db->beginTransaction();
44 $generatedItems = array();
47 foreach( $this->_items as $type=>$items )
50 foreach( $items as $name )
53 if( $authManager->getAuthItem($name)===null )
56 $sql =
"INSERT INTO {$itemTable} (name, type, data)
57 VALUES (:name, :type, :data)";
58 $command = $this->db->createCommand($sql);
59 $command->bindValue(
':name', $name);
60 $command->bindValue(
':type', $type);
61 $command->bindValue(
':data',
'N;');
64 $generatedItems[] = $name;
71 return $generatedItems;
73 catch( CDbException $e )
88 if( isset($this->_items[ $type ])===
false )
89 $this->_items[ $type ] = array();
91 foreach( $items as $itemname )
92 $this->_items[ $type ][] = $itemname;
104 foreach( $items[
'controllers'] as $controllerName=>$controller )
107 $file = fopen($controller[
'path'],
'r');
109 while( feof($file)===
false )
112 $line = fgets($file);
113 preg_match(
'/public[ \t]+function[ \t]+action([A-Z]{1}[a-zA-Z0-9]+)[ \t]*\(/', $line, $matches);
114 if( $matches!==array() )
117 $actions[ strtolower($name) ] = array(
124 $items[
'controllers'][ $controllerName ][
'actions'] = $actions;
127 foreach( $items[
'modules'] as $moduleName=>$module )
139 $basePath = Yii::app()->basePath;
140 $items[
'controllers'] = $this->
getControllersInPath($basePath.DIRECTORY_SEPARATOR.
'controllers');
152 $controllers = array();
154 if( file_exists($path)===
true )
156 $controllerDirectory = scandir($path);
157 foreach( $controllerDirectory as $entry )
159 if( $entry{0}!==
'.' )
161 $entryPath = $path.DIRECTORY_SEPARATOR.$entry;
162 if( strpos(strtolower($entry),
'controller')!==
false )
164 $name = substr($entry, 0, -14);
165 $controllers[ strtolower($name) ] = array(
172 if( is_dir($entryPath)===
true )
174 $controllers[ $controllerName ] = $controller;
191 $modulePath = $path.DIRECTORY_SEPARATOR.
'modules';
192 if( file_exists($modulePath)===
true )
194 $moduleDirectory = scandir($modulePath);
195 foreach( $moduleDirectory as $entry )
197 if( substr($entry, 0, 1)!==
'.' && $entry!==
'rights' )
199 $subModulePath = $modulePath.DIRECTORY_SEPARATOR.$entry;
200 if( file_exists($subModulePath)===
true )
202 $items[ $entry ][
'controllers'] = $this->
getControllersInPath($subModulePath.DIRECTORY_SEPARATOR.
'controllers');