Code

summary added
[gosa.git] / plugins / admin / systems / class_servService.inc
index 5343f155d0561b3d8c1fb2a89f2b55fdf63ce366..9189fad0d9706526080d866a05c94018d00b9af4 100644 (file)
@@ -21,6 +21,8 @@ class servservice extends plugin
   /* attribute list for save action */
   var $ignore_account= TRUE;
   var $attributes       = array("goLdapBase","goXdmcpIsEnabled","goFontPath");
+  var $possible_objectclasses= array( "goNfsServer", "goNtpServer", "goServer", "goLdapServer",
+                                      "goTerminalServer", "goSyslogServer", "goCupsServer");
   var $objectclasses    = array("top","goServer"); 
   var $additionaloc     = array( "goNfsServer"     => array("goExportEntry"),
                                  "goNtpServer"     => array("goTimeSource"),
@@ -42,12 +44,13 @@ class servservice extends plugin
 
     /* Load arrays */
     foreach (array("goTimeSource", "goExportEntry") as $name){
-      $this->$name= array();
+      $tmp= array();
       if (isset($this->attrs[$name])){
         for ($i= 0; $i<$this->attrs[$name]['count']; $i++){
-          $this->$name[$this->attrs[$name][$i]]= $this->attrs[$name][$i];
+          $tmp[$this->attrs[$name][$i]]= $this->attrs[$name][$i];
         }
       }
+      $this->$name= $tmp;
     }
 
     /* Always is account... */
@@ -177,7 +180,6 @@ class servservice extends plugin
   /* Save to LDAP */
   function save()
   {
-
     /* Normalize lazy objectclass arrays */
     $objectclasses= array();
     foreach($this->objectclasses as $oc){
@@ -187,8 +189,24 @@ class servservice extends plugin
 
     plugin::save();
 
-    /* Normalize objectclasses */
-    $this->attrs['objectClass']= $this->objectclasses;
+    $tmp= array();
+
+    /* Remove all from this plugin */
+    foreach($this->attrs['objectClass'] as $oc){
+      if (!in_array_ics($oc, $this->possible_objectclasses)){
+        $tmp[]= $oc;
+      }
+    }
+
+    /* Merge our current objectclasses */
+    foreach($this->objectclasses as $oc){
+      if (!in_array_ics($oc, $tmp)){
+        $tmp[]= $oc;
+      }
+    }
+
+    /* Reassign cleaned value */
+    $this->attrs['objectClass']= $tmp;
 
     /* Remove illegal attributes */
     foreach ($this->additionaloc as $oc => $attrs){
@@ -199,6 +217,14 @@ class servservice extends plugin
       }
     }
 
+    /* Arrays */
+    foreach (array("goTimeSource", "goExportEntry") as $name){
+      $this->attrs[$name]= array();
+      foreach ($this->$name as $element){
+        $this->attrs[$name][]= $element;
+      }
+    }
+
     /* Write to LDAP */
     $ldap= $this->config->get_ldap_link();
     $ldap->cd($this->dn);