From: hickert Date: Fri, 1 Dec 2006 07:17:20 +0000 (+0000) Subject: Remove old ppd configuration file if printer is removed, or ppd has changed X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=5535f08eb25977f40ade7520313c97166d0e4e03;p=gosa.git Remove old ppd configuration file if printer is removed, or ppd has changed git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@5280 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/systems/class_printGeneric.inc b/plugins/admin/systems/class_printGeneric.inc index b38825df3..18a936bbf 100644 --- a/plugins/admin/systems/class_printGeneric.inc +++ b/plugins/admin/systems/class_printGeneric.inc @@ -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{ diff --git a/plugins/admin/systems/class_printerPPDDialog.inc b/plugins/admin/systems/class_printerPPDDialog.inc index 9296afe61..fd041b762 100644 --- a/plugins/admin/systems/class_printerPPDDialog.inc +++ b/plugins/admin/systems/class_printerPPDDialog.inc @@ -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() {