You are here

function sf_notifications_settings_form in Salesforce Suite 7.2

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

Salesforce 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
Implements hook_menu.

File

sf_notifications/sf_notifications.admin.inc, line 16

Code

function sf_notifications_settings_form($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_fieldmap_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_entity . ' : ' . $map->drupal_bundle,
      '@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())),
  );

  // Queue Settings form
  $queue = DrupalQueue::get('sf_notifications_queue');
  $form['sf_notifications_queue'] = array(
    '#type' => 'fieldset',
    '#title' => t('Incoming Notifications Queue'),
    '#description' => t('Settings for the queueing of incoming notifications.<br/> There are @count items currently in the queue. !link', array(
      '@count' => $queue
        ->numberOfItems(),
      '!link' => l(t('View and manage the queue'), SALESFORCE_PATH_NOTIFICATIONS_ADMIN . '/queue'),
    )),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#access' => user_access('administer salesforce'),
  );
  $form['sf_notifications_queue']['sf_notifications_use_queue'] = array(
    '#type' => 'checkbox',
    '#title' => t('Queue incoming salesforce messages.'),
    '#default_value' => variable_get('sf_notifications_use_queue', 0),
    '#description' => t('By placing incoming notifications into a queue, your site can stand up to the odd time when Salesforce sends a large volume of outbound notifications at once. However, the incoming messages will not be processed immediately.'),
  );
  $form['sf_notifications_queue']['sf_notifications_use_drupal_cron'] = array(
    '#type' => 'checkbox',
    '#title' => t('Process messages on Drupal cron.'),
    '#default_value' => variable_get('sf_notifications_use_drupal_cron', 1),
    '#description' => t('This checkbox has no effect it the queue is not enabled above. If this box is checked, the queue will be processed as part of the normal Drupal cron. However, if you want your messages processed on a different schedule, you can create a system cron job to execute the sf-process-notifications drush task. Note: The user executing the cron job / drush task must have read access to your AES module keyfile.'),
  );
  return system_settings_form($form);
}