function _cmis_sync_cmis_to_drupal_prepare in CMIS API 6.2
Maps a cmis_object to a drupal node.
@todo Add workflow properties
Parameters
$cmis_repository :
$sync_map_type Sync rules for current type:
$cmis_object:
Return value
$drupal_node
1 call to _cmis_sync_cmis_to_drupal_prepare()
- _cmis_sync_cmis_to_drupal_handle_updates in cmis_sync/
cmis_sync.module - Creates/updates Drupal nodes with CMIS content.
File
- cmis_sync/
cmis_sync.module, line 258
Code
function _cmis_sync_cmis_to_drupal_prepare($repository, $sync_map_type, $node_type, $cmis_object) {
module_load_include('api.inc', 'cmis');
if ($sync_map_type['enabled']) {
$drupal_nid = NULL;
// Identify Drupal nid
if (!array_key_exists('nid', $sync_map_type['fields'])) {
if ($cmis_sync_node = db_fetch_object(db_query('SELECT nid FROM {cmis_sync_node} WHERE cmis_objectId = \'%s\'', $cmis_object->id))) {
$drupal_nid = $cmis_sync_node->nid;
}
}
else {
$drupal_nid = $cmis_object->properties[$sync_map_type['fields']['nid']];
}
// Load Drupal node
$node = node_load($drupal_nid);
$node->type = $node_type;
// Map cmis properties to drupal node fields
foreach ($sync_map_type['fields'] as $node_field => $cmis_field) {
if (is_string($cmis_field)) {
_cmis_sync_node_field_value($node, $node_field, $cmis_object->properties[$cmis_field]);
}
elseif (is_array($cmis_field)) {
if (array_key_exists('cmis to drupal', $cmis_field) && $cmis_field['cmis to drupal'] === False) {
continue;
}
_cmis_sync_node_field_value($node, $cmis_field['drupal'], $cmis_object->properties[$cmis_field['cmis']]);
}
else {
throw new CMISException(t('Unknown field map type. Expects "string" or "array". Received "@type"', array(
'@type' => gettype($cmis_field),
)));
}
}
// Load content field
if (array_key_exists('content_field', $sync_map_type)) {
_cmis_sync_node_field_value($node, $sync_map_type['content_field'], cmisapi_getContentStream($repository->repositoryId, $cmis_object->id), array(
'cmis' => $cmis_object,
));
}
return $node;
}
return FALSE;
}