function _cmis_sync_cmis_drupal_handle_deletes in CMIS API 7.2
Same name and namespace in other branches
- 6.4 cmis_sync/cmis_sync.cmis.inc \_cmis_sync_cmis_drupal_handle_deletes()
- 6.3 cmis_sync/cmis_sync.cmis.inc \_cmis_sync_cmis_drupal_handle_deletes()
- 7 cmis_sync/cmis_sync.cmis.inc \_cmis_sync_cmis_drupal_handle_deletes()
Deletes Drupal nodes referencing to CMIS deleted objects.
Parameters
$repository:
$sync_map_type:
1 call to _cmis_sync_cmis_drupal_handle_deletes()
- _cmis_sync_cmis_drupal_update in cmis_sync/
cmis_sync.cmis.inc - Handles CMIS to Drupal updates.
File
- cmis_sync/
cmis_sync.cmis.inc, line 134
Code
function _cmis_sync_cmis_drupal_handle_deletes($repository, $sync_map_type, $node_type) {
// get node list
$sync_nodes = '';
$cmis_nodes = array();
$sync_nodes = db_query('SELECT nid, cmis_objectId FROM {cmis_sync_node} WHERE cmis_repositoryId = :repo', array(
':repo' => $repository->repositoryId,
));
foreach ($sync_nodes as $sync_node) {
if (node_load($sync_node->nid)->type == $node_type) {
$cmis_nodes[$sync_node->cmis_objectId] = $sync_node->nid;
}
}
if ($sync_nodes
->rowCount()) {
// identify existing CMIS objects
$cmis_objects = cmisapi_query($repository->repositoryId, sprintf('SELECT cmis:objectId FROM %s WHERE cmis:objectId IN (\'%s\')', $sync_map_type['cmis_type'], join('\',\'', array_keys($cmis_nodes))));
foreach ($cmis_objects->objectList as $cmis_object) {
if (array_key_exists($cmis_object->id, $cmis_nodes)) {
unset($cmis_nodes[$cmis_object->id]);
}
}
if (count($cmis_nodes)) {
// delete CMIS - Drupal reference
db_delete('cmis_sync_node')
->condition('nid', array_values($cmis_nodes), 'IN')
->execute();
// delete Drupal nodes
foreach ($cmis_nodes as $cmis_objectId => $drupal_nid) {
node_delete($drupal_nid);
}
}
}
}