Code

Fixed department list
[gosa.git] / plugins / admin / fai / class_faiVariable.inc
index 4b10b70e4f2bf530972723bbfcc380834705ca8f..4e51ef8402784bcbe997faf42a119501c3800899 100644 (file)
@@ -38,6 +38,9 @@ class faiVariable extends plugin
   var $base             = "";
   var $release          = "";
   var $copy_paste_mode  = false;
+  var $cut_paste_mode   = false;
+
+  var $CopyPasteVars  = array("SubObjects");
 
   function faiVariable ($config, $dn= NULL)
   {
@@ -270,7 +273,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;
@@ -292,7 +295,12 @@ class faiVariable extends plugin
     plugin::save();
  
     $ldap = $this->config->get_ldap_link();
-  
+    /* Copy & Paste : Ensure that FAIstate is copied too */
+    if($this->copy_paste_mode && preg_match("/freeze/",$this->FAIstate)){
+      $this->attrs['FAIstate'] = $this->FAIstate;
+    }
     $ldap->cat($this->dn,array("objectClass"));
     if($ldap->count()!=0){
       /* Write FAIscript to ldap*/
@@ -347,6 +355,10 @@ class faiVariable extends plugin
 
       $sub_dn = "cn=".$obj['cn'].",".$this->dn;
 
+      if($this->copy_paste_mode){
+        $obj['status'] = "new";
+      }
+
       if($obj['status']=="new"){
         $ldap->cat($sub_dn,array("objectClass"));
         if($ldap->count()){
@@ -394,6 +406,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: