You are here

function ldap_user_update_check_user_fields in Lightweight Directory Access Protocol (LDAP) 7.2

Same name and namespace in other branches
  1. 8.2 ldap_user/ldap_user.install \ldap_user_update_check_user_fields()
3 calls to ldap_user_update_check_user_fields()
ldap_user_requirements in ldap_user/ldap_user.install
Implements hook_requirements().
ldap_user_update_7203 in ldap_user/ldap_user.install
Make sure all user entity fields are created.
ldap_user_update_7204 in ldap_user/ldap_user.install
Make sure all user entity field instances are created.

File

ldap_user/ldap_user.install, line 498
Install, update and uninstall functions for the LDAP User module.

Code

function ldap_user_update_check_user_fields($query = FALSE) {
  if (!$query) {
    module_enable([
      'number',
    ]);
  }
  $fields_added = [];
  foreach (ldap_user_user_entity_fields() as $field_id => $field_conf) {
    $field_info = field_info_field($field_id);
    if (!$field_info) {
      $fields_added[] = $field_id;
      if (!$query) {
        field_create_field($field_conf['field']);
      }
    }
    $field_instance_info = field_info_instance('user', $field_id, 'user');
    if (!$field_instance_info) {
      $fields_added[] = $field_id . " instance";
      if (!$query) {
        field_create_instance($field_conf['instance']);
      }
    }
  }
  return $fields_added;
}