Quote from: splittingred at Dec 16, 2010, 08:58 AM
No, it is not. It refers to it as $resourceGroupAccess[’id’], so you should be fine just putting the ID in the array.
Thanks.
It looks like I just need to send the ones I want to change.
BTW, it looks to me like if you send the ID of a non-existent group in the JSON string, the create and update processors will create resourceGroupResource objects for groups that don’t exist, without creating the resource groups themselves. In that case the resourceGroupResource will point to a nonexistent group with no name.
<?php
if (!empty($resourceGroupAccess['access'])) {
// Should probably check for existence of modResourceGroup here first, and if it doesn't exist,
// create it using $resourceGroupAccess['name'] and then get its ID for the next step.
// ( or else just skip the group assignment altogether for nonexistent groups).
$resourceGroupResource = $modx->getObject('modResourceGroupResource',array(
'document_group' => $resourceGroupAccess['id'],
'document' => $resource->get('id'),
));
if (empty($resourceGroupResource)) {
$resourceGroupResource = $modx->newObject('modResourceGroupResource');
}
$resourceGroupResource->set('document_group',$resourceGroupAccess['id']);
$resourceGroupResource->set('document',$resource->get('id'));
$resourceGroupResource->save();
}