Skip to content

wearethefoos/owned

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Owned

Owned is a CakePHP plugin that gives models of your choice ownership awareness.

Usage

You can either install it as a plugin in your App, or just take the behavior file and put in your APP/models/behaviors folder.

Set up the ownership table

Run the sql in the plugin's config/sql folder.

Configuration options

You can set various configuration options in the config array:

  • The owner model to use;
  • The user model;
  • The user model's primary key (needed if you change the user model);
  • The access mode ('crud' or 'owner');
  • How to deal with users trying to access objects that are not theirs ('quiet', 'error').

Adding the behavior to a model (plugin)

To add the behavior to a model add it to the $actsAs array in your model:

	$actsAs = array('Owned.Owned');

Or set some config options (shorthand mode sets access mode):

	$actsAs = array(
		'Owned.Owned' => 'owner'
	);

or using an extended array for more options:

	$actsAs = array(
		'Owned.Owned' => array(
			'userModel' => 'Member',
			'userPrimaryKey => 'member_id',
			'returnMode' => 'error',
		)
	);

About

cakephp plugin to manage ownership on a model level

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages