Cakephp Acl error - cakephp

I try to use alaxos acl plugin for study of Acl code
and I got error
Warning (512): AclNode::node() - Couldn't find Aro node identified by "Array
(
[Aro0.model] => Group
[Aro0.foreign_key] => admin
)
" [CORE\cake\libs\model\db_acl.php, line 191]
Warning (512): DbAcl::check() - Failed ARO/ACO node lookup in permissions check. Node references:
Aro: Array
(
[User] => Array
(
[id] => 76
[username] => tttttt
[group_id] => admin
[active] => 1
[activation_code] =>
[widget_count] =>
[lastvisit] =>
)
)
Aco: Users/add [CORE\cake\libs\controller\components\acl.php, line 273]
Warning (2): Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\cakephp\cake\libs\debugger.php:673) [CORE\cake\libs\
My Db picture here
User and Group Model
thank for answer

You should to set basic require data in database
it important for acl component to work right

Related

cakephp Associations Delete not working

I have a table of files and a table of permissions. The idea is that the user can assign permissions to other users to allow them to read, edit, etc. I set up an association so that the files, which I call workspaces, have many permissions. Here is the declaration in the workspaces model linking the permissions model
public $hasMany = array(
'Permission' => array(
'className' => 'Permission',
'foreignKey'=> 'workspace_id',
'dependent' => true
)
);
The problem is that when I go to delete a file, I get an error.
Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Permission.id' in 'field list'
SQL Query: SELECT `Permission`.`id` FROM `cadwolfc_workspaces`.`permissions` AS `Permission` WHERE `Permission`.`workspace_id` = 71
Why is cakephp looking for an id parameter in the permissions table when I have clearly defined the workspace_id as the foreign key? I had assumed that by linking the models and then deleting a workspace, the associated permissions would be deleted. That is what I am trying to do here. I don't understand why a select query is being executed when a delete query is what is needed?
Update: The call to delete the workspace item is done through an ajax call by passing the id of the workspace. I have confirmed that $fileid is the correct number.
$this->Workspace->delete($fileid);
Update 2: When I add a column to the permissions table titled 'id' add make its value the appropriate number, then the delete call works fine and all items are deleted. Why is this?

CakePHP "missing table" error when table should not exist

I'm getting the following error:
Array (
[0] => Missing table 'TEST_USERS'. If running from a test you may need to add 'app.TEST_USER' to the fixtures array. See output
below for more details.
[1] => Array
(
[className] => TESTUSER
[table] => TEST_USERS
[code] => 500
)
)
The table does not exist.
The table should not exist.
I grepped my code and found no reference to TEST_USERS, TESTUSERS or TEST.USERS.
I do have a table called USERS_TEST.
Can I get some trouble shooting hints?
Thanks!
Solution:
I changed:
var $useTable = 'TEST';
to:
var $useTable = 'test';
and it worked.

ACO alias doesn't work with 'controllers/Controller' value

I am new to ACLs in CakePHP. I believe my Administrator group is set up correctly with full access to the 'controllers' ACO. However I get an error when I try to go to any controller or action that is not explicitly made public.
Warning (512): DbAcl::check() - Failed ARO/ACO node lookup in permissions check. Node references:
Aro: Array
(
[User] => Array
(
[id] => 9
[email] => Admin
[group_id] => 3
[is_active] => 1
[created] => 2013-04-08 07:59:52
[modified] => 2013-04-08 07:59:52
[Group] => Array
(
[id] => 3
[name] => Administrators
[user_count] => 2
[created] => 2013-04-08 06:34:58
[modified] => 2013-04-08 06:34:58
)
)
)
Aco: controllers/Users/index [CORE/Cake/Model/Permission.php, line 94]
In my acos table there is an entry for 'controllers/Users/index' as the alias. This entry has a parent_id that references 'controllers/Users', which in turn has a parent_id which references 'controllers'.
There is only one entry in my 'aros_acos' table that is granting full permission to the Administrators group.
Based on the error above I did a little digging and found that if I directly try to call $this->Acl->Aco->node('controllers/Users/index'); the returned value is false. But if I do the same query on $this->Acl->Aco->node('controllers'); the returned value is the correct array.
Something is clearly not functioning properly but I can't figure out where I am going wrong. I have been digging in the Documentation Book and API all day and have not found any reason why 'controllers/Users/index' isn't found but 'controllers' is. At this point it seems like it has something to do with the / character but I don't know why. I used the same string when adding the Aco and it saved correctly.
Thanks!
I found the problem by installing the ACL Plugin at:
http://www.alaxos.net/blaxos/pages/view/plugin_acl_2.0
After running this great utility I found that I was incorrectly adding my ACOs with the fill path in the alias. It turns out the alias is just the action or controller name and based on the parent_id's it finds the correct path.
This is not very well documented in the CakePHP Documentation, but what else is new.
Example:
I was adding 'controllers/Users/index' instead of 'index'.
Hope this can help someone else solve this problem! I wasted an entire day on it.

CakePHP retrieving data from model using find(). Different array keys on production server

I have the same exact code on my production and development servers but I seem to get different array keys when using find('first') to retrieve data.
Development:
Array
(
[Page] => Array
(
[title] => Welcome!
[keywords] => keyword 1 keyword 2 keyword 3
)
)
Production:
Array
(
[0] => Array
(
[title] => Welcome!
[keywords] => keyword 1 keyword 2 keyword 3
)
)
Code in AppController:
//get page title and keywords
$currentPage = $this->Page->find('first',
array(
'conditions' => array('Page.name' => $this->params['controller']),
'fields' => array('Page.title', 'Page.keywords')
));
pr($currentPage);
I remember this one... :P I had the same problem before
It's caused either by the php version or the mysql version. Check if your server passes the minimum requirements for your cake version
requirements for cakephp2.0
requirements for cakephp1.3
you can check them using a phpinfo();
Hope this helps
use $this->set(compact('currentPage',$currentPage));

CakePHP - HABTM - adding multiple tags to multiple points

I am trying to 'tag' multiple 'points' with multiple tags. I'm tagging my single points successfully. Unfortunately, when i try and use a tag, such as 'test2' on another point as a tag it is either giving me a duplicate entry error if i have my 'unique' set to false or if 'unique' is set to true, it will del my tag for all other points for 'test2' and create a single new one.
Here is what i have for my post data:
Array
(
[Tag] => Array
(
[id] => 4b7af6d7-787c-4f10-aa49-2502c0a80001
[name] => Test2
)
[Point] => Array
(
[id] => 4b47c66f-a130-4d12-8ccd-60824051e4b0
)
)
In my tag model i have this:
public $hasAndBelongsToMany = array(
'Point' => array(
'className' => 'Point',
'joinTable' => 'points_tags',
'foreignKey' => 'tag_id',
'associationForeignKey' => 'point_id',
'unique' => false)
);
I have tried this with 'unique' set as true, too. Unfortunately, this will delete any other instances of 'Test2' in the join table ('points_tags').
I have tried this using both save() and saveAll(). Both are giving me this error:
Warning (512): SQL Error: 1062: Duplicate entry '4b7af6d7-787c-4f10-aa49-2502c0a80001-4b47c66f-a130-4d12-8ccd-608' for key 'MAN_ADD' [CORE/cake/libs/model/datasources/dbo_source.php, line 527]
Query: INSERT INTO points_tags (tag_id,point_id,id) VALUES ('4b7af6d7-787c-4f10-aa49-2502c0a80001','4b47c66f-a130-4d12-8ccd-60824051e4b0','4b7b39f3-46f8-4744-ac53-3973c0a80001')
Thoughts????
Suggestions????
Where does the id come from? I'm guessing its a primary key of the table, and from what I understand from your post (please write more clearly, help us help you) the problem isn't with points or tags, but with the id in the points_tags table.
When you use the save method, are you doing it inside of a loop? Remember, best practice is to call model::create() whenever you're saving in a loop.
I frequently find that when I have issues with the HABTM saving behavior, it's because I didn't call model::create.

Resources