Code

Update phoneAccounts->goFonHomeServer too, if server name has changed
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 24 Sep 2007 07:47:12 +0000 (07:47 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 24 Sep 2007 07:47:12 +0000 (07:47 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@7380 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_servDB.inc

index c6c6f83d35173b6296d64fd844ddabf57e0a6c1a..eca4b3524407edcb69b3ab6bfa02dae2362cf2df 100644 (file)
@@ -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){