I am using cakephp for some time now and just started with ACL. I've got it up and running, except one thing. How can I find all documents available to the current user?
I have several groups (super users, admins and general users) set up in the Aros table. I have several documents which should be all accessible to the super users and admins, but only specific ones to the general users. The closest thing I came up with is:
$this->data=$this->Document->find('all',array('fields'=>array('Document.id','Document.filename','Document.title')));
foreach($this->data as $i=>$document){
if($this->Acl->check(array('model'=>'User','foreign_key'=>$this->Session->read('User.id')),array('model'=>'Document','foreign_key'=>$document['Document']['id']))!=1){
unset($this->data[$i]);
}
}
The problem with the above "solution" is that it first queries all documents (which will become several thousands in the near future) and then brings it down to potentially a couple of documents by deleting all inaccessible documents from the $this->data array...