PHP Classes
elePHPant
Icontem

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

Recommend this page to a friend!
  Info   View files Documentation   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2016-11-16 (1 year ago) RSS 2.0 feedNot enough user ratingsTotal: 192 This week: 1All time: 8,093 This week: 607Up
Version License PHP version Categories
ci-acl 1.0.0MIT/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.

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

Details

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  
File Role Description
Files folder imageconfig (1 file)
Files folder imagelibraries (1 file)
Accessible without login Plain text file README.md Doc. Documentation

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

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

 Version Control Unique User Downloads Download Rankings  
 100%
Total:192
This week:1
All time:8,093
This week:607Up
User Comments (1)
I had to rate you for creating this package.
11 months ago (Johnny Mast)
52%StarStarStar