function salesforce_user in Salesforce Suite 5
Implementation of hook_user().
2 string references to 'salesforce_user'
- salesforce in includes/
salesforce_api.inc - salesforce include + connecting via SOAP
- salesforce_admin_settings in ./
salesforce.module - NO LONGER: Implementation of hook_settings(). CHANGEME!!! 4.7 to 5.x conversion: is now admin settings form function and not hook_settings implementation
File
- ./
salesforce.module, line 173 - Original Creator, Maintainer & Developer: Steve McKenzie (http://drupal.org/user/45890) Drupal and Salesforce.com (mainly only working with contacts / leads but can be extended to do anything the salesforce API version 6 can do) Current…
Code
function salesforce_user($op, &$edit, &$account, $category = NULL) {
switch ($op) {
case 'load':
// create the salesforce array and append all salesforce id's associated to this account
$account->salesforce = array();
$ids = _salesforce_user_ids($account);
if (!empty($ids)) {
foreach ($ids as $id => $value) {
$account->salesforce[$id] = $value;
}
}
break;
case 'insert':
// we check on a form value so we can display a checkbox instead of a hidden field if it's an admin viewing the page
if ($edit['create_lead']) {
// must reload the object with user_load() to grab the updated profile fields
// because profile NULL's all the data from $edit
salesforce_lead('insert', user_load(array(
'uid' => $account->uid,
)), array(
'Description' => t('new site user: @date', array(
'@date' => format_date(time(), 'large'),
)),
));
}
break;
case 'update':
if (_salesforce_is_form('leads', 'user_edit')) {
// must reload the object with user_load() to grab the updated profile fields
$updated_account = user_load(array(
'uid' => $account->uid,
));
if ($account->salesforce['contact_id']) {
salesforce_contact('update', $updated_account);
}
else {
if ($account->salesforce['lead_id']) {
salesforce_lead('update', $updated_account, array(
'Description' => t('last updated account information: @date', array(
'@date' => format_date(time(), 'large'),
)),
));
}
else {
// we check on a form value so we can display a checkbox instead of a hidden field if it's an admin viewing the page
if ($edit['create_lead']) {
// must reload the object with user_load() to grab the updated profile fields
salesforce_lead('insert', user_load(array(
'uid' => $account->uid,
)), array(
'Description' => t('admin adding lead: @date', array(
'@date' => format_date(time(), 'large'),
)),
));
}
}
}
}
break;
case 'view':
break;
}
}