dev-master
9999999-devUsers Permissions Management plugin for CakePHP with GUI
Apache-2.0
The Requires
- php >=5.4.16
- cakephp/cakephp ~3.0
The Development Requires
by Hassnain Abass
cakephp users user permissions
Wallogit.com
2017 © Pedro Peláez
Users Permissions Management plugin for CakePHP with GUI
The UsersPermissions plugin is for allowing admins to add user permissions for each module in Cakephp. It provides a basic interface to manage user permissions and check upon each request. It provides check box based user permissions in a form like magento. The plugin uses bootstrap by default but you can change that. It will automatically get all controllers and actions from Your Cakephp application and in a GUI you can select the permissions for all controller or actions inside a controller., (*1)
, (*2)
You can install this plugin into your CakePHP 3 application using composer., (*3)
The recommended way to install composer packages is:, (*4)
composer require "hassnainabass/users-permissions:*"
Or download the files and move to root/plugins and paste it there, Please rename the folder to UsersPermissions, (*5)
Plugin::load('UsersPermissions', ['routes' => true]);
Open console/terminal and run the following migration,please make sure to load migration plugin first, (*6)
bin/cake migrations migrate -p UsersPermissions
Or create the following table in database:, (*7)
CREATE TABLE user_permissions ( id int(11) NOT NULL AUTO_INCREMENT, user_id int(11) DEFAULT NULL, permissions text DEFAULT NULL, created_on timestamp NULL DEFAULT CURRENT_TIMESTAMP, updated_on date DEFAULT NULL, PRIMARY KEY (id) ) ENGINE = INNODB AUTO_INCREMENT = 1 CHARACTER SET latin1 COLLATE latin1_swedish_ci;
It will create a table named "user_permissions" in database using default database connection configured in config/app.php of your cakephp installation., (*8)
Change the route for your plugin GUI in plugins/UserPermissions/config/routes.php , By default it is domain.com/users-permissions, (*9)
Router::plugin(
'UsersPermissions',
['path' => '/users-permissions'],
function ($routes) {
$routes->fallbacks('DashedRoute');
}
);
return $this->_registry->getController()->redirect('/dashboard');
composer dumpautoload
Thats all your plugin has been installed, yay :), (*10)
You can access the GUI if you have 'admin' role in Users table in user authentication and authorization of cakephp application., (*11)
If you want to load the plugin and permissions for all actions of all controllers and routes. Add the following code in cakephpapp/src/controller/AppController.php, (*12)
public function initialize()
{
parent::initialize();
// Some code
// Load Resource Component
$this->loadComponent('UsersPermissions.Resource');
}
public function beforeFilter(Event $event)
{
parent::beforeFilter($event);
// Some code
// Load permissions check function from Resource component
$this->Resource->checkPermision();
}
If you want to load the plugin and permissions for all actions of only one controllers. Add the following code in desired controller (same as above) cakephpapp/src/controller/ExampleController.php, (*13)
public function initialize()
{
parent::initialize();
// Some code
// Load Resource Component
$this->loadComponent('UsersPermissions.Resource');
}
public function beforeFilter(Event $event)
{
parent::beforeFilter($event);
// Some code
// Load permissions check function from Resource component
$this->Resource->checkPermision();
}
If you want to load the plugin and permissions for only one actions of only one controllers. Add the following code in desired controller and in the start of desired action/function in cakephpapp/src/controller/ExampleController.php, (*14)
public function initialize()
{
parent::initialize();
// Some code
// Load Resource Component
$this->loadComponent('UsersPermissions.Resource');
}
public function exampleAction($param = null)
{
// Load permissions check function from Resource component
$this->Resource->checkPermision();
// Some code
}
*The plugin uses bootstrap as front-end styling but you can update the views. To do that you can update the following files., (*15)
plugins/UsersPermissions/src/template/Permissions/index.ctp plugins/UsersPermissions/src/template/Permissions/userpermission.ctp, (*16)
Developed by Hassnain Abass - Senior Web Developer and Freelancer, (*17)
This repository follows the CakePhp Plugin Standards. If you'd like to contribute new features, enhancements or bug fixes to the plugin, please feel free to pull or report/open issues., (*18)
Copyright 2017-2020 Hassnain Abass. All rights reserved., (*19)
Licensed under the MIT License. Redistributions of the source code included in this repository must retain the copyright notice found in each file., (*20)
Goodluck And Happy Coding., (*21)
Users Permissions Management plugin for CakePHP with GUI
Apache-2.0
cakephp users user permissions