This code isn't going anywhere because, from what I understand, the functionality will be handled by the core in Revo 2.3. In the meantime, I need new resources to inherit the resource groups of their parents. I think this should be the default behavior, sort of like file systems have inheritable permissions.
Here's the code I'm using to handle things while I wait for 2.3. Does anyone have suggestions? Is there a better way to do this?
It's a plugin that fires when resources are saved:
/* Inherit resource groups only if resource is new */
if ($mode == modSystemEvent::MODE_NEW) {
/* get the id of the parent */
$parentId = $_POST['parent'];
/* get all the resource group data of the parent as a collection */
$groupCollection = $modx->getCollection('modResourceGroupResource', array('document'=>$parentId));
/* join the resource to resource groups in the collection */
foreach($groupCollection as $group) {
$success = $resource->joinGroup($group->get('document_group'));
}
}
(I also hacked together some code to batch set resource groups to children of a selected parent. The current drag-and-drop-one-resource-at-a-time interface doesn't work at all for large sites. I'm hoping that interface will also be improved soon.)