Code

Removed duplicated addslashes
[gosa.git] / plugins / admin / fai / class_faiManagement.inc
index 990e43dd368793404873d3ee4defbe5851cad1df..cc71020a27a0d30fcf7e6a6ffbe9e4af4d1dad3c 100644 (file)
@@ -388,22 +388,28 @@ class faiManagement extends plugin
 
       /* Duplicate applications 
        */
-      $ldap->cd ($appdst);
-      $ldap->recursive_remove();
-      $ldap->cd ($this->config->current['BASE']);
-      $ldap->copy_FAI_resource_recursive($appsrc,$appdst,$NewReleaseName,$type,true);
-
+      $ldap->cat($appsrc,array("dn")) ;
+      if($ldap->count()){
+        $ldap->cd ($appdst);
+        $ldap->recursive_remove();
+        $ldap->cd ($this->config->current['BASE']);
+        $ldap->copy_FAI_resource_recursive($appsrc,$appdst,$NewReleaseName,$type,true);
+      }
+  
       /* Duplicate mime types 
        */
-      $ldap->cd ($appdst);
-      $ldap->recursive_remove();
-      $ldap->cd ($this->config->current['BASE']);
-      $ldap->copy_FAI_resource_recursive($mimesrc,$mimedst,$NewReleaseName,$type,true);
-
+      $ldap->cat($mimesrc,array("dn")) ;
+      if($ldap->count()){
+        $ldap->cd ($appdst);
+        $ldap->recursive_remove();
+        $ldap->cd ($this->config->current['BASE']);
+        $ldap->copy_FAI_resource_recursive($mimesrc,$mimedst,$NewReleaseName,$type,true);
+      }
 
       $attr = array();
       $attr['objectClass'] = array("organizationalUnit","FAIbranch");
-      $attr['ou'] = $name;
+      $attr['ou']       = $name;
+      $attr['FAIstate'] = $type;
       $ldap->cd($this->config->current['BASE']);
       $ldap->cd("ou=".$name.",".$baseToUse);
       $ldap->cat("ou=".$name.",".$baseToUse);
@@ -486,7 +492,7 @@ class faiManagement extends plugin
 
       $this->dialog = new $a_setup[0]($this->config,
           $this->config->data['TABS'][$a_setup[2]],$this->dn);
-      $this->is_dialog = true;
+      $this->is_dialog = false;
     }
 
 
@@ -568,25 +574,36 @@ class faiManagement extends plugin
                if(($this->dialog != NULL) && (isset($this->dialog->config))){
                        $display .= $this->dialog->execute();
                        /* Don't show buttons if tab dialog requests this */
-                       if (((isset($this->dialog->current))&&($this->dialog->by_object[$this->dialog->current]->is_dialog))){
-                               
-                       }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\" style=\"width:80px\" value=\""._("Ok")."\">\n";
-                               $display.= "&nbsp;\n";
-        if ($this->dn != "new"){
-          $display.= "<input type=submit name=\"edit_apply\" value=\""._("Apply")."\">\n";
+
+      if(isset($this->dialog->current)){
+
+        $obj = $this->dialog->by_object[$this->dialog->current];
+
+        if((isset($obj->is_dialog) && (!$obj->is_dialog)) || (isset($obj->dialog) && (!$obj->dialog))){
+
+          $display.= "<p style=\"text-align:right\">\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)){
+          $display.= "<p style=\"text-align:right\">\n";
+          $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\">&nbsp;";
+          $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
+          $display.= "</p>";
         }
-                               $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
-                               $display.= "</p>";
-                       }elseif(!isset($this->dialog->current)){
-                               $display.= "<p style=\"text-align:right\">\n";
-                               $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\">&nbsp;";
-                               $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
-                               $display.= "</p>";
-                       }
-                       return($display);
+      }else{
+        $display.= "<p style=\"text-align:right\">\n";
+        $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\">&nbsp;";
+        $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
+        $display.= "</p>";
+
+      }
+      return($display);
                }
                
 
@@ -632,16 +649,12 @@ class faiManagement extends plugin
     $ret = array("main"=>"/");
     $ldap = $this->config->get_ldap_link();
     if(!$base){
-      $base= "ou=fai,ou=configs,ou=systems,".$_SESSION['CurrentMainBase'];
+      $base= $_SESSION['CurrentMainBase'];
     }
-    $ldap->ls("(objectClass=FAIbranch)",$base);
-    while($attrs = $ldap->fetch()){
-      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]."/"));
-      }
+    $tmp = get_all_releases_from_base($base,true);
+    foreach($tmp as $dn => $name){
+      $ret[$dn]=$name;
     }
-
     return ($ret);
   }
 
@@ -666,6 +679,8 @@ class faiManagement extends plugin
       }
     }
 
+    $this->lock_type = get_release_tag(get_release_dn($base));
+
     /* Get resolved release dependencies */
     $tmp = get_all_objects_for_given_base($base,"(&(|(objectClass=FAIpartitionTable)(objectClass=FAIpackageList)(objectClass=FAIscript)
       (objectClass=FAIvariable)(objectClass=FAIhook)(objectClass=FAIprofile)(objectClass=FAItemplate))(cn=$Regex))");
@@ -708,6 +723,7 @@ class faiManagement extends plugin
           }
 
           /* Clean up object informations */
+          $obj                  = array();
           $obj['cn']                         = $object['cn'][0];
           $obj['dn']                         = $object['dn'];
           $obj['description']   = $object['description'][0];
@@ -716,28 +732,18 @@ class faiManagement extends plugin
           /* Append type to this string, to be able to check if the selected 
            * entry is of type 'freeze' or 'branch'
            */
-          if(isset($object['FAIstate'])){
-            $obj['FAIstate'] = $object['FAIstate'][0];
-            $str.="|".$obj['FAIstate'];
+          if(!isset($object['FAIstate'])){
+            $obj['FAIstate'] = $this->lock_type;
           }else{
-            $obj['FAIstate'] ="";
+            $obj['FAIstate'] = $object['FAIstate'][0]; 
           }
+
           $this->objects[strtolower($obj['cn']).$obj['cn'].$type] = $obj;
           $this->objects[strtolower($obj['cn']).$obj['cn'].$type]['type']=$type;
         }
                        }
                }
 
-    /* Tell class what we have currently opened 
-        'main' has type '' */
-    if(preg_match("/freeze/",$str)){
-      $this->lock_type = "freeze";
-    }elseif(preg_match("/branch/",$str)){
-      $this->lock_type = "branch";
-    }else{
-      $this->lock_type = "";
-    }
-
                ksort($this->objects);
                reset ($this->objects);
        
@@ -785,12 +791,10 @@ class faiManagement extends plugin
   function CheckNewBranchName($name,$base)
   {
     $f = $this->DivListFai->selectedBranch;
-    if(empty($name)){
+    if($name == ""){
       return(false);
     }elseif(in_array($name,$this->getBranches($f))) {
       return(false);
-    }elseif(empty($name)){
-      return(false);
     }elseif(is_department_name_reserved($name,$base)){
       return(false);
     }
@@ -802,6 +806,21 @@ class faiManagement extends plugin
     $this->DivListFai->save_object();
   }
 
+
+  /* Return plugin informations for acl handling */ 
+  function plInfo()
+  {
+    return (array( 
+          "plShortName"   => _("Management"),
+          "plDescription" => _("FAI management"),
+          "plSelfModify"  => FALSE,
+          "plDepends"     => array(),
+          "plPriority"    => 0,
+          "plSection"     => array("administration"),           
+          "plCategory"    => array("fai"=> array("description" => _("FAI"),
+                                                 "objectClass" => "FAIclass")),
+          "plProvidedAcls"=> array()));
+  }
 }
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>