You are here

function sf_notifications_fieldmap_settings in Salesforce Suite 6.2

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

File

sf_notifications/sf_notifications.admin.inc, line 52

Code

function sf_notifications_fieldmap_settings(&$form_state, $fieldmap_id) {
  $map = salesforce_api_fieldmap_load($fieldmap_id);
  $active = variable_get('sf_notifications_active_maps', array());
  $active = $active[$fieldmap_id];
  $form = array(
    'active' => array(
      '#type' => 'checkbox',
      '#title' => 'Active',
      '#description' => 'Check this box if this fieldmap should respond to Salesforce Outbound Message events.',
      '#default_value' => $active,
    ),
  );
  $form['sf_notifications_settings'] = array(
    '#tree' => TRUE,
  );
  $settings = variable_get('sf_notifications_settings', array(
    'condition' => array(),
  ));
  foreach ($settings as $id => $setting) {
    $form['sf_notifications_settings'][$id] = array(
      '#type' => 'value',
      '#value' => $setting,
    );
  }
  $form['sf_notifications_settings'][$fieldmap_id] = array(
    '#tree' => TRUE,
    '#type' => 'fieldset',
    '#title' => 'Conditions',
    '#descripiton' => 'You may assign conditions under which notifications will respond to Outbound Message events. Notifications failing these conditions will not trigger this fieldmap. This may be particularly useful, e.g. in the case of Salesforce objects that are mapped to multiple Drupal objects.',
  );
  $settings = $settings[$fieldmap_id];
  $form['sf_notifications_settings'][$fieldmap_id]['condition'] = array(
    '#type' => 'textarea',
    '#title' => FALSE,
    '#default_value' => $settings['condition'],
    '#description' => t('PHP code - <strong>do not include &lt;?php ?> tags</strong>. This code should return TRUE or FALSE to determine whether this fieldmap should be triggered on a relevant Outbound Message event. Available variables are $map (fieldmap object to be used to create the import), $notification_data (array of parsed object data from salesforce, keys are "oid" - drupal object id on update or empty on insert; "name" - machine name of fieldmap used for this operation; "fields" - object with the actual data from Salesforce), $operation ("insert", "update", or "delete")'),
  );
  return system_settings_form($form);
}