function sf_notifications_delete_record in Salesforce Suite 7.2
Same name and namespace in other branches
- 6.2 sf_notifications/sf_notifications.module \sf_notifications_delete_record()
Helper function for _sf_notifications_handle_message() - attempt to delete the local object data, given the salesforce object_record.
1 call to sf_notifications_delete_record()
- _sf_notifications_handle_message in sf_notifications/
sf_notifications.module - Loop through an array of SObjects from Salesforce and save them according to any existing sf fieldmaps, notification settings, and data.
File
- sf_notifications/
sf_notifications.module, line 271
Code
function sf_notifications_delete_record($object_record) {
// Try to delete the local record. Since the record is no more, in this
// case we're agnostic to the drupal_entity ("node" or "user").
$success = TRUE;
switch ($object_record['drupal_entity']) {
case 'user':
user_cancel(array(), $object_record['oid'], $method = 'user_cancel_block');
// Invoke hook_sf_notifications_processed().
module_invoke_all('sf_notifications_processed', 'delete', $object_record);
salesforce_api_log(SALESFORCE_LOG_ALL, 'Salesforce Notifications deleted user ' . $object_record['oid'] . ' sfid ' . $sfid);
break;
case 'node':
// Can't use node_delete() since it's wrapped in node_access and we're
// probably anonymous. The following is adapted from node_delete().
$node = node_load($nid, NULL, TRUE);
db_delete('node')
->condition('nid', $node->nid)
->execute();
db_delete('node_revisions')
->condition('nid', $node->nid)
->execute();
// Call the node-specific callback (if any):
node_invoke($node, 'delete');
module_invoke_all('node_delete', $node);
search_wipe($node->nid, 'node');
// Invoke hook_sf_notifications_processed().
module_invoke_all('sf_notifications_processed', 'delete', $object_record);
salesforce_api_log(SALESFORCE_LOG_ALL, 'Salesforce Notifications deleted node ' . $object_record['oid'] . ' sfid ' . $sfid);
break;
default:
if (function_exists($object_record['drupal_entity'] . '_delete')) {
$function = $object_record['drupal_entity'] . '_delete';
$function($object_record['oid']);
// Invoke hook_sf_notifications_processed().
module_invoke_all('sf_notifications_processed', 'delete', $object_record);
salesforce_api_log(SALESFORCE_LOG_ALL, 'Salesforce Notifications deleted ' . $object_record['drupal_type'] . ' ' . $object_record['oid'] . ' sfid ' . $sfid);
}
else {
salesforce_api_log(SALESFORCE_LOG_SOME, ' Salesforce Notifications: Could not find delete handler for deleted
Salesforce record <pre>' . print_r($object_record, TRUE) . '</pre>');
$success = FALSE;
}
break;
}
return $success;
}