Code

Updated preg_matches
[gosa.git] / plugins / admin / fai / class_faiTemplate.inc
index 0ef911b09a230b1983e0ee2831fc15c863da6bf0..cb74de6b9202322bab3f9028c7af315bb3d79434 100644 (file)
@@ -40,6 +40,7 @@ class faiTemplate extends plugin
   var $base             = "";
   var $release          = "";
   var $copy_paste_mode  = false;
+  var $cut_paste_mode   = false;
 
   var $CopyPasteVars  = array("SubObjects","FAIstate");
 
@@ -344,7 +345,7 @@ class faiTemplate 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=templates,".$this->release;
@@ -464,12 +465,12 @@ class faiTemplate extends plugin
         $ldap->cd($sub_dn);
         $ldap->rmdir_recursive($sub_dn);
         $this->handle_post_events("remove");
-        show_ldap_error($ldap->get_error(), _("Removing FAI template base failed")); 
+        show_ldap_error($ldap->get_error(), _("Removing FAI template entry failed")); 
       }elseif($obj['status'] == "edited"){
         $ldap->cd($sub_dn);
         $this->cleanup();
         $ldap->modify ($tmp); 
-        show_ldap_error($ldap->get_error(), _("Saving FAI template failed")); 
+        show_ldap_error($ldap->get_error(), _("Modifying FAI template entry failed")); 
 
         $this->handle_post_events("modify");
       }elseif($obj['status']=="new"){
@@ -482,12 +483,34 @@ class faiTemplate extends plugin
         $ldap->cd($sub_dn);
         $ldap->add($tmp); 
         $this->handle_post_events("add");
-        show_ldap_error($ldap->get_error(), _("Saving FAI template failed")); 
+        show_ldap_error($ldap->get_error(), _("Creating FAI template entry failed")); 
       }
 
       $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: