Code

Updated preg_matches
[gosa.git] / plugins / admin / fai / class_faiProfile.inc
index 1b11447e4dd890d3e6632f3c52c0c9e3993c73cd..2df7bac2f60a375b3a7b04a9f85e786a6738f9ea 100644 (file)
@@ -34,6 +34,7 @@ class faiProfile extends plugin
   var $base           = "";
   var $release        = "";
   var $copy_paste_mode= false;
+  var $cut_paste_mode = false;
 
   var $CopyPasteVars  = array("FAIclass","FAIclasses","FAIAllclasses","FAIstate");
 
@@ -388,7 +389,7 @@ class faiProfile extends plugin
     if($this->copy_paste_mode){
 
       /* 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=profiles,".$this->release;
@@ -442,6 +443,11 @@ class faiProfile extends plugin
 
     $this->attrs['FAIclass']=trim($this->FAIclass);
 
+    /* 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*/
@@ -461,6 +467,29 @@ class faiProfile extends plugin
     $this->handle_object_tagging();
     show_ldap_error($ldap->get_error());
   }
+
+  
+  /* 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: