diff --git a/plugins/admin/systems/class_printGeneric.inc b/plugins/admin/systems/class_printGeneric.inc
index 1a37efb1a2daeed2a5dff030efe1f4de636e5342..9000b008bebf3a644e6f6a9fff24d2bc915f51b3 100644 (file)
var $description = "";
var $labeledURI = "";
var $gotoPrinterPPD = "";
+ var $initial_PPD = "";
var $orig_dn = "";
var $UserMember ="";
$this->gotoPrinterPPD = preg_replace("/^http.*ppd\//i","",$this->gotoPrinterPPD);
}
+ $this->initial_PPD = $this->gotoPrinterPPD;
+
/* Prepare different member types */
foreach(array("AddUser" =>"gotoUserPrinter",
"AddGroup" =>"gotoGroupPrinter",
}
}
}
+
+ if($this->is_account){
+ @log::log("view","printer/".get_class($this),$this->dn);
+ }
}
function set_acl_base($base)
$smarty->assign($name."ACL", $this->getacl($name));
}
- /* Create base acls */
- $baseACL = $this->getacl("base");
- if(!$this->acl_is_moveable()) {
- $baseACL = preg_replace("/w/","",$baseACL);
- }
- $smarty->assign("baseACL", $baseACL);
-
-
$display="";
/* Tell smarty if this is a standalone object or a terminal / WS depending printer */
$this->dialog = false;
$this->baseSelection = false;
}elseif($this->dialog->isSelected()){
- $this->base = $this->dialog->isSelected();
+
+ /* A new base was selected, check if it is a valid one */
+ $tmp = $this->get_allowed_bases();
+ if(isset($tmp[$this->dialog->isSelected()])){
+ $this->base = $this->dialog->isSelected();
+ }
+
$this->dialog= false;
$this->baseSelection = false;
}else{
$this->dialog = $this->PPDdialogToSave;
}else{
$this->dialog = new printerPPDDialog($this->config, $this->dn,$this->gotoPrinterPPD);
+ $this->dialog->cn= $this->cn;
}
}
/* Remove account & dns extension */
$this->netConfigDNS->remove_from_parent();
$ldap->rmdir($this->dn);
+
+ @log::log("remove","printer/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+
show_ldap_error($ldap->get_error(), sprintf(_("Removing of system print/generic with dn '%s' failed."),$this->dn));
$this->handle_post_events("remove");
unset($og->member[$this->dn]);
$og->save ();
}
+
+ /* Remove previously selected ppd file.*/
+ if(!empty($this->initial_PPD)){
+ $tmp = new printerPPDDialog($this->config, $this->dn,$this->initial_PPD);
+ $tmp->removeModifiedPPD();
+ }
}
}
/* Save data to object */
function save_object()
{
+ /* Create a base backup and reset the
+ base directly after calling plugin::save_object();
+ Base will be set seperatly a few lines below */
+ $base_tmp = $this->base;
plugin::save_object();
-
+ $this->base = $base_tmp;
+
if(is_object($this->netConfigDNS)){
$this->netConfigDNS->save_object();
}
-
- /* Save base, since this is no LDAP attribute */
- if((isset($_POST['base'])) && ($this->acl_is_moveable()) ) {
- $this->set_acl_base('dummy,'.$_POST['base']);
- if($this->acl_is_moveable()){
-
- if(isset($this->config->idepartments[$_POST['base']])){
- $this->base = $_POST['base'];
- if ($_POST['base'] != $this->base){
- $this->is_modified= TRUE;
- }
- }
- }else{
-
- print_red(sprintf(_("You are not allowed to move this object to '%s'."),LDAP::fix($_POST['base'])));
- $this->set_acl_base('dummy,'.$this->base);
+
+ /* Set new base if allowed */
+ $tmp = $this->get_allowed_bases();
+ if(isset($_POST['base'])){
+ if(isset($tmp[$_POST['base']])){
+ $this->base= $_POST['base'];
}
}
}
$message[]= "The required field 'Printer name' is not set.";
}
- /* Set new acl base */
- if($this->dn == "new") {
- $this->set_acl_base($this->base);
- }
-
- if(preg_match("/printer/i",$this->BelongsTo)){
- if ($this->orig_dn == "new" && !$this->acl_is_createable()){
- $message[]= _("You have no permissions to create a group on this 'Base'.");
- }
- }
-
/* must: labeledURI */
if(empty($this->labeledURI)){
$message[]= "The required field 'Printer URL' is not set.";
$this->PPDdialogToSave->save_ppd();
}
+ /* Remove previously selected ppd file.*/
+ if($this->initial_PPD != $this->gotoPrinterPPD){
+ if(!empty($this->initial_PPD)){
+ $tmp = new printerPPDDialog($this->config, $this->dn,$this->initial_PPD);
+ $tmp->removeModifiedPPD();
+ }
+ }
+
if(preg_match("/https/i",$_SERVER['HTTP_REFERER'])){
$method="https://";
}else{
}
}
+ /* Ensure to create a new object */
+ if(preg_match("/ou=incoming,/",$this->orig_dn)){
+ $this->orig_dn = "new";
+ }
+
/* Move object in necessary*/
if (($this->orig_dn != $this->dn) && ($this->orig_dn != 'new')){
$this->move($this->orig_dn, $this->dn);
$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");
+ @log::log("create","printer/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
} else {
$ldap->cd($this->dn);
$this->cleanup();
$ldap->modify ($this->attrs);
$this->handle_post_events("modify");
+ @log::log("modify","printer/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
}
show_ldap_error($ldap->get_error(), sprintf(_("Saving of system print/generic with dn '%s' failed."),$this->dn));
"plDescription" => _("Print generic"),
"plSelfModify" => FALSE,
"plDepends" => array(),
- "plPriority" => 11,
+ "plPriority" => 4,
"plSection" => array("administration"),
"plCategory" => array("printer" => array("description" => _("Printer"),
"objectClass" => "gotoPrinter"),"workstation","terminal"),