function salesforce_api_id_unlink in Salesforce Suite 6.2
Same name and namespace in other branches
- 7.2 salesforce_api/salesforce_api.module \salesforce_api_id_unlink()
Removes a link between a Salesforce record and a Drupal object. Arguments correspond to the columns in the salesforce_object_map table
Parameters
array $args: Associative array of criteria for deletion. These criteria will be AND'ed together to create a sql DELETE query. Keys are:
- 'oid' drupal id of the object (nid, uid, etc).
- 'name' machine name of the fieldmap corresponding to this linkage. 'name' or 'drupal_type' MUST be set.
- 'drupal_type' type of drupal object corresponding to this linkage. e.g. "node", "user", etc. 'name' or 'drupal_type' MUST be set.
- 'sfid' the salesforce id of the object
Keys can be supplied in various combinations, but $args must not be empty. EITHER "oid" must be set along with "drupal_type" or "name" OR "sfid" must be set
In other words, minimal valid key combinations are:
- 'sfid'
- 'drupal_type', 'oid'
- 'name', 'oid'
6 calls to salesforce_api_id_unlink()
- sf_node_export in sf_node/
sf_node.module - Exports a node to Salesforce using the specified fieldmap and stores the ID of the Salesforce object for the node.
- sf_node_salesforce_form in sf_node/
sf_node.module - sf_node_salesforce_form_submit in sf_node/
sf_node.module - sf_user_export in sf_user/
sf_user.module - Exports a user to Salesforce using the specified fieldmap and stores the ID of the Salesforce object for the user.
- sf_user_salesforce_form in sf_user/
sf_user.module
File
- salesforce_api/
salesforce_api.module, line 1233 - Defines an API that enables modules to interact with the Salesforce server.
Code
function salesforce_api_id_unlink($args) {
$valid_args = !empty($args['sfid']) || !empty($args['oid']) && (!empty($args['drupal_type']) || !empty($args['name']));
if (!$valid_args) {
return FALSE;
}
$sql = "DELETE FROM {salesforce_object_map} ";
$sql_args = array();
$where = array();
if (!empty($args['oid'])) {
$where[] = ' oid = %d ';
$sql_args[] = $args['oid'];
}
if (!empty($args['sfid'])) {
$where[] = ' sfid = "%s" ';
$sql_args[] = $args['sfid'];
}
if (!empty($args['name'])) {
$where[] = ' name = "%s" ';
$sql_args[] = $args['name'];
}
if (!empty($args['drupal_type'])) {
$where[] = ' drupal_type = "%s" ';
$sql_args[] = $args['drupal_type'];
}
$sql .= ' WHERE ' . implode(' AND ', $where);
db_query($sql, $sql_args);
module_invoke_all('salesforce_api_post_unlink', $args);
}