diff --git a/plugins/admin/systems/class_printGeneric.inc b/plugins/admin/systems/class_printGeneric.inc
index d70986981b0fc67c1f4c45b186b419cf6b231b76..7c51299fe51f3e6c49e77dbf020cce1e3f62d089 100644 (file)
/* set orig dn to new if object is new */
$ldap= $this->config->get_ldap_link();
- $ldap->cat($this->dn);
+ $ldap->cat($this->dn, array('dn'));
if(!$ldap->count()){
$this->orig_dn = "new";
}
$this->base= dn2base($ui->dn);
$this->cn= "";
} else {
- $this->base= dn2base($this->dn);
+
+ /* Set base and check if the extracted base exists */
+ if(preg_match("/ou=incoming,/",$this->dn)){
+ $this->base= preg_replace("/ou=incoming,/","",dn2base($this->dn));
+ }else{
+ $this->base= preg_replace("/ou=printers,ou=systems,/","",dn2base($this->dn));
+ }
+
+ if(!isset($this->config->idepartments[$this->base])){
+ print_red(_("Can't extract a valid base out of object dn, setting base to '%s'."),$_SESSION['CurrentMainBase']);
+ $this->base = $_SESSION['CurrentMainBase'];
+ }
}
/* Extract selected ppd */
/* Detect type of printer via parent tabs.
*/
- if(isset($this->parent->by_name['workgeneric'])){
+ if(isset($this->parent->by_object['workgeneric'])){
/* Exclude templates
*/
- $this->cn = $this->parent->by_name['workgeneric']->cn;
+ $this->cn = $this->parent->by_object['workgeneric']->cn;
if($this->parent->by_object['workgeneric']->cn == "wdefault"){
$this->BelongsTo = "WorkstationTemplate";
}else{
$this->BelongsTo = "Workstation";
}
- }elseif(isset($this->parent->by_name['termgeneric'])){
+ }elseif(isset($this->parent->by_object['termgeneric'])){
/* Exclude templates
*/
- $this->cn = $this->parent->by_name['termgeneric']->cn;
+ $this->cn = $this->parent->by_object['termgeneric']->cn;
if($this->parent->by_object['termgeneric']->cn == "default"){
$this->BelongsTo = "TerminalTemplate";
}else{
/* Detect if this is a valid printer account;
*/
+ //FIXME: do we need to do this? we've already everything we need in $this->attrs...
$ldap = $this->config->get_ldap_link();
- $ldap->cd($this->config->current['BASE']);
- $ldap->cat($this->dn);
+ $ldap->cat($this->dn, array('objectClass'));
if($ldap->count()){
$attrs = $ldap->fetch();
/* Call parent execute */
plugin::execute();
- /* If type of printer couldn't be detected (because of missing parent object in construcktion)
+ /* If type of printer couldn't be detected (because of missing parent object in construction)
* hide this tab.
*/
if($this->BelongsTo == "unknown"){
$display= $this->show_header(_("Add printer extension"),
- _("Could not intialise printer tab, parameter parent was missing while construcktion."),TRUE,TRUE);
+ _("Could not intialize printer tab, parameter parent was missing while construction."),TRUE,TRUE);
return($display);
}
if($this->BelongsTo != "Printer"){
if((empty($this->cn)) && ($this->dn != "new")){
$display= $this->show_header(_("Add printer extension"),
- _("This obejct has printer extension disabled. You can't enable it while 'cn' is not present in entry. Possibly you are currently creating a new terminal template"),TRUE,TRUE);
+ _("This object has printer extension disabled. You can't enable it while 'cn' is not present in entry. Possibly you are currently creating a new terminal template"),TRUE,TRUE);
$this->is_account= false;
return $display;
}
$smarty->assign("$attr", $this->$attr);
}
+ $smarty->assign("baseACL", chkacl($this->acl,"base"));
+
if(isset($_POST['AddUser'])){
$this->dialog = new selectUserToPrinterDialog($this->config, get_userinfo(),"AddUser");
}
$ppdManager= new ppdManager($path);
if(!empty($this->gotoPrinterPPD)){
if((!file_exists($path.$this->gotoPrinterPPD))){
- $smarty->assign("driverInfo", "<b>".sprintf(_("Your currently selected PPD file '%s' doesn't exist."),$this->gotoPrinterPPD))."</b>";
+ $smarty->assign("driverInfo", "<b>".sprintf(_("Your currently selected PPD file '%s' doesn't exist."),$path.$this->gotoPrinterPPD))."</b>";
}else{
$smarty->assign("driverInfo", $ppdManager->loadDescription($path.$this->gotoPrinterPPD));
}
/* Check if this dn points to a printer, to avoid deleting something else */
$ldap= $this->config->get_ldap_link();
- $ldap->cat($this->dn);
+ $ldap->cat($this->dn, array('dn',"objectClass"));
if(!$ldap->count()){
- print_red("Trying to remove printer obejct which isn't a printer. Aborted to avoid data loss.");
+ print_red("Trying to remove printer object which isn't a printer. Aborted to avoid data loss.");
return;
}
/* Check if obejct is a printer */
$CheckPrinter = $ldap->fetch();
if(!in_array("gotoPrinter",$CheckPrinter['objectClass'])){
- print_red("Trying to remove printer obejct which isn't a printer. Aborted to avoid data loss.");
+ print_red("Trying to remove printer object which isn't a printer. Aborted to avoid data loss.");
return;
}
/* Remove account & dns extension */
$this->netConfigDNS->remove_from_parent();
$ldap->rmdir($this->dn);
- show_ldap_error($ldap->get_error());
+ show_ldap_error($ldap->get_error(), _("Removing printer failed"));
$this->handle_post_events("remove");
/* Delete references to object groups */
$message= array_merge($message, $this->netConfigDNS->check());
/* Don't display check messages if this is a template object */
- if(isset($this->parent->by_name['workgeneric'])){
+ if(isset($this->parent->by_object['workgeneric'])){
if($this->parent->by_object['workgeneric']->cn == "wdefault"){
return $message;
}
- }elseif(isset($this->parent->by_name['termgeneric'])){
+ }elseif(isset($this->parent->by_object['termgeneric'])){
if($this->parent->by_object['termgeneric']->cn == "default"){
return $message;
}
if(($this->BelongsTo == "Printer") && (empty($this->cn))){
$message[]= "The required field 'Printer name' is not set.";
}
-
+
+ /* must: labeledURI */
+ if(empty($this->labeledURI)){
+ $message[]= "The required field 'Printer URL' is not set.";
+ }
+
/* Check if there is already an entry with this cn*/
if (($this->orig_dn != $dn)&&($this->BelongsTo == "Printer")){
$ldap= $this->config->get_ldap_link();
}
if(!$this->is_account) return;
- if(isset($this->parent->by_name['workgeneric'])){
+ if(isset($this->parent->by_object['workgeneric'])){
if($this->parent->by_object['workgeneric']->cn == "wdefault"){
return;
}
- }elseif(isset($this->parent->by_name['termgeneric'])){
+ }elseif(isset($this->parent->by_object['termgeneric'])){
if($this->parent->by_object['termgeneric']->cn == "default"){
return;
}
$this->handle_post_events("modify");
}
- show_ldap_error($ldap->get_error());
+ show_ldap_error($ldap->get_error(), _("Saving printer failed"));
$this->netConfigDNS->cn = $this->cn;
$this->netConfigDNS->dn = $this->dn;