ACL Management Plugin
A simple, easy, AJAXY, solution for managing your access control lists.
Introduction
It has been done before. I believe both Mariano Iglesias (mariano_iglesias) and Andy Dawson (ad7six) have both created ACL plugins. But unfortunately, at the time of this writing, neither of them worked for me. So I decided to create an AJAX ACL plugin. I needed one for my current project, plus I wanted to contribute something else to CakePHP outside of the crappy Oracle DBO that I wrote a year ago; and writing a fancy new plugin is way more fun that writing data import scripts and reports for my boss.
Before I waste too much of your time, you're welcome to check out a demo here:
http://dev.newnewmedia.com/cakephp/admin/acl
If you're still with me, then I can explain how you can get this puppy working for yourself.
Requirements:
Note: At the time of this writing, CakePHP has no way of bundling images/css/js within the plugin. So if you want this thing to look pretty, you're going to have to do a little extra work.
That's it! The ACL management plugin should be installed. Usage instructions are built into the plugin, so I do not have to go on at length about it here.
If you have any questions feel free to leave comments here in the Bakery.
It has been done before. I believe both Mariano Iglesias (mariano_iglesias) and Andy Dawson (ad7six) have both created ACL plugins. But unfortunately, at the time of this writing, neither of them worked for me. So I decided to create an AJAX ACL plugin. I needed one for my current project, plus I wanted to contribute something else to CakePHP outside of the crappy Oracle DBO that I wrote a year ago; and writing a fancy new plugin is way more fun that writing data import scripts and reports for my boss.
Before I waste too much of your time, you're welcome to check out a demo here:
http://dev.newnewmedia.com/cakephp/admin/acl
If you're still with me, then I can explain how you can get this puppy working for yourself.
Requirements:
- PHP 4 or 5
- CakePHP 1.2 Beta
- ACL Plugin - svn://newnewmedia.com/cakephp/plugins/acl
- Prototype 1.5.1.1 - http://www.prototypejs.org/assets/2007/6/20/prototype.js
- Tango Icon Library - http://tango-project.org/releases/tango-icon-theme-0.8.1.tar.gz
Note: At the time of this writing, CakePHP has no way of bundling images/css/js within the plugin. So if you want this thing to look pretty, you're going to have to do a little extra work.
- Download Prototype, drop the file directly into /app/webroot/js
- Download Tango Icon Library, name the folder 'tango', and put it in /app/webroot/img
- Checkout the ACL plugin source from svn and put the 'acl' folder in /app/plugins
- edit your core.php and turn on admin routing
- Browse to the address /admin/acl
That's it! The ACL management plugin should be installed. Usage instructions are built into the plugin, so I do not have to go on at length about it here.
If you have any questions feel free to leave comments here in the Bakery.

http://github.com/phishy/acl_plugin http://github.com/markstory/acl_extras for cake1.3
http://github.com/thatcode/PermissiblePlugin http://github.com/jmcneese/permissionable
Louis
now that the code is on github how do we load this into our apps?
I've got lots more folders in the tarball and don't know where they all go.
thx for the help
and the source from http://github.com/phishy doesn't work also.
Can anybody put the code to any other location?
Thanks a lot.
Mareg
I've just installed the plugin and initialize acl's tables in my BD with a script found here : http://www.formation-cakephp.com/32/gestion-des-droits-dacces-par-groupes-dutilisateurs-avec-acl (sorry im french) and the plugin donn't find anything and on all the plugin's page it show that there is no aros and acos.
Do someone know why ?
Is ACL Management Plugin still available. I have tried to checkout but the repository is not available.
svn://newnewmedia.com/cakephp/plugins/acl
But i get the following error..
Can't connect to host 'newnewmedia.com': No connection could be made because the target machine actively refused it.
I couldn't get it either. But, think he's got a copy here http://github.com/phishy
I am having an issue while setting up CakePHP ACL Plugin.
Missing Method in AclController
Error: The action index is not defined in controller AclController
Error: Create AclController::index() in file: admin\controllers\acl_controller.php.
Could you please provide me some advice on this?
Thanks
You can put the images, js and css files into de vendors directory of your plugin.
Ed
When I tried to run the ACL admin, I ran into the following error:
Fatal error: Class 'AclNode' not found in ../app/plugins/acl/models/acl_aco.php on line 7
Adding the this piece of code to acl_aco.php and acl_aro.php solved the problem.
<?php
if (!class_exists('AclNode')) {
uses('model' . DS . 'db_acl');
}
//Model code
class AclAro extends AclNode {
}
?>
I'm seeing a couple of issues when running this locally though.
My display doesn't look like your demo. I downloaded the latest from subversion, but I don't see the bits at the bottom of the page when assigning permissions (or more importantly, I have to click the lists again to see the updated permissions).
I had to copy the acl.css to my webroot/css folder to get the right CSS on the pages (this seems to sort have fixed the issue with the debug too, since now it's all nicely formatted, although the debug code still shows up in the list boxes).
Appears to me that the fix is to change the acl/views/layout/default.ctp at line 40 from:
<?php echo $html->css('acl');?>To:<?php echo $html->css('/acl/css/acl');?>However, http://localhost/admin/acl/acl does work. Probably because the Book says plugins should be called like /pluginname/controllername/action.
http://book.cakephp.org/view/119/Plugin-Tips
it seems that I am unable to find the plugin.
copied your plugin to my app/plugins
saved prototype.js and tango icons
enabled admin routing
but it can't find it
I use acl, and tried to add an aro for it and to allow me to access: no success
Any hint? thanks!
marco
http://tango.freedesktop.org/releases/
and the direct download
http://tango.freedesktop.org/releases/tango-icon-theme-0.8.1.tar.gz
That's the demo, while svn repo's can be accessed via http sometimes he has his setup via the svn protocol. The correct address is svn://newnewmedia.com/cakephp/plugins/acl
when i want to checkout then show failed.
why?
I really like your work. I use your versionbehavior as well which i took sometime to fgure out.
Anyways, I cannot seem to get my hand on the acl plugin sources. the SVN doesnt exist. I tried cakeforge, your project is lsited but no files again.
Is it not usable anymore?
Thanks, this ACL plugin stuff looks great
To get arround it (temporarily) I used the following:
/app/plugins/views/acl/admin_aros.cpt
change:
function (transport) {
data = eval("("+transport.responseText+")");
$('aro_editor_id').value = data.id;
$('aro_editor_originalParentId').value = data.parent_id;
$('aro_editor_alias').value = data.alias;
$('aro_editor_model').value = data.model;
$('aro_editor_foreignKey').value = data.key;
$('aro_editor_create').hide();
$('aro_editor_update').show();
$('aro_editor_cancel').show();
$('aro_editor_delete').show();
indicator_hide();
}});
to:
function (transport) {
TspRsp = transport.responseText;
TspRsp = TspRsp.split(",");
idsplit = TspRsp[0].split('"');
id = idsplit[3];
aliasSplit = TspRsp[1].split('"');
alias = aliasSplit[3];
modelSplit = TspRsp[2].split('"');
model = modelSplit[3];
fkSplit = TspRsp[3].split('"');
fk = fkSplit[3];
$('aro_editor_id').value = id;
$('aro_editor_alias').value = alias;
$('aro_editor_model').value = model;
$('aro_editor_foreignKey').value = fk;
$('aro_editor_create').hide();
$('aro_editor_update').show();
$('aro_editor_cancel').show();
$('aro_editor_delete').show();
indicator_hide();
}});
Not elegant but did the trick.
I tried your demo of the acl manager and want to give it a try!
But I get an error when I try to "browse" the link svn://newnewmedia.com/cakephp/plugins/acl (I use tortoise SVN)
Can you double check that the files are in place?
Regs and greets
Par
The only biggish issue I am having is with compatibility with IE7. It doesnt load AJAX dropdowns for some reason. Any clues why? Its OK under Firefox.
Please read:
http://forum.mootools.net/topic.php?id=4186#post-39085
http://tango.freedesktop.org/Tango_Icon_Library
the acl_app_controller.php is in the app directory and the other controllers in the same named folder....
And one more question ! Can any one simulate a scenario on DEMO site http://dev.newnewmedia.com/cakephp/admin/acl
e.g for Post vs User/Groups such that
Post
-add
-edit
-view
-delete
-admin_add
-admin_edit
-admin_view
-admin_delete
-admin-verify
Group
(root) SuperAdmin Has all rights
/create group
/create user
/create acos/aros and permissions
Mediators - cannot delete
Users - can post /and edit his own posts
An how about if we can list controllers dynamically as acos and their actions . Is not that be good if we can create alias and keys values for the acos/and aros dynamically .
Thanks in advance for your time and knowledge .
PHP 5
CakePHP 1.2.0.6811 - Beta
Plugin
Prototype 1.5.1.1
Tango Icon Library
CalePHP is in a subdirectory "Tor".
"http://localhost/Tor/admin/acl/aros" results in the manage aros page showing but a moment later it is replaced by a broken version of the page with database debug info. If I click the "stop" button at the right time, I can catch the original manage aros page. Its almost like a redirect somewhere is activated.
i had to fix it adding the $name var to the controllers
var $name = 'AclAros';
var $name = 'AclAcos';
var $name = 'Acl';
var $name = 'AclPermissions';
Now it works!
to people facing problems. run this cmd from ROOT\app. it will issue a warning that the its deprecated and give another cmd: cake schema run create DbAcl
this will work. (ps: ur database config file should be workable)
I'm having problem opening the ur svn url. FYI i'm using kdesvn.
cake acl initdbgives following error:
...cake\console\config not foundCan any one help me sort out this bug ??
Thanks in advance.
yes i can confirm this as well. ANYONE PLS?!
cake acl initdbgives following error:
..\console\config\ not found
Can any one help me sort out this bug ??
Thanks in advance.
Missing controller
You are seeing this error because controller AclController could not be found.
Notice: If you want to customize this error message, create app\views\errors\missing_controller.ctp
Fatal: Create the class below in file: app\controllers\acl_controller.php
class AclController extends AppController {
var $name = 'Acl';
}
?>
What am I doing wrong?
Due to the use of a deprecated function (loadModel()) the plugins JSON model isn't loaded anymore. To solve the issue you have to replace the function
loadModel('JSON');
in each of the plugins controllers with
App::import(
$type = 'Model',
$name = 'JSON',
$parent = true,
$search = array("/your/path/to/the/plugins/JSON/dir","/Add/optional/paths/at/will"),
$file = 'JSON.php',
$return = false
);
Please help by hunting down bugs in other usefull plugins. Thanks for the ACL Manager, Jeff.
Now for the silly newbie question. How do I download the plugin code from svn://newnewmedia.com/cakephp/plugins/acl ?
I haven’t come across ‘svn’ before.
http://tortoisesvn.tigris.org/
a pleasure to use, simple also
I am unable to get this plugin going. The issue is that the json requests are not returned. Initially upon installing I get this error
Parse error: parse error, unexpected '&', expecting T_VARIABLE or '$' in D:\Apache2.2.4\vhosts\..\app\plugins\acl\controllers\acl_aros_controller.php on line 36
removing the & in the foreach loop, still does not mena that requests are returned.
Warning (2): Missing argument 1 for children() [CORE\html\plugins\acl\controllers\acl_aros_controller.php, line 31]
I have made the changes above with the navigation and had a general fiddle around.
php4.4.7 cake1.2 pre beta
where am I going wrong??
i did all this:
1. Download Prototype, drop the file directly into /app/webroot/js
2. Download Tango Icon Library, name the folder 'tango', and put it in /app/webroot/img
3. Checkout the ACL plugin source from svn and put the 'acl' folder in /app/plugins
4. Browse to the address /admin/acl
http://www.dev.localhost/admin/acl
"You are seeing this error because controller AdminController could not be found.
Notice: If you want to customize this error message, create app/views/errors/missing_controller.thtml.
Fatal: Create the class below in file : app/controllers/admin_controller.php
class AdminController extends AppController {
var $name = 'Admin';
}
?>"
What should I do?
You'll probably want to open up a shell, cd into the cake/console directory, and run this..
./cake acl initdb
in ../acl/views/elements/acl_menu.ctp
<div class="acl_menu"><?php print $html->image('/tango/32x32/places/folder.png', array('align' => 'absmiddle')) ?><?php print $html->link('Acl Menu', array('controller'=>'acl','action'=>'admin_index')); ?>
<?php print $html->image('/tango/32x32/apps/system-users.png', array('align' => 'absmiddle')) ?><?php print $html->link('Manage Aros', array('controller'=>'acl','action'=>'admin_aros')); ?>
<?php print $html->image('/tango/32x32/apps/preferences-system-windows.png', array('align' => 'absmiddle')) ?><?php print $html->link('Manage Acos', array('controller'=>'acl','action'=>'admin_acos')); ?>
<?php print $html->image('/tango/32x32/emblems/emblem-readonly.png', array('align' => 'absmiddle')) ?><?php print $html->link('Manage Permissions', array('controller'=>'acl','action'=>'admin_permissions')); ?>
</div>
And for the index page, ../acl/views/acl/admin_index.ctp
<ul class="acl"><li><?php print $html->image('/tango/32x32/apps/system-users.png', array('align' => 'absmiddle')) ?><?php print $html->link('Manage Aros', array('controller'=>'acl','action'=>'admin_aros')); ?></li>
<li><?php print $html->image('/tango/32x32/apps/preferences-system-windows.png', array('align' => 'absmiddle')) ?><?php print $html->link('Manage Acos', array('controller'=>'acl','action'=>'admin_acos')); ?></li>
<li><?php print $html->image('/tango/32x32/emblems/emblem-readonly.png', array('align' => 'absmiddle')) ?><?php print $html->link('Manage Permissions', array('controller'=>'acl','action'=>'admin_permissions')); ?></li>
</ul>
And by the way Jeff, this is a really nice plugin and I am sure it will help me in my struggling with the auth/acl mess I've run into!
The first page comes ok, but I've got a "Missing controller" error by clicking on anything (Manage Aros, Manage Acos or Manage Permissions).
Error details: "You are seeing this error because controller AclController could not be found."
Could you help with this?
Thank you
Im getting the same error using the pre-beta version of 1.2.