Skip to content

funayaki/acl-manager

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ACL Manager for CakePHP 3.x

Version: 2.3.0 Date: 2013-05-02 Author: Nicolas Rod [email protected] Website: http://www.alaxos.net/blaxos/pages/view/plugin_acl_2.0 License: http://www.opensource.org/licenses/mit-license.php The MIT License

Requirements

Installation

Install acl and cakephp-js

At first, you need to install acl and cakephp-jp plugins using composer.

The recommended way to install composer packages is:

composer require cakephp/acl
composer require oldskool/cakephp-js:dev-master

Enable acl plugin

In 3.0 you need to enable the plugin your config/bootstrap.php file:

Plugin::load('Acl', ['bootstrap' => true]);

Install acl-manager

[Manual]

  • Download and unzip the repo (see the download button somewhere on this git page)
  • Copy the resulting folder into plugins
  • Rename the folder you just copied to AclManager

[GIT Submodule]

In your app directory type:

git submodule add -b master git://github.com/tsmsogn/acl-manager.git plugins/AclManager
git submodule init
git submodule update

[GIT Clone]

In your plugins directory type:

git clone -b master git://github.com/tsmsogn/acl-manager.git AclManager

Enable plugin

In 3.0 you need to enable the plugin your config/bootstrap.php file:

Plugin::load('AclManager', ['bootstrap' => true, 'routes' => true, 'autoload' => true]);

Acting as a requester

Add $this->addBehavior('Acl.Acl', ['type' => 'requester']); to the initialize function in the files src/Model/Table/RolesTable.php and src/Model/Table/UsersTable.php:

    public function initialize(array $config) {
        parent::initialize($config);

        $this->addBehavior('Acl.Acl', ['type' => 'requester']);
    }

Implement parentNode function in Role entity

Add the following implementation of parentNode to the file src/Model/Entity/Role.php:

    public function parentNode()
    {
        return null;
    }

Implement parentNode function in User entity

Add the following implementation of parentNode to the file src/Model/Entity/User.php:

    public function parentNode()
    {
        if (!$this->id) {
            return null;
        }
        if (isset($this->role_id)) {
            $roleId = $this->role_id;
        } else {
            $Users = TableRegistry::get('Users');
            $user = $Users->find('all', ['fields' => ['role_id']])->where(['id' => $this->id])->first();
            $roleId = $user->role_id;
        }
        if (!$roleId) {
            return null;
        }
        return ['Roles' => ['id' => $roleId]];
    }

Visit acl-manager using browser

Visit /admin/acl_manager/acos/index using browser, you will see anything.

About

[WIP] Yet another acl manager

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 90.3%
  • JavaScript 8.3%
  • CSS 1.4%