[eluser]alekz[/eluser]
Hi, popcorn thank's for all.
I was working with the code of my last post and i have some improvements to make this more powerful an easy to use, this are my improvements
first i made a change to the has_permissions function...
by this way we can give a major priority to controller/function permission over a global controller permision.
i found that can be more convinient if this can works in transparent mode, thats mean that we dont be worried about put a piece of code on every constructor to check if the user has permissions, so i made inherit the Controller core class with MY_Controller put this code in a file named MY_Controller.php under applications/Library folder
Code:
<?php
class MY_Controller extends Controller {
function MY_Controller()
{
parent::Controller();
if(!$this->redux_auth->has_permissions())
redirect(''); //<-- here you can redirect to wherever you want
}
}
?>
all you need to do is inherit your controllers from MY_Controller, and all your application will be using a Controller/Function based access control
im working in another has_permissions function that use the name of group instead of id_group to make more readable the configuration of the permissions.
Code:
//using group id's
$config['auth']['permissions']['/controller1/function1'] = array(1, 2);
//using name of groups
$config['auth']['permissions']['/controller1/function1'] = array('admin', 'publisher');
i think this gonna be a great change...
i'm using this addon in two projects that i'm working and is great for my entire applications and pretty convenient to protect my ajax functions...