You are here

civicrm_entity_profile.module in CiviCRM Entity 7.2

File

modules/civicrm_entity_profile/civicrm_entity_profile.module
View source
<?php

/**
 * @file
 * Provide CiviCRM Entity Profile Support.
 * Provides utility function for profile forms
 * Provides field type for selecting profiles for Events and Contribution Pages.
 */
module_load_include('inc', 'civicrm_entity_profile', 'includes/civicrm_entity_profile.profile');

/**
 * Implements hook_menu().
 * code example taken from https://www.drupal.org/project/multiple_fields_remove_button module
 */
function civicrm_entity_profile_menu() {
  $items = array();
  $items['civicrm_entity_profile_multiple_fields_remove_button/ajax'] = array(
    'title' => 'Remove item callback',
    'page callback' => 'civicrm_entity_profile_multiple_fields_remove_button_js',
    'delivery callback' => 'ajax_deliver',
    'access callback' => TRUE,
    'theme callback' => 'ajax_base_page_theme',
    'type' => MENU_CALLBACK,
  );
  return $items;
}

/**
 * Page callback for civicrm_entity_profile_multiple_fields_remove_button/ajax path.
 * code example taken from https://www.drupal.org/project/multiple_fields_remove_button module
 */
function civicrm_entity_profile_multiple_fields_remove_button_js() {
  if (isset($_POST['ajax_html_ids'])) {
    unset($_POST['ajax_html_ids']);
  }
  list($form, $form_state) = ajax_get_form();
  drupal_process_form($form['#form_id'], $form, $form_state);

  // Get the information on what we're removing.
  $button = $form_state['triggering_element'];

  // Go two levels up in the form, to the whole widget.
  $element = drupal_array_get_nested_value($form, array_slice($button['#array_parents'], 0, -3));

  // Now send back the proper AJAX command to replace it.
  $return = array(
    '#type' => 'ajax',
    '#commands' => array(
      ajax_command_replace('#' . $element['#id'], drupal_render($element)),
    ),
  );

  // Because we're doing this ourselves, messages aren't automatic. We have
  // to add them.
  $messages = theme('status_messages');
  if ($messages) {
    $return['#commands'][] = ajax_command_prepend('#' . $element['#id'], $messages);
  }
  return $return;
}
function civicrm_entity_profile_civicrm_entity_supported_info(&$civicrm_entity_info) {
  $civicrm_entity_info['civicrm_uf_field'] = array(
    'civicrm entity name' => 'uf_field',
    'label property' => 'label',
    'permissions' => array(
      'view' => array(),
      'edit' => array(),
      'update' => array(),
      'create' => array(),
      'delete' => array(),
    ),
    'theme' => array(
      'template' => 'civicrm-uf-field',
      'path' => drupal_get_path('module', 'civicrm_entity_profile') . '/templates',
    ),
    'display suite' => array(
      'link fields' => array(
        array(
          'link_field' => 'uf_group_id',
          'target' => 'civicrm_uf_group',
        ),
      ),
      'boolean fields' => array(
        'is_active',
        'is_view',
        'is_required',
        'in_selector',
        'is_searchable',
        'is_reserved',
        'is_multi_summary',
      ),
      'option fields' => array(
        'location_type_id',
        'phone_type_id',
        'website_type_id',
        'field_type',
      ),
    ),
  );
  $civicrm_entity_info['civicrm_uf_group'] = array(
    'civicrm entity name' => 'uf_group',
    'label property' => 'title',
    'permissions' => array(
      'view' => array(),
      'edit' => array(),
      'update' => array(),
      'create' => array(),
      'delete' => array(),
    ),
    'theme' => array(
      'template' => 'civicrm-uf-group',
      'path' => drupal_get_path('module', 'civicrm_entity_profile') . '/templates',
    ),
    'display suite' => array(
      'link fields' => array(),
      'boolean fields' => array(
        'is_active',
        'is_map',
        'add_captcha',
        'is_edit_link',
        'is_uf_link',
        'is_update_dupe',
        'is_reserved',
        'is_cms_user',
        'is_proximity_search',
      ),
      'date fields' => array(
        'created_date',
      ),
    ),
  );
  $civicrm_entity_info['civicrm_uf_join'] = array(
    'civicrm entity name' => 'uf_join',
    'label property' => 'id',
    'permissions' => array(
      'view' => array(),
      'edit' => array(),
      'update' => array(),
      'create' => array(),
      'delete' => array(),
    ),
    'theme' => array(
      'template' => 'civicrm-uf-join',
      'path' => drupal_get_path('module', 'civicrm_entity_profile') . '/templates',
    ),
    'display suite' => array(
      'link fields' => array(
        array(
          'link_field' => 'uf_group_id',
          'target' => 'civicrm_uf_group',
        ),
      ),
      'boolean fields' => array(
        'is_active',
      ),
    ),
  );
}

/**
 * Implements hook_field_info().
 *
 * @return array
 */
function civicrm_entity_profile_field_info() {
  return array(
    'civicrm_entity_profile_field' => array(
      'label' => t('CiviCRM Entity Profile'),
      'description' => t('This field provides a widget selecting profiles for Events and Contribution Pages'),
      'settings' => array(
        'groups' => array(),
      ),
      'instance_settings' => array(),
      'default_widget' => 'civicrm_entity_profile_field_default_widget',
      'default_formatter' => 'civicrm_entity_profile_field_default_formatter',
    ),
  );
}

/**
 * Implements hook_form_FORMID_alter().
 *
 * form id : field_ui_field_overview_form
 *
 * Only allow creation of civicrm_entity_profile_fields to civicrm_event or civicrm_contribution_page entity types
 *
 * @param $form
 * @param $form_state
 */
function civicrm_entity_profile_form_field_ui_field_overview_form_alter(&$form, &$form_state) {
  $supported_entities = array(
    'civicrm_event',
    'civicrm_contribution_page',
  );
  if (!in_array($form['#entity_type'], $supported_entities)) {
    unset($form['fields']['_add_new_field']['type']['#options']['civicrm_entity_profile_field']);
    foreach ($form['fields']['_add_existing_field']['field_name']['#options'] as $field_name => $description) {
      if (strpos($description, 'CiviCRM Entity Profile') !== FALSE) {
        unset($form['fields']['_add_existing_field']['field_name']['#options'][$field_name]);
      }
    }
  }
}

/**
 * Implements hook_field_settings_form().
 *
 * @param $field
 * @param $instance
 * @return array
 */
function civicrm_entity_profile_field_instance_settings_form($field, $instance) {
  if ($instance['entity_type'] == 'civicrm_event') {
    $settings = $instance['settings'];
    $form['registrant_type'] = array(
      '#type' => 'select',
      '#multiple' => FALSE,
      '#title' => t('Registrant Type'),
      '#default_value' => !empty($settings['registrant_type']) ? $settings['registrant_type'] : 'CiviEvent',
      '#description' => t('Groups to include for this field '),
      '#options' => array(
        'CiviEvent' => 'Main Registrant',
        'CiviEvent_Additional' => 'Additional Participant',
      ),
    );
    return $form;
  }
}

/**
 * Implements hook_field_is_empty().
 *
 * @param $item
 * @param $field
 * @return bool
 */
function civicrm_entity_profile_field_is_empty($item, $field) {
  if (empty($item['uf_group_id'])) {
    if (empty($item['target_id'])) {
      return TRUE;
    }
  }
  return FALSE;
}

/**
 * Implements hook_field_load().
 *
 * @param $entity_type
 * @param $entities
 * @param $field
 * @param $instances
 * @param $langcode
 * @param $items
 * @param $age
 */
function civicrm_entity_profile_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) {
  $supported_entities = array(
    'civicrm_event',
    'civicrm_contribution_page',
  );
  if (in_array($entity_type, $supported_entities)) {
    foreach ($entities as $id => $entity) {
      if ($entity_type == 'civicrm_event') {
        $type = !empty($instances[$id]['settings']['registrant_type']) ? $instances[$id]['settings']['registrant_type'] : 'CiviEvent';
      }
      else {
        $type = 'CiviContribute';
      }
      $uf_joins = _civicrm_entity_profile_get_ufjoins($entity_type, $id, $type);
      if (!empty($uf_joins) && count($uf_joins)) {
        foreach ($uf_joins as $delta => $uf_join) {
          $items[$id][$delta]['target_id'] = $uf_join;
        }
      }
    }
  }
}

/**
 * Implements hook_field_insert().
 *
 * @param $entity_type
 * @param $entity
 * @param $field
 * @param $instance
 * @param $langcode
 * @param $items
 */
function civicrm_entity_profile_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items) {
  if (($entity_type == 'civicrm_event' || $entity_type == 'civicrm_contribution_page') && $instance['widget']['type'] == 'civicrm_entity_profile_field_default_widget') {
    if (!empty($items)) {
      if (!empty($entity->id)) {
        foreach ($items as $delta => $item) {
          _civicrm_entity_profile_process_field_item($entity_type, $entity, $instance, $item, $delta);
          unset($items[$delta]);
        }
      }
    }
  }
}

/**
 * Implements hook_field_update().
 *
 * @param $entity_type
 * @param $entity
 * @param $field
 * @param $instance
 * @param $langcode
 * @param $items
 */
function civicrm_entity_profile_field_update($entity_type, $entity, $field, $instance, $langcode, &$items) {
  if (($entity_type == 'civicrm_event' || $entity_type == 'civicrm_contribution_page') && $instance['widget']['type'] == 'civicrm_entity_profile_field_default_widget') {
    if (!empty($items)) {
      if (!empty($entity->id)) {

        // need to handle deletion of items that exist but have been removed via multiple fields 'Remove' button
        if ($entity_type == 'civicrm_event') {
          $module = !empty($instance['settings']['registrant_type']) ? $instance['settings']['registrant_type'] : 'CiviEvent';
        }
        else {
          $module = 'CiviContribute';
        }
        $uf_join_ids_pre = _civicrm_entity_profile_get_ufjoins($entity_type, $entity->id, $module);
        foreach ($uf_join_ids_pre as $uf_join_id) {
          $delete = 1;
          foreach ($items as $delta => $item) {
            if ($item['target_id'] == $uf_join_id) {
              $delete = 0;
            }
          }
          if ($delete) {
            entity_delete($entity_type, $uf_join_id);
          }
        }
        foreach ($items as $delta => $item) {
          _civicrm_entity_profile_process_field_item($entity_type, $entity, $instance, $item, $delta);
          unset($items[$delta]);
        }
      }
    }
  }
}

/**
 * * Helper function to process field item on entity insert or update
 *
 * @param $entity_type
 * @param $entity
 * @param $instance
 * @param $item
 */
function _civicrm_entity_profile_process_field_item($entity_type, $entity, $instance, $item, $delta) {
  if ($entity_type == 'civicrm_event') {
    $module = !empty($instance['settings']['registrant_type']) ? $instance['settings']['registrant_type'] : 'CiviEvent';
  }
  else {
    $module = 'CiviContribute';
  }
  if (!empty($item['target_id'])) {
    if (!empty($item['uf_group_id'])) {
      $uf_join = entity_load_single('civicrm_uf_join', $item['target_id']);
      $uf_join->uf_group_id = $item['uf_group_id'];
      $uf_join->weight = $delta + 1;
      $uf_join->is_active = 1;
      $uf_join_wrapper = entity_metadata_wrapper('civicrm_uf_join', $uf_join);
      $uf_join_wrapper
        ->save();
    }
    else {
      entity_delete('civicrm_uf_join', $item['target_id']);
    }
  }
  else {
    if (!empty($item['uf_group_id'])) {
      $uf_join = new CivicrmEntity(array(
        'is_active' => 1,
        'module' => $module,
        'entity_table' => $entity_type,
        'entity_id' => $entity->id,
        'weight' => $delta + 1,
        'uf_group_id' => $item['uf_group_id'],
      ), 'civicrm_uf_join');
      $uf_join_wrapper = entity_metadata_wrapper('civicrm_uf_join', $uf_join);
      $uf_join_wrapper
        ->save();
    }
  }
}

/**
 * Implements hook_field_widget_info().
 */
function civicrm_entity_profile_field_widget_info() {
  return array(
    'civicrm_entity_profile_field_default_widget' => array(
      'label' => t('Default'),
      'field types' => array(
        'civicrm_entity_profile_field',
      ),
      'settings' => array(),
      'behaviors' => array(
        'multiple values' => FIELD_BEHAVIOR_DEFAULT,
        'default value' => FIELD_BEHAVIOR_DEFAULT,
      ),
    ),
  );
}

/**
 * Implements hook_field_widget_info_alter().
 *
 * @param $info
 */
function civicrm_entity_profile_field_widget_info_alter(&$info) {
  $info['inline_entity_form']['field types'][] = 'civicrm_entity_profile_field';
  $info['inline_entity_form_single']['field types'][] = 'civicrm_entity_profile_field';
}

/**
 * Implements hook_inline_entity_form_settings_alter().
 *
 * @param $settings
 * @param $field
 * @param $instance
 */
function civicrm_entity_profile_inline_entity_form_settings_alter(&$settings, $field, $instance) {
  if ($field['type'] == 'civicrm_entity_profile_field') {
    $settings['entity_type'] = 'civicrm_uf_join';
    $settings['column'] = 'target_id';
    $settings['bundles'] = array(
      'civicrm_uf_join',
    );
  }
}

/**
 * Implements hook_field_widget_form().
 */
function civicrm_entity_profile_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
  $orig_element = $element;
  $options = _civicrm_entity_profile_get_profiles_for_options_list();
  switch ($instance['widget']['type']) {
    case 'civicrm_entity_profile_field_default_widget':
      $uf_group_id = NULL;
      $target_id = NULL;
      if (!empty($items[$delta]['target_id'])) {
        $target_id = $items[$delta]['target_id'];
        $uf_join = entity_load_single('civicrm_uf_join', $target_id);
        if (!empty($uf_join->uf_group_id)) {
          $uf_group_id = $uf_join->uf_group_id;
        }
      }
      $widget = array();
      $widget = $orig_element + array(
        '#type' => 'hidden',
        '#value' => $target_id,
      );

      //just have field label?
      $widget['#weight'] = 0;
      $element['target_id'] = $widget;
      $widget = array();
      $widget = $orig_element + array(
        '#type' => 'select',
        '#default_value' => $uf_group_id,
        '#options' => $options,
      );

      //just have field label?
      $widget['#weight'] = 0;
      $element['uf_group_id'] = $widget;
      break;
  }

  // add remove button for fields with unlimited field values
  // code example taken from https://www.drupal.org/project/multiple_fields_remove_button module
  $field_parents = isset($element['#field_parents']) ? $element['#field_parents'] : array();
  $field_name = isset($element['#field_name']) ? $element['#field_name'] : NULL;
  $parents = array_merge($field_parents, array(
    $field_name,
    $langcode,
    $delta,
  ));
  if ($field['cardinality'] == FIELD_CARDINALITY_UNLIMITED) {
    $element['remove_button'] = array(
      '#delta' => $delta,
      '#name' => implode('_', $parents) . '_remove_button',
      '#type' => 'submit',
      '#value' => t('Remove'),
      '#validate' => array(),
      '#attributes' => array(
        'class' => array(
          'multiple-fields-remove-button',
        ),
      ),
      '#submit' => array(
        '_civicrm_entity_profile_remove_button_submit_handler',
      ),
      '#limit_validation_errors' => array(),
      '#ajax' => array(
        'path' => 'civicrm_entity_profile_multiple_fields_remove_button/ajax',
        'effect' => 'fade',
      ),
      '#weight' => 1000,
    );
  }
  return $element;
}

/**
 * Implements hook_field_formatter_info().
 */
function civicrm_entity_profile_field_formatter_info() {
  return array(
    'civicrm_entity_profile_field_default_formatter' => array(
      // Machine name of the formatter
      'label' => t('List Profiles'),
      'field types' => array(
        'civicrm_entity_profile_field',
      ),
      'settings' => array(
        // Array of the settings we'll create
        'link_to_profile' => 0,
      ),
    ),
  );
}

/**
 * Implements hook_field_formatter_settings_form().
 *
 * @param $field
 * @param $instance
 * @param $view_mode
 * @param $form
 * @param $form_state
 * @return array
 */
function civicrm_entity_profile_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
  if ($field['type'] == 'civicrm_entity_profile_field') {
    $display = $instance['display'][$view_mode];
    $settings = $display['settings'];
    $element = array();
    $element['link_to_profile'] = array(
      '#type' => 'checkbox',
      '#title' => t('Output as links to civicrm_uf_group entities'),
      '#default_value' => isset($settings['link_to_profile']) ? $settings['link_to_profile'] : 0,
      '#return_value' => 1,
    );
    return $element;
  }
}

/**
 * Implements hook_field_formatter_settings_summary().
 *
 * @param $field
 * @param $instance
 * @param $view_mode
 * @return string
 */
function civicrm_entity_profile_field_formatter_settings_summary($field, $instance, $view_mode) {
  if ($field['type'] == 'civicrm_entity_profile_field') {
    $display = $instance['display'][$view_mode];
    $settings = $display['settings'];
    $summary = '';
    if ($display['type'] == 'civicrm_entity_profile_field_default_formatter') {
      $summary = t('Link to profile: @data', array(
        '@data' => !empty($settings['link_to_profile']) ? 'Yes' : 'No',
      ));
    }
    return $summary;
  }
}

/**
 * Implements hook_field_formatter_view().
 */
function civicrm_entity_profile_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $element = array();
  $settings = $display['settings'];
  switch ($display['type']) {
    case 'civicrm_entity_profile_field_default_formatter':
      $output_as_link = !empty($settings['link_to_profile']) ? 1 : 0;
      foreach ($items as $delta => $item) {
        if (!empty($item['target_id'])) {
          $uf_join = entity_load_single('civicrm_uf_join', $item['target_id']);
          $uf_group = entity_load_single('civicrm_uf_group', $uf_join->uf_group_id);
          if ($output_as_link) {
            $value = l($uf_group->title, 'civicrm-uf-group/' . $uf_group->id);
          }
          else {
            $value = $uf_group->title;
          }
          $element[$delta] = array(
            '#markup' => $value,
          );
        }
      }
      break;
  }
  return $element;
}

/**
 * Implements hook_civicrm_post().
 *
 * Here we need to probably clear some field caches when contacts are added / removed from group
 *
 * @param $op
 * @param $objectName
 * @param $objectId
 * @param $objectRef
 */
function civicrm_entity_profile_civicrm_post($op, $objectName, $objectId, &$objectRef) {

  // only gets called if something that updates the contribution page sql table directly
  // updating only profiles on a contribution page via CiviCRM Admin side, doesn't trigger this
  if (($objectName == 'Event' || $objectName == 'ContributionPage') && ($op == 'create' || $op == 'delete' || $op == 'edit')) {
    if ($objectName == 'Event') {
      $entity_type = 'civicrm_event';
    }
    elseif ($objectName == 'ContributionPage') {
      $entity_type = 'civicrm_contribution_page';
    }
    $query = db_select('field_config', 'fc');
    $query
      ->join('field_config_instance', 'fci');
    $civicrm_entity_profile_fields = $query
      ->fields('fc', array(
      'id',
    ))
      ->condition('fc.type', 'civicrm_entity_profile_field')
      ->condition('fci.entity_type', $entity_type)
      ->execute();
    if ($civicrm_entity_profile_fields
      ->rowCount()) {
      cache_clear_all('field:' . $entity_type . ':' . $objectRef->id, 'cache_field');
    }
  }
}

/**
 * Submit callback to remove an item from the field UI multiple wrapper.
 *
 * code example taken from https://www.drupal.org/project/multiple_fields_remove_button module
 *
 * When a remove button is submitted, we need to find the item that it
 * referenced and delete it. Since field UI has the deltas as a straight
 * unbroken array key, we have to renumber everything down. Since we do this
 * we *also* need to move all the deltas around in the $form_state['values']
 * and $form_state['input'] so that user changed values follow. This is a bit
 * of a complicated process.
 */
function _civicrm_entity_profile_remove_button_submit_handler($form, &$form_state) {
  $button = $form_state['triggering_element'];
  $delta = $button['#delta'];
  $inpt = 'input';

  // Where in the form we'll find the parent element.
  $address = array_slice($button['#array_parents'], 0, -2);

  // Go one level up in the form, to the widgets container.
  $parent_element = drupal_array_get_nested_value($form, $address);
  $field_name = $parent_element['#field_name'];
  $langcode = $parent_element['#language'];
  $parents = $parent_element['#field_parents'];
  $field_state = field_form_get_state($parents, $field_name, $langcode, $form_state);

  // Go ahead and renumber everything from our delta to the last
  // item down one. This will overwrite the item being removed.
  for ($i = $delta; $i <= $field_state['items_count']; $i++) {
    $old_element_address = array_merge($address, array(
      $i + 1,
    ));
    $new_element_address = array_merge($address, array(
      $i,
    ));
    $moving_element = drupal_array_get_nested_value($form, $old_element_address);
    $moving_element_value = drupal_array_get_nested_value($form_state['values'], $old_element_address);
    $moving_element_input = drupal_array_get_nested_value($form_state[$inpt], $old_element_address);

    // Tell the element where it's being moved to.
    $moving_element['#parents'] = $new_element_address;

    // Move the element around.
    form_set_value($moving_element, $moving_element_value, $form_state);
    drupal_array_set_nested_value($form_state[$inpt], $moving_element['#parents'], $moving_element_input);

    // Move the entity in our saved state.
    if (isset($field_state['entity'][$i + 1])) {
      $field_state['entity'][$i] = $field_state['entity'][$i + 1];
    }
    else {
      unset($field_state['entity'][$i]);
    }
  }

  // Replace the deleted entity with an empty one. This helps to ensure that
  // trying to add a new entity won't ressurect a deleted entity
  // from thev trash bin.
  // $count = count($field_state['entity']);
  // Then remove the last item. But we must not go negative.
  if ($field_state['items_count'] > 0) {
    $field_state['items_count']--;
  }

  // Fix the weights. Field UI lets the weights be in a range of
  // (-1 * item_count) to (item_count). This means that when we remove one,
  // the range shrinks; weights outside of that range then get set to
  // the first item in the select by the browser, floating them to the top.
  // We use a brute force method because we lost weights on both ends
  // and if the user has moved things around, we have to cascade because
  // if I have items weight weights 3 and 4, and I change 4 to 3 but leave
  // the 3, the order of the two 3s now is undefined and may not match what
  // the user had selected.
  $input = drupal_array_get_nested_value($form_state[$inpt], $address);

  // Sort by weight.
  uasort($input, '_field_sort_items_helper');

  // Reweight everything in the correct order.
  $weight = -1 * $field_state['items_count'];
  foreach ($input as $key => $item) {
    if ($item) {
      $input[$key]['_weight'] = $weight++;
    }
  }
  drupal_array_set_nested_value($form_state[$inpt], $address, $input);
  field_form_set_state($parents, $field_name, $langcode, $form_state, $field_state);
  $form_state['rebuild'] = TRUE;
}

/**
 * Implements hook_form_FORM_ID_alter().
 *
 * Alter the CiviCRM Entity enabled entities settings form
 *
 * Insure necessary entity types for this module remain enabled
 *
 * @param $form
 * @param $form_state
 */
function civicrm_entity_profile_form_civicrm_entity_admin_settings_form_alter(&$form, &$form_state) {
  $required_entities = array(
    'civicrm_event' => 'Event',
    'civicrm_uf_field' => 'UF Field',
    'civicrm_uf_group' => 'UF Group',
    'civicrm_uf_join' => 'UF Join',
  );
  foreach ($required_entities as $drupal_entity_type => $entity_type_label) {
    if (empty($selected_entities[$drupal_entity_type])) {
      $form['civicrm_entity_admin_enabled_entities'][$drupal_entity_type]['#disabled'] = TRUE;
      $form['civicrm_entity_admin_enabled_entities'][$drupal_entity_type]['#default_value'] = 1;
    }
  }
  $form['#validate'][] = 'civicrm_entity_profile_admin_settings_form_validate';
}

/**
 * Validation callback for the CiviCRM Entity Enabled Entities form at 'admin/structure/civicrm-entity/settings'
 *
 * @param $form
 * @param $form_state
 */
function civicrm_entity_profile_admin_settings_form_validate($form, &$form_state) {
  $selected_entities = $form_state['values']['civicrm_entity_admin_enabled_entities'];
  $required_entities = array(
    'civicrm_event' => 'Event',
    'civicrm_uf_field' => 'UF Field',
    'civicrm_uf_group' => 'UF Group',
    'civicrm_uf_join' => 'UF Join',
  );
  foreach ($required_entities as $drupal_entity_type => $entity_type_label) {
    if (empty($selected_entities[$drupal_entity_type])) {
      form_set_error('civicrm_entity_admin_enabled_entities][' . $drupal_entity_type, $entity_type_label . ' required by CiviCRM Entity Profile Field module');
    }
  }
}

Functions

Namesort descending Description
civicrm_entity_profile_admin_settings_form_validate Validation callback for the CiviCRM Entity Enabled Entities form at 'admin/structure/civicrm-entity/settings'
civicrm_entity_profile_civicrm_entity_supported_info
civicrm_entity_profile_civicrm_post Implements hook_civicrm_post().
civicrm_entity_profile_field_formatter_info Implements hook_field_formatter_info().
civicrm_entity_profile_field_formatter_settings_form Implements hook_field_formatter_settings_form().
civicrm_entity_profile_field_formatter_settings_summary Implements hook_field_formatter_settings_summary().
civicrm_entity_profile_field_formatter_view Implements hook_field_formatter_view().
civicrm_entity_profile_field_info Implements hook_field_info().
civicrm_entity_profile_field_insert Implements hook_field_insert().
civicrm_entity_profile_field_instance_settings_form Implements hook_field_settings_form().
civicrm_entity_profile_field_is_empty Implements hook_field_is_empty().
civicrm_entity_profile_field_load Implements hook_field_load().
civicrm_entity_profile_field_update Implements hook_field_update().
civicrm_entity_profile_field_widget_form Implements hook_field_widget_form().
civicrm_entity_profile_field_widget_info Implements hook_field_widget_info().
civicrm_entity_profile_field_widget_info_alter Implements hook_field_widget_info_alter().
civicrm_entity_profile_form_civicrm_entity_admin_settings_form_alter Implements hook_form_FORM_ID_alter().
civicrm_entity_profile_form_field_ui_field_overview_form_alter Implements hook_form_FORMID_alter().
civicrm_entity_profile_inline_entity_form_settings_alter Implements hook_inline_entity_form_settings_alter().
civicrm_entity_profile_menu Implements hook_menu(). code example taken from https://www.drupal.org/project/multiple_fields_remove_button module
civicrm_entity_profile_multiple_fields_remove_button_js Page callback for civicrm_entity_profile_multiple_fields_remove_button/ajax path. code example taken from https://www.drupal.org/project/multiple_fields_remove_button module
_civicrm_entity_profile_process_field_item Helper function to process field item on entity insert or update
_civicrm_entity_profile_remove_button_submit_handler Submit callback to remove an item from the field UI multiple wrapper.