Code

Fixed printer object tagging
[gosa.git] / plugins / admin / systems / class_workstationStartup.inc
index ae317e9af894d59d0a81c774099793b1def4c914..ef0244274ed5e61fb09bec445d83698d12d15889 100644 (file)
@@ -67,12 +67,18 @@ class workstartup extends plugin
     $_SESSION['getAvailableClassesForThisRelease_CACHE'] = array();
     $_SESSION['getAvailableClassesForThisRelease_CACHED_CLASSES'] = array();
 
-    /* Search all FAI objects */
-    $ldap->search("(|(objectClass=FAIpackageList)(objectClass=FAItemplate)(objectClass=FAIvariable)(objectClass=FAIscript)(objectClass=FAIhook)(objectClass=FAIprofile)(objectClass=FAIpartitionTable))",array("cn","objectClass","FAIdebianSection"));
-    /* Sort all entries, and attach elementtype.
-     * To be able to show the types in the listbox.
-     */
-    while($attr = $ldap->fetch()){
+    $ui = get_userinfo();
+    $res = get_list(          "(|(objectClass=FAIpackageList)".
+        "(objectClass=FAItemplate)".
+        "(objectClass=FAIvariable)".
+        "(objectClass=FAIscript)".
+        "(objectClass=FAIhook)".
+        "(objectClass=FAIprofile)".
+        "(objectClass=FAIpartitionTable))",
+        $ui->subtreeACL,$this->config->current['BASE'],
+        array("cn","objectClass","FAIdebianSection"));
+    
+    foreach($res as $attr){
       $cn = $attr['cn'][0];
     
       $_SESSION['getAvailableClassesForThisRelease_CACHED_CLASSES'][] = $attr;
@@ -118,8 +124,11 @@ class workstartup extends plugin
       natcasesort($this->FAIclasses);
     }
 
-    $this->FAIclassInfo = $tmp2;
-
+    if(isset($tmp2)){
+      $this->FAIclassInfo = $tmp2;
+    } else {
+      $this->FAIclassInfo = array();
+    }
 
     /* Build up an array like this one :
         [$url]['SERVER'] = 'srv1-002';
@@ -338,28 +347,6 @@ class workstartup extends plugin
       return($_SESSION['getAvailableClassesForThisRelease_CACHE'][$release]);
     }
 
-    /* Create cache with all classes 
-     */
-    if((!isset($_SESSION['getAvailableClassesForThisRelease_CACHED_CLASSES'])) ||
-       (!is_array($_SESSION['getAvailableClassesForThisRelease_CACHED_CLASSES'])) ||
-       (count($_SESSION['getAvailableClassesForThisRelease_CACHED_CLASSES']) ==0 )){
-
-      /* Get ldap connection */
-      $ldap   = $this->config->get_ldap_link();
-      $ldap->cd($this->config->current['BASE']);
-
-      /* Get possible classes ... 
-         This would be faste with some kind of caching ... 
-       */
-      $ldap->search("(|(objectClass=FAIpackageList)(objectClass=FAItemplate)(objectClass=FAIvariable)(objectClass=FAIscript)(objectClass=FAIhook)(objectClass=FAIprofile)(objectClass=FAIpartitionTable))",array("cn"),true);
-      /* Sort all entries, and attach elementtype.
-       * To be able to show the types in the listbox.
-       */
-      while($attr = $ldap->fetch()){
-        $_SESSION['getAvailableClassesForThisRelease_CACHED_CLASSES'][] = $attr;
-      }  
-    }
-
     /* Walk through cache and get out what we need.
      *   
      *   Function od : "$this->generateDNSyn($release)"
@@ -583,13 +570,6 @@ class workstartup extends plugin
       }
     }
 
-    /* Delete selected class from our list */
-    if((isset($_POST['DelClass']))&&(isset($_POST['FAIclassSel']))){
-      if(isset($this->FAIclass[$_POST['FAIclassSel']])){
-        unset($this->FAIclass[$_POST['FAIclassSel']]);
-      }
-    }
-
     /* Show main page */
     $smarty= get_smarty();
     $smarty->assign("SelectBoxLdapServer","");
@@ -662,9 +642,9 @@ class workstartup extends plugin
 
       $SelectBoxLdapServer->AddEntry(
           array(
-            array("string"=>$display),
             array("string"=>"<input type='radio' name='gotoLdapServer' value='".$key."' ".$use.">",
-                  "attach"=>"style='border-right:0px;'")
+                  "attach"=>"style='border-left:0px;'"),
+            array("string"=>$display)
             ));
     }    
 
@@ -1000,8 +980,14 @@ class workstartup extends plugin
       $this->FAIdebianMirror = "";
     }
    
+    /* Get FAIstate from object, the generic tab could have changed it during execute */
+    $ldap= $this->config->get_ldap_link();
+    $ldap->cd($this->dn);
+    $ldap->cat($this->dn,array("FAIstate"));
+    $checkFAIstate = $ldap->fetch();
+
     /* Remove FAI objects if no FAI class is selected */ 
-    if(count($this->FAIclass)==0){
+    if((count($this->FAIclass)==0) && (!isset($checkFAIstate['FAIstate']))){
       $tmp = array();
       foreach($this->attrs['objectClass'] as $class){
         if($class != "FAIobject"){
@@ -1022,8 +1008,6 @@ class workstartup extends plugin
     }
     $this->attrs['gotoShare']=$tmp;
 
-    $ldap= $this->config->get_ldap_link();
-    $ldap->cd($this->dn);
     $this->cleanup();
     $ldap->modify ($this->attrs);