Code

Remove old ppd configuration file if printer is removed, or ppd has changed
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 1 Dec 2006 07:17:20 +0000 (07:17 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 1 Dec 2006 07:17:20 +0000 (07:17 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@5280 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_printGeneric.inc
plugins/admin/systems/class_printerPPDDialog.inc

index b38825df345393e46dc97c807b443f67d8d114a6..18a936bbf47345835d89e708adf7052ea0e7901a 100644 (file)
@@ -18,6 +18,7 @@ class printgeneric extends plugin
   var $description      = "";
   var $labeledURI       = "";
   var $gotoPrinterPPD   = "";
+  var $initial_PPD      = "";
   var $orig_dn          = "";
 
   var $UserMember       ="";
@@ -115,6 +116,8 @@ class printgeneric extends plugin
       $this->gotoPrinterPPD = preg_replace("/^http.*ppd\//i","",$this->gotoPrinterPPD);
     }
 
+    $this->initial_PPD = $this->gotoPrinterPPD;
+
     /* Prepare different member types */ 
     foreach(array("AddUser"       =>"gotoUserPrinter",
           "AddGroup"      =>"gotoGroupPrinter",
@@ -574,6 +577,12 @@ class printgeneric extends plugin
         unset($og->member[$this->dn]);
         $og->save ();
       }
+
+      /* Remove previously selected ppd file.*/
+      if(!empty($this->initial_PPD)){
+        $tmp = new printerPPDDialog($this->config, $this->dn,$this->initial_PPD);
+        $tmp->removeModifiedPPD();
+      }
     }
   }
 
@@ -686,6 +695,14 @@ class printgeneric extends plugin
       $this->PPDdialogToSave->save_ppd();
     }
 
+    /* Remove previously selected ppd file.*/
+    if($this->initial_PPD != $this->gotoPrinterPPD){
+      if(!empty($this->initial_PPD)){
+        $tmp = new printerPPDDialog($this->config, $this->dn,$this->initial_PPD);
+        $tmp->removeModifiedPPD();
+      }
+    }
+
     if(preg_match("/https/i",$_SERVER['HTTP_REFERER'])){
       $method="https://";
     }else{
index 9296afe61985cfcd1585baae1e9ef623dcdb16c7..fd041b762aad8eed5f15933145a9b86a4de6b269 100644 (file)
@@ -477,6 +477,23 @@ class printerPPDDialog extends plugin
     }
     return($str);
   }
+
+  function removeModifiedPPD()
+  {
+    $path = $this->pathToPPD.$this->pathToModified.$this->selectedPPD['link'];
+
+    if(file_exists($path)){
+      if(is_writeable($path)){
+        if(!@unlink($path)){
+          print_red(sprintf(_("Removing old ppd file '%s' failed."),$path));
+        }
+      }else{
+        print_red(sprintf(_("Removing old ppd file '%s' failed. File is not accessible."),$path));
+      }
+    }else{
+      print_red(sprintf(_("Removing old ppd file '%s' failed. File does not exists or is not accessible."),$path));
+    }
+  }
   
   function check()
   {