27 $this->_authManager = Yii::app()->getAuthManager();
28 $this->db = $this->_authManager->db;
39 $itemTable = $authManager->itemTable;
42 $txn = $this->db->beginTransaction();
45 $generatedItems = array();
48 foreach ($this->_items as $type => $items) {
50 foreach ($items as $name) {
52 if ($authManager->getAuthItem($name) === null) {
54 $sql =
"INSERT INTO {$itemTable} (name, type, data)
55 VALUES (:name, :type, :data)";
56 $command = $this->db->createCommand($sql);
57 $command->bindValue(
':name', $name);
58 $command->bindValue(
':type', $type);
59 $command->bindValue(
':data',
'N;');
62 $generatedItems[] = $name;
70 return $generatedItems;
71 }
catch (CDbException $e) {
87 if (isset($this->_items[ $type ]) ===
false) {
88 $this->_items[ $type ] = array();
91 foreach ($items as $itemname) {
92 $this->_items[ $type ][] = $itemname;
103 if ($items === null) {
107 foreach ($items[
'controllers'] as $controllerName => $controller) {
109 $file = fopen($controller[
'path'],
'r');
111 while (feof($file) ===
false) {
113 $line = fgets($file);
114 preg_match(
'/public[ \t]+function[ \t]+action([A-Z]{1}[a-zA-Z0-9]+)[ \t]*\(/', $line, $matches);
115 if ($matches !== array()) {
117 $actions[ strtolower($name) ] = array(
119 'line' => $lineNumber,
124 $items[
'controllers'][ $controllerName ][
'actions'] = $actions;
127 foreach ($items[
'modules'] as $moduleName => $module) {
141 $basePath = Yii::app()->basePath;
142 $items[
'controllers'] = $this->
getControllersInPath($basePath.DIRECTORY_SEPARATOR.
'controllers');
157 $controllers = array();
159 if (file_exists($path) ===
true) {
160 $controllerDirectory = scandir($path);
161 foreach ($controllerDirectory as $entry) {
162 if ($entry{0} !==
'.') {
163 $entryPath = $path.DIRECTORY_SEPARATOR.$entry;
164 if (strpos(strtolower($entry),
'controller') !==
false) {
165 $name = substr($entry, 0, -14);
166 $controllers[ strtolower($name) ] = array(
169 'path' => $entryPath,
173 if (is_dir($entryPath) ===
true) {
175 $controllers[ $controllerName ] = $controller;
196 $modulePath = $path.DIRECTORY_SEPARATOR.
'modules';
197 if (file_exists($modulePath) ===
true) {
198 $moduleDirectory = scandir($modulePath);
199 foreach ($moduleDirectory as $entry) {
200 if (substr($entry, 0, 1) !==
'.' && $entry !==
'rights') {
201 $subModulePath = $modulePath.DIRECTORY_SEPARATOR.$entry;
202 if (file_exists($subModulePath) ===
true) {
203 $items[ $entry ][
'controllers'] = $this->
getControllersInPath($subModulePath.DIRECTORY_SEPARATOR.
'controllers');