AddCheckBox */ var $ShowServers; var $ShowTerminals; var $ShowWorkstations; var $ShowWinWorkstations; var $ShowPrinters; var $ShowDevices; var $ShowPhones; var $ShowOpsiHosts; /* Subsearch checkbox */ var $SubSearch; var $parent ; var $ui ; function divListSystem (&$config,$parent) { $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(); /* Set list strings */ $this->SetTitle(_("List of systems")); $this->SetSummary(_("List of systems")); /* Result page will look like a headpage */ $this->SetHeadpageMode(); $this->EnableAplhabet (true); /* Disable buttonsm */ $this->EnableCloseButton(false); $this->EnableSaveButton (false); /* Dynamic action col, depending on snapshot icons */ $action_col_size = 120; if($this->parent->snapshotEnabled()){ $action_col_size += 38; } /* Toggle all selected / deselected */ $chk = ""; /* set Page header */ $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); $this->AddHeader(array("string"=>" ","attach"=>"style='width:20px;'")); $this->AddHeader(array("string"=>_("Systems")." / "._("Department"))); /* Add header for selected FAI release, if fai is active */ if($this->parent->fai_activated){ $this->AddHeader(array("string"=>_("Release"),"attach"=>"style='width:100px;'")); } $this->AddHeader(array("string"=>_("Actions"),"attach"=>"style='width:".$action_col_size."px;border-right:0px;'")); /* Text ,Value ,Name ,Is selected */ if(class_available("servtabs")){ $this->AddCheckBox("ShowServers", msgPool::selectToView( _("servers")), sprintf(_("Show %s"), _("servers")),true); } if(class_available("termtabs")){ $this->AddCheckBox("ShowTerminals", msgPool::selectToView( _("Linux terminals")), sprintf(_("Show %s"), _("terminals")),true); } if(class_available("worktabs")){ $this->AddCheckBox("ShowWorkstations", msgPool::selectToView( _("Linux workstations")), sprintf(_("Show %s"), _("workstations")),true); } if(class_available("wintabs")){ $this->AddCheckBox("ShowWinWorkstations", 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")), sprintf(_("Show %s"), _("network printers")) ,true); } if(class_available("phonetabs")){ $this->AddCheckBox("ShowPhones", msgPool::selectToView( _("VoIP phones")), sprintf(_("Show %s"), _("phones")) ,true); } if(class_available("componenttabs")){ $this->AddCheckBox("ShowDevices", msgPool::selectToView( _("network devices")), sprintf(_("Show %s"), _("network devices")), true); } /* Add SubSearch checkbox */ $this->AddCheckBox(SEPERATOR); $this->AddCheckBox("SubSearch", msgPool::selectToView("","subsearch"), msgPool::selectToView("","subsearch_small"), false); /* Name ,Text ,Default , Connect with alphabet */ $this->AddRegex ("Regex", _("Display systems matching"),"*" , true); $this->AddRegex ("UserRegex", _("Display systems of user"), "*" , false, "images/lists/search-user.png"); } function GenHeader() { /* Prepare departments, which are shown in the listbox on top of the listbox */ $options= ""; /* Get all departments within this subtree */ $base = $this->config->current['BASE']; $options = $this->create_department_list($this->module); /* If there is at least one c (Create) and one w (Write) acl in this combination display the snapshot paste icon. BUT check the correct acls in the management plugin */ $all_module_acls = ""; $ui = get_userinfo(); foreach($this->module as $module){ $all_module_acls .= $ui->has_complete_category_acls($this->selectedBase,$module); } /* Must we add an additional seperator */ $add_sep = false; /* Add default header */ $listhead = MultiSelectWindow::get_default_header(); /* Add base selection */ $listhead .= _("Base")."  ". "  "; /* Handle create icons */ $s = ".|"._("Actions")."|\n"; $s.= "..|". " "._("Create")."|\n"; if(class_available("termtabs") && preg_match("/c/",$ui->get_permissions($this->selectedBase,"terminal/termgeneric"))){ $s.= "...|". " "._("Terminal")."|"."newsystem_terminal|\n"; } if(class_available("worktabs") && preg_match("/c/",$ui->get_permissions($this->selectedBase,"workstation/workgeneric"))){ $s.= "...|". " "._("Workstation")."|"."newsystem_workstation|\n"; } if(class_available("servtabs") && preg_match("/c/",$ui->get_permissions($this->selectedBase,"server/servgeneric"))){ $s.= "...|". " "._("Server")."|"."newsystem_server|\n"; } if(class_available("phonetabs") && preg_match("/c/",$ui->get_permissions($this->selectedBase,"phone/phoneGeneric"))){ $s.= "...|". " "._("Phone")."|"."newsystem_phone|\n"; } if(class_available("printtabs") && preg_match("/c/",$ui->get_permissions($this->selectedBase,"printer/printgeneric"))){ $s.= "...|". " "._("Printer")."|"."newsystem_printer|\n"; } if(class_available("componenttabs") && preg_match("/c/",$ui->get_permissions($this->selectedBase,"component/componentGeneric"))){ $s.= "...|". " "._("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.= "...|". " "._("Opsi client")."|"."newsystem_opsi_client|\n"; } if($this->parent->si_active){ $events = DaemonEvent::get_event_types(SYSTEM_EVENT); $s.= "..|". " "._("Trigger action")."|\n"; foreach($events['TRIGGERED'] as $name => $event){ $s.= "...|".$event['MenuImage']." ".$event['s_Menu_Name']."|trigger_event_".$name."\n"; } $s.= "..|". " "._("Schedule action")."|\n"; foreach($events['SCHEDULED'] as $name => $event){ $s.= "...|".$event['MenuImage']." ".$event['s_Menu_Name']."|schedule_event_".$name."\n"; } } $s.= "..|". " "._("Remove")."|"."remove_multiple|\n"; $s.= "..|". " "._("Activate systems")."|activate_multiple|\n"; /* Add Copy & Paste header */ $s .= $this->parent->get_copypaste_header($this->selectedBase,$this->module); /* Add snapshot icons */ $s .= $this->parent->get_snapshot_header($this->selectedBase,$this->module); $this->SetDropDownHeaderMenu($s); $this->SetListHeader($listhead); } function execute() { $this->ClearElementsList(); $this->GenHeader(); } function setEntries($terminals) { $empty =""; /* Dynamic action col, depending on snapshot icons */ $action_col_size = 120; if($this->parent->snapshotEnabled()){ $action_col_size += 38; } // User and Template Images $editlink = "%s"; /* ACL mapping */ $ui = get_userinfo(); $tabs = $this->parent->get_tab_defs(); $cnts = array("component" => 0 , "terminal" => 0 , "workstation" => 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("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])) { if(!isset($og_list[$ogroup['member'][$i]])){ $ogs_release[$ogroup['member'][$i]]['STR'] = ""; $ogs_release[$ogroup['member'][$i]]['CN'] = ""; } $ogs_release[$ogroup['member'][$i]]['STR'] .= preg_replace("/^.*:/","",$ogroup['FAIclass'][0]).", "; $ogs_release[$ogroup['member'][$i]]['CN'] .= $ogroup['cn'][0].", "; } } } } // Test Every Entry and generate divlist Array foreach($terminals as $key => $val){ /* 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 */ /* Map NewDevice acls to workstation acls */ $type = $this->parent->get_system_type($val); if($type == "NewDevice" || $type == "ArpNewDevice"){ $type = "incoming"; } $acl_type = $tabs[$type]['ACLC']; $s_acl = $tabs[$type]['ACL']; $category = preg_replace("/\/.*$/","",$s_acl); $class = preg_replace("/^.*\//","",$s_acl); /* Get complete category acls */ $acl_all = $ui->has_complete_category_acls($val['dn'],$acl_type) ; /* Get specific generic acls */ $acl = $ui->get_permissions($val['dn'],$tabs[$type]['ACL']); /* Add copy & cut functionality */ $action= $this->parent->get_copypaste_action($val['dn'],$category,$class); $action.= ""; $action.= $this->parent->get_snapshot_action($val['dn'],$acl_type); if(preg_match("/d/",$acl)){ $action.= ""; }else{ $action.= $empty; } $val['cn'][0]= preg_replace('/\$$/', '', $val['cn'][0]); // Generate Array to Add $dsc= ""; if (isset($val['description'][0])){ $dsc= " [".$val['description'][0]."]"; } if((isset($val['is_new']))&&(!empty($val['is_new']))){ $display= $val["cn"][0]." ".$val['is_new'].$dsc; }else{ $display= $val["cn"][0].$dsc; } /* 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)){ $action2 = ""; }else{ $action2 = $empty; } /* 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= " ".$action2; }else{ $action2= $empty.$action2; } if(isset($val['message'])){ $display.= " (".$val['message'].")"; } $img = $this->parent->convert_list($val); /* Cutted objects should be displayed in light grey */ if($this->parent->CopyPasteHandler){ foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){ if($queue_data['dn'] == $val['dn']) { $display = "".$display.""; break; } } } $type = $this->parent->get_system_type($val); if($type == "ArpNewDevice"){ $type = "NewDevice"; } $cnts[$type] ++; /* Create each field */ $filtered_dn = str_replace('\\,', '\\2C', LDAP::fix($val['dn'])); $field0 = array("string" => "" , "attach" => "style='width:20px;'"); $field1 = array("string" => sprintf($img['img'],$val['dn']), "attach" => "style='text-align:center;width:20px;'"); if(isset($ogs_release[$filtered_dn])){ $field2 = array("string" => sprintf($editlink,$key,$display)." ", "attach" => "style='' title='".preg_replace('/ /', ' ', LDAP::fix($filtered_dn))."'"); }else{ $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' title='".preg_replace('/ /', ' ', LDAP::fix($filtered_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 =""; $release_attach = ""; if(isset($val['FAIclass'][0]) && preg_match("/:/",$val['FAIclass'][0])){ $release = preg_replace("/^.*:/","",$val['FAIclass'][0]); $release_attach = ""; }elseif(isset($ogs_release[$filtered_dn])){ $release = trim($ogs_release[$filtered_dn]['STR'],", "). " "; $release_attach = "title='".sprintf(_("Inherited from %s"),trim($ogs_release[$filtered_dn]['CN'],", "))."'"; } $field2a = array("string" => $release." ","attach"=>$release_attach." style='width:100px;'"); $this->AddElement( array($field0,$field1,$field2,$field2a,$field3)); }else{ $this->AddElement( array($field0,$field1,$field2,$field3)); } } /* Create summary string for list footer */ $num_deps=0; if(!$this->SubSearch){ $num_deps = count($this->Added_Departments); } $num_ser_str = sprintf(_("Number of listed %s"),_("servers")); $num_ws_str = sprintf(_("Number of listed %s"),_("workstations")); $num_ter_str = sprintf(_("Number of listed %s"),_("terminals")); $num_pho_str = sprintf(_("Number of listed %s"),_("phones")); $num_prt_str = sprintf(_("Number of listed %s"),_("printers")); $num_com_str = sprintf(_("Number of listed %s"),_("network components")); $num_new_str = sprintf(_("Number of listed %s"),_("new devices")); $num_wws_str = sprintf(_("Number of listed %s"),_("windows workstations")); $num_dep_str = sprintf(_("Number of listed %s"),_("departments")); $str = "".$num_ser_str." ".$cnts['server']."    "; $str.= "".$num_ws_str." ".$cnts['workstation']."    "; $str.= "".$num_ter_str." ".$cnts['terminal']."    "; $str.= "".$num_pho_str." ".$cnts['phone']."    "; $str.= "".$num_prt_str." ".$cnts['printer']."    "; $str.= "".$num_com_str." ".$cnts['component']."    "; $str.= "".$num_new_str." ".$cnts['NewDevice']."    "; $str.= "".$num_wws_str." ".$cnts['winstation']."    "; $str.= "".$num_dep_str." ".$num_deps."    "; $this->set_List_Bottom_Info($str); } function Save() { MultiSelectWindow :: Save(); } function save_object() { /* Save automatic created POSTs like regex, checkboxes */ MultiSelectWindow :: save_object(); } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?>