From: hickert Date: Fri, 11 Aug 2006 04:10:53 +0000 (+0000) Subject: Fixed printer add/remove X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=40d4c9e2d789e0f800fde0c9fb72322b689dc7b4;p=gosa.git Fixed printer add/remove git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4471 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/systems/class_printGeneric.inc b/plugins/admin/systems/class_printGeneric.inc index ea4f24dc9..803ea881e 100644 --- a/plugins/admin/systems/class_printGeneric.inc +++ b/plugins/admin/systems/class_printGeneric.inc @@ -814,7 +814,7 @@ class printgeneric extends plugin /* Check if there was a printer "dn" given, or the "cn" */ foreach($this->member[$type] as $key => $printer){ if($printer['dn'] == $id) { - $id = key; + $id = $key; } } diff --git a/plugins/personal/environment/class_environment.inc b/plugins/personal/environment/class_environment.inc index 697f5f85b..c86f52d00 100644 --- a/plugins/personal/environment/class_environment.inc +++ b/plugins/personal/environment/class_environment.inc @@ -73,6 +73,7 @@ class environment extends plugin var $objectclasses = array("gotoEnvironment"); // Specifies the objectClass which contains the attributes edited here var $cn; var $OrigCn; + var $add_del_printer_member_was_called = false; function environment ($config, $dn= NULL) { @@ -744,6 +745,7 @@ class environment extends plugin if($printerObj->by_object['printgeneric']->AddMember("AddUser",$this->dn)){ $this->gotoPrinter[$pname]=$tmp2[$pname]; $this->gotoPrinter[$pname]['mode']="user"; + $this->add_del_printer_member_was_called = true; } } @@ -760,6 +762,7 @@ class environment extends plugin $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$this->gotoPrinter[$pname]['dn']); if($printerObj->by_object['printgeneric']->DelMember("AddUser",$this->dn)){ unset($this->gotoPrinter[$pname]); + $this->add_del_printer_member_was_called = true; } } } @@ -960,49 +963,53 @@ class environment extends plugin * 2.1 There are different types of members: Users / Groups, this will be defined in $suffix * 2.2 And each type has two modes, Admin (e.g. 'gotoUserAdminPrinter') and Normal */ - $types = array( "gotoUserPrinter" => "AddUser", - "gotoGroupPrinter" => "AddGroup", - "gotoUserAdminPrinter" => "AddAdminUser", - "gotoGroupAdminPrinter" => "AddAdminGroup"); - - if($this->is_group){ - $s_suffix = "Group"; - $useVar = "cn"; - }else{ - $useVar = "uid"; - $s_suffix = "User"; - } + + if($this->add_del_printer_member_was_called){ - /* Remove old entries */ - $ldap->search("(&(objectClass=gotoPrinter)(goto".$s_suffix."Printer=".$this->uid."))",array("*")); - while($attr = $ldap->fetch()){ - $printerObj = NULL; - $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$attr['dn']); - $printerObj->by_object['printgeneric']->DelMember($types["goto".$s_suffix."Printer"],$this->uid); - $printerObj->by_object['printgeneric']->save(); - } + $types = array( "gotoUserPrinter" => "AddUser", + "gotoGroupPrinter" => "AddGroup", + "gotoUserAdminPrinter" => "AddAdminUser", + "gotoGroupAdminPrinter" => "AddAdminGroup"); - $ldap->search("(&(objectClass=gotoPrinter)(goto".$s_suffix."AdminPrinter=".$this->uid."))",array("*")); - while($attr = $ldap->fetch()){ - $printerObj = NULL; - $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$attr['dn']); - $printerObj->by_object['printgeneric']->DelMember($types["goto".$s_suffix."AdminPrinter"],$this->uid); - $printerObj->by_object['printgeneric']->save(); - } + if($this->is_group){ + $s_suffix = "Group"; + $useVar = "cn"; + }else{ + $useVar = "uid"; + $s_suffix = "User"; + } - foreach($this->gotoPrinter as $printer){ - $printerObj = NULL; - $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$printer['dn']); + /* Remove old entries */ + $ldap->search("(&(objectClass=gotoPrinter)(goto".$s_suffix."Printer=".$this->uid."))",array("*")); + while($attr = $ldap->fetch()){ + $printerObj = NULL; + $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$attr['dn']); + $printerObj->by_object['printgeneric']->DelMember($types["goto".$s_suffix."Printer"],$this->uid); + $printerObj->by_object['printgeneric']->save(); + } - if($printer['mode'] == "admin") { - $attribute = "goto".$s_suffix."AdminPrinter"; - }else{ - $attribute = "goto".$s_suffix."Printer"; + $ldap->search("(&(objectClass=gotoPrinter)(goto".$s_suffix."AdminPrinter=".$this->uid."))",array("*")); + while($attr = $ldap->fetch()){ + $printerObj = NULL; + $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$attr['dn']); + $printerObj->by_object['printgeneric']->DelMember($types["goto".$s_suffix."AdminPrinter"],$this->uid); + $printerObj->by_object['printgeneric']->save(); } - $printerObj->by_object['printgeneric']->AddMember($types[$attribute],$this->dn); - $printerObj->by_object['printgeneric']->save(); - } + foreach($this->gotoPrinter as $printer){ + $printerObj = NULL; + $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$printer['dn']); + + if($printer['mode'] == "admin") { + $attribute = "goto".$s_suffix."AdminPrinter"; + }else{ + $attribute = "goto".$s_suffix."Printer"; + } + + $printerObj->by_object['printgeneric']->AddMember($types[$attribute],$this->dn); + $printerObj->by_object['printgeneric']->save(); + } + } /* Prepare HotPlug devices */ $this->attrs['gotoHotplugDevice'] = array();