2017 © Pedro Peláez
 

library ClassifiableBehavior

ClassifiableBehavior is a propel behavior allowing to tag on a list of user defined scopes. kind of Ressource Access Control.

image

CarpeHora/ClassifiableBehavior

ClassifiableBehavior is a propel behavior allowing to tag on a list of user defined scopes. kind of Ressource Access Control.

  • Thursday, June 21, 2012
  • by themouette
  • Repository
  • 0 Watchers
  • 6 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

ClassifiableBehavior

Build Status, (*1)

Quick start

Simply declare the behavior for the classifiable objects to allow filtering by classifications:, (*2)

``` xml

, (*3)


then just add classificationements to your object: ``` php <?php // create your objects... $MyPhpRepo = new Repository(); $MyPhpRepo->setName('my php repository'); $MyPhpRepo->classify('visibility', 'public'); $MyPhpRepo->classify('language', 'php'); $MyPhpRepo->classify('language', 'js'); $MyPhpRepo->classify('license', 'MIT'); $MyJsRepo = new Repository(); $MyJsRepo->setName('my php repository'); $MyJsRepo->classify('language', 'js'); $MyJsRepo->classify('language', 'php'); // is now classified in js AND php $MyJsRepo->classify('license', 'GPL'); $MyJsRepo->disclose('language', 'js'); // now only classified in php // ...and then retrieve it RepositoryQuery::create() // filter for 'php' AND 'js' language, paranoid ->filterByClassified('language', array('php', 'js'), 'and', $paranoid = true) // filter for 'MIT'OR 'GPL' license, paranoid ->filterByClassified('license', array('MIT', 'BSD'), 'or', $paranoid = true) // filter for public visibility, // default is public, so request match if no visibility defined ->filterByClassified('visibility', 'public', null, $paranoid = false);

Previous example will return a PropelCollection with $MyPhpRepo in it., (*4)

OR searches are easily done by giving an array and the operator to use for subqueries:, (*5)

``` php <?php RepositoryQuery::create() // filter by OR queries ->filterByClassified(array( 'license' => array('MIT', 'BSD'), // licensed under MIT AND BSD as defined $operator argument 'visibility' => 'public', // or with public visibility ), $operator = 'AND', $paranoid = true), (*6)


To retrieve classifications an object is attached to, just call the ```getClassification``` method: ``` php <?php $myRepo->classify(array( 'license' => array('MIT', 'BSD'), 'visibility' => 'public' ), 'AND', $excludeUnclassified = true); // return $myRepo $myRepo->getClassification(); // array( // 'license' => array('MIT', 'BSD'), // 'visibility' => 'public' // ) $myRepo->isClassified(array( 'license' => array('MIT', 'BSD'), 'visibility' => 'public' ), 'AND', $excludeUnclassified = true); // return true $myRepo->disclose();

To ease classifications management, behavior uses a unique classification table shared for all classified content. To use separate tables, just override the classification_table parameter., (*7)

Usage

You can use ClassifiableBehavior:, (*8)

  • limit access to classified content
  • to organize collections and ease filtering
  • to tag objects
  • put your idea here

Installation

Under the hood

Behavior creates a cross reference table to access classification dictionnary and filters using EXISTS statements., (*9)

Advanced configuration

Following parameters are available :, (*10)

  • classification_table: table to use to handle classifications.
  • classification_column: classification column to use.
  • scope_column: scope column to use.
  • auto_create_classification: if no classification found for parameters, should it be created ?
  • scope_default: comma separated default scope list.
  • scope_matching: how to match on scope ?
    • strict: namespace has to be strictly equal
    • nested: namespace has to start the same. separator is defined as nesting_separator
    • none: no namespace check
  • nesting_separator: separator to use on nested scopes

Scopes

A scope can be used to organize classifications. You can use namespaced scope by providing a nesting_separator. In such case, you can organize your classifications as files and folders and search can be done on all the scope descendants., (*11)

A scope can either be a foreign key to an object., (*12)

TODO

  • AR disclose method
  • nesting namespaces
  • Index classification table fields

The Versions

21/06 2012

dev-master

9999999-dev http://carpe-hora.github.com/ClassifiableBehavior/

ClassifiableBehavior is a propel behavior allowing to tag on a list of user defined scopes. kind of Ressource Access Control.

  Sources   Download

MIT

The Requires

 

taggable propel classify classifiable ressource access control