Git Product home page Git Product logo

revisionable's Introduction

Table of Contents

CakePHP Simple Revisionable Behavior

This is a simple small plugin that adds a revisionable behavior to any of your models

It does this by grabbing a copy of your row right before you save it and saving a serialized copy of it in the serialize table

This plugin is pretty easy to use

Setup

1) First you need to add the table to your project use the following to generate that cake schema create Revisionable.revision

2) add the behavior to your model like so

var $actAs = array('Revisionable.Revisionable');

3) I've discovered that cakephp has some bugs in it's schema create script that doesn't account for longblob, so make sure that after you run the cake schema create Revisionable.revision you go change the data type for the data column to longblob otherwise you may not get your revision saved properly.

Some Configure options

If you already have a table named revisions in your project and need to call the it something else then make a new table/model in your project that has the same schema as this plugin and pass that model name to the actAs setup like so

var $actAs('Revisionable.Revisionable'=>array('revisionableModel'=>$newModelName));

To Do

So far aside from creating a revision everytime the data changes the only other feature of this plugin is the listRevisions function. It works like this

$revisions = $this->Model->listRevisions($this->Model->id);

print_r($revisions); array( '2011-12-05 01:01:01'=>array( 'Pages' => array( 'id'=> '4edd8cc3-a628-490b-8cbf-6435ac1005e9', 'name'=> 'foobar', 'body'=> '....' ) ) );

Need to create some more functions that add to this, like perhaps a diff viewer

Patches are warmly welcome.

-Analog

revisionable's People

Stargazers

Timothy C avatar  avatar J. Miller avatar Martin Palastanga avatar Vasileios Paraskevas avatar Wils avatar  avatar Tomasz Wójcik avatar Saleh Souzanchi avatar Aaron Collins avatar Takashi Nojima avatar Gustavo Dutra avatar

Watchers

Aaron Collins avatar James Cloos avatar

revisionable's Issues

No listrevisions function?

Hi,

Have setup the schema by copying to the plugins folder & the rest by pasting the model files in the /model folder.

I put the following on top of one model.

var $actAs = array('Revisionable.Revisionable');

Then in my controller, I try calling it thus:

        $revisions = $this->Driver->listRevisions($this->Driver->read(null, $id));

However, I get this error:

Warning (512): SQL Error: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'listRevisions' at line 1 [CORE\cake\libs\model\datasources\dbo_source.php, line 684]
Query: listRevisions

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.