funayaki / acl-manager

这是一个 CakePHP 插件,用于管理受 ACL 保护的 Web 应用程序。

安装: 3

依赖项: 1

建议者: 0

安全性: 0

星标: 0

关注者: 2

分支: 2

开放问题: 1

类型:cakephp-plugin

dev-master 2018-05-25 02:02 UTC

This package is not auto-updated.

Last update: 2024-09-20 20:11:02 UTC


README

版本:2.3.0 日期:2013-05-02 作者:Nicolas Rod nico@alaxos.com 网站: http://www.alaxos.net/blaxos/pages/view/plugin_acl_2.0 许可证: https://open-source.org.cn/licenses/mit-license.php MIT 许可证

要求

安装

安装 acl 和 cakephp-js

首先,您需要使用 composer 安装 aclcakephp-js 插件。

安装 composer 包的推荐方法是

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

启用 acl 插件

在 3.0 中,您需要在 config/bootstrap.php 文件中启用插件

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

安装 acl-manager

[手动]

  • 下载并解压仓库(见此 git 页面上的某个下载按钮)
  • 将生成的文件夹复制到 plugins
  • 将您刚才复制的文件夹重命名为 AclManager

[GIT 子模块]

在您的 app 目录中输入

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

[GIT 克隆]

在您的 plugins 目录中输入

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

启用插件

在 3.0 中,您需要在 config/bootstrap.php 文件中启用插件

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

作为请求者行动

$this->addBehavior('Acl.Acl', ['type' => 'requester']); 添加到 src/Model/Table/RolesTable.phpsrc/Model/Table/UsersTable.php 文件中的 initialize 函数

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

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

在角色实体中实现 parentNode 函数

将以下 parentNode 实现添加到文件 src/Model/Entity/Role.php

    public function parentNode()
    {
        return null;
    }

在用户实体中实现 parentNode 函数

将以下 parentNode 实现添加到文件 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]];
    }

使用浏览器访问 acl-manager

使用浏览器访问 /admin/acl_manager/acos/index,您将看到任何内容。