make sure we fetch users from sql
authorPhilipp Schüle <p.schuele@metaways.de>
Wed, 20 Aug 2014 10:16:29 +0000 (12:16 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 4 Sep 2014 09:26:43 +0000 (11:26 +0200)
... if we don't need the current user data from sync backend

Change-Id: I1d35455740bb9691407fd4293bd6e06aeef568ab
Reviewed-on: http://gerrit.tine20.com/customers/1022
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Calendar/Frontend/WebDAV/Container.php
tine20/Tinebase/Container.php
tine20/Tinebase/Frontend/Json/Container.php
tine20/Tinebase/Model/Filter/Container.php
tine20/Tinebase/WebDav/PrincipalBackend.php

index 8dd919b..2ed3c83 100644 (file)
@@ -290,7 +290,7 @@ class Calendar_Frontend_WebDAV_Container extends Tinebase_WebDav_Container_Abstr
                     
                 case 'user':
                     try {
-                        $contact    = Tinebase_User::getInstance()->getUserById($grant->account_id);
+                        $contact = Tinebase_User::getInstance()->getUserByPropertyFromSqlBackend('accountId', $grant->account_id);
                     } catch (Tinebase_Exception_NotFound $tenf) {
                         continue;
                     }
index cca6a11..a764035 100644 (file)
@@ -670,7 +670,7 @@ class Tinebase_Container extends Tinebase_Backend_Sql_Abstract
             }
         }
         
-        $account = ($accountId !== NULL) ? Tinebase_User::getInstance()->getUserById($accountId) : Tinebase_Core::getUser();
+        $account = ($accountId !== NULL) ? Tinebase_User::getInstance()->getUserByPropertyFromSqlBackend('accountId', $accountId) : Tinebase_Core::getUser();
         $result = $this->getPersonalContainer($account, $recordClass, $account, Tinebase_Model_Grants::GRANT_ADD)->getFirstRecord();
         
         if ($result === NULL) {
index c51dacf..a32a0c2 100644 (file)
@@ -196,7 +196,7 @@ class Tinebase_Frontend_Json_Container
             switch($value['account_type']) {
                 case Tinebase_Acl_Rights::ACCOUNT_TYPE_USER:
                     try {
-                        $account = Tinebase_User::getInstance()->getUserById($value['account_id']);
+                        $account = Tinebase_User::getInstance()->getUserByPropertyFromSqlBackend('accountId', $value['account_id']);
                     } catch (Tinebase_Exception_NotFound $e) {
                         $account = Tinebase_User::getInstance()->getNonExistentUser();
                     }
index ebdf540..0316146 100644 (file)
@@ -169,7 +169,7 @@ class Tinebase_Model_Filter_Container extends Tinebase_Model_Filter_Abstract imp
                     $containerData = array_merge($containerData, Tinebase_Container::getInstance()->getContainerById($containerId, TRUE)->toArray());
                 } else if (($ownerId = Tinebase_Model_Container::pathIsPersonalNode($path))) {
                     // transform current user 
-                    $owner = Tinebase_User::getInstance()->getUserById($ownerId);
+                    $owner = Tinebase_User::getInstance()->getUserByPropertyFromSqlBackend('accountId', $ownerId);
                     $containerData['name']  = $owner->accountDisplayName;
                     $containerData['path']  = "/personal/$ownerId";
                     $containerData['owner'] = $owner->toArray();
index 3ba9250..8066e6a 100644 (file)
@@ -541,8 +541,19 @@ class Tinebase_WebDav_PrincipalBackend implements \Sabre\DAVACL\PrincipalBackend
         return $principal;
     }
     
+    /**
+     * convert container grants to principals 
+     * 
+     * @param Tinebase_Record_RecordSet $containers
+     * @return array
+     * 
+     * @todo improve algorithm to fetch all contact/list_ids at once
+     */
     protected function _containerGrantsToPrincipals(Tinebase_Record_RecordSet $containers)
     {
+        if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(
+                __METHOD__ . '::' . __LINE__ . ' Converting grants to principals for ' . count($containers) . ' containers.');
+        
         $result = array();
         
         foreach ($containers as $container) {
@@ -562,7 +573,7 @@ class Tinebase_WebDav_PrincipalBackend implements \Sabre\DAVACL\PrincipalBackend
                         if ($contact->account_id == $grant->account_id) {
                             continue;
                         }
-                        $user = Tinebase_User::getInstance()->getUserById($grant->account_id);
+                        $user = Tinebase_User::getInstance()->getUserByPropertyFromSqlBackend('accountId', $grant->account_id);
                         if ($user->contact_id) {
                             $result[] = self::PREFIX_USERS . '/' . $user->contact_id;
                         }