Adding ACL rules to your component
From Joomla! Documentation
Revision as of 00:23, 5 December 2011 by Mrs.siam
This tutorial will demonstrate how to add custom action permission to your component down to object level. Normally we familiar with ACL in global configuration level, category level and component level. Now we will learn how to add action permission control in our component.
JTable class has some built-in support for ACL, to use this you have to add one integer field in your table named 'asset_id'. This field will be used to control action control for your object. Do not confuse with 'access', that is only for access permission (read side) as Joomla! separates other actions from read acess.
Normally, we have to override __construct() method in our descendant class. We may also override check() method to validate our data before saving to database. For ACL action support we have to override these methods:-
public function bind($array, $ignore = )to let JTable save rule data to Joomla's assets table.
protected function _getAssetName()to give asset name for our asset.
protected function _getAssetParentId($table = null, $id = null)to give parent id of our asset, normally Joomla! uses root (1) as a parent. Generally we will change this to our component.