function _cmis_sync_cmis_drupal_handle_deletes in CMIS API 6.3
Same name and namespace in other branches
- 6.4 cmis_sync/cmis_sync.cmis.inc \_cmis_sync_cmis_drupal_handle_deletes()
- 7.2 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 121
Code
function _cmis_sync_cmis_drupal_handle_deletes($repository, $sync_map_type, $node_type) {
// get node list
$sync_nodes = array();
$sync_nodes_query = db_query('SELECT nid, cmis_objectId FROM {cmis_sync_node} WHERE cmis_repositoryId="%s"', $repository->repositoryId);
while ($sync_node = db_fetch_object($sync_nodes_query)) {
if (node_load($sync_node->nid)->type == $node_type) {
$sync_nodes[$sync_node->cmis_objectId] = $sync_node->nid;
}
}
if (count($sync_nodes)) {
// 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($sync_nodes))));
foreach ($cmis_objects->objectList as $cmis_object) {
if (array_key_exists($cmis_object->id, $sync_nodes)) {
unset($sync_nodes[$cmis_object->id]);
}
}
// delete CMIS - Drupal reference
db_query('DELETE FROM {cmis_sync_node} WHERE nid IN (\'%s\')', join('\',\'', array_values($sync_nodes)));
// delete Drupal nodes
foreach ($sync_nodes as $cmis_objectId => $drupal_nid) {
node_delete($drupal_nid);
}
}
}