Row-level filtering of models via bitmasks.
- PHP5.2+ (Fully featured with 5.3+)
- CakePHP 1.3+
- Download this: http://github.com/jmcneese/bitmasked/zipball/master
- Unzip that download.
- Copy the resulting folder to app/plugins
- Rename the folder you just copied to
From your repository root directory type:
git submodule add git://github.com/jmcneese/bitmasked.git app/plugins/bitmasked git submodule update --init
In your plugin directory type
git clone git://github.com/jmcneese/bitmasked.git
- Import the SQL in config/schema/bitmasked_bits.sql into your application’s database
- Activate the behavior in whichever model(s) you desire, via:
public $actsAs = array( 'Bitmasked.Bitmasked' );
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).
- Add behavior method to reconfigure, e.g. change configuration options.
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