resolve group member principals
[tine20] / tine20 / Tinebase / Import / CalDav / Client.php
index 14b35ec..f707229 100644 (file)
@@ -167,7 +167,29 @@ class Tinebase_Import_CalDav_Client extends \Sabre\DAV\Client
                          continue;
             $result = $this->calDavRequest('PROPFIND', $ace['principal'], self::resolvePrincipalRequest);
             if (isset($result['{DAV:}group-member-set'])) {
-                $this->principalGroups[$ace['principal']] = $result['{DAV:}group-member-set']->getPrincipals();
+                $principals = $result['{DAV:}group-member-set']->getPrincipals();
+                
+                if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . ' ' . __LINE__
+                        . ' ' . print_r($principals, true));
+                
+                $groupPrincipals = array();
+                foreach ($principals as $key => $principal) {
+                    if (! isset($this->principals[$principal])) {
+                        $result = $this->calDavRequest('PROPFIND', $principal, self::resolvePrincipalRequest);
+                        if (isset($result['{DAV:}group-member-set'])) {
+                            
+                            $groupMemberPrincipals = $result['{DAV:}group-member-set']->getPrincipals();
+                            if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . ' ' . __LINE__
+                                    . ' Found group member principals (group: ' . principal . '): ' . print_r($groupMemberPrincipals, true));
+                            
+                            $groupPrincipals = array_merge($groupPrincipals, $groupMemberPrincipals);
+
+                            unset($principals[$key]);
+                        }
+                    }
+                }
+                
+                $this->principalGroups[$ace['principal']] = array_merge($groupPrincipals, $principals);
             }
         }
     }