You are here

function smart_ip_is_eu_gdpr_country in Smart IP 8.4

Same name and namespace in other branches
  1. 8.3 smart_ip.module \smart_ip_is_eu_gdpr_country()
  2. 6.2 smart_ip.module \smart_ip_is_eu_gdpr_country()
  3. 7.2 smart_ip.module \smart_ip_is_eu_gdpr_country()

Helper function for checking if EU member country and if country follows GDPR.

See also

https://gist.github.com/henrik/1688572

https://europa.eu/european-union/about-eu/countries/member-countries_en

1 call to smart_ip_is_eu_gdpr_country()
SmartIp::updateFields in src/SmartIp.php
Update the values of location fields.

File

./smart_ip.module, line 194
Determines country, geo location (longitude/latitude), region, city and postal code of the user, based on IP address

Code

function smart_ip_is_eu_gdpr_country($country_code, $eu_member_only = TRUE) {
  $eu_gdpr_country =& drupal_static(__FUNCTION__);
  if (!isset($eu_gdpr_country[$country_code][$eu_member_only])) {
    $eu_member_list = [
      'AT' => 'Austria',
      'BE' => 'Belgium',
      'BG' => 'Bulgaria',
      'HR' => 'Croatia',
      'CY' => 'Cyprus',
      'CZ' => 'Czech Republic',
      'DK' => 'Denmark',
      'EE' => 'Estonia',
      'FI' => 'Finland',
      'FR' => 'France',
      'DE' => 'Germany',
      'GR' => 'Greece',
      'HU' => 'Hungary',
      'IE' => 'Ireland, Republic of (EIRE)',
      'IT' => 'Italy',
      'LV' => 'Latvia',
      'LT' => 'Lithuania',
      'LU' => 'Luxembourg',
      'MT' => 'Malta',
      'NL' => 'Netherlands',
      'PL' => 'Poland',
      'PT' => 'Portugal',
      'RO' => 'Romania',
      'SK' => 'Slovakia',
      'SI' => 'Slovenia',
      'ES' => 'Spain',
      'SE' => 'Sweden',
    ];
    $additional_gdpr_list = [
      'GF' => 'French Guiana',
      'GP' => 'Guadeloupe',
      'MQ' => 'Martinique',
      'ME' => 'Montenegro',
      'YT' => 'Mayotte',
      'RE' => 'Réunion',
      'MF' => 'Saint Martin',
      'GI' => 'Gibraltar',
      'AX' => 'Åland Islands',
      'PM' => 'Saint Pierre and Miquelon',
      'GL' => 'Greenland',
      'BL' => 'Saint Bartelemey',
      'SX' => 'Sint Maarten',
      'AW' => 'Aruba',
      'CW' => 'Curacao',
      'WF' => 'Wallis and Futuna',
      'PF' => 'French Polynesia',
      'NC' => 'New Caledonia',
      'TF' => 'French Southern Territories',
      'AI' => 'Anguilla',
      'BM' => 'Bermuda',
      'IO' => 'British Indian Ocean Territory',
      'VG' => 'Virgin Islands, British',
      'KY' => 'Cayman Islands',
      'FK' => 'Falkland Islands (Malvinas)',
      'MS' => 'Montserrat',
      'PN' => 'Pitcairn',
      'SH' => 'Saint Helena',
      'GS' => 'South Georgia and the South Sandwich Islands',
      'TC' => 'Turks and Caicos Islands',
      'AD' => 'Andorra',
      'LI' => 'Liechtenstein',
      'MC' => 'Monaco',
      'SM' => 'San Marino',
      'VA' => 'Vatican City',
      'JE' => 'Jersey',
      'GG' => 'Guernsey',
      'GI' => 'Gibraltar',
    ];
    $eu_gdpr_country[$country_code][$eu_member_only] = isset($eu_member_list[$country_code]) ? $eu_member_list[$country_code] : NULL;
    if (!$eu_member_only && empty($eu_gdpr_country[$country_code][$eu_member_only])) {

      // The country is not EU member now check if the country follows GDPR.
      $eu_gdpr_country[$country_code][$eu_member_only] = isset($additional_gdpr_list[$country_code]) ? $additional_gdpr_list[$country_code] : NULL;
    }
  }
  return $eu_gdpr_country[$country_code][$eu_member_only];
}