Skip to content

Latest commit

 

History

History
81 lines (56 loc) · 3.05 KB

README.textile

File metadata and controls

81 lines (56 loc) · 3.05 KB

Bitmasked Plugin

Row-level filtering of models via bitmasks.

Requirements

  • PHP5.2+ (Fully featured with 5.3+)
  • CakePHP 1.3+

Installation

Manual

  1. Download this: http://github.com/jmcneese/bitmasked/zipball/master
  2. Unzip that download.
  3. Copy the resulting folder to app/plugins
  4. Rename the folder you just copied to bitmasked

GIT Submodule

From your repository root directory type:

git submodule add git://github.com/jmcneese/bitmasked.git app/plugins/bitmasked
git submodule update --init

GIT Clone

In your plugin directory type

git clone git://github.com/jmcneese/bitmasked.git

Usage

  1. Import the SQL in config/schema/bitmasked_bits.sql into your application’s database
  2. Activate the behavior in whichever model(s) you desire, via:
    
    public $actsAs = array(
    	'Bitmasked.Bitmasked'
    );
    

Options

There are several configurable options that can be passed into the behavior:

  • disabled — If you want the behavior to start as disabled, i.e. not automatically filter rows based on bitmask, set this to true. Default: false
  • default — This is the default bit that is saved for new records for this model, unless otherwise specified in save data. Default: 1
  • bits — An array of flags (string) that map to bits (integer) to use for this particular model. Default: array(‘ALL’ => 1)
  • mask — The bitmask to use when finding records on this model. There are several possible settings here:
    • Implicit (integer). This is when the bitmask is static across all finds.
    • Flag (string). This is a string representation of a flag you have defined in the ‘bits’ option.
    • Flags (array). An array of flags in string form.
    • Callback (mixed). Either a string referring to a function name in global scope, a method in the attached model or an anonymous function (PHP5.3 only).

Examples

Todo

  • Add behavior method to reconfigure, e.g. change configuration options.

License

Copyright © 2009-2011 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.