Code

Use binary operator instead of boolean
[gosa.git] / plugins / admin / fai / class_faiPartitionTable.inc
index f5ca9f7b1ec3568fbdfc860c86543c8293db9232..96b4adc2201e1acf5a6b0ddc52b01fd1c30a531c 100644 (file)
@@ -23,6 +23,9 @@ class faiPartitionTable extends plugin
   var $base             = "";
   var $release          = "";
   var $copy_paste_mode  = false;
+  var $cut_paste_mode  = false;
+
+  var $CopyPasteVars  = array("disks");
 
   function faiPartitionTable ($config, $dn= NULL)
   {
@@ -320,7 +323,7 @@ class faiPartitionTable 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=disk,".$this->release;
@@ -347,6 +350,11 @@ class faiPartitionTable extends plugin
      * 3 : Save partitions for each disk
      */  
 
+    /* Copy & Paste : Ensure that FAIstate is copied too */
+    if($this->copy_paste_mode && preg_match("/freeze/",$this->FAIstate)){
+      $this->attrs['FAIstate'] = $this->FAIstate;
+    }
+
     $ldap = $this->config->get_ldap_link();
 
     if($this->new){
@@ -386,6 +394,11 @@ class faiPartitionTable extends plugin
       $disk_attrs['description']  =  $disk['description']; 
       $disk_attrs['objectClass']  =  array("top","FAIclass","FAIpartitionDisk");
 
+      /* We currently use the copy & paste method */
+      if($this->copy_paste_mode){
+        $disk['status'] = "new";
+      }
+
       if($disk['status']=="new"){
         $ldap->cat($disk_dn,array("objectClass"));
         if($ldap->count()){
@@ -399,7 +412,7 @@ class faiPartitionTable extends plugin
       if(isset($attrs['objectClass']) && in_array_ics("gosaAdministrativeUnitTag",$attrs['objectClass'])){
         $disk_attrs['objectClass'][] = "gosaAdministrativeUnitTag";
       }
+
       if($disk['status'] == "delete"){
         $ldap->cd($disk_dn);
         $ldap->rmdir_recursive($disk_dn);
@@ -456,6 +469,11 @@ class faiPartitionTable extends plugin
           unset($partition_attrs['status']);
           unset($partition_attrs['old_cn']);
 
+          /* We currently use the copy & paste method */
+          if($this->copy_paste_mode){
+            $partition['status']="new";
+          }
+
           /* Check if this partition is realy new .. */
           if($partition['status']=="new"){
             $ldap->cat($partition_dn,array("objectClass"));
@@ -523,6 +541,29 @@ class faiPartitionTable extends plugin
     }
     $this->handle_post_events("add");
   }
+
+  
+  /* 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: