Merge branch '2013.10' into 2014.11
[tine20] / tine20 / Tinebase / WebDav / PrincipalBackend.php
index fd2d3ee..a4cdb01 100644 (file)
@@ -72,7 +72,7 @@ class Tinebase_WebDav_PrincipalBackend implements \Sabre\DAVACL\PrincipalBackend
     public function getPrincipalByPath($path) 
     {
         // any user has to lookup the data at least once
-        $cacheId = convertCacheId('getPrincipalByPath' . Tinebase_Core::getUser()->getId() . $path);
+        $cacheId = Tinebase_Helper::convertCacheId('getPrincipalByPath' . Tinebase_Core::getUser()->getId() . $path);
         
         $principal = Tinebase_Core::getCache()->load($cacheId);
         if ($principal !== false) {
@@ -360,31 +360,33 @@ class Tinebase_WebDav_PrincipalBackend implements \Sabre\DAVACL\PrincipalBackend
                         }
                     }
                     
-                    // return user only, if the containers have the sync AND read grant set
-                    $otherUsersSync = Tinebase_Container::getInstance()->getOtherUsers($user, 'Calendar', Tinebase_Model_Grants::GRANT_SYNC);
-                    
-                    if ($otherUsersSync->count() > 0) {
-                        $otherUsersRead = Tinebase_Container::getInstance()->getOtherUsers($user, 'Calendar', Tinebase_Model_Grants::GRANT_READ);
-                        
-                        $otherUsersIds = array_intersect($otherUsersSync->getArrayOfIds(), $otherUsersRead->getArrayOfIds());
+                    if (Tinebase_Core::getUser()->hasRight('Calendar', Tinebase_Acl_Rights::RUN)) {
+                        // return user only, if the containers have the sync AND read grant set
+                        $otherUsersSync = Tinebase_Container::getInstance()->getOtherUsers($user, 'Calendar', Tinebase_Model_Grants::GRANT_SYNC);
                         
-                        foreach ($otherUsersIds as $userId) {
-                            if ($otherUsersSync->getById($userId)->contact_id && $otherUsersSync->getById($userId)->visibility == Tinebase_Model_User::VISIBILITY_DISPLAYED) {
-                                $result[] = self::PREFIX_USERS . '/' . $otherUsersSync->getById($userId)->contact_id . '/calendar-proxy-write';
+                        if ($otherUsersSync->count() > 0) {
+                            $otherUsersRead = Tinebase_Container::getInstance()->getOtherUsers($user, 'Calendar', Tinebase_Model_Grants::GRANT_READ);
+                            
+                            $otherUsersIds = array_intersect($otherUsersSync->getArrayOfIds(), $otherUsersRead->getArrayOfIds());
+                            
+                            foreach ($otherUsersIds as $userId) {
+                                if ($otherUsersSync->getById($userId)->contact_id && $otherUsersSync->getById($userId)->visibility == Tinebase_Model_User::VISIBILITY_DISPLAYED) {
+                                    $result[] = self::PREFIX_USERS . '/' . $otherUsersSync->getById($userId)->contact_id . '/calendar-proxy-write';
+                                }
                             }
                         }
-                    }
-                    
-                    // return user only, if the containers have the sync AND read grant set
-                    $sharedContainersSync = Tinebase_Container::getInstance()->getSharedContainer($user, 'Calendar', Tinebase_Model_Grants::GRANT_SYNC);
-                    
-                    if ($sharedContainersSync->count() > 0) {
-                        $sharedContainersRead = Tinebase_Container::getInstance()->getSharedContainer($user, 'Calendar', Tinebase_Model_Grants::GRANT_READ);
                         
-                        $sharedContainerIds = array_intersect($sharedContainersSync->getArrayOfIds(), $sharedContainersRead->getArrayOfIds());
+                        // return user only, if the containers have the sync AND read grant set
+                        $sharedContainersSync = Tinebase_Container::getInstance()->getSharedContainer($user, 'Calendar', Tinebase_Model_Grants::GRANT_SYNC);
                         
-                        if (count($sharedContainerIds) > 0) {
-                            $result[] = self::PREFIX_USERS . '/' . self::SHARED . '/calendar-proxy-write';
+                        if ($sharedContainersSync->count() > 0) {
+                            $sharedContainersRead = Tinebase_Container::getInstance()->getSharedContainer($user, 'Calendar', Tinebase_Model_Grants::GRANT_READ);
+                            
+                            $sharedContainerIds = array_intersect($sharedContainersSync->getArrayOfIds(), $sharedContainersRead->getArrayOfIds());
+                            
+                            if (count($sharedContainerIds) > 0) {
+                                $result[] = self::PREFIX_USERS . '/' . self::SHARED . '/calendar-proxy-write';
+                            }
                         }
                     }
                     Tinebase_Cache_PerRequest::getInstance()->save(__CLASS__, __FUNCTION__, $classCacheId, $result);
@@ -600,7 +602,7 @@ class Tinebase_WebDav_PrincipalBackend implements \Sabre\DAVACL\PrincipalBackend
         $result = array();
         
         foreach ($containers as $container) {
-            $cacheId = convertCacheId('_containerGrantsToPrincipals' . $container->getId() . $container->seq);
+            $cacheId = Tinebase_Helper::convertCacheId('_containerGrantsToPrincipals' . $container->getId() . $container->seq);
             
             $containerPrincipals = Tinebase_Core::getCache()->load($cacheId);