if you export a date then you get something like this:

a:3:{s:3:"day";s:2:"24";s:5:"month";s:1:"9";s:4:"year";s:4:"1995";}

we need a way that this gets to something like: 1995-09-24

Comments

Tobias Maier’s picture

here is a patch for this
I know it is no patch-file, but this is because it is inside the same file as the forms api conversion patch

so replace _get_profile() with this

function _get_profile($uid = 0) {
  $profile_flds = _get_profile_fields();

  $profile_result = array();
  foreach($profile_flds as $profile_field => $profile_field_type) {
    $value = db_result(db_query("SELECT pv.value FROM {profile_fields} pf, {profile_values} pv
      WHERE pv.fid = pf.fid
      AND pf.name = '%s'
      AND pv.uid = %d", $profile_field, $uid));
    if ($profile_field_type == 'date') {
      $value = unserialize($value);
      $value = $value['year'] .'-'. $value['month'] .'-'. $value['day'];
    }
    $profile_result[] = $value;
  }
  return $profile_result;
}

and _get_profile_fields() with this one

function _get_profile_fields() {
  static $fields;
  
  if (!isset($fields)) {
    $fields = array();
    $result = db_query('SELECT fid, name, type FROM {profile_fields}');
    while ($row = db_fetch_object($result)) {
      if (variable_get(CSV_PARAM . 'profile_' . $row->fid, 0)) {
        $fields[$row->name] = $row->type;
      }
    }
  }
  return $fields;
}

there is a second change in this function: it caches the result of this function, because it will never change during one session and it gets called with every user...

one suggestion:
it would be nice if all functions starting with "_" could get a better name.
like _profile_csv_get_profile() instead of _get_profile()
because then it would never come to a name clash...

Tobias Maier’s picture

Status: Active » Needs review
wafaa’s picture

Status: Needs review » Fixed

fixed in 4.7 , thanks for Tobias Maier.

Anonymous’s picture

Status: Fixed » Closed (fixed)