Code

Added description to workstation startup, fai assigment
[gosa.git] / plugins / admin / systems / class_workstationStartup.inc
index 1b5e032afec695573a632023e210f4c311099a06..4b55ee073be156e1a7531b5ef5187f8f08a2b09e 100644 (file)
@@ -51,6 +51,7 @@ class workstartup extends plugin
   var $FAIServRepConfig   = array();
 
   var $fai_activated      = FALSE;
+  var $member_of_ogroup   = FALSE;
 
   function workstartup ($config, $dn= NULL, $parent= NULL)
   {
@@ -65,6 +66,13 @@ class workstartup extends plugin
 
     plugin::plugin ($config, $dn, $parent);
 
+    if(!isset($this->parent->by_object['ogroup'])){
+      $ldap = $this->config->get_ldap_link();
+      $ldap->cd ($this->config->current['BASE']);
+      $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".$this->dn."))",array("cn"));
+      $this->member_of_ogroup = $ldap->count() >= 1;
+    }
+
     /* Creating a list of valid Mirrors 
      * none will not be saved to ldap.
      */
@@ -91,7 +99,7 @@ class workstartup extends plugin
           "(objectClass=FAIprofile)".
           "(objectClass=FAIpartitionTable))",
           $ui->subtreeACL,$this->config->current['BASE'],
-          array("cn","objectClass","FAIdebianSection"));
+          array("cn","objectClass","FAIdebianSection","description"));
 
       foreach($res as $attr){
         $cn = $attr['cn'][0];
@@ -102,36 +110,43 @@ class workstartup extends plugin
           $tmp2[$cn]['FAIpackageList']['obj']   = 'FAIpackageList'; 
           $tmp2[$cn]['FAIpackageList']['kzl']   = 'Pl';
           $tmp2[$cn]['FAIpackageList']['sec']   = $attr['FAIdebianSection'];
+          $tmp2[$cn]['FAIpackageList']['desc']  = $attr['description'];
           $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0];
         }
         if(in_array('FAItemplate',$attr['objectClass'])){
           $tmp2[$cn]['FAItemplate']['obj']      = 'FAItemplate'; 
           $tmp2[$cn]['FAItemplate']['kzl']      = 'T'; 
+          $tmp2[$cn]['FAItemplate']['desc']  = $attr['description'];
           $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0];
         }
         if(in_array('FAIvariable',$attr['objectClass'])){
           $tmp2[$cn]['FAIvariable']['obj']      = 'FAIvariable'; 
           $tmp2[$cn]['FAIvariable']['kzl']      = 'V'; 
+          $tmp2[$cn]['FAIvariable']['desc']  = $attr['description'];
           $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0];
         }
         if(in_array('FAIscript',$attr['objectClass'])){
           $tmp2[$cn]['FAIscript']['obj']        = 'FAIscript'; 
           $tmp2[$cn]['FAIscript']['kzl']        = 'S'; 
+          $tmp2[$cn]['FAIscript']['desc']  = $attr['description'];
           $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0];
         }
         if(in_array('FAIhook',$attr['objectClass'])){
           $tmp2[$cn]['FAIhook']['obj']          = 'FAIhook'; 
           $tmp2[$cn]['FAIhook']['kzl']          = 'H'; 
+          $tmp2[$cn]['FAIhook']['desc']  = $attr['description'];
           $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0];
         }
         if(in_array('FAIpartitionTable',$attr['objectClass'])){
           $tmp2[$cn]['FAIpartitionTable']['obj']= 'FAIpartitionTable'; 
           $tmp2[$cn]['FAIpartitionTable']['kzl']= 'Pt'; 
+          $tmp2[$cn]['FAIpartitionTable']['desc']  = $attr['description'];
           $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0];
         }
         if(in_array('FAIprofile',$attr['objectClass'])){
           $tmp2[$cn]['FAIprofile']['obj']= 'FAIprofile'; 
           $tmp2[$cn]['FAIprofile']['kzl']= 'P'; 
+          $tmp2[$cn]['FAIprofile']['desc']  = $attr['description'];
           $this->FAIclasses[$attr['cn'][0]]=$attr['cn'][0];
         }
       }
@@ -154,8 +169,10 @@ class workstartup extends plugin
          ['PACKAGES'][0] "pkg1";
          ['PACKAGES'][1] "postfix";
        */
-
-      $ldap->search("(&(FAIrepository=*)(objectClass=FAIrepositoryServer))",array("FAIrepository"));
+      $filter= "";
+      $ui= get_userinfo();
+      if (isset($config->current['STRICT_UNITS']) && preg_match('/TRUE/i', $config->current['STRICT_UNITS']) && $ui->gosaUnitTag != ""){                                                                                                                                  $filter= "(gosaUnitTag=".$ui->gosaUnitTag.")";
+      }                                                                                                                                $ldap->search("(&(FAIrepository=*)(objectClass=FAIrepositoryServer)$filter)",array("FAIrepository"));
       $test = array();
       while($attr = $ldap->fetch()){
         if(isset($attr['FAIrepository'])){
@@ -294,11 +311,11 @@ class workstartup extends plugin
 
 
     /* Load hardware list */
-    $ldap= $this->config->get_ldap_link();
-    $ldap->cd($this->config->current['BASE']);
-    $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".$this->dn."))");
-    if ($ldap->count() == 1){
+    if ($this->member_of_ogroup){
 
+      if(count($this->FAIclass)==0 && $this->FAIrelease == ""){
+        $this->FAIdebianMirror = "inherited";
+      }
 
       if($this->fai_activated){
         $map= array("gotoLdapServer","FAIclass","FAIdebianMirror","gotoBootKernel");
@@ -374,9 +391,6 @@ class workstartup extends plugin
       $this->gotoBootKernel= "default";
     }
 
-    if(count($this->FAIclass)==0 && $this->FAIrelease == ""){
-      $this->FAIdebianMirror = "inherited";
-    }
   }
 
   
@@ -758,13 +772,22 @@ class workstartup extends plugin
           }
         }
         $i ++ ; 
+  
+        $desc = ""; 
+        foreach($this->FAIclassInfo[$class] as $types ){
+          if(isset($types['desc'][0])){
+            $desc.= $types['desc'][0]." ";
+          }
+        }
+        if(!empty($desc)){
+          $desc = " [".trim($desc)."]";
+        }        
 
         $div->AddEntry(array(
-              array("string"=>$class.$marker),
+              array("string"=>$class.$desc.$marker),
               array("string"=>preg_replace("/\%s/",base64_encode($class),$str),"attach"=>"style='width:50px;border-right:none;'")
               ));
       }  
-
       $smarty->assign("FAIScriptlist",$div->DrawList()); 
     }
 
@@ -823,7 +846,13 @@ class workstartup extends plugin
   function getFAIdebianMirrors()
   {
     $ret = array();
-    $ret['inherited']="["._("inherited")."]";
+
+    /* Only add inherit option, if we are part in an object group 
+     */
+    if($this->member_of_ogroup)    {
+      $ret['inherited']="["._("inherited")."]";
+    }
+
     $ret['auto']=_("automatic");
     $secs  = array();