We're doing a massive import of categories from another CMS, and using the below code to create the categories:
$basePath = JPATH_ADMINISTRATOR.'/components/com_categories'; require_once $basePath.'/models/category.php'; $config = array('table_path' => $basePath.'/tables'); $catmodel = new CategoriesModelCategory($config); // Populate the params array with values to save, for rules: $params['rules'] = array( 'core.edit.state' => array(), 'core.edit.delete' => array(), 'core.edit.edit' => array(), 'core.edit.state' => array(), 'core.edit.edit.own' => array(1=>true) ); if(!$catmodel->save($params)) return false; This all works marvelously, creating the category, with the Permissions as expected.
However, examining other categories that have been manually added along the way, all with the same parent_id ancestry, I see two different varieties of the rules column in the #__assets table.
#__assets rules Example #1 (as created by the above code, and some with Admin Category Manager, in use by many categories)
{ "core.create":[], "core.delete":[], "core.edit":[], "core.edit.state":[], "core.edit.own":{"1":1} } #__assets rules Example #2 (as created by the Admin Category Manager, and in use by many categories)
{ "core.create":{"6":1,"3":1}, "core.delete":{"6":1}, "core.edit":{"6":1,"4":1}, "core.edit.state":{"6":1,"5":1}, "core.edit.own":{"1":1,"6":1,"3":1} } When I view them in the Category manager, both categories appear to have the same permissions - inheriting everything except "Edit Own" being set to "Allowed". So, the real question is two-fold:
- What are the differences between these two sets of rules
- Is the method we're using (yielding example #1) incomplete in anyway