From e7ce1030c00c63800fe77226d7707e08158289c3 Mon Sep 17 00:00:00 2001 From: Deon George Date: Tue, 7 Jul 2009 19:35:37 +1000 Subject: [PATCH] Enchanced getLDAPmodify() to allow multiple update calls --- lib/Template.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/Template.php b/lib/Template.php index d232d76..4da50db 100644 --- a/lib/Template.php +++ b/lib/Template.php @@ -1256,12 +1256,15 @@ class Template extends xmlTemplate { * * @param boolean Return the attribute objects (useful for a confirmation process), or the modification array for ldap_modify() */ - public function getLDAPmodify($attrsOnly=false) { + public function getLDAPmodify($attrsOnly=false,$index=0) { static $return = array(); static $returnattrs = array(); - if ($attrsOnly && count($returnattrs)) - return $returnattrs; + if ($attrsOnly && isset($returnattrs[$index]) && count($returnattrs[$index])) + return $returnattrs[$index]; + + $returnattrs[$index] = array(); + $return[$index] = array(); # If an objectclass is being modified, we need to remove all the orphan attributes that would result. if ($this->getAttribute('objectclass')->hasBeenModified()) { @@ -1316,15 +1319,15 @@ class Template extends xmlTemplate { if ($attribute->hasBeenModified() && (count(array_diff($attribute->getValues(),$attribute->getOldValues())) || ! count($attribute->getValues()) || $attribute->isForceDelete() || (count($attribute->getValues()) != count($attribute->getOldValues())))) - $returnattrs[$attribute->getName()] = $attribute; + $returnattrs[$index][$attribute->getName()] = $attribute; if ($attrsOnly) - return $returnattrs; + return $returnattrs[$index]; - foreach ($returnattrs as $attribute) - $return[$attribute->getName()] = $attribute->getValues(); + foreach ($returnattrs[$index] as $attribute) + $return[$index][$attribute->getName()] = $attribute->getValues(); - return $return; + return $return[$index]; } /**