You are here

function gdpr_get_user_data in General Data Protection Regulation 7

Gets all collected data for the given user.

Parameters

\stdClass $user: The user entity.

Return value

array Keys are data machine names, and values the collected data itself.

1 call to gdpr_get_user_data()
gdpr_collected_user_data in ./gdpr.module
Implements a page callback to render a user's GDPR data collection page.

File

./gdpr.module, line 304
Contains hook implementations and shared functions.

Code

function gdpr_get_user_data(\stdClass $user) {
  $user_data = [];
  foreach ($user as $key => $value) {
    if (empty($value)) {
      continue;
    }
    if (is_scalar($value)) {
      $user_data[$key] = $value;
    }
    elseif (is_array($value)) {
      $scalar_list = TRUE;
      foreach ($value as $item) {
        if (!is_scalar($item)) {
          $scalar_list = FALSE;
          break;
        }
      }
      if ($scalar_list) {
        $user_data[$key] = implode(', ', $value);
      }
    }
  }
  $user_data['pass'] = gdpr_star_value($user_data['pass']);
  ksort($user_data);
  return $user_data;
}