Come promesso inserisco la spiegazione per pippoacl per chi vuole lavorarci implementarlo nei suoi progetti, a memoria dovrebbe esserci anche un readme nel pacchetto, è scritta in inglese e non ho volgia di tradurla tongue.

[h3]What does it do?[/h3]

Basically with this plugin you can have an application controlled by auth/acl.


Ajax based acl permission.
Simple search form i made with autocompletion.
Highlight of tables row.
Autocomplete search form field.
Mail based registration
Password forgot and reset by mail.
Simple profile editor.
A function to clean up acl.
Menu based on acl.
some i can’t remember smile



To install just extract ‘pippoacl’ folder in your plugins directory.
Execute the sql code located in pippoacl/docs/sql/pippoacl.sql into your db.
Next if you want that your application is acl/auth controlled, add this to your app_controller.php

var $helpers = array(‘Html’,’Ajax’,’Javascript’);
var $components = array(‘Acl’, ‘Auth’, ‘RequestHandler’,’Cookie’);

function beforeFilter()
$this->Auth->authorize = ‘actions’;
$this->Auth->loginAction = array(‘plugin’=>’pippoacl’,’controller’ => ‘users’, ‘action’ => ‘login’);
$this->Auth->logoutRedirect = array(‘plugin’=>’pippoacl’,’controller’ => ‘users’, ‘action’ => ‘login’);

//action that doesn’t need have an acl all can access to this
$this->Auth->allowedActions = array(‘display’,’logout’,’login’,’register’, ‘confirm’, ‘forget’, ‘activate’, ‘reset’,’profile’,’switch_language’);

//user needs to be active.
$this->Auth->userScope = array(‘’ => 1);

//add this if you want to localize your application
# Localization
App::import(‘Core’, ‘l10n’);
$this->L10n = new L10n();
# if language is already set in session, get that
$language = $this->Session->read(‘Config.language’);

if(!$language) {
$this->Session->write(‘Config.language’, $language);
# now set the language

substr($this->L10n->locale, 0, 3) .
strtoupper(substr($this->L10n->locale, 3, 2)) .
‘.’ . $this->L10n->charset


Pippoacl have some routes in pippoacl/config/routes.php, copy and paste or add this line to your routes.php:

Add this to your default.ctp or your default view if you wanna use the js and css bundled in the plugin:

<?php echo $javascript->link(‘/pippoacl/js/prototype’);?>
<?php echo $javascript->link(‘/pippoacl/js/scriptaculous.js?load=effects’);?>
<?php echo $javascript->link(‘/pippoacl/js/controls’);?>
<?php echo $javascript->link(‘/pippoacl/js/table’);?>
<?php echo $html->css(‘/pippoacl/css/pippo’);?>
or copy the folder inside pippoacl/vendor directory into your app/webroot folder and then add them in ypur default.ctp/default view layout like:

<?php echo $javascript->link(‘prototype’);?>
<?php echo $javascript->link(‘scriptaculous.js?load=effects’);?>
<?php echo $javascript->link(‘controls’);?>
<?php echo $javascript->link(‘table’);?>
<?php echo $html->css(‘pippo’);?>
remember to change in pippoacl/controllers/users_controller.php this line:

var $activationEmail = ‘Activation <[email protected]>’;
var $activationSubject = ‘Activate Your Account’;
var $forgetEmail = ‘Forget Email <[email protected]>’;
var $forgetSubject = ‘Forgot Password’;
var $resetEmail = ‘Reset Password <[email protected]>’;
var $resetSubject = ‘Reset Password’;

they are used to email notification.

also remember to change line 211 in users_controller.php:
//set default role

to set the default role associated to new user, in my example 1 = administrator.

call the url http://yourserver/roles/cleanupAcl to initialize/cleanup the acl for your controller.
login with username= admin passwd = admin

Ok the plugin now is installed and here’s some basic function used inside, next i will explain how to improve integrate your application with some cool stuff contained in pippoacl.

Basic function/action (if u use pippoacl’s routes.php of course):

/users/index – list of user
/users/login – login function
/users/logout – logout function
/users/register – simple form to register to your site
/users/forget – password forget form, to reset it, an email will be sent to the user or email address with the reset code
/users/reset/code – to reset the password only works with code
/users/activate – action for activating user
/users/profile – simple users’s profile, if logged ofc

/roles/index – list of roles
/roles/acl – ajax based acl management
/roles/cleanupAcl – used for automatic clean/delete of the acl

all the mail layout can be modified, they are stored in pippoacl/views/elements/email folder.

In next page i will add some customization u can do.


To add language to your app you need to put in yourapp/app/config/bootstrap.php this line:

Configure::write('Languages', array(
    'en' => 'English',
    'it' => 'Italiano'


All example of configuration can be found in the docs/example folder.
Now add your desidered language, after create in your app/locale the folder referred to your language and edit pippoacl/docs/locale/localedefault.ctp to your language and rename it in default.po

so for example for italian in the end i have appname/app/locale/ita/LC_MESSAGES/default.po with all the translated message.

I make a simple elements to show the language,  you can edit that to suite your need in pippoacl/views/elements/languages.ctp next to add in your view:

<?php echo $this->element(‘languages’); ?>

[h3]Acl Based Menu[/h3]

Pippoacl come with a simple acl based menu, one component and one helper to render in the view.
The component take care to build the menu and to store it in the session, based on the current user logged in or to generate a “public menu” if no one is logged.

To add to your app just put this 2 line of code in app_controller.php:

var $helpers = array(‘Html’,’Ajax’,’Javascript’,’Pippoacl.Menu’);
var $components      = array(‘Acl’, ‘Auth’, ‘RequestHandler’,’Cookie’,’Pippoacl.Menu’);

For set up the component u only need to change the first variables into appname/app/plugins/pippoacl/controllers/components/menu.php and change the lines below:

//avoid some of the controller, controller that don’t have a menu
public $avoidControllers   = array(‘Pages’, ‘Utils’,’App’);

//menu displayed in every page
public $everMenu = array(‘Home’ => ‘/’);

//public menu items, menu stuff that don’t need authentication
public $publicMenu   = array(‘Register’=>’/users/register’,’Forget’=> ‘/users/forget’);

//action that don’t need to be included in menu
public $avoidActions   = array(‘switch_language’,’forget’,’reset’,’register’,’activate’,’adjustperm’,’login’,’logout’);

//user login menu
public $userLogin = array(‘Login’ => ‘/users/login’);

//user logout menu
public $userLogout = array(‘Logout’ => ‘/users/logout’);

This component take care of generate the menu, and store in a session variable called pippomenu, you can read and display the array in the view with:

<?php pr($session->read('pippomenu')); ?>

if you’re lazy or you want an example how to reuse this menu i create a menu helper located in appname/app/plugins/pippoacl/views/helper/menu.php.

The main function is render and the default syntax to use in your view is:

//Controller’s action that need to be displayed, other in the controller will be not displayed
$display = array(‘index’,’profile’,’acl’,’cleanupAcl’);

//u can give a title to a action, else the title is taken with the controller name
$title=array(‘Profile’ => ‘/users/profile’,’Acl’ => ‘/roles/acl’
,’Forget’ => ‘/users/forget’,’Clean ACL’=>’/roles/cleanupAcl’);

// u can only display some of your controller, this are displayed

//else u can exclude (not display) other controller

//u can pass also a parameter, for example for edit, or delete function

//u can pass also a message for example for the delete message
$message=”Are you sure you want to delete # %s?”;

echo $menu->render($session->read(‘pippomenu’),$display,$title,$filtercontroller,$id,$exclude,$message);


for the basic menu i use div and ul,li , u can copy and paste,edit the code to suite your needs.

[h5]Real word example usage:[/h5]

so if u want to customize the basic index view created with “cake bake”, exactly the action row (edit,add,etc etc)
u can use this piece of code:

//action we wanna display
$display = array(‘view’,’edit’,’delete’);

//give them some title
$title=array(‘Edit’ => ‘/roles/edit’,’View’ => ‘/roles/view’
,’Delete’ => ‘/roles/delete’);

//we filter only the controller we want
$filter= array(‘Roles’);

//we give every row a different id

echo $menu->rendertable($session->read(‘pippomenu’),$display,$title,$filter,$id);

so we now u have a simple menu based on acl,  try to enable disable acl to see the magic happens.