You are here

function salesforce_api_settings_form in Salesforce Suite 7

Same name and namespace in other branches
  1. 5.2 salesforce_api/salesforce_api.module \salesforce_api_settings_form()
  2. 6.2 salesforce_api/salesforce_api.admin.inc \salesforce_api_settings_form()
  3. 7.2 salesforce_api/salesforce_api.admin.inc \salesforce_api_settings_form()

The settings form at admin/config/salesforce.

2 string references to 'salesforce_api_settings_form'
salesforce_api_menu in salesforce_api/salesforce_api.module
Implements hook_menu().
sf_prematch_form_alter in sf_prematch/sf_prematch.module
Implementation of hook_form_alter().

File

salesforce_api/salesforce_api.admin.inc, line 12
Contains the admin page callbacks for the Salesforce module, including forms for general settings and fieldmap administration.

Code

function salesforce_api_settings_form($form, &$form_state) {
  $form = array();

  // Use the username field to collapse the API settings fieldset.
  $username = variable_get('salesforce_api_username', '');
  $form['api'] = array(
    '#type' => 'fieldset',
    '#title' => t('Salesforce API settings'),
    '#description' => t('Use your Salesforce.com login information for these username and password fields.'),
    '#collapsible' => !empty($username),
    '#collapsed' => !empty($username),
    '#weight' => -10,
  );
  $form['api']['salesforce_api_username'] = array(
    '#type' => 'textfield',
    '#title' => t('Username'),
    '#description' => t('Should be in the form of an e-mail address.'),
    '#default_value' => variable_get('salesforce_api_username', ''),
    '#required' => TRUE,
  );
  $form['api']['salesforce_api_password'] = array(
    '#type' => 'password',
    '#title' => t('Password'),
    '#description' => t('Enter the password used when logging into Salesforce.'),
    '#default_value' => variable_get('salesforce_api_password', ''),
  );
  $form['api']['salesforce_api_token'] = array(
    '#type' => 'textfield',
    '#title' => t('Security token'),
    '#description' => t('Set your security token by logging into Salesforce and navigating to Setup > My Personal Information > Reset My Security Token.'),
    '#required' => TRUE,
    '#default_value' => variable_get('salesforce_api_token', ''),
  );
  $form['log'] = array(
    '#type' => 'fieldset',
    '#title' => t('Log settings'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#weight' => -9,
  );
  $form['log']['salesforce_api_activity_log'] = array(
    '#type' => 'radios',
    '#title' => t('Activity log level'),
    '#options' => array(
      SALESFORCE_LOG_NONE => t('Do not log any Salesforce activities.'),
      SALESFORCE_LOG_SOME => t('Log important Salesforce activities.'),
      SALESFORCE_LOG_ALL => t('Log all Salesforce activitiies.'),
    ),
    '#default_value' => variable_get('salesforce_api_activity_log', SALESFORCE_LOG_SOME),
  );
  $form['log']['salesforce_api_error_log'] = array(
    '#type' => 'radios',
    '#title' => t('Error log level'),
    '#options' => array(
      SALESFORCE_LOG_NONE => t('Do not log any Salesforce errors.'),
      SALESFORCE_LOG_SOME => t('Log important Salesforce errors.'),
      SALESFORCE_LOG_ALL => t('Log all Salesforce errors.'),
    ),
    '#default_value' => variable_get('salesforce_api_error_log', SALESFORCE_LOG_ALL),
  );
  $form['objects'] = array(
    '#type' => 'fieldset',
    '#title' => t('Object settings'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#weight' => -9,
  );
  $form['objects']['clear_cache'] = array(
    '#type' => 'item',
    '#value' => t('Caching data improves performance, however your Drupal site will be unaware of any alterations made to your Salesforce installation unless the cached data is refreshed. Select the lifetime the object data after which the cache will be automatically refreshed.  To refresh all cached object data on your site, click the button below.'),
  );
  $period = drupal_map_assoc(array(
    32400,
    43200,
    86400,
    172800,
    259200,
    604800,
    1209600,
    2419200,
    4838400,
    9676800,
  ), 'format_interval');
  $period[CACHE_PERMANENT] = t('<none>');
  $form['objects']['salesforce_api_object_expire'] = array(
    '#type' => 'select',
    '#title' => t('Minimum cache lifetime'),
    '#options' => $period,
    '#default_value' => variable_get('salesforce_api_object_expire', CACHE_PERMANENT),
  );
  $form['objects']['clear_cache_clear'] = array(
    '#type' => 'submit',
    '#value' => t('Clear cached object data'),
    '#submit' => array(
      'salesforce_api_cache_build',
    ),
  );

  // Validate handler makes sure that the salesforce_api_password doesn't get set to null on accident
  $form['#validate'][] = 'salesforce_api_settings_form_validate';
  $form['#submit'][] = 'salesforce_api_settings_form_submit';
  return system_settings_form($form);
}