From b56a9b86c8a3f311eb2f203f2825f21e633f7fc1 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sun, 20 Jun 2004 09:18:59 +0000 Subject: [PATCH] fix to use fn (=fullname) in the addr_id function --- infolog/csv_import.php | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/infolog/csv_import.php b/infolog/csv_import.php index b792574794..aa4a02339b 100644 --- a/infolog/csv_import.php +++ b/infolog/csv_import.php @@ -66,19 +66,30 @@ $CPre = '|['; $CPreReg = '\|\['; // |{csv-fieldname} is expanded to the value of the csv-field $CPos = ']'; $CPosReg = '\]'; // if used together with @ (replacement is eval-ed) value gets autom. quoted -function addr_id( $n_family,$n_given,$org_name ) +function addr_id( $n_family,$n_given=False,$org_name=False ) { // find in Addressbook, at least n_family AND (n_given OR org_name) have to match $contacts = createobject('phpgwapi.contacts'); - $addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,n_given=$n_given,org_name=$org_name" ); - if (!count($addrs)) + if ($org_name !== False) // org_name given? + { + $addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,n_given=$n_given,org_name=$org_name" ); + if (!count($addrs)) + { + $addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,org_name=$org_name" ); + } + } + if ($n_given !== False && ($org_name === False || !count($addrs))) // first name given and no result so far + { $addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,n_given=$n_given" ); - if (!count($addrs)) - $addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,org_name=$org_name" ); - + } + if ($n_given === False && $org_name === False) // just one name given, check against fn (= full name) + { + $addrs = $contacts->read( 0,0,array('id'),'',"fn=$n_family" ); + } if (count($addrs)) + { return $addrs[0]['id']; - + } return False; }