resolve group member principals
authorPhilipp Schüle <p.schuele@metaways.de>
Mon, 18 Aug 2014 14:40:40 +0000 (16:40 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 4 Sep 2014 09:26:42 +0000 (11:26 +0200)
Change-Id: I5734bffcfea0c2092e5ad9acb3dd518c863e9ea5
Reviewed-on: http://gerrit.tine20.com/customers/1012
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
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);
             }
         }
     }