mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-25 16:19:00 +01:00
preventing invalid birthdays stored with the datastore such as 0000-00-00 or 0.0.00 to transform to a birthday
This commit is contained in:
parent
cb7fb29b2e
commit
b976930423
@ -1632,6 +1632,22 @@ class calendar_bo
|
||||
usort($bdays,create_function('$a,$b','return (int) $a[\'bday\'] == (int) $b[\'bday\'] ? strcmp($a[\'bday\'],$b[\'bday\']) : (int) $a[\'bday\'] - (int) $b[\'bday\'];'));
|
||||
foreach($bdays as $pers)
|
||||
{
|
||||
if (isset($pers['bday']) && ($pers['bday']=='0000-00-00 0' || $pers['bday']=='0000-00-00' || $pers['bday']=='0.0.00'))
|
||||
{
|
||||
//error_log(__METHOD__.__LINE__.' Entry with invalid birthday:'.array2string($pers));
|
||||
$pers['bday']=null;
|
||||
}
|
||||
if (isset($pers['contact_bday']) && ($pers['contact_bday']=='0000-00-00 0' || $pers['contact_bday']=='0000-00-00' || $pers['contact_bday']=='0.0.00'))
|
||||
{
|
||||
//error_log(__METHOD__.__LINE__.' Entry with invalid birthday:'.array2string($pers));
|
||||
$pers['contact_bday']=null;
|
||||
}
|
||||
if (empty($pers['bday']) && !empty($pers['contact_bday'])) $pers['bday'] = $pers['contact_bday'];
|
||||
if (empty($pers['bday']))
|
||||
{
|
||||
//error_log(__METHOD__.__LINE__.' Skipping entry for invalid birthday:'.array2string($pers));
|
||||
continue;
|
||||
}
|
||||
$pers['bday'] = egw_time::to($pers['bday'],"m/d/Y");
|
||||
list($m,$d,$y) = explode('/',$pers['bday']);
|
||||
if ($y > $year) continue; // not yet born
|
||||
|
@ -140,9 +140,22 @@ class contacts extends addressbook_bo
|
||||
|
||||
if (isset($row['bday']) || isset($row['contact_bday']))
|
||||
{
|
||||
$bdayset=true;
|
||||
if (isset($row['bday']) && ($row['bday']=='0000-00-00 0' || $row['bday']=='0000-00-00' || $row['bday']=='0.0.00'))
|
||||
{
|
||||
$rows[$n]['bday'] = $row['bday']=null;
|
||||
$bdayset=false;
|
||||
}
|
||||
if (isset($row['contact_bday']) && ($row['contact_bday']=='0000-00-00 0' || $row['contact_bday']=='0000-00-00' || $row['contact_bday']=='0.0.00'))
|
||||
{
|
||||
$rows[$n]['contact_bday'] = $row['contact_bday']=null;
|
||||
$bdayset=false;
|
||||
}
|
||||
if ($bdayset==false) continue; // dont try to make a date out of that
|
||||
$row['bday'] = egw_time::to((isset($row['bday'])?$row['bday']:$row['contact_bday']),"Y-m-d");
|
||||
list($y,$m,$d) = explode('-',$row['bday']);
|
||||
$rows[$n]['bday'] = sprintf('%d/%d/%04d',$m,$d,$y);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user