I have a model, Volume, for which I want to limit access from Group,
using record-level ACL. Volume is also stored using MPTT
(TreeBehavior). So far, I've been able to create the entries in aros,
acos, & aros_acos.

Now, what I need to do is figure out a way to display the Volume tree
(easy) but, along with the Volume threaded data, fetch each Volume's
permissions wrt a specific Group. This is so that an admin can see at
a glance which Volumes a Group has access to by queerying against a
specific Group. I plan on using this tree to grant/deny access.

I can grab the Aco key for each Volume but can't figure out how to get
from that to the Group's permissions. The following code leaves me
with the proper tree and, for each Volume, its Aco. But there's no
join applied for Permission (aros_acos) nor Aro.

Anyone have any ideas?

$this->bindModel(
        array(
                'belongsTo' => array(
                        'Aco' => array(
                                'foreignKey' => false,
                                'conditions' => array(
                                        'Aco.model' => 'Volume',
                                        'Aco.foreign_key = Volume.id'
                                )
                        )
                )
        )
);

$filters = array(
        'fields' => array(
                'Volume.id',
                'Volume.parent_id',
                'Volume.lft',
                'Volume.rght',
                'Volume.name',
        ),
        'contain' => array(
                'Aco' => array(
                        'fields' => array('Aco.id'),
                        'Permission' => array(
                                'Aro' => array(
                                        'conditions' => array(
                                                'Aro.model' => 'Group',
                                                "Aro.foreign_key = ${group_id}"
                                        )
                                )
                        )
                )
        )
);

return $this->find('threaded', $filters);

The returned array is like:

Array
(
  [0] => Array
    (
      [Volume] => Array
        (
          [id] => 1
          [parent_id] =>
          [lft] => 1
          [rght] => 171
          [name] =>
        )

      [Aco] => Array
        (
          [id] => 2
        )

      [children] => Array
        (
          ...

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to