Fork me on GitHub

permissionable by jmcneese

A CakePHP 1.3 plugin that provides UNIX-like row-level permissions for model data.

Dependencies

Install

  1. check out the code from github:
    $ cd /path/to/your/app/plugins && git clone git://github.com/jmcneese/permissionable.git
    if you already have your project under git you can do this (it's call sub-tree'ing), or muddle through setting up and using submodules.  pick your poison.
  2. create the required db table. you can either do this via the SQL files included in permissionable/config/schema (there are two, those who prefer UUID ids, and those who prefer INT), or you can use the schema shell to do this:
    $ cake schema create Permissionable.permission
  3. take a look at permissionable/controllers/components/permissionable.php. you'll need to include this in the components array for whichever controllers use your permissioned models, or in AppController.
    public $components = array('Permissionable.Permissionable');
    also, you'll need to put some code in the initialize method of the component that sets the id of the logged in user (via AuthComponent or whatever method you use), as well as the group id(s).
  4. next up, you'll need to include the behavior in whatever models you want to be permission-controlled:
    public $actsAs = array('Permissionable.Permissionable' => array('defaultBits'=>480);
    note: you need not include the defaultBits option to the behavior, unless you a) know what you are doing, b) can calculate up the proper bits and c) really need to. if any of the above apply, feel free.  if you need a refresher course, look here.

License

Copyright (c) 2009,2010 Joshua M. McNeese, Curtis J. Beeson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Contact

Joshua McNeese (jmcneese@gmail.com)
Joe Beeson (jbeeson@gmail.com)

Download

You can download this project in either zip or tar formats.

You can also clone the project with Git by running:

$ git clone git://github.com/jmcneese/permissionable