* fixed birthday of contacts/accounts in LDAP could not be modified in addressbook

This commit is contained in:
Ralf Becker 2010-12-06 18:25:35 +00:00
parent 23c02699a8
commit 0e4217f37f
2 changed files with 8 additions and 18 deletions

View File

@ -159,7 +159,6 @@ class addressbook_ldap
# categories(deprecated) # categories(deprecated)
'evolutionperson' => array( 'evolutionperson' => array(
'bday' => 'birthdate', 'bday' => 'birthdate',
'contact_bday' => 'birthdate', // birthday may be requested as either bday or contact_bday
'note' => 'note', 'note' => 'note',
'tel_car' => 'carphone', 'tel_car' => 'carphone',
'tel_prefer' => 'primaryphone', 'tel_prefer' => 'primaryphone',

View File

@ -1654,33 +1654,24 @@ class calendar_bo
// search for birthdays // search for birthdays
if ($GLOBALS['egw_info']['server']['hide_birthdays'] != 'yes') if ($GLOBALS['egw_info']['server']['hide_birthdays'] != 'yes')
{ {
$contacts = CreateObject('phpgwapi.contacts'); $contacts = new addressbook_bo();
// note: contact read/old_read transforms contact_bday to bday only $filter = array(
$bdays =& $contacts->read(0,0,array('id','n_family','n_given','n_prefix','n_middle','contact_bday'),'',"contact_bday=!'',n_family=!''",'ASC','contact_bday'); 'n_family' => "!''",
'bday' => "!''",
);
$bdays =& $contacts->search('',array('id','n_family','n_given','n_prefix','n_middle','bday'),'contact_bday ASC',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter);
if ($bdays) if ($bdays)
{ {
// sort by month and day only // sort by month and day only
usort($bdays,create_function('$a,$b','return (int) $a[\'bday\'] == (int) $b[\'bday\'] ? strcmp($a[\'bday\'],$b[\'bday\']) : (int) $a[\'bday\'] - (int) $b[\'bday\'];')); 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) foreach($bdays as $pers)
{ {
if (isset($pers['bday']) && ($pers['bday']=='0000-00-00 0' || $pers['bday']=='0000-00-00' || $pers['bday']=='0.0.00')) if (empty($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)); //error_log(__METHOD__.__LINE__.' Skipping entry for invalid birthday:'.array2string($pers));
continue; continue;
} }
$pers['bday'] = egw_time::to($pers['bday'],"m/d/Y"); list($y,$m,$d) = explode('-',$pers['bday']);
list($m,$d,$y) = explode('/',$pers['bday']);
if ($y > $year) continue; // not yet born if ($y > $year) continue; // not yet born
$this->cached_holidays[$year][sprintf('%04d%02d%02d',$year,$m,$d)][] = array( $this->cached_holidays[$year][sprintf('%04d%02d%02d',$year,$m,$d)][] = array(
'day' => $d, 'day' => $d,