Code

Added apply button
[gosa.git] / plugins / admin / fai / class_faiManagement.inc
index 32152b9cab5b6ed51cba3c94e8c8f775fb532cdc..b0b48dbbce4dfcca9730c7cdcaee1373d0cd5441 100644 (file)
@@ -353,6 +353,19 @@ class faiManagement extends plugin
       if($this->DivListFai->selectedBranch != "main" ){
         $baseToUse = $this->DivListFai->selectedBranch;
       }
+  
+      /* Create new Release name to be able to set faidebianRelease for FAIpackageList */
+      
+      $CurrentReleases  = $this->getBranches();
+      $NewReleaseName   = $name;
+      if(isset($CurrentReleases[$this->DivListFai->selectedBranch])) {
+        if($this->DivListFai->selectedBranch != "main"){
+          $NewReleaseName = $CurrentReleases[$this->DivListFai->selectedBranch]."/".$name;
+          $NewReleaseName = preg_replace("#\/#","/",$NewReleaseName); 
+        }else{
+          $NewReleaseName   = $name;
+        }
+      }
 
       $appsrc = preg_replace("/ou=fai,ou=configs,ou=systems,/","ou=apps,",$baseToUse); 
       $appdst = preg_replace("/ou=fai,ou=configs,ou=systems,/","ou=apps,","ou=".$name.",".$baseToUse) ; 
@@ -366,14 +379,14 @@ class faiManagement extends plugin
       $ldap->cd ($appdst);
       $ldap->recursive_remove();
       $ldap->cd ($this->config->current['BASE']);
-      $ldap->copy_FAI_resource_recursive($appsrc,$appdst,$type,true);
+      $ldap->copy_FAI_resource_recursive($appsrc,$appdst,$NewReleaseName,$type,true);
 
       /* Duplicate fai objects 
        */
       $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);
+      $ldap->copy_FAI_resource_recursive($baseToUse,"ou=".$name.",".$baseToUse,$NewReleaseName,$type,true);
 
       echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
               <br><input type='submit' name='CloseIFrame' value='"._("Continue")."'>
@@ -489,19 +502,22 @@ class faiManagement extends plugin
                 * If it was possible to save it, remove dialog object. 
                 * If it wasn't possible, show errors and keep dialog.
                 */
-               if((isset($_POST['edit_finish'])) && (isset($this->dialog->config))){
+               if((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->dialog->config))){
                        $this->dialog->save_object();
-                       if(count($this->dialog->check())!=0){
-                               foreach($this->dialog->check() as $msg){
+      $msgs= $this->dialog->check();
+                       if(count($msgs)!=0){
+                               foreach($msgs as $msg){
                                        print_red($msg);
                                }
                        }else{
-                               del_lock ($this->dn);
                                $this->dialog->save();
-                               unset($this->dialog);
-                               $this->dialog=NULL;
-                               $this->is_dialog=false;
-                               unset($_SESSION['objectinfo']);
+        if (!isset($_POST['edit_apply'])){
+          del_lock ($this->dn);
+          unset($this->dialog);
+          $this->dialog=NULL;
+          $this->is_dialog=false;
+          unset($_SESSION['objectinfo']);
+        }
                        }
                }
 
@@ -523,8 +539,12 @@ class faiManagement extends plugin
                                
                        }elseif(((isset($this->dialog->current))&&(!$this->dialog->by_object[$this->dialog->current]->is_dialog))){
                                $display.= "<p style=\"text-align:right\">\n";
-                               $display.= "<input type=\"submit\" name=\"edit_finish\" value=\""._("Save")."\">\n";
+                               $display.= "<input type=\"submit\" name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
                                $display.= "&nbsp;\n";
+        if ($this->dn != "new"){
+          $display.= "<input type=submit name=\"edit_apply\" value=\""._("Apply")."\">\n";
+          $display.= "&nbsp;\n";
+        }
                                $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
                                $display.= "</p>";
                        }elseif(!isset($this->dialog->current)){
@@ -542,6 +562,7 @@ class faiManagement extends plugin
      ****************/
 
     /* Display dialog with system list */
+    $this->DivListFai->parent = $this;
     $this->DivListFai->execute();
     $this->DivListFai->AddDepartments($this->DivListFai->selectedBase,4);
     $this->reload();
@@ -705,7 +726,7 @@ class faiManagement extends plugin
       return(false);
     }elseif(empty($name)){
       return(false);
-    }elseif(in_array($name,array("fai","disk","packages","scripts","templates","hooks","variables","profiles","apps"))){
+    }elseif(is_department_name_reserved($name,$base)){
       return(false);
     }
     return(true);