Code

Added function
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 12 Sep 2006 10:41:55 +0000 (10:41 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 12 Sep 2006 10:41:55 +0000 (10:41 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@4645 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/personal/environment/class_environment.inc

index f9671b54a9124e772d3f04944990e16334b75748..79471d4329af60a6de73e02a7895efd485b5fdcf 100644 (file)
@@ -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();