From 0e4217f37f9f7a4343ff1558f3a0bf596a41e282 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 6 Dec 2010 18:25:35 +0000 Subject: [PATCH] * fixed birthday of contacts/accounts in LDAP could not be modified in addressbook --- .../inc/class.addressbook_ldap.inc.php | 1 - calendar/inc/class.calendar_bo.inc.php | 25 ++++++------------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/addressbook/inc/class.addressbook_ldap.inc.php b/addressbook/inc/class.addressbook_ldap.inc.php index d0e7915ef4..2641ba9ec0 100644 --- a/addressbook/inc/class.addressbook_ldap.inc.php +++ b/addressbook/inc/class.addressbook_ldap.inc.php @@ -159,7 +159,6 @@ class addressbook_ldap # categories(deprecated) 'evolutionperson' => array( 'bday' => 'birthdate', - 'contact_bday' => 'birthdate', // birthday may be requested as either bday or contact_bday 'note' => 'note', 'tel_car' => 'carphone', 'tel_prefer' => 'primaryphone', diff --git a/calendar/inc/class.calendar_bo.inc.php b/calendar/inc/class.calendar_bo.inc.php index a4733685fe..8214a83def 100644 --- a/calendar/inc/class.calendar_bo.inc.php +++ b/calendar/inc/class.calendar_bo.inc.php @@ -1654,33 +1654,24 @@ class calendar_bo // search for birthdays if ($GLOBALS['egw_info']['server']['hide_birthdays'] != 'yes') { - $contacts = CreateObject('phpgwapi.contacts'); - // note: contact read/old_read transforms contact_bday to bday only - $bdays =& $contacts->read(0,0,array('id','n_family','n_given','n_prefix','n_middle','contact_bday'),'',"contact_bday=!'',n_family=!''",'ASC','contact_bday'); + $contacts = new addressbook_bo(); + $filter = array( + '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) { // 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\'];')); 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'])) + if (empty($pers['bday']) || $pers['bday']=='0000-00-00 0' || $pers['bday']=='0000-00-00' || $pers['bday']=='0.0.00') { //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']); + list($y,$m,$d) = explode('-',$pers['bday']); if ($y > $year) continue; // not yet born $this->cached_holidays[$year][sprintf('%04d%02d%02d',$year,$m,$d)][] = array( 'day' => $d,