Code

Display status information about branching
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 3 Mar 2006 10:00:20 +0000 (10:00 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 3 Mar 2006 10:00:20 +0000 (10:00 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2807 594d385d-05f5-0310-b6e9-bd551577e9d8

include/class_ldap.inc
plugins/admin/fai/class_faiManagement.inc
plugins/admin/fai/faiNewBranch.tpl

index 1570b8aab6ad2cd2bcb68dce134a6855128a17cd..142235dba64023eefad71e9c7b2369966c5aed26 100644 (file)
@@ -396,18 +396,30 @@ class LDAP{
   }
 
   /* Copy given attributes and sub-dns with attributes to destination dn 
-      
   */
-  function copy_FAI_resource_recursive($sourcedn,$destinationdn,$type="branch",$is_first = false)
+  function copy_FAI_resource_recursive($sourcedn,$destinationdn,$type="branch",$is_first = true,$depth=0)
   {
     error_reporting(E_ALL);
+   
+    if($is_first){
+      echo "<font style='font-size:11px;'><b>".
+              sprintf(_("Creating duplicate of '%s' in '%s':<br>"),$sourcedn,$destinationdn)."</b>";
+    }else{
+      if($depth == 1 ){
+        echo "<br>"._("creating")." : ".preg_replace("/,.*$/","",$destinationdn);
+      }else{
+        echo ". ";
+      }
+    }
+    
     if($this->hascon){
       if ($this->reconnect) $this->connect();
 
       /* Save base dn */
       $basedn= $this->basedn;
       $delarray= array();
-      
+     
       /* Check if destination entry already exists */
       if($this->count($this->fetch($this->cat($destinationdn)))){
         return;
@@ -507,16 +519,21 @@ class LDAP{
       asort ($delarray);
       reset ($delarray);
 
+       $depth ++;
       foreach($delarray as $dn => $bla){
         if($dn != $destinationdn){
           $this->cd($basedn);
           $item = $this->fetch($this->cat($dn));
           if(!in_array("FAIbranch",$item['objectClass'])){
-            $this->copy_FAI_resource_recursive($dn,str_replace($sourcedn,$destinationdn,$dn),$type);
+            $this->copy_FAI_resource_recursive($dn,str_replace($sourcedn,$destinationdn,$dn),$type,false,$depth);
           } 
         }
       }
     }
+    if($is_first){
+      echo "<br><br><b>"._("Successfully finished")."</b></font>";
+    }
+
   }
 
   function modify($attrs)
index 920257bcc45716abac6a5844193586b9734b5918..9ca356db27df040b2cdd04719c6e3dd0dd1b6583 100644 (file)
@@ -303,71 +303,15 @@ class faiManagement extends plugin
         09.01.2006
     */
 
-    /* Create new branch */
-    if((isset($_POST['UseBranchName']))&&($this->dispNewBranch)){
-     
-      /* Check branch name */
-      $name = $_POST['BranchName'];
-      $is_ok = true;
-
-      $smarty->assign("BranchName",$name);
-                 $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'],$faifilter['branch'])){
-        print_red(_("This name is already in use."));
-        $is_ok = false;
-      }
-     
-      if($is_ok){
-        /* Create it know */
-        $ldap = $this->config->get_ldap_link();
-
-        $baseToUse = $base;
-        if($_SESSION['faifilter']['branch']!="main"){
-          $baseToUse = $_SESSION['faifilter']['branch'];
-        }
-
-        $ldap->cd($this->config->current['BASE']);
-        $ldap->create_missing_trees($baseToUse);
-        $ldap->cd ("ou=".$name.",".$baseToUse);
-        $ldap->recursive_remove();
-        
-        $ldap->cd ($this->config->current['BASE']);
-        $ldap->copy_FAI_resource_recursive($baseToUse,"ou=".$name.",".$baseToUse,"branch",true);
-
-        /* Postcreate */ 
-
-        /* Assign possible attributes */
-        $this->lock_type  = "branch"; 
-        $this->lock_name  = $name; 
-        $this->lock_dn    = $baseToUse; 
-        $this->postcreate();
-        $this->dispNewBranch = false; 
-      }
-    }
-
-    /* Abort creating new branch */
+    /* Abort creating new branch 
+     */
     if(isset($_POST['CancelBranchName'])){
       $this->dispNewBranch = false;
       $this->dispNewFreeze = false;
     }
-
-    /* Open dialog to insert new branch name */
-    if(($s_action == "branch_branch")||($this->dispNewBranch)){
-      $this->dispNewBranch=true;
-                 $base= "ou=fai,ou=configs,ou=systems,".$faifilter['base'];
-                 $display      .= $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
-      return($display);
-    }
-
-    /* Remove branch */
+    
+    /* Remove branch 
+     */
     if($s_action == "remove_branch"){
       $base= $faifilter['branch'];
       /* Load permissions for selected 'dn' and check if
@@ -382,7 +326,8 @@ class faiManagement extends plugin
       }
     }
 
-    /* Delete this entry */
+    /* Delete this entry 
+     */
     if(isset($_POST['delete_branch_confirm'])){
       $bb =  $faifilter['branch'];
       if(!isset($ldap)){
@@ -401,7 +346,7 @@ class faiManagement extends plugin
 
         /* Post remove */
                 
-//        $this->lock_type is set from this->reload
+        //  $this->lock_type is set from this->reload
         $this->lock_name   = $name;
         $this->lock_dn     = $bb;
 
@@ -409,57 +354,97 @@ class faiManagement extends plugin
       }
     }
 
+    /* Open dialog to insert new branch name 
+     */
+
+    if((isset($_POST['UseBranchName']))&&(($this->dispNewBranch)||($this->dispNewFreeze))){
+      $_SESSION['LASTPOST'] = $_POST;
+
+      if($this->dispNewBranch){
+        $type = "branch";
+      }else{
+        $type = "freeze";
+      }
 
-    if((isset($_POST['UseBranchName']))&&($this->dispNewFreeze)){
       /* Check branch name */
       $name = $_POST['BranchName'];
       $is_ok = true;
 
       $smarty->assign("BranchName",$name);
 
-                 $base= "ou=fai,ou=configs,ou=systems,".$faifilter['base'];
-      
+      $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."));
+        if($type == "branch"){
+          print_red(_("Specified branch name is invalid."));
+        }else{
+          print_red(_("Specified freeze name is invalid."));
+        }
         $is_ok = false;
       }
-   
+
       /* Check if this name is already in use */
       if(!$this->CheckNewBranchName($_POST['BranchName'],$faifilter['branch'])){
         print_red(_("This name is already in use."));
         $is_ok = false;
       }
-     
+
       if($is_ok){
-        /* Create it know */
-        $ldap = $this->config->get_ldap_link();
+        $_SESSION['LASTPOST']['base'] = $base;
+        $_SESSION['LASTPOST']['type'] = $type;
+        $smarty->assign("iframe", true);
+        $smarty->assign("plugID", $_GET['plug']);
+        $display       = $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
+        return($display);
+      }
+    }
 
-        $baseToUse = $base;
-        if($_SESSION['faifilter']['branch']!="main"){
-          $baseToUse = $_SESSION['faifilter']['branch'];
-        }
-        
-        $ldap->cd ("ou=".$name.",".$baseToUse);
-        $ldap->recursive_remove();
-        
-        $ldap->cd ($this->config->current['BASE']);
-        $ldap->copy_FAI_resource_recursive($baseToUse,"ou=".$name.",".$baseToUse,"freeze",true);
-        
-        $this->dispNewFreeze = false; 
-        
-        /* Postcreate */ 
-
-        /* Assign possible attributes */
-        $this->lock_type  = "branch"; 
-        $this->lock_name  = $name; 
-        $this->lock_dn    = $baseToUse;
-        $this->postcreate();
+    if(isset($_GET['PerformBranch'])){
+      /* Create it know */
+      $this->dispNewBranch = false;
+      $this->dispNewFreeze = false;
+      $base = $_SESSION['LASTPOST']['base'];
+      $_POST = $_SESSION['LASTPOST'];      
+      $name = $_POST['BranchName'];
+
+      $type = $_SESSION['LASTPOST']['type'];
+
+      $ldap = $this->config->get_ldap_link();
+
+      $baseToUse = $base;
+      if($_SESSION['faifilter']['branch']!="main"){
+        $baseToUse = $_SESSION['faifilter']['branch'];
       }
+
+      $ldap->cd ("ou=".$name.",".$baseToUse);
+      $ldap->recursive_remove();
+
+      $ldap->cd ($this->config->current['BASE']);
+      $ldap->copy_FAI_resource_recursive($baseToUse,"ou=".$name.",".$baseToUse,$type,true);
+
+      $this->dispNewFreeze = false; 
+
+      /* Postcreate */ 
+
+      /* Assign possible attributes */
+      $this->lock_type  = $type; 
+      $this->lock_name  = $name; 
+      $this->lock_dn    = $baseToUse;
+      $this->postcreate();
+      exit();
+    }
+
+    if(($s_action == "branch_branch")||($this->dispNewBranch)){
+      $this->dispNewBranch=true;
+      $smarty->assign("iframe",false);
+                 $display      .= $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
+      return($display);
     }
     
     if(($s_action == "freeze_branch")||($this->dispNewFreeze)){
       $this->dispNewFreeze = true;
+      $smarty->assign("iframe",false);
                  $display      .= $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
       return($display);
     }
@@ -468,71 +453,71 @@ class faiManagement extends plugin
      */
 
     /* Dialog handling */
-               if($s_action == "new_partition"){
-                       $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIpartitionTable");
-               }
+    if($s_action == "new_partition"){
+      $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIpartitionTable");
+    }
 
-               /* Dialog handling */
-               if($s_action == "new_script"){
-                       $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIscript");
-               }
+    /* Dialog handling */
+    if($s_action == "new_script"){
+      $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIscript");
+    }
 
-               /* Dialog handling */
-               if($s_action == "new_hook"){
-                       $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIhook");
-               }
+    /* Dialog handling */
+    if($s_action == "new_hook"){
+      $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIhook");
+    }
 
-               /* Dialog handling */
-               if($s_action == "new_variable"){
-                       $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIvariable");
-               }
+    /* Dialog handling */
+    if($s_action == "new_variable"){
+      $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIvariable");
+    }
 
-               /* Dialog handling */
-               if($s_action == "new_template"){
-                       $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAItemplate");
-               }
+    /* Dialog handling */
+    if($s_action == "new_template"){
+      $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAItemplate");
+    }
 
-               /* Dialog handling */
-               if($s_action == "new_package"){
-                       $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIpackageList");
-               }
+    /* Dialog handling */
+    if($s_action == "new_package"){
+      $this->dialog = new askClassName($this->config,$this->dn,$this->ui,"FAIpackageList");
+    }
 
-               /* New Profile */
-               if($s_action == "new_profile"){
-                       $this->dn = "new" ;
-                       $a_setup= $this->get_type(array("objectClass"=>array("FAIprofile")));
+    /* New Profile */
+    if($s_action == "new_profile"){
+      $this->dn = "new" ;
+      $a_setup= $this->get_type(array("objectClass"=>array("FAIprofile")));
 
-                       $this->dialog = new $a_setup[0]($this->config,
-                                       $this->config->data['TABS'][$a_setup[2]],$this->dn);
-                       $this->is_dialog = true;
+      $this->dialog = new $a_setup[0]($this->config,
+          $this->config->data['TABS'][$a_setup[2]],$this->dn);
+      $this->is_dialog = true;
 
-               }
+    }
 
-               if($s_action == "select_class_name_finished"){
-                       $this->dialog->save_object();
-                       if(count($this->dialog->check())!=0){
-                               foreach($this->dialog->check() as $msg){
-                                       print_red($msg);
-                               }               
-                       }else{
-                               $this->dn = "new" ;
-                               $a_setup= $this->get_type(array("objectClass"=>array($this->dialog->objectClass)));
-                               $name = $this->dialog->save();
-
-                               $this->dialog = new $a_setup[0]($this->config,
-                                               $this->config->data['TABS'][$a_setup[2]],$this->dn,$name);
-                               $this->dialog->by_object[$a_setup[1]]->cn = $name;
-                               $this->is_dialog = true;
-                       }               
-               }       
-
-               /* Search is set */
-               if(isset($_GET['search'])){
-                       $faifilter['regex']=$_GET['search']."*";
-               }
+    if($s_action == "select_class_name_finished"){
+      $this->dialog->save_object();
+      if(count($this->dialog->check())!=0){
+        foreach($this->dialog->check() as $msg){
+          print_red($msg);
+        }              
+      }else{
+        $this->dn = "new" ;
+        $a_setup= $this->get_type(array("objectClass"=>array($this->dialog->objectClass)));
+        $name = $this->dialog->save();
+
+        $this->dialog = new $a_setup[0]($this->config,
+            $this->config->data['TABS'][$a_setup[2]],$this->dn,$name);
+        $this->dialog->by_object[$a_setup[1]]->cn = $name;
+        $this->is_dialog = true;
+      }                
+    }  
+
+    /* Search is set */
+    if(isset($_GET['search'])){
+      $faifilter['regex']=$_GET['search']."*";
+    }
 
-               /* Department select */
-               if((isset($_POST['base']))&&($s_action=="")){
+    /* Department select */
+    if((isset($_POST['base']))&&($s_action=="")){
                        $faifilter['base']=$_POST['base'];
                }
 
@@ -1018,10 +1003,14 @@ class faiManagement extends plugin
   function CheckNewBranchName($name,$base){
     $f = $_SESSION['faifilter']['branch'];
 
+    if(empty($name)){
+      return(false);
+    }
+
     if($f == "main"){
       $f = $_SESSION['faifilter']['base'];
     } 
-    
+  
     if(in_array($name,$this->getBranches($f))) {
       return(false);
     }
index 7d90245752ee4fdc8954ef88aff397a92f428bb3..4c42c9e841ad79fcc5506df1b2bb265f3a20003b 100755 (executable)
@@ -1,3 +1,5 @@
+{if $iframe == false}
+
 <br>
 <p class="seperator">
 {t}You are now going to create a branch or locked branch. This action clones the existing release to another release name. Branches can be modified as usual. FAI classes of locked branches cannot be modified, just additional classes are possible. Branch names should be alphanumeric, excluding the reserved names 'scripts', 'hooks', 'partitions', 'variables', 'templates' and 'fai'.{/t}
        </p>
 </div>
 
-
-
-
-
-
-
-
 <!-- Place cursor -->
 <script language="JavaScript" type="text/javascript">
        <!--
        document.mainform.BranchName.focus();
        -->
 </script>
+{else}
 
+<h2>{t}Processing requested operation, the status of this operation will be displayed in an iframe below.{/t}</h2>
 
+<div>
+<iframe src="?plug={$plugID}&PerformBranch=1" width="100%" name="status" style="height:450px;background-color:#FFFFFF;">
 
-
-
+       <p>{t}Your browser doesn't support iframes, please use this link to perform the requested operation.{/t}
+               <br>
+               <a href='?plug={$plugID}&PerformBranch=1' target="_blank" title="{t}Perform requested operation.{/t}"><b>{t}Initiate operation{/t}</b></a>
+       </p>    
+</iframe>
+</div>
+<p class="seperator">&nbsp;</p>
+<div style="text-align: right;width:99%;">
+       <p>
+               <input type="submit" name="CancelBranchName" value="{t}Back{/t}">
+       </p>
+</div>
+{/if}