X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fadmin%2Fsystems%2Fclass_printGeneric.inc;h=b38825df345393e46dc97c807b443f67d8d114a6;hb=b8358a5412b082ef08c36c441a85a4a651d84f7a;hp=cc57c88fad2638ebd49c0f83a1ec0b2a62be2866;hpb=ae440e33ff13896a6e847c6597dd8a72a1af0957;p=gosa.git diff --git a/plugins/admin/systems/class_printGeneric.inc b/plugins/admin/systems/class_printGeneric.inc index cc57c88fa..b38825df3 100644 --- a/plugins/admin/systems/class_printGeneric.inc +++ b/plugins/admin/systems/class_printGeneric.inc @@ -64,11 +64,11 @@ class printgeneric extends plugin } /* Update dn, to ensure storing as printer instead of WS / terminal */ - if($this->BelongsTo == "Terminal"){ + if($this->BelongsTo == "Terminal" || $this->BelongsTo == "TerminalTemplate"){ $this->dn= preg_replace("/ou=terminals,/","ou=printers,",$this->dn); } - if($this->BelongsTo == "Workstation"){ + if($this->BelongsTo == "Workstation" || $this->BelongsTo == "WorkstationTemplate"){ $this->dn= preg_replace("/ou=workstations,/","ou=printers,",$this->dn); } @@ -686,6 +686,19 @@ class printgeneric extends plugin $this->PPDdialogToSave->save_ppd(); } + if(preg_match("/https/i",$_SERVER['HTTP_REFERER'])){ + $method="https://"; + }else{ + $method="http://"; + } + + /* If no ppd is selected, remove this attribute */ + if(!empty($this->gotoPrinterPPD)) { + $this->gotoPrinterPPD = $method.str_replace("//","/",$_SERVER['SERVER_NAME']."/ppd/".$this->gotoPrinterPPD); + }else{ + $this->gotoPrinterPPD = array(); + } + $dn= $this->dn; plugin::save(); $ldap= $this->config->get_ldap_link(); @@ -705,20 +718,6 @@ class printgeneric extends plugin $this->attrs= $attrs; } - if(preg_match("/https/i",$_SERVER['HTTP_REFERER'])){ - $method="https://"; - }else{ - $method="http://"; - } - - /* Only save ppd path, if the path is not empty (no ppd selected )*/ - if(!empty($this->gotoPrinterPPD)) { - $this->attrs['gotoPrinterPPD'] = $method.str_replace("//","/",$_SERVER['SERVER_NAME']."/ppd/".$this->gotoPrinterPPD); - }else{ - $this->attrs['gotoPrinterPPD'] = array(); - } - - /* Append printer user */ $this->attrs['gotoUserPrinter']=array(); @@ -759,12 +758,25 @@ class printgeneric extends plugin } } + /* Ensure to create a new object */ + if(preg_match("/ou=incoming,/",$this->orig_dn)){ + $this->orig_dn = "new"; + } + /* Write back to ldap */ $ldap= $this->config->get_ldap_link(); if ($this->orig_dn == 'new'){ $ldap->cd($this->config->current['BASE']); $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); $ldap->cd($this->dn); + + /* Remove empty values */ + foreach($this->attrs as $name => $value){ + if(empty($value)){ + unset($this->attrs[$name]); + } + } + $ldap->add($this->attrs); $this->handle_post_events("add"); } else {