Code

Keep PPD server path when editing ppd options.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 11 May 2009 07:44:29 +0000 (07:44 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 11 May 2009 07:44:29 +0000 (07:44 +0000)
- 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

gosa-plugins/goto/admin/systems/goto/class_printGeneric.inc
gosa-plugins/goto/admin/systems/goto/printer.tpl

index 377f6c4b1c5029e83c90211e85d3f3ceac232bd4..88bc20956e3b83dab580e5695caf8715bb8e8009 100644 (file)
@@ -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", "<b>".sprintf(_("Your currently selected PPD file '%s' doesn't exist."),$path.$this->gotoPrinterPPD)."</b>");
@@ -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();
     }
index 25de9728cc68d2b1ec0a493349f5b6bdf9fb0d2c..f8622bc58fb63991ca6c29bf69b604a2b5f186ba 100644 (file)
@@ -46,7 +46,7 @@
        <td><LABEL for="l">{t}Printer location{/t}</LABEL></td>
        <td>
 {render acl=$lACL}
-        <input id="l" name="l" size=25 maxlength=80 value="{$l}">
+        <input id="l" name="l" size=30 maxlength=80 value="{$l}">
 {/render}
        </td>
      </tr>
        <td><LABEL for="labeledURI">{t}Printer URL{/t}</LABEL>{$must}</td>
        <td>
 {render acl=$labeledURIACL}
-        <input id="labeledURI" name="labeledURI" size=25 maxlength=80 value="{$labeledURI}">
+        <input id="labeledURI" name="labeledURI" size=30 maxlength=80 value="{$labeledURI}">
 {/render}
        </td>
      </tr>
+{if $displayServerPath && 0}
+    <tr>
+     <td>{t}PPD Provider{/t}
+     </td>
+     <td>
+      <input size=30 type='text' value='{$ppdServerPart}' name='ppdServerPart'>
+     </td>
+    </tr>
+{/if}
    </table>
    <table summary="">
     <tr>