Problem adding ACO and ARO

2008-01-07 Thread Andreas

Hi,
I've followed the tutorial at 
http://bakery.cakephp.org/articles/view/how-to-use-acl-in-1-2-x
and ran in to some problems. Signing up a new user is working fine,
both ACO and ARO are created, but when trying to add a new post I get:

Warning (512): AclNode::node() - Couldn't find Aco node identified by
Array
(
[Aco0.model] = Post
[Aco0.foreign_key] = 14
)
 [CORE/cake/libs/model/db_acl.php, line 172]

Warning (512): DB_ACL::allow() - Invalid node [CORE/cake/libs/
controller/components/acl.php, line 362].

The post is still added to the database though. The Post model lookes
like this

?php
class Post extends AppModel {
var $name = 'Post';
var $actAs = array('Acl' = 'controlled');
var $belongsTo = array('User' =
array('className' = 'User'
)
  );
function parentNode()
{
return $this-name;
}
?

and the add-action in PostsController
function add()
{
if (!empty($this-data))
{
$this-Post-data = $this-data;
$id = $this-Session-read('Auth.User.id');
$this-data['Post']['user_id'] = $id;

$this-Post-create();
if($this-Post-save($this-data))
{
debug($this-Post);

// ACL
$aroNode = array('model' = 'User', 'foreign_key' =
$id);
$acoNode = array('model' = 'Post', 'foreign_key' =
$this-Post-getLastInsertID());
$this-Acl-allow($aroNode,$acoNode,'*');

$this-flash('Success','/users/profile/'.$id);
}
}
}

All help I can get is appreciated!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Problem adding ACO and ARO

2008-01-07 Thread Andreas

Looking at the SQL debug the failing one is
SELECT `Aco`.`id`, `Aco`.`parent_id`, `Aco`.`model`,
`Aco`.`foreign_key`, `Aco`.`alias` FROM `acos` AS `Aco` LEFT JOIN
`acos` AS `Aco0` ON (`Aco`.`lft` = `Aco0`.`lft` AND `Aco`.`rght` =
`Aco0`.`rght`) WHERE `Aco0`.`model` = 'Post' AND `Aco0`.`foreign_key`
= 16 ORDER BY `Aco`.`lft` DESC

It seems as the Post model never creates the ACO upon saving... to
quote the tutorial from the Bakery Above code, will now automatically
create a new aco for every new post that is posted. The Acl behavior
takes care of all details. :/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Problem adding ACO and ARO

2008-01-07 Thread Andreas

I'm and idiot, a simple typo was the problem, never mind this thread.
About 2h wasted because I thaught it would be better to type the code
by hand instead of copypaste :) Oh well...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---