I am creating a page_standard
asset using PHP. Something like this:
function createAsset(Array $asset_spec, Asset &$parent_asset, $schema_id, Array $metadata_mapping)
{
$attribs = Array();
echo '- Creating asset';
// Check Matrix Type Code
$GLOBALS['SQ_SYSTEM']->am->includeAsset('page_standard');
$new = new Page_Standard();
echo '.';
// Set attributes
$new->setAttrValue('name', $asset_spec['name']);
echo '.';
$new->saveAttributes();
// Might need this later
// $folders_children = $GLOBALS['SQ_SYSTEM']->am->getChildren($asset->id);
// Link the new asset under the parent folder
$link = Array(
'asset' => &$parent_asset,
'link_type' => SQ_LINK_TYPE_1,
'link_value' => '',
'sort_order' => 0,
'is_exclusive' => FALSE,
'is_dependant' => FALSE,
);
$link_id = $new->create($link);
echo '.';
$GLOBALS['SQ_SYSTEM']->am->releaseLock($new->id, 'all');
$GLOBALS['SQ_SYSTEM']->am->acquireLock($new->id, 'all');
$file_contents = "TEST CONTENT";
// Set body contents
$bodycopy_div = $GLOBALS['SQ_SYSTEM']->am->getAsset($new->id+2);
$wysiwyg_content = $GLOBALS['SQ_SYSTEM']->am->getAsset($new->id+3);
if (!is_null($bodycopy_div) && !is_null($wysiwyg_content)) {
$GLOBALS['SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_FORCED);
$wysiwyg_content->setContent($file_contents);
$bodycopy_div_edit_fns = $bodycopy_div->getEditFns();
$bodycopy_div_edit_fns->generateContentFile($bodycopy_div);
$new->saveAttributes();
$GLOBALS['SQ_SYSTEM']->restoreRunLevel();
$GLOBALS['SQ_SYSTEM']->am->forgetAsset($bodycopy_div, TRUE);
$GLOBALS['SQ_SYSTEM']->am->forgetAsset($wysiwyg_content, TRUE);
unset($bodycopy_div);
unset($wysiwyg_contnet);
unset($bodycopy_div_edit_fns);
unset($file_contents);
}//end if
$GLOBALS['SQ_SYSTEM']->am->forgetAsset($bodycopy, TRUE);
unset($bodycopy);
// Assign metadata schema and values to the asset
editMetadata($new, $asset_spec, $metadata_mapping, $schema_id);
echo '.';
$GLOBALS['SQ_SYSTEM']->am->releaseLock($new->id, 'all');
// Free memory
$GLOBALS['SQ_SYSTEM']->am->forgetAsset($new);
echo ' => asset ID '.$new->id."\n";
return Array(reset($asset_spec) => $new->id);
}//end createAsset()
The problem I am having is, when I view the created asset in the Matrix _admin and try to edit and save the contents, I get permissions errors:
Does anyone have any ideas why I don’t have permissions to edit the assets after I have created them? *I did make sure to switch to the root user when creating the assets then changed back after I was done.