title: Zend_Acl, How to check a user with multiple roles for resource access
body: <p><br/>
     i am implementing RBAC for my app, and everything is managed from database. </p>
  
  <p>for example i am storing all resources/permissions in a table called <code>permission</code> , all roles in <code>role</code> table, and another table called <code>role_permission</code> to define which role have access to which resources/permissions.</p>
  
  <p>the purpose for going with this approach is because i want the administrator of the app to create the <code>role</code> and assign the permission to role by himself.</p>
  
  <p>User of the app can have multiple roles for example <code>administrator</code>, <code>supervisor</code>, <code>player</code>, <code>referee</code> etc.</p>
  
  <p>I created a model class for <code>Zend_Acl</code> to add roles and resources and assign permission to it.</p>
  
  <p>Below is what i did.</p>
  
  <pre><code>foreach($this-&gt;_roles as $role) {
      $this-&gt;addRole(new Zend_Acl_Role($role['id']));
  }
  foreach($this-&gt;_permissions as $permmission) {
      $this-&gt;addResource(new Zend_Acl_Resource($permmission['id']));
  }
  foreach($this-&gt;_rolePermissions as $value) {
      $this-&gt;allow($value['role_id'], $value['permmission_id']);
  }
  $this-&gt;allow($this-&gt;_roleAdmin);
  </code></pre>
  
  <p>it works fine if i want to check wether a permission exist for a particular role for example by using this code.</p>
  
  <pre><code>echo $acl-&gt;isAllowed($role, $permission) ? 'allowed' : 'denied';
  </code></pre>
  
  <p>however i want to check with multiple roles wether the current permission exist for a user with multiple roles.</p>
  
  <p>how am i supposed to check wether the user with multiple roles such as <code>referee</code>, <code>supervisor</code>  has the access to resource <code>create report</code>. with isAllowed() you can only check for permission for only 1 role.</p>