You are here

function sf_notifications_settings_form in Salesforce Suite 6.2

Same name and namespace in other branches
  1. 7.2 sf_notifications/sf_notifications.admin.inc \sf_notifications_settings_form()

SF Notifications settings

@todo Response handling: under what conditions should we return a successful response? Note if we do not return a successful response, Salesforce will re-send the outbound message indefinitely.

1 string reference to 'sf_notifications_settings_form'
sf_notifications_menu in sf_notifications/sf_notifications.module
hook_menu implementation

File

sf_notifications/sf_notifications.admin.inc, line 15

Code

function sf_notifications_settings_form(&$form_state) {
  $form = array(
    'sf_notifications' => array(
      '#type' => 'fieldset',
      '#title' => 'Active Notification Fieldmaps',
      '#description' => 'Please check the box for each fieldmap you would like to respond to Salesforce Outbound Message events.',
      'sf_notifications_active_maps' => array(
        '#type' => 'checkboxes',
        '#default_value' => variable_get('sf_notifications_active_maps', array()),
      ),
    ),
  );
  $maps = salesforce_api_salesforce_field_map_load_all();
  foreach ($maps as $id => $map) {
    $edit = l(t('edit'), SALESFORCE_PATH_FIELDMAPS . '/' . $id . '/edit', array(
      'query' => array(
        'destination' => drupal_get_destination(),
      ),
    ));
    $form['sf_notifications']['sf_notifications_active_maps']['#options'][$id] = t('@drupal => @salesforce - %description (!edit)', array(
      '@drupal' => $map->drupal,
      '@salesforce' => $map->salesforce,
      '%description' => $map->description,
      '!edit' => $edit,
    ));
  }

  // IP Whitelist form
  $form['sf_notifications_ip_whitelist'] = array(
    '#type' => 'fieldset',
    '#title' => t('IP Whitelist'),
    '#description' => t('Settings for an IP whitelist of valid Salesforce IPs.'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#access' => user_access('administer salesforce'),
  );
  $form['sf_notifications_ip_whitelist']['sf_notifications_allowed_ips'] = array(
    '#type' => 'textarea',
    '#title' => t('Allowed IPs'),
    '#description' => t('Enter the <a href="@IPs">Salesforce IP addresses</a> that will send outbound messages to your site. Enter one IP address or CIDR mask per line.', array(
      '@IPs' => url('https://help.salesforce.com/apex/HTViewSolution?id=102757&language=en'),
    )),
    '#cols' => 60,
    '#rows' => 5,
    '#default_value' => variable_get('sf_notifications_allowed_ips', implode("\n", sf_notifications_default_allowed_ips())),
  );
  return system_settings_form($form);
}