title: Zend Framework dynamic ACL with special privileges depending on DB entries
body: <p>I need to implement ACL in a ZF application (with Doctrine 2).</p>
  
  <p>The goal is:
  When a user logs in, all his privileges should be determined an saved to memcache, to be accessible quickly throughout the session.</p>
  
  <p>The problem is that there a special privileges the can't be described via module > controller > action.</p>
  
  <p>e.g.</p>
  
  <p>table 'user'</p>
  
  <p>id  &nbsp;name</p>
  
  <p>1   &nbsp;&nbsp;Admin</p>
  
  <p>2   &nbsp;&nbsp;Peter</p>
  
  <p>…</p>
  
  <p>table 'role'</p>
  
  <p>id  &nbsp;name</p>
  
  <p>1   &nbsp;&nbsp;admin</p>
  
  <p>2   &nbsp;&nbsp;user</p>
  
  <p>… </p>
  
  <p>table 'user_role'</p>
  
  <p>id  &nbsp;&nbsp;&nbsp;user_id   &nbsp;&nbsp;&nbsp;role_id</p>
  
  <p>1      &nbsp;&nbsp;&nbsp; 1     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1</p>
  
  <p>2   &nbsp;&nbsp;&nbsp;&nbsp;2   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  2</p>
  
  <p>… </p>
  
  <p>table 'item'</p>
  
  <p>id&nbsp;    owner</p>
  
  <p>1   &nbsp;&nbsp;1</p>
  
  <p>2   &nbsp;&nbsp;4</p>
  
  <p>…</p>
  
  <p>We have items, which only should be editable by the admin or the user who has created the item (owner).
  How could this be described in a privileges table ?</p>
  
  <p>table 'privilege'</p>
  
  <p>id  &nbsp;role_id       … </p>
  
  <p>1   &nbsp;&nbsp;2</p>