Well, the first step was to set up a fresh Drupal 5.x (5.3) install.
Then, enabled core contact and profile modules (required by legacy salesforce module).
Then, copied 4.7 salesforce module into ./sites/all/modules, and edited salesforce.module and salesforce.install so that the function module_exist() became module_exists().
Then, enabled salesforce module. Install went ahead with the usual success messages (created tables, created profile fields).
Profile fields were created.
Getting admin settings form to work
Next step was to convert old (obsolete) hook_settings function to the Drupal 5 way.
4.7 settings setup:
/** * Implementation of hook_settings(). */ function salesforce_settings() { drupal_set_title(t('SalesForce.com Settings')); _salesforce_settings(); $form['salesforce_account'] = array( '#type' => 'fieldset', '#title' => t('SalesForce.com Account'), '#collapsible' => true, '#description' => t('this information is required for this module to work') ); ... ... return $form; }
5.x setup – Instead of using obsolete hook_settings(), now directly setup menu callback in salesforce_menu(), which refers to modified admin form function salesforce_admin_settings() (replaces salesforce_settings()):
/** * Implementation of hook_menu(). */ function salesforce_menu($may_cache) { $items = array(); // 4.7 to 5.x conversion: replace hook_settings with menu callback $items[] = array( 'path' => 'admin/settings/salesforce', 'title' => t('Salesforce'), 'description' => t('Configure salesforce access.'), 'callback' => 'drupal_get_form', 'callback arguments' => array('salesforce_admin_settings'), 'access' => user_access('administer site configuration'), 'type' => MENU_NORMAL_ITEM, // optional ); .... }
function salesforce_admin_settings() { drupal_set_title(t('SalesForce.com Settings')); _salesforce_settings(); $form['salesforce_account'] = array( '#type' => 'fieldset', '#title' => t('SalesForce.com Account'), '#collapsible' => true, '#description' => t('this information is required for this module to work') ); ... ... // 4.7 to 5.x conversion: // return $form; return system_settings_form($form); }
Success! A Salesforce entry now appeared in my Site Configuration admin section. So I was now able to set up my salesforce account user and password info.
Getting site-wide contact form to insert lead
But when I tried to use the site-wide contact form to insert a lead into my Salesforce account, I got the following error:
Hmm.
Solved! Contact form submit handler changed:
function salesforce_contact_form($form_id, $form_values) { global $user; if ($user->uid > 0) { $account->uid = $user->uid; } //Works in 4.7: //$name = explode(' ', $_POST['edit']['name']); //Works in 5.x: $name = explode(' ', $form_values['name']);
Inserting newly created Drupal User into SalesForce as lead
However, success in creating a lead upon creating a Drupal User! Updating works too:
Admin content pages
one change to get the admin content menu callback function to work:
Before (4.7, doesn’t work for 5.x):
function salesforce_admin_page() { theme('add_style', drupal_get_path('module', 'salesforce') .'/salesforce.css'); $op = arg(2);
After (works for 5.x):
function salesforce_admin_page() { theme('add_style', drupal_get_path('module', 'salesforce') .'/salesforce.css'); // in 4.7 was arg(2), now arg(3) works! $op = arg(3);