Code

Some changes
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 10 Jan 2006 16:17:27 +0000 (16:17 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 10 Jan 2006 16:17:27 +0000 (16:17 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2437 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/fai/class_faiManagement.inc
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 8ee09f1ff4310bd4f2833c1e4bac1d57968a9faa..42438f6dddf83dc383e8f7e19528ba1fb652ced4 100644 (file)
@@ -17,6 +17,7 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 require "tabsPartition.inc";
 require "tabsVariable.inc";
 require "tabsHook.inc";
@@ -363,27 +364,44 @@ class faiManagement extends plugin
     }
 
     if($s_action == "freeze_branch"){
-      $base= "ou=fai,ou=configs,ou=systems,".$faifilter['base'];
-      $ldap = $this->config->get_ldap_link();
-      $ldap->cd ($base);
-  
-      $attrs = $ldap->fetch($ldap->cat ($base));
+      $this->dispNewFreeze = true;
+                 $display      .= $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
+      return($display);
+    }
 
-      if(!in_array("FAIbranch",$attrs)){
-        $attrs['objectClass'][] = "FAIbranch";
-      }
-     
-      if((!isset($attrs['FAIstate']))||($attrs['FAIstate'] != "frozen")){
-        $attrs['FAIstate']= "frozen";
-      }
-    
-      print "Freeze ";
+    if((isset($_POST['UseBranchName']))&&($this->dispNewFreeze)){
+      /* Check branch name */
+      $name = $_POST['BranchName'];
+      $is_ok = true;
 
+                 $base= "ou=fai,ou=configs,ou=systems,".$faifilter['base'];
       
+      /* Check used characters */
+      if(preg_match("/[^0-9a-z]/i",$name)){
+        print_red(_("Specified branch name is invalid."));
+        $is_ok = false;
+      }
+   
+      /* Check if this name is already in use */
+      if(!$this->CheckNewBranchName($_POST['BranchName'])){
+        print_red(_("This name is already in use."));
+        $this->is_ok = false;
+      }
+     
+      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_FAI_resource_recursive($base,"ou=".$name.",".$base,"freeze",true);
+        
+        $this->dispNewFreeze = false; 
+      }
     }
+    
 
     /* ENDE Branch handling 
      */
@@ -447,7 +465,6 @@ class faiManagement extends plugin
                        }               
                }       
 
-
                /* Search is set */
                if(isset($_GET['search'])){
                        $faifilter['regex']=$_GET['search']."*";
@@ -695,14 +712,16 @@ class faiManagement extends plugin
                                                $desc= "";
                                        }
 
-          if($value['FAIstate'] == "branch"){
+          if($value['FAIstate'] == "freeze"){
             $acti = "";
+            $edi  = "%NAME%";
           }else{
             $acti = $action;
+            $edi = $editlink;
           }
 
                                        $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=''");
+                                       $field2 = array("string" => preg_replace(array("/%KEY%/","/%NAME%/"),array($key,$value['cn'].$desc),$edi) , "attach" => "style=''");
                                        $field3 = array("string" => $info, "attach" => "style='width:200px;'");
                                        $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));
@@ -737,7 +756,7 @@ class faiManagement extends plugin
                return ($display);
        }
 
-  function getBranches()
+  function getBranches($base = false,$prefix = "")
   {
     $ret = array("main"=>_("main"));
     $ldap = $this->config->get_ldap_link();
@@ -745,14 +764,19 @@ class faiManagement extends plugin
     $ldap->cd($this->config->current['BASE']);
 
     $faifilter = $_SESSION['faifilter'];
-               $base= "ou=fai,ou=configs,ou=systems,".$faifilter['base'];
+
+
+    if(!$base){
+               $base= "ou=fai,ou=configs,ou=systems,".$faifilter['base'];
+    }
     $ldap->cd($base);
-    $ldap->search("(objectClass=FAIbranch)",array("*"));
+    $ldap->ls("(objectClass=FAIbranch)",$base);
 
     while($attrs = $ldap->fetch()){
-      if(isset($attrs['ou'])){
-        $ou = $attrs['ou'][0];
-        $ret[$ou]=$ou;
+      
+      if((isset($attrs['ou']))&&($attrs['dn']!=$base)){
+        $ret[$attrs['dn']]= $prefix.$attrs['ou'][0];
+        $ret = array_merge($ret,$this->getBranches($attrs['dn'],$prefix."/".$attrs['ou'][0]));
       }
     }
     return($ret);
@@ -771,7 +795,7 @@ class faiManagement extends plugin
                $base= "ou=fai,ou=configs,ou=systems,".$faifilter['base'];
 
     if($faifilter['branch'] !="main"){
-      $base = "ou=".$faifilter['branch'].",".$base;
+      $base = $faifilter['branch'];
     }
    
                $regex = $faifilter['regex'];   
@@ -899,8 +923,10 @@ class faiManagement extends plugin
                }
        }
 
-  function checknewbranchname($name){
-  
+  function CheckNewBranchName($name){
+    if(in_array($name,$this->getBranches())) {
+      return(false);
+    }
     return(true);
   }
 
index a44816fe38befb3b071ccab275c7a3d3e1a3131c..cae153ef2956f11b8b608cc5340836421dc4bfec 100644 (file)
@@ -19,15 +19,12 @@ class tabsHook extends tabs
   {
        $baseobject= $this->by_object['faiHook'];
 
-       $branch = "";
+       $new_dn= 'cn='.$baseobject->cn.",ou=hooks,ou=fai,ou=configs,ou=systems,".$_SESSION['faifilter']['base'];
+       
        if($_SESSION['faifilter']['branch']!="main"){
-               $branch = "ou=".$_SESSION['faifilter']['branch'].",";
+               $new_dn ='cn='.$baseobject->cn.",ou=hooks,".$_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"){
                
                /* if( new_dn is subtree of this->dn ) */
index f0c16646ead262b45a8019717aeb0fcffa1fc3a7..1ac6ab563ba4c6ce83c24d59368016263676c10f 100644 (file)
@@ -19,13 +19,11 @@ class tabsPackage extends tabs
   {
        $baseobject= $this->by_object['faiPackage'];
 
-       $branch = "";
+       $new_dn= 'cn='.$baseobject->cn.",ou=packages,ou=fai,ou=configs,ou=systems,".$_SESSION['faifilter']['base'];
        if($_SESSION['faifilter']['branch']!="main"){
-               $branch = "ou=".$_SESSION['faifilter']['branch'].",";
+               $new_dn ='cn='.$baseobject->cn.",ou=packages,".$_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"){
                
                /* if( new_dn is subtree of this->dn ) */
index 2308dcec84d41287482c18297b64787d6135d66a..c8c622210a3a32364b811e4ec7ccc14e376be2a7 100644 (file)
@@ -19,16 +19,12 @@ class tabsPartition extends tabs
   {
        $baseobject= $this->by_object['faiPartitionTable'];
 
-       $branch = "";
+       $new_dn= 'cn='.$baseobject->cn.",ou=disk,ou=fai,ou=configs,ou=systems,".$_SESSION['faifilter']['base'];
+       
        if($_SESSION['faifilter']['branch']!="main"){
-               $branch = "ou=".$_SESSION['faifilter']['branch'].",";
+               $new_dn ='cn='.$baseobject->cn.",ou=disk,".$_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;
-
        if ($this->dn != $new_dn && $this->dn != "new"){
                
                /* if( new_dn is subtree of this->dn ) */
index f40addaf387834bb2627d633be83942bd3977cf9..599f6772c877714dec37fa5b77a2ab664bb5af3c 100644 (file)
@@ -19,13 +19,12 @@ class tabsProfile extends tabs
   {
        $baseobject= $this->by_object['faiProfile'];
 
-       $branch = "";
+       $new_dn= 'cn='.$baseobject->cn.",ou=profiles,ou=fai,ou=configs,ou=systems,".$_SESSION['faifilter']['base'];
+
        if($_SESSION['faifilter']['branch']!="main"){
-               $branch = "ou=".$_SESSION['faifilter']['branch'].",";
+               $new_dn ='cn='.$baseobject->cn.",ou=profiles,".$_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"){
                
                /* if( new_dn is subtree of this->dn ) */
index 60d70673efb63c4e2967950efa1ff40afa0747c0..f85bde58798775f5cfcbd5aea1bab1ef0d0c8628 100644 (file)
@@ -19,12 +19,11 @@ class tabsScript extends tabs
   {
        $baseobject= $this->by_object['faiScript'];
 
-       $branch = "";
+       $new_dn= 'cn='.$baseobject->cn.",ou=scripts,ou=fai,ou=configs,ou=systems,".$_SESSION['faifilter']['base'];
+
        if($_SESSION['faifilter']['branch']!="main"){
-               $branch = "ou=".$_SESSION['faifilter']['branch'].",";
+               $new_dn ='cn='.$baseobject->cn.",ou=scripts,".$_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 98be6054ef18b578328ec2097e6da358c0bae263..1363b09bc873bb5612f81e65cde9209046490e29 100644 (file)
@@ -19,13 +19,12 @@ class tabsTemplate extends tabs
   {
        $baseobject= $this->by_object['faiTemplate'];
        
-       $branch = "";
+       $new_dn= 'cn='.$baseobject->cn.",ou=templates,ou=fai,ou=configs,ou=systems,".$_SESSION['faifilter']['base'];
+
        if($_SESSION['faifilter']['branch']!="main"){
-               $branch = "ou=".$_SESSION['faifilter']['branch'].",";
+               $new_dn ='cn='.$baseobject->cn.",ou=templates,".$_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"){
                
                /* if( new_dn is subtree of this->dn ) */
index cf4f2b910ca1a70ce2d981837ed8442700b7d880..b526884dfee468993c1b30d85884f1d672ba275b 100644 (file)
@@ -19,13 +19,12 @@ class tabsVariable extends tabs
   {
        $baseobject= $this->by_object['faiVariable'];
 
-       $branch = "";
+       $new_dn= 'cn='.$baseobject->cn.",ou=variables,ou=fai,ou=configs,ou=systems,".$_SESSION['faifilter']['base'];
+       
        if($_SESSION['faifilter']['branch']!="main"){
-               $branch = "ou=".$_SESSION['faifilter']['branch'].",";
+               $new_dn ='cn='.$baseobject->cn.",ou=variables,".$_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"){
                
                /* if( new_dn is subtree of this->dn ) */