From 2035e2a950fe9abbde29e820ef80bcf2cf483e88 Mon Sep 17 00:00:00 2001 From: hickert Date: Mon, 11 May 2009 07:44:29 +0000 Subject: [PATCH] Keep PPD server path when editing ppd options. - Tunneling GOsa via ssh and editing printers led into broken gotoPrinterPdd entries. - Fixed error when removing and adding ppds. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13643 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../admin/systems/goto/class_printGeneric.inc | 72 ++++++++++++++----- .../goto/admin/systems/goto/printer.tpl | 13 +++- 2 files changed, 66 insertions(+), 19 deletions(-) diff --git a/gosa-plugins/goto/admin/systems/goto/class_printGeneric.inc b/gosa-plugins/goto/admin/systems/goto/class_printGeneric.inc index 377f6c4b1..88bc20956 100644 --- a/gosa-plugins/goto/admin/systems/goto/class_printGeneric.inc +++ b/gosa-plugins/goto/admin/systems/goto/class_printGeneric.inc @@ -26,6 +26,8 @@ class printgeneric extends plugin var $AdminMembers =array(); var $AdminMemberKeys =array(); + var $ppdServerPart = ""; + var $PPDdialogToSave = NULL; var $BelongsTo = "unknown"; // Specifies if this is a standalone printer, or belongs to a terminal / WS @@ -108,6 +110,28 @@ class printgeneric extends plugin } } + /* If no ppd is selected, remove this attribute */ + if(!empty($this->gotoPrinterPPD) && $this->initially_was_account) { + $this->ppdServerPart = preg_replace("/^(http.*ppd)\/.*$/i","\\1",$this->gotoPrinterPPD); + }else{ + + /* Detect PPD server part */ + if(preg_match("/https/i",$_SERVER['HTTP_REFERER'])){ + $method="https://"; + }else{ + $method="http://"; + } + + /* Get servername */ + $server = $_SERVER['SERVER_NAME']; + if(tests::is_ip($server)){ + $server_name = @gethostbyaddr($server); + }else{ + $server_name = @gethostbyaddr(gethostbyname($server)); + } + $this->ppdServerPart = $method.str_replace("//","/",$server_name."/ppd"); + } + /* Extract selected ppd */ if(isset($this->gotoPrinterPPD)){ $this->gotoPrinterPPD = preg_replace("/^http.*ppd\//i","",$this->gotoPrinterPPD); @@ -254,7 +278,6 @@ class printgeneric extends plugin new log("view","printer/".get_class($this),$this->dn); } - /* If type of printer couldn't be detected (because of missing parent object in construction) * hide this tab. */ @@ -410,13 +433,33 @@ class printgeneric extends plugin if($this->PPDdialogToSave && is_object($this->PPDdialogToSave)){ $this->dialog = $this->PPDdialogToSave; }else{ - $this->dialog = new printerPPDDialog($this->config, $this->dn,$this->gotoPrinterPPD); + + if(is_array($this->gotoPrinterPPD)){ + $this->dialog = new printerPPDDialog($this->config, $this->dn,""); + }else{ + $this->dialog = new printerPPDDialog($this->config, $this->dn,$this->gotoPrinterPPD); + } $this->dialog->cn= $this->cn; } } /* remove ppd */ if(isset($_POST['RemoveDriver'])){ + /* Detect PPD server part */ + if(preg_match("/https/i",$_SERVER['HTTP_REFERER'])){ + $method="https://"; + }else{ + $method="http://"; + } + + /* Get servername */ + $server = $_SERVER['SERVER_NAME']; + if(tests::is_ip($server)){ + $server_name = @gethostbyaddr($server); + }else{ + $server_name = @gethostbyaddr(gethostbyname($server)); + } + $this->ppdServerPart = $method.str_replace("//","/",$server_name."/ppd"); $this->gotoPrinterPPD = array(); $this->PPDdialogToSave = NULL; } @@ -508,6 +551,7 @@ class printgeneric extends plugin } $ppdManager= new ppdManager($path); + $smarty->assign("displayServerPath",true); 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).""); @@ -517,10 +561,14 @@ class printgeneric extends plugin } }else{ $smarty->assign("driverInfo", _("Not defined")); + $smarty->assign("displayServerPath",false); } }else{ $smarty->assign("driverInfo",_("Can't get ppd informations.")); + $smarty->assign("displayServerPath",true); } + $smarty->assign("ppdServerPart",$this->ppdServerPart); + /* Create user & admin user list */ $list=$this->generateList(); @@ -631,6 +679,10 @@ class printgeneric extends plugin plugin::save_object(); $this->base = $base_tmp; + if(isset($_POST['ppdServerPart'])){ + $this->ppdServerPart = get_post('ppdServerPart'); + } + if(is_object($this->netConfigDNS)){ $this->netConfigDNS->save_object(); } @@ -770,23 +822,9 @@ class printgeneric extends plugin } } - if(preg_match("/https/i",$_SERVER['HTTP_REFERER'])){ - $method="https://"; - }else{ - $method="http://"; - } - - /* Get servername */ - $server = $_SERVER['SERVER_NAME']; - if(tests::is_ip($server)){ - $server_name = gethostbyaddr($server); - }else{ - $server_name = gethostbyaddr(gethostbyname($server)); - } - /* If no ppd is selected, remove this attribute */ if(!empty($this->gotoPrinterPPD) && $this->initially_was_account) { - $this->gotoPrinterPPD = $method.str_replace("//","/",$server_name."/ppd/".$this->gotoPrinterPPD); + $this->gotoPrinterPPD = $this->ppdServerPart.'/'.$this->gotoPrinterPPD; }else{ $this->gotoPrinterPPD = array(); } diff --git a/gosa-plugins/goto/admin/systems/goto/printer.tpl b/gosa-plugins/goto/admin/systems/goto/printer.tpl index 25de9728c..f8622bc58 100644 --- a/gosa-plugins/goto/admin/systems/goto/printer.tpl +++ b/gosa-plugins/goto/admin/systems/goto/printer.tpl @@ -46,7 +46,7 @@ {render acl=$lACL} - + {/render} @@ -54,10 +54,19 @@ {$must} {render acl=$labeledURIACL} - + {/render} +{if $displayServerPath && 0} + + {t}PPD Provider{/t} + + + + + +{/if} -- 2.30.2