diff -r 5e7a0fedabdf -r 877f952ae2bd web/lib/Zend/Ldap/Node.php --- a/web/lib/Zend/Ldap/Node.php Thu Mar 21 17:31:31 2013 +0100 +++ b/web/lib/Zend/Ldap/Node.php Thu Mar 21 19:50:53 2013 +0100 @@ -15,9 +15,9 @@ * @category Zend * @package Zend_Ldap * @subpackage Node - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Node.php 22662 2010-07-24 17:37:36Z mabe $ + * @version $Id: Node.php 24610 2012-01-21 13:54:27Z sgehrig $ */ /** @@ -35,7 +35,7 @@ * @category Zend * @package Zend_Ldap * @subpackage Node - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Ldap_Node extends Zend_Ldap_Node_Abstract implements Iterator, RecursiveIterator @@ -171,6 +171,7 @@ $this->_ldap = $ldap; if (is_array($this->_children)) { foreach ($this->_children as $child) { + /* @var Zend_Ldap_Node $child */ $child->attachLdap($ldap); } } @@ -190,6 +191,7 @@ $this->_ldap = null; if (is_array($this->_children)) { foreach ($this->_children as $child) { + /* @var Zend_Ldap_Node $child */ $child->detachLdap(); } } @@ -319,12 +321,17 @@ /** * Ensures that teh RDN attributes are correctly set. * + * @param boolean $overwrite True to overwrite the RDN attributes * @return void */ - protected function _ensureRdnAttributeValues() + protected function _ensureRdnAttributeValues($overwrite = false) { foreach ($this->getRdnArray() as $key => $value) { - Zend_Ldap_Attribute::setAttribute($this->_currentData, $key, $value, false); + if (!array_key_exists($key, $this->_currentData) || $overwrite) { + Zend_Ldap_Attribute::setAttribute($this->_currentData, $key, $value, false); + } else if (!in_array($value, $this->_currentData[$key])) { + Zend_Ldap_Attribute::setAttribute($this->_currentData, $key, $value, true); + } } } @@ -428,20 +435,25 @@ if ($this->willBeDeleted()) { if ($ldap->exists($this->_dn)) { + $this->_preDelete(); $ldap->delete($this->_dn); + $this->_postDelete(); } return $this; } if ($this->isNew()) { + $this->_preAdd(); $data = $this->getData(); $ldap->add($this->_getDn(), $data); $this->_loadData($data, true); + $this->_postAdd(); return $this; } $changedData = $this->getChangedData(); if ($this->willBeMoved()) { + $this->_preRename(); $recursive = $this->hasChildren(); $ldap->rename($this->_dn, $this->_newDn, $recursive, false); foreach ($this->_newDn->getRdn() as $key => $value) { @@ -451,9 +463,12 @@ } $this->_dn = $this->_newDn; $this->_newDn = null; + $this->_postRename(); } if (count($changedData) > 0) { + $this->_preUpdate(); $ldap->update($this->_getDn(), $changedData); + $this->_postUpdate(); } $this->_originalData = $this->_currentData; return $this; @@ -501,7 +516,7 @@ } else { $this->_newDn = Zend_Ldap_Dn::factory($newDn); } - $this->_ensureRdnAttributeValues(); + $this->_ensureRdnAttributeValues(true); return $this; } @@ -1019,6 +1034,7 @@ if ($this->isAttached()) { $children = $this->searchChildren('(objectClass=*)', null); foreach ($children as $child) { + /* @var Zend_Ldap_Node $child */ $this->_children[$child->getRdnString(Zend_Ldap_Dn::ATTR_CASEFOLD_LOWER)] = $child; } } @@ -1098,4 +1114,72 @@ { return $this->_iteratorRewind; } + + #################################################### + # Empty method bodies for overriding in subclasses # + #################################################### + + /** + * Allows pre-delete logic to be applied to node. + * Subclasses may override this method. + * + * @return void + */ + protected function _preDelete() { } + + /** + * Allows post-delete logic to be applied to node. + * Subclasses may override this method. + * + * @return void + */ + protected function _postDelete() { } + + /** + * Allows pre-add logic to be applied to node. + * Subclasses may override this method. + * + * @return void + */ + protected function _preAdd() { } + + /** + * Allows post-add logic to be applied to node. + * Subclasses may override this method. + * + * @return void + */ + protected function _postAdd() { } + + /** + * Allows pre-rename logic to be applied to node. + * Subclasses may override this method. + * + * @return void + */ + protected function _preRename() { } + + /** + * Allows post-rename logic to be applied to node. + * Subclasses may override this method. + * + * @return void + */ + protected function _postRename() { } + + /** + * Allows pre-update logic to be applied to node. + * Subclasses may override this method. + * + * @return void + */ + protected function _preUpdate() { } + + /** + * Allows post-update logic to be applied to node. + * Subclasses may override this method. + * + * @return void + */ + protected function _postUpdate() { } } \ No newline at end of file