Manage ACL with already Auth user

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Manage ACL with already Auth user

mbagiella
This post has NOT been accepted by the mailing list yet.
This post was updated on .
Hi everybody,
My question is pretty simple and should be easy to be resolved by expert zend 1.11 like you :D
I develop an application zend into a iFrame and the loggin part it's already done by an other project.
I receive only the id of the user not the role.
Roles are stored as follow in the mysql database in the same table of user id :

user id, role, create, read, update, delete
1,admin,1,1,1,1
2,guest,0,1,0,0
3,user,1,1,1.0

Can someone show me how I can manage the acl, I'm lost :(
What should I use, can I develop all the logic on the bootstrap ?
Something like

<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
   
    protected function _initAcl()
    {
        $this->bootstrap('db');
        $acl = new Zend_Acl();
        Zend_Registry::set('session', $session = new Zend_Session_Namespace('app'));
        $user = new Application_Model_DbTable_User();
        $role = $user->find($session->id)->current();
        ($role->create)?$acl->allow(null,null,'create'):$acl->deny(null,null,'create');
        ($role->read)?$acl->allow(null,null,'read'):$acl->deny(null,null,'read');
        ($role->update)?$acl->allow(null,null,'update'):$acl->deny(null,null,'update');
        ($role->delete)?$acl->allow(null,null,'delete'):$acl->deny(null,null,'delete');
    }

Thanks for help