From f3bb7b7c4e0dfacc0aa1e4985816775a3e712b8b Mon Sep 17 00:00:00 2001 From: Miles Lott Date: Thu, 17 May 2001 03:50:34 +0000 Subject: [PATCH] Add in code from Tombstone to use ldap_del in update --- addressbook/inc/class.contacts_ldap_wip.inc.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/addressbook/inc/class.contacts_ldap_wip.inc.php b/addressbook/inc/class.contacts_ldap_wip.inc.php index f51e9b099d..6e930f6259 100644 --- a/addressbook/inc/class.contacts_ldap_wip.inc.php +++ b/addressbook/inc/class.contacts_ldap_wip.inc.php @@ -734,7 +734,7 @@ while ( list($fname,$fvalue) = each($allfields) ) { //if ($ldap_fields[0][$fvalue]) - if ($ldap_fields[0][$fvalue] && $stock_fields[$fname] && $ldap_fields[0][$fvalue] != $stock_fields[$fname]) + if ($ldap_fields[0][$fvalue] && $stock_fields[$fname] && $ldap_fields[0][$fvalue][0] != $stock_fields[$fname] ) { //echo "
".$fname." => ".$fvalue." was there"; $err = ldap_modify($this->ldap,$dn,array($fvalue => $stock_fields[$fname])); @@ -745,6 +745,15 @@ //echo "
".$fname." not there - '".$fvalue."'"; $err = ldap_mod_add($this->ldap,$dn,array($fvalue => $stock_fields[$fname])); } + elseif ($ldap_fields[0][$fvalue] && !$stock_fields[$fname]) + { + //echo "
".$fname." gone... deleting - '".$fvalue."'"; + // NOTE: we use the ldap_fields because we need to send the + // _ORIGINAL_ contents as the value. see: + // http://www.php.net/manual/en/function.ldap-mod-del.php + $err = ldap_mod_del($this->ldap,$dn,array($fvalue => $ldap_fields[0][$fvalue][0])); + } + // Else we have nothing to do. } }