From: hickert Date: Tue, 10 Jan 2006 15:28:08 +0000 (+0000) Subject: Added branch functionality (Not complete now !!) X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=577dff940a258beec4ea8ca380556a891b121452;p=gosa.git Added branch functionality (Not complete now !!) git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2436 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/fai/class_askClassName.inc b/plugins/admin/fai/class_askClassName.inc index ae0d33657..a5bddcd7f 100644 --- a/plugins/admin/fai/class_askClassName.inc +++ b/plugins/admin/fai/class_askClassName.inc @@ -41,7 +41,12 @@ class askClassName extends plugin /* First search for every ou, in given fai base * With a second search detect all object that belong to the different ous. */ - $base = "ou=fai,ou=configs,ou=systems,".$faifilter['base']; + + $bb =""; + if($faifilter['branch'] != "main"){ + $bb = "ou=".$faifilter['branch'].","; + } + $base = $bb."ou=fai,ou=configs,ou=systems,".$faifilter['base']; $ldap = $this->config->get_ldap_link(); $res = get_list($this->ui->subtreeACL, "(objectClass=organizationalUnit)",FALSE, $base, array("cn","description","objectClass"),TRUE); $used = array(); @@ -59,7 +64,9 @@ class askClassName extends plugin /* Skip profiles */ if(!in_array("FAIprofile",$object['objectClass'])){ - $used[$object['cn'][0]]= $object['cn'][0]; + if(isset($object['cn'])){ + $used[$object['cn'][0]]= $object['cn'][0]; + } } } } diff --git a/plugins/admin/fai/class_faiManagement.inc b/plugins/admin/fai/class_faiManagement.inc index c9c2363e5..8ee09f1ff 100644 --- a/plugins/admin/fai/class_faiManagement.inc +++ b/plugins/admin/fai/class_faiManagement.inc @@ -72,7 +72,7 @@ class faiManagement extends plugin if (!is_global("faifilter")){ $base = get_base_from_people($ui->dn); $faifilter= array("base" => $base, - "regex" => "*"); + "regex" => "*","branch" => "main"); $faifilter['ShowProfiles'] = true; $faifilter['ShowTemplates'] = true; $faifilter['ShowScripts'] = true; @@ -114,6 +114,12 @@ class faiManagement extends plugin } } + if((isset($_POST['select_branch']))&&(!empty($_POST['select_branch']))){ + $faifilter['branch'] = $_POST['select_branch']; + } + + $smarty->assign("select_branch",$_SESSION['faifilter']['branch']); + /* Check ImageButton posts * Create new tab ich new_xx is posted */ @@ -311,18 +317,14 @@ class faiManagement extends plugin if($is_ok){ /* Create it know */ - $ldap = $this->config->get_ldap_link(); - -// $ldap->cd ("ou=".$name.",".$base); -// $ldap->recursive_remove(); - - $ldap->cd ($this->config->current['BASE']); - $ldap->copy_recursive($base,"ou=".$name.",".$base); + $ldap->cd ("ou=".$name.",".$base); + $ldap->recursive_remove(); + $ldap->cd ($this->config->current['BASE']); + $ldap->copy_FAI_resource_recursive($base,"ou=".$name.",".$base,"branch",true); - print "created new branch .... bla"; $this->dispNewBranch = false; } } @@ -623,8 +625,7 @@ class faiManagement extends plugin $divlist->AddEntry( array($field0,$field1,$field2,$field3)); } - - + /* Attach objects */ foreach($this->objects as $key => $value){ $info= ""; @@ -694,10 +695,16 @@ class faiManagement extends plugin $desc= ""; } + if($value['FAIstate'] == "branch"){ + $acti = ""; + }else{ + $acti = $action; + } + $field1 = array("string" => $img , "attach" => "style='text-align:center;width:20px;'"); $field2 = array("string" => preg_replace(array("/%KEY%/","/%NAME%/"),array($key,$value['cn'].$desc),$editlink) , "attach" => "style=''"); $field3 = array("string" => $info, "attach" => "style='width:200px;'"); - $field4 = array("string" => preg_replace("/%KEY%/",$key,$action) , "attach" => "style='width:60px;border-right:0px;text-align:right;'"); + $field4 = array("string" => preg_replace("/%KEY%/",$key,$acti) , "attach" => "style='width:60px;border-right:0px;text-align:right;'"); $divlist->AddEntry(array($field1,$field2,$field3,$field4)); } @@ -713,8 +720,8 @@ class faiManagement extends plugin /* Assign all reguired vars to template engine */ - $smarty->assign("branchKeys",array()); - $smarty->assign("branches",array()); + $smarty->assign("branchKeys",array_flip($this->getBranches())); + $smarty->assign("branches",$this->getBranches()); $smarty->assign("faihead" , $faihead); $smarty->assign("failist" , $divlist->DrawList()); @@ -732,15 +739,23 @@ class faiManagement extends plugin function getBranches() { + $ret = array("main"=>_("main")); $ldap = $this->config->get_ldap_link(); $ldap->cd($this->config->current['BASE']); - $ldap->search("(objectClass=FAIbranch)",array("FAIstate","cn","ou")); + $faifilter = $_SESSION['faifilter']; + $base= "ou=fai,ou=configs,ou=systems,".$faifilter['base']; + $ldap->cd($base); + $ldap->search("(objectClass=FAIbranch)",array("*")); while($attrs = $ldap->fetch()){ - print_a($attrs); + if(isset($attrs['ou'])){ + $ou = $attrs['ou'][0]; + $ret[$ou]=$ou; + } } + return($ret); } function reload() @@ -754,6 +769,11 @@ class faiManagement extends plugin /* Set base for all searches */ $base= "ou=fai,ou=configs,ou=systems,".$faifilter['base']; + + if($faifilter['branch'] !="main"){ + $base = "ou=".$faifilter['branch'].",".$base; + } + $regex = $faifilter['regex']; /* Array to save objects */ @@ -793,7 +813,7 @@ class faiManagement extends plugin foreach($res as $objecttypes){ $res2 = get_list($this->ui->subtreeACL, "(&(objectClass=*)(cn=".$regex."))", - FALSE, $objecttypes['dn'], array("cn","description","objectClass","FAIclass"),TRUE); + FALSE, $objecttypes['dn'], array("cn","description","objectClass","FAIclass","FAIstate"),TRUE); foreach($res2 as $object){ $type= ""; unset($object['objectClass']['count']); @@ -807,6 +827,12 @@ class faiManagement extends plugin $obj['description'] = $object['description'][0]; $obj['objectClass'] = $object['objectClass']; + if(isset($object['FAIstate'])){ + $obj['FAIstate'] = $object['FAIstate'][0]; + }else{ + $obj['FAIstate'] =""; + } + if(in_array("FAIpartitionTable",$obj['objectClass'])){ $type = "FAIpartitionTable"; }elseif(in_array("FAIpackageList",$obj['objectClass'])){ diff --git a/plugins/admin/fai/headpage.tpl b/plugins/admin/fai/headpage.tpl index 506ad012d..e8ccfbf03 100644 --- a/plugins/admin/fai/headpage.tpl +++ b/plugins/admin/fai/headpage.tpl @@ -30,8 +30,8 @@
- + {html_options values=$branchKeys output=$branches selected=$select_branch}
{t}Delete this branch.{/t} diff --git a/plugins/admin/fai/tabsHook.inc b/plugins/admin/fai/tabsHook.inc index 1a434eadd..a44816fe3 100644 --- a/plugins/admin/fai/tabsHook.inc +++ b/plugins/admin/fai/tabsHook.inc @@ -19,7 +19,14 @@ class tabsHook extends tabs { $baseobject= $this->by_object['faiHook']; - $new_dn= 'cn='.$baseobject->cn.",ou=hooks,ou=fai,ou=configs,ou=systems,".$_SESSION['faifilter']['base']; + $branch = ""; + if($_SESSION['faifilter']['branch']!="main"){ + $branch = "ou=".$_SESSION['faifilter']['branch'].","; + } + + $new_dn= 'cn='.$baseobject->cn.",ou=hooks,".$branch."ou=fai,ou=configs,ou=systems,".$_SESSION['faifilter']['base']; + + print $new_dn; if ($this->dn != $new_dn && $this->dn != "new"){ diff --git a/plugins/admin/fai/tabsPackage.inc b/plugins/admin/fai/tabsPackage.inc index c91455548..f0c16646e 100644 --- a/plugins/admin/fai/tabsPackage.inc +++ b/plugins/admin/fai/tabsPackage.inc @@ -19,7 +19,12 @@ class tabsPackage extends tabs { $baseobject= $this->by_object['faiPackage']; - $new_dn= 'cn='.$baseobject->cn.",ou=packages,ou=fai,ou=configs,ou=systems,".$_SESSION['faifilter']['base']; + $branch = ""; + if($_SESSION['faifilter']['branch']!="main"){ + $branch = "ou=".$_SESSION['faifilter']['branch'].","; + } + + $new_dn= 'cn='.$baseobject->cn.",ou=packages,".$branch."ou=fai,ou=configs,ou=systems,".$_SESSION['faifilter']['base']; if ($this->dn != $new_dn && $this->dn != "new"){ diff --git a/plugins/admin/fai/tabsPartition.inc b/plugins/admin/fai/tabsPartition.inc index df8327117..2308dcec8 100644 --- a/plugins/admin/fai/tabsPartition.inc +++ b/plugins/admin/fai/tabsPartition.inc @@ -19,8 +19,13 @@ class tabsPartition extends tabs { $baseobject= $this->by_object['faiPartitionTable']; - // cn=FAIBASE,ou=disk,ou=fai,ou=configs,ou=systems,dc=gonicus,dc=de - $new_dn= 'cn='.$baseobject->cn.",ou=disk,ou=fai,ou=configs,ou=systems,".$_SESSION['faifilter']['base']; + $branch = ""; + if($_SESSION['faifilter']['branch']!="main"){ + $branch = "ou=".$_SESSION['faifilter']['branch'].","; + } + + // cn=FAIBASE,ou=disk,".$branch."ou=fai,ou=configs,ou=systems,dc=gonicus,dc=de + $new_dn= 'cn='.$baseobject->cn.",ou=disk,".$branch."ou=fai,ou=configs,ou=systems,".$_SESSION['faifilter']['base']; // Old .. $new_dn= 'ou='.$baseobject->ou.','.$baseobject->base; diff --git a/plugins/admin/fai/tabsProfile.inc b/plugins/admin/fai/tabsProfile.inc index bb42efeb9..f40addaf3 100644 --- a/plugins/admin/fai/tabsProfile.inc +++ b/plugins/admin/fai/tabsProfile.inc @@ -19,7 +19,12 @@ class tabsProfile extends tabs { $baseobject= $this->by_object['faiProfile']; - $new_dn= 'cn='.$baseobject->cn.",ou=profiles,ou=fai,ou=configs,ou=systems,".$_SESSION['faifilter']['base']; + $branch = ""; + if($_SESSION['faifilter']['branch']!="main"){ + $branch = "ou=".$_SESSION['faifilter']['branch'].","; + } + + $new_dn= 'cn='.$baseobject->cn.",ou=profiles,".$branch."ou=fai,ou=configs,ou=systems,".$_SESSION['faifilter']['base']; if ($this->dn != $new_dn && $this->dn != "new"){ diff --git a/plugins/admin/fai/tabsScript.inc b/plugins/admin/fai/tabsScript.inc index b9a63d34b..60d70673e 100644 --- a/plugins/admin/fai/tabsScript.inc +++ b/plugins/admin/fai/tabsScript.inc @@ -19,7 +19,12 @@ class tabsScript extends tabs { $baseobject= $this->by_object['faiScript']; - $new_dn= 'cn='.$baseobject->cn.",ou=scripts,ou=fai,ou=configs,ou=systems,".$_SESSION['faifilter']['base']; + $branch = ""; + if($_SESSION['faifilter']['branch']!="main"){ + $branch = "ou=".$_SESSION['faifilter']['branch'].","; + } + + $new_dn= 'cn='.$baseobject->cn.",ou=scripts,".$branch."ou=fai,ou=configs,ou=systems,".$_SESSION['faifilter']['base']; if ($this->dn != $new_dn && $this->dn != "new"){ diff --git a/plugins/admin/fai/tabsTemplate.inc b/plugins/admin/fai/tabsTemplate.inc index cc49f0ce6..98be6054e 100644 --- a/plugins/admin/fai/tabsTemplate.inc +++ b/plugins/admin/fai/tabsTemplate.inc @@ -18,8 +18,13 @@ class tabsTemplate extends tabs function save() { $baseobject= $this->by_object['faiTemplate']; - - $new_dn= 'cn='.$baseobject->cn.",ou=templates,ou=fai,ou=configs,ou=systems,".$_SESSION['faifilter']['base']; + + $branch = ""; + if($_SESSION['faifilter']['branch']!="main"){ + $branch = "ou=".$_SESSION['faifilter']['branch'].","; + } + + $new_dn= 'cn='.$baseobject->cn.",ou=templates,".$branch."ou=fai,ou=configs,ou=systems,".$_SESSION['faifilter']['base']; if ($this->dn != $new_dn && $this->dn != "new"){ diff --git a/plugins/admin/fai/tabsVariable.inc b/plugins/admin/fai/tabsVariable.inc index 81e2baccc..cf4f2b910 100644 --- a/plugins/admin/fai/tabsVariable.inc +++ b/plugins/admin/fai/tabsVariable.inc @@ -19,7 +19,12 @@ class tabsVariable extends tabs { $baseobject= $this->by_object['faiVariable']; - $new_dn= 'cn='.$baseobject->cn.",ou=variables,ou=fai,ou=configs,ou=systems,".$_SESSION['faifilter']['base']; + $branch = ""; + if($_SESSION['faifilter']['branch']!="main"){ + $branch = "ou=".$_SESSION['faifilter']['branch'].","; + } + + $new_dn= 'cn='.$baseobject->cn.",ou=variables,".$branch."ou=fai,ou=configs,ou=systems,".$_SESSION['faifilter']['base']; if ($this->dn != $new_dn && $this->dn != "new"){