From: hickert Date: Mon, 24 Sep 2007 07:47:12 +0000 (+0000) Subject: Update phoneAccounts->goFonHomeServer too, if server name has changed X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=5c31aab99d415bc782e94548b7269f3ea5e4bc47;p=gosa.git Update phoneAccounts->goFonHomeServer too, if server name has changed git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@7380 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/systems/class_servDB.inc b/plugins/admin/systems/class_servDB.inc index c6c6f83d3..eca4b3524 100644 --- a/plugins/admin/systems/class_servDB.inc +++ b/plugins/admin/systems/class_servDB.inc @@ -46,11 +46,15 @@ class servdb extends plugin "goGlpiServer" => array("goGlpiAdmin","goGlpiDatabase","goGlpiPassword"), "goFonServer" => array("goFonAdmin", "goFonPassword", "goFonAreaCode", "goFonCountryCode")); + var $orig_dn = ""; function servdb ($config, $dn= NULL, $parent= NULL) { plugin::plugin ($config, $dn, $parent); + /* Save original dn */ + $this->orig_dn = $dn; + /* Make dynamic list of objectClasses */ foreach ($this->additionaloc as $oc => $dummy){ if (isset($this->attrs['objectClass']) && in_array($oc, $this->attrs['objectClass'])){ @@ -273,6 +277,25 @@ class servdb extends plugin show_ldap_error($ldap->get_error(), _("Saving server db settings failed")); + /* Update goFonAccounts if server was is renamed. + Set attribute goFonHomeServer to current dn + */ + if(in_array("goFonServer",$this->objectclasses)){ + if($this->orig_dn != "new" && $this->orig_dn != $this->dn){ + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(goFonHomeServer=*)(|(objectClass=goFonAccount)(objectClass=goFonConference)))",array("goFonHomeServer")); + $dns = array(); + while($attrs = $ldap->fetch()){ + $dns[] = $attrs['dn']; + } + foreach($dns as $dn){ + $ldap->cd($dn); + $ldap->modify(array("goFonHomeServer" => $this->dn)); + show_ldap_error($ldap->get_error(),sprintf(_("Updating gofon home server failed for '%s'."),$dn)); + } + } + } + /* Optionally execute a command after we're done */ if ($this->initially_was_account == $this->is_account){ if ($this->is_modified){