diff --git a/plugins/admin/systems/class_printGeneric.inc b/plugins/admin/systems/class_printGeneric.inc
index 8154a89ac994e9dcf1c37bbeba584b67fd4f83d8..b38825df345393e46dc97c807b443f67d8d114a6 100644 (file)
}
/* 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);
}
if(($this->BelongsTo == "Printer") && (empty($this->cn))){
$message[]= "The required field 'Printer name' is not set.";
}
+
+ if($this->BelongsTo == "Printer"){
+ $ui= get_userinfo();
+ $acl= get_permissions ($dn, $ui->subtreeACL);
+ $acl= get_module_permission($acl, "printer", $this->dn);
+ if (chkacl($acl, "create") != ""){
+ $message[]= _("You have no permissions to create a printer on this 'Base'.");
+ }
+ }
+
/* must: labeledURI */
if(empty($this->labeledURI)){
if($this->BelongsTo == "Workstation"){
$this->dn= preg_replace("/ou=workstations,/","ou=printers,",$this->dn);
+ $mac = $this->parent->by_object['workgeneric']->netConfigDNS->macAddress;
+ $this->netConfigDNS->macAddress = $mac;
}
if(!$this->is_account) return;
$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();
$this->attrs= $attrs;
}
- if(preg_match("/https/i",$_SERVER['HTTP_REFERER'])){
- $method="https://";
- }else{
- $method="http://";
- }
-
- $this->attrs['gotoPrinterPPD'] = $method.str_replace("//","/",$_SERVER['SERVER_NAME']."/ppd/".$this->gotoPrinterPPD);
-
/* Append printer user
*/
$this->attrs['gotoUserPrinter']=array();
}
}
+ /* 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 {
}
show_ldap_error($ldap->get_error(), _("Saving printer failed"));
+
$this->netConfigDNS->cn = $this->cn;
$this->netConfigDNS->dn = $this->dn;
$this->netConfigDNS->save($this->dn);