PHP Classes

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 (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2022-10-21 (28 days ago) RSS 2.0 feedNot enough user ratingsTotal: 342 This week: 4All time: 7,030 This week: 221Up
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

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 LICENSE Lic. License text
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:342
This week:4
All time:7,030
This week:221Up
User Comments (1)
I had to rate you for creating this package.
5 years ago (Johnny Mast)
52%StarStarStar
 
For more information send a message to info at phpclasses dot org.