Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-24-2008, 11:08 PM
Junior Member
 
Join Date: Apr 2008
Posts: 6
Default Zend Framework ACL ... issue getting parents

'ello all.

I am having one heck of a time getting ZF's ACL to accept inheritance.

Here is my code, sans DB info. It should, hopefully, be pretty self explanatory.

PHP Code:
$acl = new Zend_Acl;
      
$acl->add(new Zend_Acl_Resource($resources_id_GUID));
      
$userRolesArray array_reverse($userRolesArray);
      foreach(
$userRolesArray as $key => $value){
        if(!empty(
$value['roles_name'])){
          
$acl->addRole(new Zend_Acl_Role($value['roles_name'], $roles->getParent($value['roles_name'])));
          if(
is_array($value['permissions']) && count($value['permissions']) > 0){
            
$tmp $value['permissions'];
            
$perms = array();
            foreach(
$tmp as $ke => $va)
              
$perms[] = $va['permissions_name'];
            
$acl->allow($value['roles_name'], $resources_id_GUID$perms);
          }
        } else continue;
      } 
But to elaborate ...
I have a resource that I add to the ACL
Then I loop an array of known user roles
I add the role and find it's parent
I add the permissions
Allow access to the resource
restart

My end object looks like this for some reason though:
Code:
Zend_Acl Object
(
    [_roleRegistry:protected] => Zend_Acl_Role_Registry Object
        (
            [_roles:protected] => Array
                (
                    [guest] => Array
                        (
                            [instance] => Zend_Acl_Role Object
                                (
                                    [_roleId:protected] => guest
                                )

                            [parents] => Array
                                (
                                )

                            [children] => Array
                                (
                                )

                        )

                    [member] => Array
                        (
                            [instance] => Zend_Acl_Role Object
                                (
                                    [_roleId:protected] => member
                                )

                            [parents] => Array
                                (
                                )

                            [children] => Array
                                (
                                )

                        )

                    [moderator] => Array
                        (
                            [instance] => Zend_Acl_Role Object
                                (
                                    [_roleId:protected] => moderator
                                )

                            [parents] => Array
                                (
                                )

                            [children] => Array
                                (
                                )

                        )

                    [admin] => Array
                        (
                            [instance] => Zend_Acl_Role Object
                                (
                                    [_roleId:protected] => admin
                                )

                            [parents] => Array
                                (
                                )

                            [children] => Array
                                (
                                )

                        )

                    [super] => Array
                        (
                            [instance] => Zend_Acl_Role Object
                                (
                                    [_roleId:protected] => super
                                )

                            [parents] => Array
                                (
                                )

                            [children] => Array
                                (
                                )

                        )

                )

        )

    [_resources:protected] => Array
        (
            [be5824da-5ef5-45ed-907a-89fe76ec3473] => Array
                (
                    [instance] => Zend_Acl_Resource Object
                        (
                            [_resourceId:protected] => be5824da-5ef5-45ed-907a-89fe76ec3473
                        )

                    [parent] => 
                    [children] => Array
                        (
                        )

                )

        )

    [_rules:protected] => Array
        (
            [allResources] => Array
                (
                    [allRoles] => Array
                        (
                            [allPrivileges] => Array
                                (
                                    [type] => TYPE_DENY
                                    [assert] => 
                                )

                            [byPrivilegeId] => Array
                                (
                                )

                        )

                    [byRoleId] => Array
                        (
                        )

                )

            [byResourceId] => Array
                (
                    [be5824da-5ef5-45ed-907a-89fe76ec3473] => Array
                        (
                            [byRoleId] => Array
                                (
                                    [admin] => Array
                                        (
                                            [byPrivilegeId] => Array
                                                (
                                                    [write] => Array
                                                        (
                                                            [type] => TYPE_ALLOW
                                                            [assert] => 
                                                        )

                                                    [read] => Array
                                                        (
                                                            [type] => TYPE_ALLOW
                                                            [assert] => 
                                                        )

                                                )

                                        )

                                )

                        )

                )

        )

)
Roles
*Super
**Admin
***Moderator
****Member
*****Guest

Any help would be awesome. As you can see, the parents property is not populated in any role.

TIA!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 07-25-2008, 02:47 PM
Junior Member
 
Join Date: Apr 2008
Posts: 6
Default

The issue was a ) in the wrong spot.

The correction looks like

PHP Code:
$acl->addRole(new Zend_Acl_Role($value['roles_name']), $roles->getParent($value['roles_name'])); 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 04:03 AM.