Code

Added check to prevent overwriting existing sub entries of fai object
[gosa.git] / plugins / admin / fai / class_faiVariable.inc
index 83027c7dfb31307909ea6a1e6dc6f0bb4b2bccca..171ad312d99130b3a8d5beb0ca07efbd7d3adb0f 100644 (file)
@@ -2,11 +2,6 @@
 
 class faiVariable extends plugin
 {
-  /* CLI vars */
-  var $cli_summary      = "Manage server basic objects";
-  var $cli_description  = "Some longer text\nfor help";
-  var $cli_parameters   = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
   /* attribute list for save action */
   var $ignore_account   = TRUE;
 
@@ -38,8 +33,9 @@ class faiVariable extends plugin
   var $base             = "";
   var $release          = "";
   var $copy_paste_mode  = false;
+  var $cut_paste_mode   = false;
 
-  var $CopyPasteVars  = array("SubObjects","FAIstate");
+  var $CopyPasteVars  = array("SubObjects");
 
   function faiVariable ($config, $dn= NULL)
   {
@@ -107,8 +103,9 @@ class faiVariable extends plugin
 
     /* Add new sub object */
     if(isset($_POST['AddSubObject'])){
-      $this->dialog= new $this->subClassName($this->config,"new");
-      $this->dialog->acl = $this->acl;
+      $this->dialog         = new $this->subClassName($this->config,"new");
+      $this->dialog->acl    = $this->acl;
+      $this->dialog->parent = $this;
       $this->is_dialog=true;
     }
 
@@ -123,6 +120,7 @@ class faiVariable extends plugin
       $var = $_POST['SubObject'][0];
       $this->dialog= new $this->subClassName($this->config,$this->dn,$this->SubObjects[$var]);
       $this->dialog->acl = $this->acl;
+      $this->dialog->parent = $this;
       $_SESSION['objectinfo'] = $this->SubObjects[$var]['dn'];
       $this->is_dialog=true;
     }
@@ -272,7 +270,7 @@ class faiVariable extends plugin
     $message= plugin::check();
 
     /* If this is a new script, check if a script with this name already exists */
-    if(!empty($this->release) && $this->copy_paste_mode){
+    if(!empty($this->release) && ($this->copy_paste_mode || $this->cut_paste_mode) ){
 
       /* Check if current name is already used for fai scripts in selected release */
       $dn = 'cn='.$this->cn.",ou=variables,".$this->release;
@@ -405,6 +403,28 @@ class faiVariable extends plugin
       $this->handle_object_tagging($sub_dn, $this->gosaUnitTag);
     }
   }
+  
+  /* return copy & paste dialog
+   */
+  function getCopyDialog()
+  {
+    /* Ask for cn */
+    $smarty = get_smarty();
+    $smarty->assign("cn" ,$this->cn);
+    $str = $smarty->fetch(get_template_path("paste_fai_object.tpl",TRUE));
+    $ret = array();
+    $ret['string'] = $str;
+    $ret['status'] = "";
+    return($ret);
+  }
+
+  /* Get posted cn */
+  function saveCopyDialog()
+  {
+    if(isset($_POST['cn'])){
+      $this->cn = $_POST['cn'];
+    }
+  }
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: