/** * Sends all pending changes to the LDAP server * * @param Zend_Ldap $ldap * @return Zend_Ldap_Node Provides a fluent interface * @throws Zend_Ldap_Exception */ public function update(Zend_Ldap $ldap = null) { if ($ldap !== null) { $this->attachLdap($ldap); } $ldap = $this->getLdap(); if (!$ldap instanceof Zend_Ldap) { /** * @see Zend_Ldap_Exception */ // require_once 'Zend/Ldap/Exception.php'; throw new Zend_Ldap_Exception(null, 'No LDAP connection available'); } 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) { if (array_key_exists($key, $changedData)) { unset($changedData[$key]); } } $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; }