config = $config; $this->ui = $ui; $this->storagePoints = array( get_ou('faiPartitionRDN'), get_ou('faiPackageRDN'), get_ou('faiScriptRDN'), get_ou('faiVariableRDN'), get_ou('faiHookRDN'), get_ou('faiProfileRDN'),get_ou('faiTemplateRDN')); // Build filter # if (session::global_is_set(get_class($this)."_filter")){ # $filter= session::global_get(get_class($this)."_filter"); # } else { $filter = new filter(get_template_path("fai-filter.xml", true)); $filter->setObjectStorage($this->storagePoints); # } $this->setFilter($filter); // Build headpage $headpage = new listing(get_template_path("fai-list.xml", true)); $headpage->setFilter($filter); $headpage->registerElementFilter("filterProperties", "faiManagement::filterProperties"); // Add copy&paste and snapshot handler. if ($this->config->boolValueIsTrue("main", "copyPaste")){ $this->cpHandler = new CopyPasteHandler($this->config); } if($this->config->get_cfg_value("enableSnapshots") == "true"){ $this->snapHandler = new SnapshotHandler($this->config); } $this->registerAction("editByGroup","editByGroup"); parent::__construct($config, $ui, "roles", $headpage); } function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="") { $headpage = $this->getHeadpage(); if(count($target) == 1){ foreach($headpage->entries as $entry){ if($entry['dn'] == $target[0]){ if(count($entry['GROUPS']) == 1){ $data = array_pop($entry['GROUPS']); $type = $this->get_type($data); management::editEntry('editEntry',array($data['dn']),array(),$type[0],$type[2],$type[1]); }else{ $this->dialogObject = new faiGroupHandle($entry['GROUPS'],"edit"); } break; } } } } function editByGroup() { if($this->dialogObject instanceOf faiGroupHandle && $this->dialogObject->get_mode() == "edit"){ $entry = $this->dialogObject->get_selected(); $this->editEntryByType(key($entry), array_pop($entry)); } } function editEntryByType($type, $data) { $this->closeDialogs(); $type = $this->get_type($data); management::editEntry('editEntry',array($data['dn']),array(),$type[0],$type[2],$type[1]); } function detectPostActions() { $action = management::detectPostActions(); if(isset($_POST['faiGroupHandle_cancel'])) $action['action'] = "cancel"; if(isset($_POST['faiGroupHandle_apply'])) $action['action'] = "editByGroup"; return($action); } function renderList() { $filter = $this->getFilter(); $headpage = $this->getHeadpage(); $filter->setComboBoxOptions("RELEASE",$this->getReleaseList()); if(isset($_POST['RELEASE'])){ $this->fai_release = get_post('RELEASE'); } $headpage->setBase($this->fai_release); $headpage->update(); $display = $headpage->render(); return($this->getHeader().$display); } function getReleaseList($base = "", $prefix ="") { $list = array(); if(empty($base)){ $base = get_ou('faiBaseRDN').$this->config->current['BASE']; $list[$base] = "/"; } $ldap = $this->config->get_ldap_link(); $ldap->ls("(objectClass=FAIbranch)",$base,array("ou","FAIstate")); $cfg_rel = $this->config->search("faiManagement","DEFAULTFAIRELEASE",array("menu")); while($release = $ldap->fetch()){ $list[$release['dn']] = $prefix.$release['ou'][0]; // Preset to prefered releaes if necessary if(empty($this->fai_release) && $cfg_rel == $release['dn']){ $this->fai_release = $release['dn']; } $list = array_merge($list,$this->getReleaseList($release['dn'],$prefix."  ")); } print_a($_POST); return($list); } static function filterProperties($row, $classes) { $objects = array( "FAIpartitionTable" => array("IMG"=> "plugins/fai/images/fai_partitionTable.png", "NAME"=>_("Partition table"),"KZL"=> "PT", "VAR"=>"ShowPartitions"), "FAIpackageList" => array("IMG"=> "plugins/fai/images/fai_packages.png", "NAME"=>_("Package list") , "KZL"=> "PL", "VAR"=>"ShowPackages"), "FAIscript" => array("IMG"=> "plugins/fai/images/fai_script.png", "NAME"=>_("Scripts") , "KZL"=> "S", "VAR"=>"ShowScripts"), "FAIvariable" => array("IMG"=> "plugins/fai/images/fai_variable.png", "NAME"=>_("Variables") , "KZL"=> "V", "VAR"=>"ShowVariables"), "FAIhook" => array("IMG"=> "plugins/fai/images/fai_hook.png", "NAME"=>_("Hooks"), "KZL"=> "H", "VAR"=>"ShowHooks"), "FAIprofile" => array("IMG"=> "plugins/fai/images/fai_profile.png", "NAME"=>_("Profile") , "KZL"=> "P", "VAR"=>"ShowProfiles"), "FAItemplate" => array("IMG"=> "plugins/fai/images/fai_template.png", "NAME"=>_("Templates") , "KZL"=> "T", "VAR"=>"ShowTemplates"), "opsi_netboot" => array("IMG"=> "plugins/opsi/images/netboot_package.png", "NAME"=>_("OPSI netboot product") , "KZL"=> "ON", "VAR"=>"ShowOpsiNetboot"), "opsi_local" => array("IMG"=> "plugins/opsi/images/local_package.png", "NAME"=>_("OPSI localboot product") , "KZL"=> "OL", "VAR"=>"ShowOpsiLocal")); $icon_list = ""; foreach($objects as $type => $type_data){ if(in_array($type, $classes)){ $icon_list .= "\n"; }else{ $icon_list .= " \n"; } } return $icon_list; } function get_type($array){ if(!isset($array['objectClass'])) return(array()); if(in_array("FAIpartitionTable",$array['objectClass'])){ return(array("tabsPartition","faiPartitionTable","FAIPARTITIONTABS")); } if(in_array("FAIscript",$array['objectClass'])){ return(array("tabsScript","faiScript","FAISCRIPTTABS")); } if(in_array("FAItemplate",$array['objectClass'])){ return(array("tabsTemplate","faiTemplate","FAITEMPLATETABS")); } if(in_array("FAIhook",$array['objectClass'])){ return(array("tabsHook","faiHook","FAIHOOKTABS")); } if(in_array("FAIvariable",$array['objectClass'])){ return(array("tabsVariable","faiVariable","FAIVARIABLETABS")); } if(in_array("FAIprofile",$array['objectClass'])){ return(array("tabsProfile","faiProfile","FAIPROFILETABS")); } if(in_array("FAIpackageList",$array['objectClass'])){ return(array("tabsPackage","faiPackage","FAIPACKAGETABS")); } return(array()); } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?>