PHP Classes

CodeIgniter ACL User Management: Manage the access of CodeIgniter users using ACL

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 355 All time: 6,953 This week: 74Up
Version License PHP version Categories
ci-acl 1.0.1MIT/X Consortium ...5PHP 5, User Management, Libraries
Description 

Author

This class can manage the access of CodeIgniter users using ACL.

It takes a array of configuration of routes and the respective user access permissions.

The class can evaluate if the current user has access to the page given its current route.

Picture of Rogério Taques
Name: Rogério Taques <contact>
Classes: 4 packages by
Country: Japan Japan
Age: ???
All time rank: 236810 in Japan Japan
Week rank: 180 Up1 in Japan Japan Up

Documentation

CI ACL 1.0 beta

Implements an Access Control List for your applications written with Codeigniter.

You should use it in order to help you control which path the user can (or cannot) access.

Getting Started

Download this project, and copy its content into your Codeigniter app, under `application` folder.

For example:


   / (project root directory)
   /application
   --/config
   --/libraries
   -- ...

After "instal" it on your app, then you'll need to setup all acl definitions.

All those definitions should be placed in ` ./applicaton/config/acl.php`, i.e:


$acl = array(

	/WELCOME/

	'welcome/index' => array(
		'public'
	),

	'welcome/private_users' => array(
		'user'  => TRUE,
        'admin' => FALSE
	),

	'welcome/private_admins' => array(
		'user'  => FALSE,
        'admin' => TRUE
	)

);

Finally, in order to test if given path is valid or not, do as following:

    
    $ci =& get_instance();
    $ci->load->library('acl');
    
    // check if given path isn't public
    if (! $ci->acl->is_public('path/to/test'))
    {
    
        if (! $ci->acl->is_allowed('path/to/test', 'role-to-test'))
        {
            // do your stuff here ...
            // i.e: set the error message and redirect to some page.
        }
    
    }

That's all.

Methods

There some methods that can be used on runtime:

is_public( path : string ) : boolean

Return TRUE when given path is set as 'public', otherwise, return FALSE.

is_allowed( path: string, role : string ) : boolean

Return TRUE when given role is set as 'true' for given path, otherwise, return FALSE.

set( path : string, config : array ) : void

This method is used to add new ACL rules that are not present on `config/acl` on runtime.

It's very useful when you're storing your ACL rules on database.

I.e:


   $ci->acl->set( 'a/new/path/to/check', array( 'user' => FALSE, 'admin' => TRUE ) ); // or
   $ci->acl->set( 'a/new/path/to/check', array( 'public' ) );

Get involved

Report bugs, make suggestions and get involved on contributions.

Feel free to get in touch. ;)


  Files folder image Files (4)  
File Role Description
Files folder imageconfig (1 file)
Files folder imagelibraries (1 file)
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (4)  /  config  
File Role Description
  Accessible without login Plain text file acl.php Aux. Auxiliary script

  Files folder image Files (4)  /  libraries  
File Role Description
  Plain text file Acl.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:355
This week:0
All time:6,953
This week:74Up
User Comments (1)
I had to rate you for creating this package.
7 years ago (Johnny Mast)
52%StarStarStar