2017 © Pedro Peláez
 

cakephp-plugin deleteable

Detects which database records can be deleted. Database records can be locked preventing deletion.

image

justinatack/deleteable

Detects which database records can be deleted. Database records can be locked preventing deletion.

  • Thursday, January 29, 2015
  • by justinatack
  • Repository
  • 1 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

CakePHP DeleteableBehavior

Deleteable provides a way to flag a database record as deleteable or not deleteable. I created this CakePHP Behavior with the need to be able to set a tinyint(1) "delete" field in my database and set it to true or false (0 or 1). The plugin is flexible, you can set your own field name as long as it stores a boolean value. You can also specify the value on which the delete is blocked or not. So you could have the DeleteableBehavior work when it's true and not when false (default behavior is false). The reason you might want to do this when you name your Deletable field to say "locked" and hence you might want to have "locked" field set to 1 (or true), in other words "locked" records can not be deleted because they are "locked" = true., (*1)

Requirements

The master branch has the following requirements:, (*2)

  • CakePHP 2.2.0 or greater.
  • PHP 5.3.0 or greater.

Installation

[Using Composer], (*3)

From your command line you can enter, (*4)

composer require justinatack/deleteable="*"

or add the plugin to your project's composer.json - something like this:, (*5)

{
    "require": {
        "justinatack/deleteable": "*"
    }
}

Because this plugin has the type cakephp-plugin set in it's own composer.json, composer knows to install it inside your /Plugin directory, rather than in the usual vendors file. It is recommended that you add /Plugin/Deleteable to your .gitignore file. (Why? read this.), (*6)

Consider using "require-dev" if you only want to include Deleteable for your development environment., (*7)

[Manual], (*8)

  • Download the Deleteable archive.
  • Unzip that download.
  • Rename the resulting folder to Deleteable
  • Then copy this folder into app/Plugin/

[GIT Submodule], (*9)

In your app directory type:, (*10)

git submodule add git://github.com/justinatack/deleteable.git Plugin/Deleteable
git submodule init
git submodule update

[GIT Clone], (*11)

In your plugin directory type, (*12)

git clone git://github.com/justinatack/deleteable.git Deleteable

Enable plugin

  • In 2.x you need to enable the plugin your app/Config/bootstrap.php file. If you are already using CakePlugin::loadAll();, then the following is not necessary.:
CakePlugin::load('Deleteable');
  • Include the Deleteable behavior in your app/Model/AppModel.php:
class AppModel extends Model
{
    public $actsAs = array(
        'Deleteable.Deleteable',
            array(
                'field' => 'delete',
                'boolean' => false
            )
        );
}
  • Set field to your database field name that you want checked by the DeleteableBehavior. Default field is set to "delete". Make sure you create a TINYINT(1) field type in MySQL.
  • Set the 'boolean' value to false for default behavior or use true to flip the behavior.
  • By default a boolean value of '0' will prevent a record from being deleted. A value of '1' will allow a record to be deleted. Set 'boolean' to 'true' to invert this behavior.

Reporting Issues

If you have a problem with Deleteable please open an issue on GitHub., (*13)

Contributing

If you'd like to contribute to Deleteable, check out the roadmap for any planned features. You can fork the project, add features, and send pull requests or open issues., (*14)

Versions

Deleteable has only one release so far. Please feel free to submit a pull request to add or improve the codebase., (*15)

  • '0.0.1' a working patch, the code base may well change.

License

The MIT License (MIT), (*16)

Copyright (c) 2015 Justin Atack, (*17)

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:, (*18)

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software., (*19)

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., (*20)

The Versions

29/01 2015

dev-master

9999999-dev https://github.com/justinatack/deleteable

Detects which database records can be deleted. Database records can be locked preventing deletion.

  Sources   Download

MIT

The Requires

 

cakephp