Code

Only save complete tab, if group is mailGroup
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 9 Mar 2006 11:24:40 +0000 (11:24 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 9 Mar 2006 11:24:40 +0000 (11:24 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2832 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/personal/posix/class_posixAccount.inc

index 4df3640f4a66d4f766388d9deb49ba5f0cabec86..a5498c798aa7c89f166d7c42d929f288d33d2a01 100644 (file)
@@ -850,22 +850,37 @@ $ldap->modify ($this->attrs);
         $g->save ();
       }
     }
-
     /* Take care about groupMembership values: add to groups */
     foreach ($this->groupMembership as $key => $value){
-      $g= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $key);
-      $g->by_object['group']->addUser ($this->uid);
+      $g= new group($this->config, $key);
+      $g->addUser ($this->uid);
       $g->save();
-    }
 
-    /* Remove from groups not listed in groupMembership */
-    foreach ($this->savedGroupMembership as $key => $value){
-      if (!array_key_exists ($key, $this->groupMembership)){
+      /* May need to save the mail part, too */
+      if ($g->has_mailAccount){
         $g= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $key);
         $g->by_object['group']->removeUser ($this->uid);
         $g->save();
       }
     }
+    
+    /* Remove from groups not listed in groupMembership */
+    foreach ($this->savedGroupMembership as $key => $value){
+      if (!isset($this->groupMembership[$key])){
+        
+        $g= new group($this->config, $key);
+        $g->removeUser ($this->uid);
+        $g->save();
+
+        /* May need to save the mail part, too */
+        if ($g->has_mailAccount){
+          $g= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $key);
+          $g->by_object['group']->removeUser ($this->uid);
+          $g->save();
+        }
+      }
+    }
 
     /* Optionally execute a command after we're done */
     if ($this->initially_was_account == $this->is_account){