X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=plugins%2Fadmin%2Ffai%2Fclass_faiProfileEntry.inc;h=30eedeb6cc1b51a7a461a2208c10c01124a91e35;hb=90cb0cbd940168e234d506e42644e52fc7af5c4d;hp=31df03c02113939bb34696338148a284829417f1;hpb=bdbf5cefda43935eedc62735d1bf9b781c847ccb;p=gosa.git diff --git a/plugins/admin/fai/class_faiProfileEntry.inc b/plugins/admin/fai/class_faiProfileEntry.inc index 31df03c02..30eedeb6c 100644 --- a/plugins/admin/fai/class_faiProfileEntry.inc +++ b/plugins/admin/fai/class_faiProfileEntry.inc @@ -20,20 +20,40 @@ class faiProfileEntry extends plugin plugin::plugin ($config, $dn); /* Search only in fai tree */ - $base = "ou=fai,ou=configs,ou=systems,".$_SESSION['faifilter']['base']; + $ObjectTypes = array( + "FAIpartitionTable" => array("OU"=>"ou=disk," ), + "FAIpackageList" => array("OU"=>"ou=packages," ), + "FAIscript" => array("OU"=>"ou=scripts," ), + "FAIvariable" => array("OU"=>"ou=variables," ), + "FAIhook" => array("OU"=>"ou=hooks," ), + "FAIprofile" => array("OU"=>"ou=profiles," ), + "FAItemplate" => array("OU"=>"ou=templates," )); - /* Create array with categories to be able to sort different types of objects */ - $categories = array("FAIscript","FAItemplate","FAIhook","FAIvariable","FAIpartitionTable","FAIpackage"); + $base= "ou=fai,ou=configs,ou=systems,".$_SESSION['CurrentMainBase']; + if($_SESSION['faifilter']['branch']!="main"){ + $base = $_SESSION['faifilter']['branch']; + } - /* Read out all objects from fai tree */ + /* Get ldap connection */ $ldap= $this->config->get_ldap_link(); $ldap->cd($base); - $ldap->search("(| (objectClass=FAIscript)(objectClass=FAItemplate)(objectClass=FAIhook)(objectClass=FAIvariable) - (objectClass=FAIpartitionTable)(objectClass=FAIpackage))",array("*")); - - $sort=array(); - while($attrs = $ldap->fetch()){ - + + /* Capture objects from given base */ + $result = array(); + foreach($ObjectTypes as $oc => $data){ + $ou = $data['OU'].$base; + + $ldap->ls("(objectClass=".$oc.")",$ou,array("cn","objectClass","dn")); + while($res = $ldap->fetch()){ + $result[] = $res; + } + } + + /* Create array with categories to be able to sort different types of objects */ + $categories = array("FAIscript","FAItemplate","FAIhook","FAIvariable","FAIpartitionTable","FAIpackageList"); + $sort = array(); + foreach($result as $attrs){ + /* Only use objects which have cn set */ if((isset($attrs['cn'][0]))&&(!in_array($attrs['cn'][0],$used))){ foreach($categories as $cat){ @@ -61,7 +81,7 @@ class faiProfileEntry extends plugin /* If no search filter is set, create one */ if (!is_global("SUBfaifilter")){ - $SUBfaifilter= array("base" => "ou=fai,ou=configs,ou=systems,".$base, "Sregex" => "*"); + $SUBfaifilter= array("base" => "ou=fai,ou=configs,ou=systems,".$_SESSION['CurrentMainBase'], "Sregex" => "*"); $SUBfaifilter['SShowTemplates'] = true; $SUBfaifilter['SShowScripts'] = true; $SUBfaifilter['SShowHooks'] = true; @@ -74,6 +94,9 @@ class faiProfileEntry extends plugin function execute() { + /* Call parent execute */ + plugin::execute(); + /* Fill templating stuff */ $smarty = get_smarty(); $display = ""; @@ -101,8 +124,9 @@ class faiProfileEntry extends plugin /* Check if we used a checkboxe from the list, to select dselect an entry */ foreach($_POST as $name => $value){ foreach($this->FAIAllclasses as $class => $obj){ - if(isset($_POST["ON_PAGE_".$class])){ - if(isset($_POST['USE_'.$class])){ + $bclass = base64_encode($class); + if(isset($_POST["ON_PAGE_".$bclass])){ + if(isset($_POST['USE_'.$bclass])){ $this->FAIAllclasses[$class]['status']=true; }else{ $this->FAIAllclasses[$class]['status']=false; @@ -112,12 +136,12 @@ class faiProfileEntry extends plugin } /* Create different picture for each object type */ - $objTypes['FAIhook'] = " "; - $objTypes['FAItemplate'] = " "; - $objTypes['FAIscript'] = " "; - $objTypes['FAIvariable'] = " "; - $objTypes['FAIpackage'] = " "; - $objTypes['FAIpartitionTable'] = " "; + $objTypes['FAIhook'] = " "; + $objTypes['FAItemplate'] = " "; + $objTypes['FAIscript'] = " "; + $objTypes['FAIvariable'] = " "; + $objTypes['FAIpackageList'] = " "; + $objTypes['FAIpartitionTable'] = " "; /* Magic quotes GPC, escapes every ' " \, to solve some security risks * If we post the escaped strings they will be escaped again @@ -146,13 +170,13 @@ class faiProfileEntry extends plugin /* Create a divlist to display all available class names with the depending object types */ $divlist = new divlist("ProfileEntry"); $divlist->SetSummary(_("This list displays all assigned class names for this profile.")); - $divlist->SetEntriesPerPage(20); - $divlist->SetHeader(array(array("string"=>"Class name"), - array("string"=>"Objects","attach"=>"style='border-right:0px;'"))); + $divlist->SetEntriesPerPage(0); + $divlist->SetHeader(array(array("string"=> _("Class name")), + array("string"=> _("Objects"),"attach"=>"style='border-right:0px;'"))); /* Action button allows us to delete an entry */ $action = " - "; + "; /* Check every single class name to match the current search filter */ foreach($this->FAIAllclasses as $usedClass => $classes){ @@ -178,7 +202,7 @@ class faiProfileEntry extends plugin if((isset($classes['objects']['FAIpartitionTable']))&&($SUBfaifilter['SShowPartitions'])){ $abort = false; } - if((isset($classes['objects']['FAIpackage']))&&($SUBfaifilter['SShowPackages'])){ + if((isset($classes['objects']['FAIpackageList']))&&($SUBfaifilter['SShowPackages'])){ $abort = false; } @@ -196,7 +220,7 @@ class faiProfileEntry extends plugin } /* Append to list */ - $field1 = array("string"=> preg_replace("/%KEY%/",$usedClass,$action_check).$usedClass,"attach"=>""); + $field1 = array("string"=> str_replace("%KEY%",base64_encode($usedClass),$action_check).$usedClass,"attach"=>""); $field2 = array("string"=> $str,"attach"=>"style='border-right:0px;'"); $divlist->AddEntry(array($field1,$field2)); } @@ -204,8 +228,8 @@ class faiProfileEntry extends plugin $smarty->assign("faihead" , ""); $smarty->assign("failist" , $divlist->DrawList()); - $smarty->assign("infoimage" , get_template_path('images/info.png')); - $smarty->assign("launchimage" , get_template_path('images/launch.png')); + $smarty->assign("infoimage" , get_template_path('images/info_small.png')); + $smarty->assign("launchimage" , get_template_path('images/small_filter.png')); $smarty->assign("alphabet" , generate_alphabet()); $smarty->assign("apply" , apply_filter(TRUE)); $smarty->assign("search_image" , get_template_path('images/search.png')); @@ -222,7 +246,9 @@ class faiProfileEntry extends plugin /* Check supplied data */ function check() { - $message= array(); + /* Call common method to give check the hook */ + $message= plugin::check(); + return ($message); }