Code

Added description to workstation startup, fai assigment
[gosa.git] / plugins / admin / systems / class_workstationStartup.inc
index fd9bcf952b3fb8710347b89d5a4e24d0773daa0b..4b55ee073be156e1a7531b5ef5187f8f08a2b09e 100644 (file)
@@ -2,11 +2,6 @@
 
 class workstartup extends plugin
 {
-  /* CLI vars */
-  var $cli_summary= "Manage terminal startup options";
-  var $cli_description= "Some longer text\nfor help";
-  var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
   /* Generic terminal attributes */
   var $bootmode             = "G";
   var $goLdapServerList     = array();
@@ -56,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)
   {
@@ -70,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.
      */
@@ -96,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];
@@ -107,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];
         }
       }
@@ -159,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'])){
@@ -299,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");
@@ -379,9 +391,6 @@ class workstartup extends plugin
       $this->gotoBootKernel= "default";
     }
 
-    if(count($this->FAIclass)==0 && $this->FAIrelease == ""){
-      $this->FAIdebianMirror = "inherited";
-    }
   }
 
   
@@ -519,7 +528,7 @@ class workstartup extends plugin
     }
 
     /* Add module */
-    if (isset ($_POST['add_module'])){
+    if (isset ($_POST['add_module']) ){
       if ($_POST['module'] != "" && chkacl ($this->acl, "gotoModule") == ""){
         $this->add_list ($this->gotoModules, $_POST['module']);
       }
@@ -533,7 +542,7 @@ class workstartup extends plugin
     }
     
     /* FAI class management */
-    if($this->fai_activated){
+    if($this->fai_activated && chkacl($this->acl,"FAIclass") == ""){
 
       if((isset($_POST['AddClass']))&&(isset($_POST['FAIclassesSel']))){
         $found = 0 ; 
@@ -639,7 +648,7 @@ class workstartup extends plugin
     /* if $_POST['gotoShareAdd'] is set, we will try to add a new entry
      * This entry will be, a combination of mountPoint and sharedefinitions
      */
-    if(isset($_POST['gotoShareAdd'])){
+    if(isset($_POST['gotoShareAdd']) && chkacl($this->acl,"gotoShare") ==""){
       /* We assign a share to this user, if we don't know where to mount the share */
       if((!isset($_POST['gotoShareMountPoint']))||(empty($_POST['gotoShareMountPoint']))||(preg_match("/[\|]/i",$_POST['gotoShareMountPoint']))){
         print_red(_("You must specify a valid mount point."));
@@ -657,7 +666,7 @@ class workstartup extends plugin
     /* if the Post  gotoShareDel is set, someone asked GOsa to delete the selected entry (if there is one selected)
      * If there is no defined share selected, we will abort the deletion without any message
      */
-    if((isset($_POST['gotoShareDel']))&&(isset($_POST['gotoShare']))){
+    if((isset($_POST['gotoShareDel']))&&(isset($_POST['gotoShare'])) && chkacl($this->acl,"gotoShare") ==""){
       unset($this->gotoShares[$_POST['gotoShare']]);
     }
 
@@ -693,6 +702,8 @@ class workstartup extends plugin
         $use = " checked ";
       };
 
+      $use .= chkacl($this->acl,"gotoLdapServer");
+
       $display = $server;
 
       $SelectBoxLdapServer->AddEntry(
@@ -761,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()); 
     }
 
@@ -826,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();