From: psc Date: Wed, 10 Jun 2009 13:32:57 +0000 (+0000) Subject: Apply patch by mba for Trac #2634 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=79e761b50e596ac6fe45d7a84c77b4f6c2cfd2ef;p=gosa.git Apply patch by mba for Trac #2634 - Show a message if a printer has been created on a different server, to warn the user. - Do not simply overwrite ppd URI when editting a printer, that has been created on a different server. git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@13703 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/trunk/gosa-plugins/goto/admin/systems/goto/class_printGeneric.inc b/trunk/gosa-plugins/goto/admin/systems/goto/class_printGeneric.inc index b907bd983..dabefb6f7 100644 --- a/trunk/gosa-plugins/goto/admin/systems/goto/class_printGeneric.inc +++ b/trunk/gosa-plugins/goto/admin/systems/goto/class_printGeneric.inc @@ -14,6 +14,7 @@ class printgeneric extends plugin var $labeledURI = ""; var $gotoPrinterPPD = ""; var $initial_PPD = ""; + var $initial_PPD_URL = ""; var $orig_dn = ""; var $orig_cn = ""; var $orig_base = ""; @@ -108,6 +109,7 @@ class printgeneric extends plugin } } + $this->initial_PPD_URL = $this->gotoPrinterPPD; /* Extract selected ppd */ if(isset($this->gotoPrinterPPD)){ $this->gotoPrinterPPD = preg_replace("/^http.*ppd\//i","",$this->gotoPrinterPPD); @@ -410,6 +412,7 @@ class printgeneric extends plugin if($this->PPDdialogToSave && is_object($this->PPDdialogToSave)){ $this->dialog = $this->PPDdialogToSave; }else{ + $this->initial_PPD_URL = ""; $this->dialog = new printerPPDDialog($this->config, $this->dn,$this->gotoPrinterPPD); $this->dialog->cn= $this->cn; } @@ -499,6 +502,24 @@ class printgeneric extends plugin return $display; } + /* Get servername */ + $server = $_SERVER['SERVER_NAME']; + if(tests::is_ip($server)){ + $server_name = gethostbyaddr($server); + }else{ + $server_name = gethostbyaddr(gethostbyname($server)); + } + $orig_server_name = ""; + if ($this->initial_PPD_URL != "") { + $ppd_server = preg_replace("/^http.*:../i","",$this->initial_PPD_URL); + $ppd_server = preg_replace("/\/.*/i","",$ppd_server); + if(tests::is_ip($ppd_server)){ + $orig_server_name = gethostbyaddr($ppd_server); + }else{ + $orig_server_name = gethostbyaddr(gethostbyname($ppd_server)); + } + } + /* Parse selected ppd file */ $config = session::get('config'); if ($config->get_cfg_value("ppdPath") != ""){ @@ -509,11 +530,15 @@ class printgeneric extends plugin $ppdManager= new ppdManager($path); if(!empty($this->gotoPrinterPPD)){ - if((!file_exists($path.$this->gotoPrinterPPD))){ - $smarty->assign("driverInfo", "".sprintf(_("Your currently selected PPD file '%s' doesn't exist."),$path.$this->gotoPrinterPPD).""); + if($orig_server_name != "" && $server_name != $orig_server_name) { + $smarty->assign("driverInfo", "".sprintf(_("Printer got configured on remote server '%s', Editing Driver will overwrite settings."),$orig_server_name).""); }else{ - $ppdDesc = $ppdManager->loadDescription($path.$this->gotoPrinterPPD); - $smarty->assign("driverInfo", $ppdDesc['name']); + if((!file_exists($path.$this->gotoPrinterPPD))){ + $smarty->assign("driverInfo", "".sprintf(_("Your currently selected PPD file '%s' doesn't exist."),$path.$this->gotoPrinterPPD).""); + }else{ + $ppdDesc = $ppdManager->loadDescription($path.$this->gotoPrinterPPD); + $smarty->assign("driverInfo", $ppdDesc['name']); + } } }else{ $smarty->assign("driverInfo", _("Not defined")); @@ -786,7 +811,16 @@ class printgeneric extends plugin /* If no ppd is selected, remove this attribute */ if(!empty($this->gotoPrinterPPD)) { - $this->gotoPrinterPPD = $method.str_replace("//","/",$server_name."/ppd/".$this->gotoPrinterPPD); + if (($this->gotoPrinterPPD != $this->initial_PPD) || ($this->initial_PPD_URL == "")) { + /* PPD has changed, update it */ + if (!preg_match('/^http[s]+:\/\/.*/', $this->gotoPrinterPPD)) { + /* ppd is not an url */ + $this->gotoPrinterPPD = $method.str_replace("//","/",$server_name."/ppd/".$this->gotoPrinterPPD); + } + } else { + /* Restore original PPD URL */ + $this->gotoPrinterPPD = $this->initial_PPD_URL; + } }else{ $this->gotoPrinterPPD = array(); }