From a8592202d4af8b1c4f70f3183f2c821e632eafe2 Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 12 Sep 2006 10:41:55 +0000 Subject: [PATCH] Added function git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@4645 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../environment/class_environment.inc | 94 ++++++++++--------- 1 file changed, 48 insertions(+), 46 deletions(-) diff --git a/plugins/personal/environment/class_environment.inc b/plugins/personal/environment/class_environment.inc index f9671b54a..79471d432 100644 --- a/plugins/personal/environment/class_environment.inc +++ b/plugins/personal/environment/class_environment.inc @@ -952,63 +952,65 @@ class environment extends plugin /* Save usersettings to Printer */ + $skip_printer_changes = false; if(chkacl($this->acl,"gotoPrinter")!=""){ - $this->gotoPrinter = array(); + $this->gotoPrinter = array(); + $skip_printer_changes = true; } - /* 1. Search all printers that have our uid/cn as member - * 2. Delete this uid/cn from every single entry and save it again. - * 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"); - - /* Detect type of edited object, sometimes this wasn't set correctly ... */ - $this->detect_grouptype(); - - if($this->is_group){ - $s_suffix = "Group"; - $useVar = "cn"; - }else{ - $useVar = "uid"; - $s_suffix = "User"; - } + if(!$skip_printer_changes){ + /* 1. Search all printers that have our uid/cn as member + * 2. Delete this uid/cn from every single entry and save it again. + * 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"); - /* 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(); - } + /* Detect type of edited object, sometimes this wasn't set correctly ... */ + $this->detect_grouptype(); - $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(); -- 2.30.2