Code

Fixed regex for opsi hosts
[gosa.git] / gosa-plugins / systems / admin / systems / class_divListSystem.inc
index 1a87b5a9b76961cd9647cc6dccf2bc7d175e94b9..fa2466df448f29682468f5f8427020b7896290b3 100644 (file)
@@ -39,6 +39,7 @@ class divListSystem extends MultiSelectWindow
   var $ShowPrinters;
   var $ShowDevices;
   var $ShowPhones;
+  var $ShowOpsiHosts;
 
   /* Subsearch checkbox */
   var $SubSearch;
@@ -48,12 +49,12 @@ class divListSystem extends MultiSelectWindow
 
   function divListSystem (&$config,$parent)
   {
-    MultiSelectWindow::MultiSelectWindow($config, "System", array("server",
-                                                                  "workstation",
-                                                                  "terminal",
-                                                                  "phone",
-                                                                  "incoming",
-                                                                  "printer"));
+    $classes = array("server","workstation","terminal","phone","incoming","winworkstation","printer","component");
+    if(class_available("opsiGeneric")){
+      $classes[] = "opsi";
+    }
+
+    MultiSelectWindow::MultiSelectWindow($config, "System", $classes);
 
     $this->parent       = $parent;
     $this->ui           = get_userinfo();
@@ -115,6 +116,12 @@ class divListSystem extends MultiSelectWindow
           msgPool::selectToView(  _("MicroSoft Windows based workstations")), 
           sprintf(_("Show %s"),   _("windows based workstations")),true);
     }
+    /* Add opsi checkboxes if opsi is enabled */
+    if($this->parent->opsi instanceof opsi && $this->parent->opsi->enabled()){
+      $this->AddCheckBox("ShowOpsiHosts" , sprintf(_("Display objects of type '%s'."),
+            _("OPSI installed client")),_("Show OPSI based clients")   ,true);
+    }
+
     if(class_available("printtabs")){
       $this->AddCheckBox("ShowPrinters",
           msgPool::selectToView(  _("network printers")),   
@@ -176,23 +183,23 @@ class divListSystem extends MultiSelectWindow
       " "._("Create")."|\n";
 
     if(class_available("termtabs") && preg_match("/c/",$ui->get_permissions($this->selectedBase,"terminal/termgeneric"))){
-      $s.= "...|<img src='images/select_terminal.png' alt='' border='0' class='center'>".
+      $s.= "...|<img src='plugins/systems/images/select_terminal.png' alt='' border='0' class='center'>".
         "&nbsp;"._("Terminal")."|"."newsystem_terminal|\n";
     }
     if(class_available("worktabs") && preg_match("/c/",$ui->get_permissions($this->selectedBase,"workstation/workgeneric"))){
-      $s.= "...|<img src='images/select_workstation.png' alt='' border='0' class='center'>".
+      $s.= "...|<img src='plugins/systems/images/select_workstation.png' alt='' border='0' class='center'>".
         "&nbsp;"._("Workstation")."|"."newsystem_workstation|\n";
     }
-    if(class_available("servtabs") && preg_match("/c/",$ui->get_permissions($this->selectedBase,"workstation/servgeneric"))){
-      $s.= "...|<img src='images/select_server.png' alt='' border='0' class='center'>".
+    if(class_available("servtabs") && preg_match("/c/",$ui->get_permissions($this->selectedBase,"server/servgeneric"))){
+      $s.= "...|<img src='plugins/systems/images/select_server.png' alt='' border='0' class='center'>".
         "&nbsp;"._("Server")."|"."newsystem_server|\n";
     }
     if(class_available("phonetabs") && preg_match("/c/",$ui->get_permissions($this->selectedBase,"phone/phoneGeneric"))){
-      $s.= "...|<img src='images/select_phone.png' alt='' border='0' class='center'>".
+      $s.= "...|<img src='plugins/systems/images/select_phone.png' alt='' border='0' class='center'>".
         "&nbsp;"._("Phone")."|"."newsystem_phone|\n";
     }
     if(class_available("printtabs") && preg_match("/c/",$ui->get_permissions($this->selectedBase,"printer/printgeneric"))){
-      $s.= "...|<img src='images/select_printer.png' alt='' border='0' class='center'>".
+      $s.= "...|<img src='plugins/systems/images/select_printer.png' alt='' border='0' class='center'>".
         "&nbsp;"._("Printer")."|"."newsystem_printer|\n";
     }
     if(class_available("componenttabs") && preg_match("/c/",$ui->get_permissions($this->selectedBase,"component/componentGeneric"))){
@@ -200,6 +207,13 @@ class divListSystem extends MultiSelectWindow
         "&nbsp;"._("Component")."|"."newsystem_component|\n";
     }
 
+    if($this->parent->opsi instanceof opsi && 
+        $this->parent->opsi->enabled() &&  
+        preg_match("/c/",$ui->get_permissions($this->selectedBase,"opsi/opsiGeneric"))){
+      $s.= "...|<img src='plugins/systems/images/select_winstation.png' alt='' border='0' class='center'>".
+        "&nbsp;"._("Opsi client")."|"."newsystem_opsi_client|\n";
+    }
+
     if($this->parent->si_active){
       $events  = DaemonEvent::get_event_types(SYSTEM_EVENT);
 
@@ -253,28 +267,18 @@ class divListSystem extends MultiSelectWindow
 
     /* ACL mapping */
     $ui = get_userinfo();
-    $tabs = array(
-          "terminal"    => array("CLASS"=>"TERMTABS",     "TABCLASS" =>"termtabs",      "ACL"=> "terminal/termgeneric"),
-          "workstation" => array("CLASS"=>"WORKTABS",     "TABCLASS" =>"worktabs",      "ACL"=> "workstation/workgeneric"),
-          "server"      => array("CLASS"=>"SERVTABS",     "TABCLASS" =>"servtabs",      "ACL"=> "server/servgeneric"),
-          "printer"     => array("CLASS"=>"PRINTTABS",    "TABCLASS" =>"printtabs",     "ACL"=> "printer/printgeneric"),
-          "phone"       => array("CLASS"=>"PHONETABS",    "TABCLASS" =>"phonetabs",     "ACL"=> "phone/phoneGeneric"),
-          "winstation"  => array("CLASS"=>"WINTABS",      "TABCLASS" =>"wintabs",       "ACL"=> "winworkstation/wingeneric"),
-          "incoming"    => array("CLASS"=>"",             "TABCLASS" =>"",              "ACL"=> "incoming/systems"),
-          "component"   => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs", "ACL"=> "component/componentGeneric"));
-
+    $tabs = $this->parent->get_tab_defs();
 
     $cnts = array("component" => 0 , "terminal" => 0 , "workstation" => 0 , 
-                  "printer" => 0 , "phone" => 0 , "server" => 0,
+                  "printer" => 0 , "phone" => 0 , "server" => 0,"opsi_client" => 0,
                   "NewDevice" => 0, "winstation"=> 0);
 
-
     /* Get list of all objectGroups and their member and release configuration 
      */
     $ogroups = array();
     if($this->parent->fai_activated){
       $ogroups = get_sub_list("(&(objectClass=gosaGroupOfNames)(FAIclass=*)(member=*))",array("ogroups"),
-          get_ou("ogroupou"),$this->config->current['BASE'],array("FAIclass","member","cn"),GL_NO_ACL_CHECK | GL_SUBSEARCH);
+          get_ou("ogroupRDN"),$this->config->current['BASE'],array("FAIclass","member","cn"),GL_NO_ACL_CHECK | GL_SUBSEARCH);
       foreach($ogroups as $ogroup){
         for($i = 0 ; $i < $ogroup['member']['count'] ; $i++){
           if(preg_match("/:/",$ogroup['FAIclass'][0])) {
@@ -294,19 +298,13 @@ class divListSystem extends MultiSelectWindow
 
       /* Get system type, it is used to fetch the acls for the current object.
           "winstation" acls are stored as 2winworkstation", so we have to map this here */
-      $type     = $this->parent->get_system_type($val);
-      if($type == "winstation") {
-        $acl_type = "winworkstation";
-      }else{
-        $acl_type = $type;
-      }
 
       /* Map NewDevice acls to workstation acls */
+      $type     = $this->parent->get_system_type($val);
       if($type == "NewDevice" || $type == "ArpNewDevice"){
         $type     = "incoming";
-        $acl_type = "incoming";
       }
-
+      $acl_type = $tabs[$type]['ACLC'];
       $s_acl    = $tabs[$type]['ACL'];
       $category = preg_replace("/\/.*$/","",$s_acl);
       $class    = preg_replace("/^.*\//","",$s_acl);
@@ -345,7 +343,7 @@ class divListSystem extends MultiSelectWindow
         $display= $val["cn"][0].$dsc;
       }
 
-      /* Check if this is a terminal/workstation && if we are allowed to change the gotoRootPasswd */
+      /* Check if this is a terminal/workstation && if we are allowed to change the userPassword */
       $display_key_for = array("terminal","workstation","server","component");
       $pwd_acl = $ui->get_permissions($val['dn'],$tabs[$type]['ACL'],"userPassword");
       if(preg_match("/w/",$pwd_acl) && in_array($type,$display_key_for)){
@@ -354,7 +352,10 @@ class divListSystem extends MultiSelectWindow
         $action2 = $empty;
       }
 
-      if(in_array("gotoWorkstation",$val['objectClass'])){
+      /* Add create FAI CD icon 
+       */
+      $acl_cd = preg_match("/w/",$ui->get_permissions($val['dn'],"workstation/workgeneric","createFAICD"));
+      if(in_array("gotoWorkstation",$val['objectClass']) && $acl_cd){
         $action2= "<input class='center' type='image' src='plugins/systems/images/cdrom.png' alt='"._("Create CD")."'   
                       name='gen_cd_%KEY%' title='"._("Create FAI CD")."'>&nbsp;".$action2;
       }else{
@@ -389,24 +390,24 @@ class divListSystem extends MultiSelectWindow
       $field1 = array("string" => sprintf($img['img'],$val['dn']),
           "attach" => "style='text-align:center;width:20px;'");
       $field2 = array("string" => sprintf($editlink,$key,$display),
-          "attach" => "style='' title='".preg_replace('/ /', '&nbsp;', @LDAP::fix($val['dn']))."'");
+          "attach" => "style='' title='".preg_replace('/ /', '&nbsp;', LDAP::fix($val['dn']))."'");
       $field3 = array("string" => preg_replace("/%KEY%/", "$key", $action2.$action),
           "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'");
 
       if($this->parent->fai_activated){
 
-        $release ="&nbsp;";
+        $release ="";
         $release_attach = ""; 
         if(isset($val['FAIclass'][0]) && preg_match("/:/",$val['FAIclass'][0])){
           $release        = preg_replace("/^.*:/","",$val['FAIclass'][0]);
           $release_attach = ""; 
         }elseif(isset($ogs_release[$val['dn']])){
           $release = trim($ogs_release[$val['dn']]['STR'],", ").
-            "&nbsp;<img src='images/select_ogroup.png' class='center' alt='' 
+            "&nbsp;<img src='plugins/ogroups/images/select_ogroup.png' class='center' alt='' 
             title='".sprintf(_("Inherited from %s"),trim($ogs_release[$val['dn']]['CN'],", "))."'>";
           $release_attach = "title='".sprintf(_("Inherited from %s"),trim($ogs_release[$val['dn']]['CN'],", "))."'"; 
         }
-        $field2a = array("string" => $release,"attach"=>$release_attach." style='width:100px;'");
+        $field2a = array("string" => $release."&nbsp;","attach"=>$release_attach." style='width:100px;'");
         $this->AddElement( array($field0,$field1,$field2,$field2a,$field3));
       }else{
         $this->AddElement( array($field0,$field1,$field2,$field3));
@@ -429,22 +430,22 @@ class divListSystem extends MultiSelectWindow
     $num_wws_str = sprintf(_("Number of listed '%s'"),_("windows workstations"));
     $num_dep_str = sprintf(_("Number of listed '%s'"),_("departments"));
 
-    $str = "<img class='center' src='images/select_server.png'
+    $str = "<img class='center' src='plugins/systems/images/select_server.png'
       title='".$num_ser_str."' alt='".$num_ser_str."'>&nbsp;".$cnts['server']."&nbsp;&nbsp;&nbsp;&nbsp;";
-    $str.= "<img class='center' src='images/select_workstation.png'
+    $str.= "<img class='center' src='plugins/systems/images/select_workstation.png'
       title='".$num_ws_str."' alt='".$num_ws_str."'>&nbsp;".$cnts['workstation']."&nbsp;&nbsp;&nbsp;&nbsp;";
-    $str.= "<img class='center' src='images/select_terminal.png'
+    $str.= "<img class='center' src='plugins/systems/images/select_terminal.png'
       title='".$num_ter_str."' alt='".$num_ter_str."'>&nbsp;".$cnts['terminal']."&nbsp;&nbsp;&nbsp;&nbsp;";
-    $str.= "<img class='center' src='images/select_phone.png'
+    $str.= "<img class='center' src='plugins/systems/images/select_phone.png'
       title='".$num_pho_str."' alt='".$num_pho_str."'>&nbsp;".$cnts['phone']."&nbsp;&nbsp;&nbsp;&nbsp;";
-    $str.= "<img class='center' src='images/select_printer.png'
+    $str.= "<img class='center' src='plugins/systems/images/select_printer.png'
       title='".$num_prt_str."' alt='".$num_prt_str."'>&nbsp;".$cnts['printer']."&nbsp;&nbsp;&nbsp;&nbsp;";
     $str.= "<img class='center' src='plugins/systems/images/select_component.png'
       title='".$num_com_str."' alt='".$num_com_str."'>&nbsp;".$cnts['component']."&nbsp;&nbsp;&nbsp;&nbsp;";
     $str.= "<img class='center' src='plugins/systems/images/select_newsystem.png'
       title='".$num_new_str."' alt='".$num_new_str."'>&nbsp;".$cnts['NewDevice']."&nbsp;&nbsp;&nbsp;&nbsp;";
-    $str.= "<img class='center' src='images/select_winstation.png'
-      title='".$num_wws_str."' alt='".$num_wws_str."'>&nbsp;".$cnts['winstation']."&nbsp;&nbsp;&nbsp;&nbsp;";
+    $str.= "<img class='center' src='plugins/systems/images/select_winstation.png'
+      title='".$num_wws_str."' alt='".$num_wws_str."'>&nbsp;".($cnts['winstation'] + $cnts['opsi_client'])."&nbsp;&nbsp;&nbsp;&nbsp;";
     $str.= "<img class='center' src='images/lists/folder.png'
       title='".$num_dep_str."' alt='".$num_dep_str."'>&nbsp;".$num_deps."&nbsp;&nbsp;&nbsp;&nbsp;";