Code

* Saved missing value for goImapSieveServer
[gosa.git] / plugins / admin / systems / class_workstationStartup.inc
index 90afd398c0c7e2b463d4b2c2dc4af46e0557f529..c5ca3cced69af4ac1b745a1d9c8278a580342e18 100644 (file)
@@ -42,13 +42,13 @@ class workstartup extends plugin
   function workstartup ($config, $dn= NULL)
   {
     plugin::plugin ($config, $dn);
-   
 
     /* Creating a list of valid Mirrors 
      * none will not be saved to ldap.
      */
     $this->FAIdebianMirrors   = array("none"=>_("none"));
     $ldap   = $this->config->get_ldap_link();
+    $ldap->cd($this->config->current['BASE']);
     $ldap->search("(objectClass=FAIrepository)",array("FAIdebianMirror"));
     
     /* attach all attributes with "index => cn" to avoid multiple entries */
@@ -109,7 +109,7 @@ class workstartup extends plugin
 
     /* Search all FAI objects */
     $ldap->search("(| (objectClass=FAIpackageList)(objectClass=FAItemplate)
-                      (objectClass=FAIvariable)(objectClass=FAIscript')(objectClass=FAIhook)
+                      (objectClass=FAIvariable)(objectClass=FAIscript)(objectClass=FAIhook)(objectClass=FAIprofile)
                       (objectClass=FAIpartitionTable))",array("objectClass","cn"),true);
     /* Sort all entries, and attach elementtype.
      * To be able to show the types in the listbox.
@@ -118,7 +118,7 @@ class workstartup extends plugin
       $cn = $attr['cn'][0];
       if(in_array('FAIpackageList',$attr['objectClass'])){
         $tmp2[$cn]['FAIpackageList']['obj']   = 'FAIpackageList'; 
-        $tmp2[$cn]['FAIpackageList']['kzl']   = 'P';
+        $tmp2[$cn]['FAIpackageList']['kzl']   = 'Pl';
         $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0];
       }
       if(in_array('FAItemplate',$attr['objectClass'])){
@@ -146,25 +146,30 @@ class workstartup extends plugin
         $tmp2[$cn]['FAIpartitionTable']['kzl']= 'Pt'; 
         $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0];
       }
+      if(in_array('FAIprofile',$attr['objectClass'])){
+        $tmp2[$cn]['FAIprofile']['obj']= 'FAIprofile'; 
+        $tmp2[$cn]['FAIprofile']['kzl']= 'P'; 
+        $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0];
+      }
     }
 
     $this->FAIclassInfo = $tmp2;
 
-    if(isset($this->attrs['FAIclass'])){
+    if((isset($this->FAIclass))&&(!is_array($this->FAIclass))){
       $tmp = array();
-      $tmp2 = $this->attrs['FAIclass'];
-      unset($tmp2['count']);
-      foreach($tmp2 as $class){
-        $tmp[$class] = $class;
+      $tmp = split(" ",$this->FAIclass);
+      $tmp2 =array();  
+    
+      foreach($tmp as $class){
+        $tmp2[$class] = $class;
       }
-      $this->FAIclass = $tmp;
+      $this->FAIclass = $tmp2;
     }
 
     if(!is_array($this->FAIclass)){
-      $this->FAIclass = array();
+      $this->FAIclass =array();
     }
 
-
     $this->orig_dn= $this->dn;
   }
 
@@ -184,11 +189,9 @@ class workstartup extends plugin
     return($tmp);
   }
 
-
   function check()
   {
     $messages = array();
-
     /* If there are packages selected, but no mirror show error */   
     if(($this->FAIdebianMirror == "none")&&(count($this->FAIclass)>0)){
       $messages[]=_("Please select a 'FAI server' or remove the 'FAI classes'.");
@@ -198,6 +201,9 @@ class workstartup extends plugin
 
   function execute()
   {
+       /* Call parent execute */
+       plugin::execute();
+
     /* Do we need to flip is_account state? */
     if (isset($_POST['modify_state'])){
       $this->is_account= !$this->is_account;
@@ -241,8 +247,8 @@ class workstartup extends plugin
         }
       }
 
-      if((isset($this->FAIclassInfo[$_POST['FAIclassesSel']]['FAIpackageList']))&&($found>0)){
-        print_red(_("There is already a profile in your selection that contain partition table configuratons."));
+      if((isset($this->FAIclassInfo[$_POST['FAIclassesSel']]['FAIpartitionTable']))&&($found>0)){
+        print_red(_("There is already a profile in your selection that contain partition table configurations."));
       }else{
         $this->FAIclass[$_POST['FAIclassesSel']]=$_POST['FAIclassesSel'];
       }
@@ -276,8 +282,8 @@ class workstartup extends plugin
         $a_share = $this->gotoAvailableShares[$_POST['gotoShareSelection']];
         $s_mount = $_POST['gotoShareMountPoint'];
         /* Preparing the new assignment */
-        $this->gotoShares[$a_share['name']]=$a_share;
-        $this->gotoShares[$a_share['name']]['mountPoint']=$s_mount;
+        $this->gotoShares[$a_share['name']."|".$a_share['server']]=$a_share;
+        $this->gotoShares[$a_share['name']."|".$a_share['server']]['mountPoint']=$s_mount;
       }
     }
 
@@ -333,15 +339,45 @@ class workstartup extends plugin
     }
 
     /* Show main page */
-    return($smarty->fetch (get_template_path('workstationStartup.tpl', TRUE)));
+    return($smarty->fetch (get_template_path('workstationStartup.tpl', TRUE,dirname(__FILE__))));
   }
 
   function remove_from_parent()
   {
+    /*
     $ldap= $this->config->get_ldap_link();
     $ldap->rmdir($this->dn);
     show_ldap_error($ldap->get_error());
     $this->handle_post_events("remove");
+    */
+
+
+    /* Depending on the baseobject (Ogroup / WS) we
+     *  use another set of objectClasses
+     * In case of WS itself, we use  "array("GOhard", "FAIobject");"
+     * if we are currently editing from ogroup menu we use (array("gotWorkstationTemplate","GOhard", "FAIobject"))
+     */
+    if(isset($this->parent->by_object['ogroup'])){
+      $this->objectclasses = array("gotoWorkstationTemplate","GOhard", "FAIobject");
+    }elseif(isset($this->parent->by_object['workgeneric'])){
+      $this->objectclasses = array("GOhard", "FAIobject");
+    }else{
+      print "unknown";
+      exit();
+    }
+
+    $ldap= $this->config->get_ldap_link();
+    plugin::remove_from_parent();
+   
+    /* Remove additional attributes.*/ 
+    foreach(array("gotoModules", "gotoAutoFs", "gotoFilesystem") as $attr){
+      $this->attrs [$attr] = array();
+    }
+
+    $ldap->cd($this->dn);
+    $ldap->modify($this->attrs);
+    show_ldap_error($ldap->get_error());
+
   }
 
 
@@ -365,6 +401,21 @@ class workstartup extends plugin
   /* Save to LDAP */
   function save()
   {
+
+    /* Depending on the baseobject (Ogroup / WS) we
+     *  use another set of objectClasses
+     * In case of WS itself, we use  "array("GOhard", "FAIobject");"
+     * if we are currently editing from ogroup menu we use (array("gotWorkstationTemplate","GOhard", "FAIobject"))
+     */
+    if(isset($this->parent->by_object['ogroup'])){
+      $this->objectclasses = array("gotoWorkstationTemplate","GOhard", "FAIobject");
+    }elseif(isset($this->parent->by_object['workgeneric'])){
+      $this->objectclasses = array("GOhard", "FAIobject");
+    }else{
+      print "unknown";
+      exit();
+    }
+
     /* Find proper terminal path for tftp configuration
        FIXME: This is suboptimal when the default has changed to
        another location! */
@@ -414,14 +465,18 @@ class workstartup extends plugin
       $this->gotoKernelParameters.= " o ".$this->customParameters;
     }
 
-    /* Create numeric index for our classes */
-    $tmp = array();
+    plugin::save();
+    
+    $str = "";
     foreach($this->FAIclass as $class){
-      $tmp[] = $class;
+      $str .= $class." ";
     }
-    $this->FAIclass = $tmp;
+    $this->attrs['FAIclass']= "";
+    $this->attrs['FAIclass']= trim($str);
 
-    plugin::save();
+    if(empty($this->attrs['FAIclass'])){
+      $this->attrs['FAIclass'] = array();
+    }
 
     /* Add missing arrays */
     foreach (array("gotoFilesystem", "gotoAutoFs", "gotoModules") as $val){
@@ -436,13 +491,6 @@ class workstartup extends plugin
       unset ($this->attrs['gotoLdapServer']);
     }
 
-    $tmp = array();
-    foreach($this->FAIclass as $class){
-      $tmp[] = $class;
-    }
-    $this->attrs['FAIclass'] = $tmp;
-    /* Write back to ldap */
-
     /* if mirror == none stop saving this attribute */
     if($this->FAIdebianMirror == "none"){
       $this->FAIdebianMirror = "";
@@ -460,6 +508,15 @@ class workstartup extends plugin
       $this->attrs['FAIdebianMirror'] = array();
     }
 
+    /* prepare share settings */
+    $tmp = array();
+    foreach($this->gotoShares as $name => $settings){
+      $tmp2= split("\|",$name);
+      $name = $tmp2[0];
+      $tmp[] = $settings['server']."|".$name."|".$settings['mountPoint'];
+    }
+    $this->attrs['gotoShare']=$tmp;
+
     $ldap= $this->config->get_ldap_link();
     $ldap->cd($this->dn);
     $ldap->modify($this->attrs);