funayaki / acl-manager
这是一个 CakePHP 插件,用于管理受 ACL 保护的 Web 应用程序。
Requires
- php: >=5.6
- cakephp/acl: ^0.2.6
- cakephp/cakephp: ^3.5.0
- oldskool/cakephp-js: dev-master
Requires (Dev)
- cakephp/cakephp-codesniffer: ^3.0
- phpunit/phpunit: ^5.7|^6.0
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 许可证
要求
- CakePHP 3.x
- Acl(见 https://github.com/cakephp/acl)
- CakeJs(见 https://github.com/oldskool/cakephp-js)
安装
安装 acl 和 cakephp-js
首先,您需要使用 composer 安装 acl
和 cakephp-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.php
和 src/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
,您将看到任何内容。