I'm trying for weeks to integrate ACL + Auth with different permissions for different users, and that they have privileges to access certain parts of the site depending on the group on this. I recently found a tutorial Arabic, and try to incorporate some files from a tutorial acl, but I'm having difficulties Uu The idea would be to use the helper and component offering, and use it for certain parts of the site will not display unless you have some privilege.
This item cost me, and I read several tutorials and practice, the majority dealt with almost the same as Users, Groups and Roles, with different permissions, but not for access to different views depending on the group.
Aros:
Groups
Group.1
Group.2
Group.3
Acos:
controllers
Subtemas: index, view, add, edit, delete
Posts: index, view, add, edit, delete
Users: register, login, logout, index
Groups: index, view, add, edit delete
In the view view to Subtemas i write ex..:
if($access->check('Subtemas/add')){ }
And I pulled:
Warning (512): DbAcl::check() - Failed ARO/ACO node lookup in permissions check. Node references:
Aro: Group:4
Aco: Subtemas/add [CORE\cake\libs\controller\components\acl.php, line 273]
<?
class AccessComponent extends Object{
var $components = array('Acl', 'Auth');
// Aro dalam format User:$id
function check($aco, $action='*'){
// check($Aro,$Aco,$Action)
if( $this->Acl->check('User:'.$this->Auth->user('id'), $aco, $action)){
return true;
} else {
return false;
}
}
function checkHelper($aro, $aco){
App::import('Component', 'Acl');
$acl = new AclComponent();
return $acl->check($aro, $aco, '*');
}
}
?>
<?
class AccessHelper extends Helper{
var $helpers = array('Session');
var $Access;
var $Auth;
var $user;
function beforeRender(){
App::import('Component', 'Access');
$this->Access = new AccessComponent();
App::import('Component', 'Auth');
$this->Auth = new AuthComponent();
$this->Auth->Session = $this->Session;
$this->user = $this->Auth->user();
}
function check($aco, $action='*'){
if(empty($this->user)) return false;
return $this->Access->checkHelper('User:'.$this->user['User']['id'], $aco);
}
function isLoggedin(){
return !empty($this->user);
}
function my($column = null){
App::import('Component', 'Auth');
$auth = new AuthComponent();
$auth->Session = $this->Session;
if($auth->user($column)){
return $auth->user($column);
}else{
return FALSE;
}
}
function isSelected($controller = null, $action = 'index'){
$curr_controller = $this->params['controller'];
$curr_action = $this->params['action'];
if($curr_controller == $controller && $curr_action == $action){
return 'selected';
} else {
return null;
}
}
}
?>
I hope I can help. Thank you very much ...!
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Thursday, September 8, 2011
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment