コード例 #1
0
ファイル: Acl.php プロジェクト: nhannhan159/T4Logs
 /**
  * Rebuilds the access list into a file
  *
  * @return \Phalcon\Acl\Adapter\Memory
  */
 public function rebuild()
 {
     $acl = new AclMemory();
     $acl->setDefaultAction(\Phalcon\Acl::DENY);
     // Register roles
     $roles = Roles::find();
     foreach ($roles as $role) {
         $acl->addRole(new AclRole($role->name));
     }
     foreach ($this->privateResources as $resource => $actions) {
         $acl->addResource(new AclResource($resource), $actions);
     }
     // Grant acess to private area to role Users
     foreach ($roles as $role) {
         // Grant permissions in "permissions" model
         foreach ($role->getPermissions() as $permission) {
             $acl->allow($role->name, $permission->controller, $permission->action);
         }
         // Always grant these permissions
         foreach ($this->privateResources as $controller => $actions) {
             foreach ($actions as $action) {
                 $acl->allow('admins', $controller, $action);
             }
         }
     }
     if (touch(APP_DIR . $this->filePath) && is_writable(APP_DIR . $this->filePath)) {
         file_put_contents(APP_DIR . $this->filePath, serialize($acl));
         chmod(APP_DIR . $this->filePath, 0777);
         // Store the ACL in APC
         if (function_exists('apc_store')) {
             apc_store('phalconseed-acl', $acl);
         }
     } else {
         $this->flash->error('The user does not have write permissions to create the ACL list at ' . APP_DIR . $this->filePath);
     }
     return $acl;
 }
コード例 #2
0
ファイル: RoleService.php プロジェクト: nhannhan159/T4Logs
 public function getAll()
 {
     return array('roles' => Roles::find()->toArray());
 }