Reply to all, reply to all... ;) -------- Original Message -------- Subject: Re: [fw-general] How to implement Zend_Acl ? Date: Thu, 19 Apr 2007 09:59:23 -0700 From: Darby Felton <[EMAIL PROTECTED]> To: Juan Felipe Alvarez Saldarriaga <[EMAIL PROTECTED]> References: <[EMAIL PROTECTED]>
Hi Juan, Zend_Acl operates by registering Role and Resource objects to it and specifying the rules that determine how Roles may access Resource objects. Juan Felipe Alvarez Saldarriaga wrote: > I want to implement Zend_Acl into my application, but I dont know how to > put work that with a database model, there are some tutorial or page > that I can see ? You ask about integrating with database model, and Zend_Acl should be able to accommodate your needs here, because an object need only implement Zend_Acl_Role_Interface or Zend_Acl_Resource_Interface if you want the object to be a valid Role or Resource, respectively. This is documented in the manual: http://framework.zend.com/manual/en/zend.acl.html An example: class Building implements Zend_Acl_Resource_Interface { public function getResourceId() { // implement this method } } In essence, an object need only uniquely identify itself to Zend_Acl in order to be treated as a Role or Resource. With the above defined, any object of class Building can be a Zend_Acl Resource, provided that it uniquely identifies itself with getResourceId(). > Another question about Zend_Acl, in the example to add resources: > $acl->add(new Zend_Acl_Resource('newsletter')); // newsletter > > This "newsletter" is what ? a controller ? a method ?, cause I want to > restrict access to the controllers, this is my idea, check permissions > of the current user using Zend_Acl, then restrict the access to some > controllers to this user, is this possible ? Zend_Acl_Resource is an extremely simple implementation of Zend_Acl_Resource_Interface, where you pass the identifier to the object's constructor. In the above example, 'newsletter' is the identifier for the added resource, nothing more. Simon Mundy and Matthew Weier O'Phinney and others whom I cannot immediately recall have posted many times in the past how this can be done. Searching the mailing list should reveal some useful results. The short version... implement preDispatch() in a controller plugin. You might also take a look at this: http://www.nabble.com/Re%3A-ACL-for-modules-p10019759s16154.html The unit tests for Zend_Acl may also illustrate how to use the component and the results you can expect when using it. We have planned to provide tutorial-style documentation that would cover this use case, but it will most likely be completed after 1.0.0, since we are currently focused on getting the framework ready for this release. Hope this helps! Best regards, Darby