Defining Model Relations for ACL Interface (gui) with CakePHP

Hello,

I have set up Auth and ACL successfully on my cakePHP app.

How, now i want to build an interface for managing the ACL's, ARO's and ACO's

ARO's and ACO's where pretty easy to build using the tree behavior.
ACL how ever got me a little messed up... especially when it came to defining the model relations.

I've named my aco and aro models Myaco and Myaro respectivly, since Aco and Aro are already taking by the AclComponent., my ACL model is Myacl.

Myaco is a "standalone" object, it isn't related to any other model.
Myaro "belongsTo" 'Customer' model (which is my "user" model) and defined as so:

//Myaro model
var $belongsTo = array('Customer'=> array(
    									'foreignKey'    => 'foreign_key'
    									));

Now the Myacl model as i understand it, is a $hasAndBelongsToMany -> Myaco and Myaro since its a table that joins two other models;
as such i've set it up like this:

class Myacl extends AppModel {
    var $useTable = 'aros_acos';
    var $hasAndBelongsToMany = array(
    	'Myaro' => array(
    					'foreignKey' => 'aro_id',
     					'associationForeignKey' => 'id',
     					'joinTable' => 'aros_acos'
    				),
    	'Myaco'	=> array(
    					'foreignKey' => 'aco_id',
    					'associationForeignKey' => 'id',
    					'joinTable' => 'aros_acos'
    					),
    );
}

Now to build the main "interface" for the ACL, i wanted to "find('all')" ACL records, and have the linked (recursed) up to the 'Customer' level - so that i could display the groups and the actual customers from the aro table; so i set the recursive parameter to "2" for the Myacl model

Though judging by the SQL queries of the debug pane - the relation isn't correct at all..
Was i totally wrong in how i set the relations?

Here is are the basic SQL queries from the find('all') call:

from this code (in the Myacl controller):

$this->Myacl->recursive = 2;
$allRules = $this->Myacl->findAll();

the queries are:

1   DESCRIBE `aros`		7	7	13
2   DESCRIBE `acos`		7	7	1
3   DESCRIBE `aros_acos`		3	3	1
4   DESCRIBE `customers`		9	9	2
5   SELECT `Myacl`.`id`, `Myacl`.`aro_id`, `Myacl`.`aco_id` FROM `aros_acos` AS `Myacl` WHERE 1 = 1 ORDER BY `Myacl`.`id` ASC 		9	9	0
6   SELECT `Myaro`.`id`, `Myaro`.`parent_id`, `Myaro`.`model`, `Myaro`.`foreign_key`, `Myaro`.`alias`, `Myaro`.`lft`, `Myaro`.`rght`, `ArosAco`.`id`, `ArosAco`.`aro_id`, `ArosAco`.`aco_id` FROM `aros` AS `Myaro` JOIN `aros_acos` AS `ArosAco` ON (`ArosAco`.`aro_id` IN (1, 2, 3, 4, 5, 6, 7, 8, 9) AND `ArosAco`.`id` = `Myaro`.`id`) WHERE 1 = 1 		9	9	0
7   SELECT `Customer`.`id`, `Customer`.`username`, `Customer`.`email`, `Customer`.`password`, `Customer`.`company_name`, `Customer`.`contact_person`, `Customer`.`contact_email`, `Customer`.`contact_phone`, `Customer`.`disabled` FROM `customers` AS `Customer` WHERE `Customer`.`id` = 1 		1	1	0
8   SELECT `Customer`.`id`, `Customer`.`username`, `Customer`.`email`, `Customer`.`password`, `Customer`.`company_name`, `Customer`.`contact_person`, `Customer`.`contact_email`, `Customer`.`contact_phone`, `Customer`.`disabled` FROM `customers` AS `Customer` WHERE `Customer`.`id` = 2 		1	1	0
9   SELECT `Customer`.`id`, `Customer`.`username`, `Customer`.`email`, `Customer`.`password`, `Customer`.`company_name`, `Customer`.`contact_person`, `Customer`.`contact_email`, `Customer`.`contact_phone`, `Customer`.`disabled` FROM `customers` AS `Customer` WHERE `Customer`.`id` = 4 		1	1	0
10  SELECT `Customer`.`id`, `Customer`.`username`, `Customer`.`email`, `Customer`.`password`, `Customer`.`company_name`, `Customer`.`contact_person`, `Customer`.`contact_email`, `Customer`.`contact_phone`, `Customer`.`disabled` FROM `customers` AS `Customer` WHERE `Customer`.`id` = 1 		1	1	0
11  SELECT `Customer`.`id`, `Customer`.`username`, `Customer`.`email`, `Customer`.`password`, `Customer`.`company_name`, `Customer`.`contact_person`, `Customer`.`contact_email`, `Customer`.`contact_phone`, `Customer`.`disabled` FROM `customers` AS `Customer` WHERE `Customer`.`id` = 2 		1	1	0
12  SELECT `Customer`.`id`, `Customer`.`username`, `Customer`.`email`, `Customer`.`password`, `Customer`.`company_name`, `Customer`.`contact_person`, `Customer`.`contact_email`, `Customer`.`contact_phone`, `Customer`.`disabled` FROM `customers` AS `Customer` WHERE `Customer`.`id` = 4 		1	1	0
13  SELECT `Customer`.`id`, `Customer`.`username`, `Customer`.`email`, `Customer`.`password`, `Customer`.`company_name`, `Customer`.`contact_person`, `Customer`.`contact_email`, `Customer`.`contact_phone`, `Customer`.`disabled` FROM `customers` AS `Customer` WHERE `Customer`.`id` = 1 		1	1	0
14  SELECT `Customer`.`id`, `Customer`.`username`, `Customer`.`email`, `Customer`.`password`, `Customer`.`company_name`, `Customer`.`contact_person`, `Customer`.`contact_email`, `Customer`.`contact_phone`, `Customer`.`disabled` FROM `customers` AS `Customer` WHERE `Customer`.`id` = 2 		1	1	0
15  SELECT `Customer`.`id`, `Customer`.`username`, `Customer`.`email`, `Customer`.`password`, `Customer`.`company_name`, `Customer`.`contact_person`, `Customer`.`contact_email`, `Customer`.`contact_phone`, `Customer`.`disabled` FROM `customers` AS `Customer` WHERE `Customer`.`id` = 4 		1	1	0
16  SELECT `Customer`.`id`, `Customer`.`username`, `Customer`.`email`, `Customer`.`password`, `Customer`.`company_name`, `Customer`.`contact_person`, `Customer`.`contact_email`, `Customer`.`contact_phone`, `Customer`.`disabled` FROM `customers` AS `Customer` WHERE `Customer`.`id` = 1 		1	1	0
17  SELECT `Customer`.`id`, `Customer`.`username`, `Customer`.`email`, `Customer`.`password`, `Customer`.`company_name`, `Customer`.`contact_person`, `Customer`.`contact_email`, `Customer`.`contact_phone`, `Customer`.`disabled` FROM `customers` AS `Customer` WHERE `Customer`.`id` = 2 		1	1	0
18  SELECT `Customer`.`id`, `Customer`.`username`, `Customer`.`email`, `Customer`.`password`, `Customer`.`company_name`, `Customer`.`contact_person`, `Customer`.`contact_email`, `Customer`.`contact_phone`, `Customer`.`disabled` FROM `customers` AS `Customer` WHERE `Customer`.`id` = 4 		1	1	0
19  SELECT `Customer`.`id`, `Customer`.`username`, `Customer`.`email`, `Customer`.`password`, `Customer`.`company_name`, `Customer`.`contact_person`, `Customer`.`contact_email`, `Customer`.`contact_phone`, `Customer`.`disabled` FROM `customers` AS `Customer` WHERE `Customer`.`id` = 1 		1	1	0
20  SELECT `Customer`.`id`, `Customer`.`username`, `Customer`.`email`, `Customer`.`password`, `Customer`.`company_name`, `Customer`.`contact_person`, `Customer`.`contact_email`, `Customer`.`contact_phone`, `Customer`.`disabled` FROM `customers` AS `Customer` WHERE `Customer`.`id` = 2 		1	1	0
21  SELECT `Customer`.`id`, `Customer`.`username`, `Customer`.`email`, `Customer`.`password`, `Customer`.`company_name`, `Customer`.`contact_person`, `Customer`.`contact_email`, `Customer`.`contact_phone`, `Customer`.`disabled` FROM `customers` AS `Customer` WHERE `Customer`.`id` = 4 		1	1	0
22  SELECT `Customer`.`id`, `Customer`.`username`, `Customer`.`email`, `Customer`.`password`, `Customer`.`company_name`, `Customer`.`contact_person`, `Customer`.`contact_email`, `Customer`.`contact_phone`, `Customer`.`disabled` FROM `customers` AS `Customer` WHERE `Customer`.`id` = 1 		1	1	0
23  SELECT `Customer`.`id`, `Customer`.`username`, `Customer`.`email`, `Customer`.`password`, `Customer`.`company_name`, `Customer`.`contact_person`, `Customer`.`contact_email`, `Customer`.`contact_phone`, `Customer`.`disabled` FROM `customers` AS `Customer` WHERE `Customer`.`id` = 2 		1	1	0
24  SELECT `Customer`.`id`, `Customer`.`username`, `Customer`.`email`, `Customer`.`password`, `Customer`.`company_name`, `Customer`.`contact_person`, `Customer`.`contact_email`, `Customer`.`contact_phone`, `Customer`.`disabled` FROM `customers` AS `Customer` WHERE `Customer`.`id` = 4 		1	1	0
25  SELECT `Customer`.`id`, `Customer`.`username`, `Customer`.`email`, `Customer`.`password`, `Customer`.`company_name`, `Customer`.`contact_person`, `Customer`.`contact_email`, `Customer`.`contact_phone`, `Customer`.`disabled` FROM `customers` AS `Customer` WHERE `Customer`.`id` = 1 		1	1	0
26  SELECT `Customer`.`id`, `Customer`.`username`, `Customer`.`email`, `Customer`.`password`, `Customer`.`company_name`, `Customer`.`contact_person`, `Customer`.`contact_email`, `Customer`.`contact_phone`, `Customer`.`disabled` FROM `customers` AS `Customer` WHERE `Customer`.`id` = 2 		1	1	0
27  SELECT `Customer`.`id`, `Customer`.`username`, `Customer`.`email`, `Customer`.`password`, `Customer`.`company_name`, `Customer`.`contact_person`, `Customer`.`contact_email`, `Customer`.`contact_phone`, `Customer`.`disabled` FROM `customers` AS `Customer` WHERE `Customer`.`id` = 4 		1	1	0
28  SELECT `Customer`.`id`, `Customer`.`username`, `Customer`.`email`, `Customer`.`password`, `Customer`.`company_name`, `Customer`.`contact_person`, `Customer`.`contact_email`, `Customer`.`contact_phone`, `Customer`.`disabled` FROM `customers` AS `Customer` WHERE `Customer`.`id` = 1 		1	1	0
29  SELECT `Customer`.`id`, `Customer`.`username`, `Customer`.`email`, `Customer`.`password`, `Customer`.`company_name`, `Customer`.`contact_person`, `Customer`.`contact_email`, `Customer`.`contact_phone`, `Customer`.`disabled` FROM `customers` AS `Customer` WHERE `Customer`.`id` = 2 		1	1	0
30  SELECT `Customer`.`id`, `Customer`.`username`, `Customer`.`email`, `Customer`.`password`, `Customer`.`company_name`, `Customer`.`contact_person`, `Customer`.`contact_email`, `Customer`.`contact_phone`, `Customer`.`disabled` FROM `customers` AS `Customer` WHERE `Customer`.`id` = 4 		1	1	0
31  SELECT `Customer`.`id`, `Customer`.`username`, `Customer`.`email`, `Customer`.`password`, `Customer`.`company_name`, `Customer`.`contact_person`, `Customer`.`contact_email`, `Customer`.`contact_phone`, `Customer`.`disabled` FROM `customers` AS `Customer` WHERE `Customer`.`id` = 1 		1	1	0
32  SELECT `Customer`.`id`, `Customer`.`username`, `Customer`.`email`, `Customer`.`password`, `Customer`.`company_name`, `Customer`.`contact_person`, `Customer`.`contact_email`, `Customer`.`contact_phone`, `Customer`.`disabled` FROM `customers` AS `Customer` WHERE `Customer`.`id` = 2 		1	1	0
33  SELECT `Customer`.`id`, `Customer`.`username`, `Customer`.`email`, `Customer`.`password`, `Customer`.`company_name`, `Customer`.`contact_person`, `Customer`.`contact_email`, `Customer`.`contact_phone`, `Customer`.`disabled` FROM `customers` AS `Customer` WHERE `Customer`.`id` = 4 		1	1	0
34  SELECT `Myaco`.`id`, `Myaco`.`parent_id`, `Myaco`.`model`, `Myaco`.`foreign_key`, `Myaco`.`alias`, `Myaco`.`lft`, `Myaco`.`rght`, `ArosAco`.`id`, `ArosAco`.`aro_id`, `ArosAco`.`aco_id` FROM `acos` AS `Myaco` JOIN `aros_acos` AS `ArosAco` ON (`ArosAco`.`aco_id` IN (1, 2, 3, 4, 5, 6, 7, 8, 9) AND `ArosAco`.`id` = `Myaco`.`id`) WHERE 1 = 1

You can see from the amount of "Customer" queries, and from the joins - that something is seriously "off" with the model relations..

Any advice or leads are greatly appreciated.
Thanks,
Ken.