Code

Added branch functionality (Not complete now !!)
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 10 Jan 2006 15:28:08 +0000 (15:28 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 10 Jan 2006 15:28:08 +0000 (15:28 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2436 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/fai/class_askClassName.inc
plugins/admin/fai/class_faiManagement.inc
plugins/admin/fai/headpage.tpl
plugins/admin/fai/tabsHook.inc
plugins/admin/fai/tabsPackage.inc
plugins/admin/fai/tabsPartition.inc
plugins/admin/fai/tabsProfile.inc
plugins/admin/fai/tabsScript.inc
plugins/admin/fai/tabsTemplate.inc
plugins/admin/fai/tabsVariable.inc

index ae0d33657b0b5caf2cc31bb57deec70edd068be8..a5bddcd7f4b0987a597b0e1195cdedf62fe3add4 100644 (file)
@@ -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];
+          }
         }
       }
     }
index c9c2363e5d6e103c1927fe7307e2679f6688d206..8ee09f1ff4310bd4f2833c1e4bac1d57968a9faa 100644 (file)
@@ -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'])){
index 506ad012d0dd8b8c57014c43d099b582838953c0..e8ccfbf03271d5530869bf6ad4aaaa7535f8c3d6 100644 (file)
@@ -30,8 +30,8 @@
    </div>
    <div class="contentboxb" style="padding:3px;">
        
-       <select name="select_branch" >
-               {html_options values=$branchKeys output=$branches }
+       <select name="select_branch" onChange="document.mainform.submit();">
+               {html_options values=$branchKeys output=$branches selected=$select_branch}
        </select>
        <br>
        {t}Delete this branch.{/t}
index 1a434eadd88847e4470e7b3b82e6fb4e77058078..a44816fe38befb3b071ccab275c7a3d3e1a3131c 100644 (file)
@@ -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"){
                
index c91455548c59eab727aa7fa49c8aec0e8f3b6e90..f0c16646ead262b45a8019717aeb0fcffa1fc3a7 100644 (file)
@@ -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"){
                
index df8327117d84469311c52fb261a5e31997fd2e38..2308dcec84d41287482c18297b64787d6135d66a 100644 (file)
@@ -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;
 
index bb42efeb96a365cf9e1726205603ff60afa3813e..f40addaf387834bb2627d633be83942bd3977cf9 100644 (file)
@@ -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"){
                
index b9a63d34bf78265dc162219924903188022d5a6e..60d70673efb63c4e2967950efa1ff40afa0747c0 100644 (file)
@@ -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"){
                
index cc49f0ce676cbc8922246cf9a929f2ef54bc429d..98be6054ef18b578328ec2097e6da358c0bae263 100644 (file)
@@ -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"){
                
index 81e2baccc73dad9a40f1a78b43adbb2b7364ce79..cf4f2b910ca1a70ce2d981837ed8442700b7d880 100644 (file)
@@ -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"){