removes some more unnecessary LDAP lookups
authorPhilipp Schüle <p.schuele@metaways.de>
Wed, 20 Aug 2014 15:02:53 +0000 (17:02 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 4 Sep 2014 09:26:44 +0000 (11:26 +0200)
Change-Id: Ieaa8a1776610439484c8dfde10fa219460813aba
Reviewed-on: http://gerrit.tine20.com/customers/1028
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Addressbook/Controller/List.php
tine20/Calendar/Frontend/WebDAV/Backend.php
tine20/Tasks/Convert/Task/VCalendar/Abstract.php
tine20/Tasks/Frontend/WebDAV/Backend.php
tine20/Tinebase/Import/CalDav/Client.php
tine20/Tinebase/Model/Tree/Node/Path.php
tine20/Tinebase/User/Sql.php
tine20/Tinebase/WebDav/PrincipalBackend.php

index aed6ad5..79c7f01 100644 (file)
@@ -348,9 +348,9 @@ class Addressbook_Controller_List extends Tinebase_Controller_Record_Abstract
         }
     
         foreach ($_userIds as $userId) {
-            $fullUser = Tinebase_User::getInstance()->getUserById($userId, 'Tinebase_Model_FullUser');
-            if (!empty($fullUser->contact_id)) {
-                $contactIds[] = $fullUser->contact_id;
+            $user = Tinebase_User::getInstance()->getUserByPropertyFromSqlBackend('accountId', $userId);
+            if (! empty($user->contact_id)) {
+                $contactIds[] = $user->contact_id;
             }
         }
     
index 62b90fb..ca835fd 100644 (file)
@@ -35,7 +35,7 @@ class Calendar_Frontend_CalDAV_Backend extends Sabre\CalDAV\Backend\AbstractBack
         
         $principalParts = explode('/', $principalUri);
         if (count($principalParts) == 2) {
-            $owner = Tinebase_User::getInstance()->getUserByLoginName($principalParts[1]);
+            $owner = Tinebase_User::getInstance()->getUserByPropertyFromSqlBackend('accountLoginName', $principalParts[1]);
             $containers = Tinebase_Container::getInstance()->getPersonalContainer(Tinebase_Core::getUser(), 'Calendar', $owner, Tinebase_Model_Grants::GRANT_READ);
         } else {
             throw new Sabre\DAV\Exception\PreconditionFailed('unsupported pricipalUri');
@@ -94,7 +94,7 @@ class Calendar_Frontend_CalDAV_Backend extends Sabre\CalDAV\Backend\AbstractBack
             $container = new Tinebase_Model_Container(array(
                 'name'              => $properties['{DAV:}displayname'],
                 'type'              => Tinebase_Model_Container::TYPE_PERSONAL,
-                'owner_id'          => Tinebase_User::getInstance()->getUserByLoginName($principalParts[1]),
+                'owner_id'          => Tinebase_User::getInstance()->getUserByPropertyFromSqlBackend('accountLoginName', $principalParts[1]),
                 'application_id'    => Tinebase_Application::getInstance()->getApplicationByName('Calendar')->getId(),
                 'backend'           => 'Sql',
                 'model'             => 'Calendar_Model_Event'
index b1992e8..01c84c0 100644 (file)
@@ -644,7 +644,7 @@ class Tasks_Convert_Task_VCalendar_Abstract implements Tinebase_Convert_Interfac
 //                                 'email'     => $matches['email'],
 //                                 'lastName'  => $name,
 //                             ));
-                            $user = Tinebase_User::getInstance()->getUserByProperty('accountEmailAddress', $matches['email']);
+                            $user = Tinebase_User::getInstance()->getUserByPropertyFromSqlBackend('accountEmailAddress', $matches['email']);
                             $task->organizer = $user ? $user->getId() : Tinebase_Core::getUser()->getId();
                         }
                     }
index ac4c933..bd402d8 100644 (file)
@@ -39,7 +39,7 @@ class Tasks_Frontend_CalDAV_Backend extends Sabre\CalDAV\Backend\AbstractBackend
         $principalParts = explode('/', $principalUri);
         
         if (count($principalParts) == 2) {
-            $owner = Tinebase_User::getInstance()->getUserByLoginName($principalParts[1]);
+            $owner = Tinebase_User::getInstance()->getUserByPropertyFromSqlBackend('accountLoginName', $principalParts[1]);
             $containers = Tinebase_Container::getInstance()->getPersonalContainer(Tinebase_Core::getUser(), 'Calendar', $owner, Tinebase_Model_Grants::GRANT_READ);
         } else {
             throw new Sabre\DAV\Exception\PreconditionFailed('unsupported pricipalUri');
@@ -99,7 +99,7 @@ class Tasks_Frontend_CalDAV_Backend extends Sabre\CalDAV\Backend\AbstractBackend
             $container = new Tinebase_Model_Container(array(
                 'name'              => $properties['{DAV:}displayname'],
                 'type'              => Tinebase_Model_Container::TYPE_PERSONAL,
-                'owner_id'          => Tinebase_User::getInstance()->getUserByLoginName($principalParts[1]),
+                'owner_id'          => Tinebase_User::getInstance()->getUserByPropertyFromSqlBackend('accountLoginName', $principalParts[1]),
                 'application_id'    => Tinebase_Application::getInstance()->getApplicationByName('Calendar')->getId(),
                 'backend'           => 'Sql',
             ));
index 4ffa435..f87a5ef 100644 (file)
@@ -105,7 +105,7 @@ class Tinebase_Import_CalDav_Client extends \Sabre\DAV\Client
     protected function _setUser()
     {
         try {
-            $user = Tinebase_User::getInstance()->getUserByLoginName($this->userName, 'Tinebase_Model_FullUser');
+            $user = Tinebase_User::getInstance()->getUserByPropertyFromSqlBackend('accountLoginName', $this->userName, 'Tinebase_Model_FullUser');
             Tinebase_Core::set(Tinebase_Core::USER, $user);
             $credentialCache = Tinebase_Auth_CredentialCache::getInstance()->cacheCredentials($this->userName, $this->password);
             Tinebase_Core::set(Tinebase_Core::USERCREDENTIALCACHE, $credentialCache);
@@ -269,4 +269,4 @@ class Tinebase_Import_CalDav_Client extends \Sabre\DAV\Client
         
         return $newResult;
     }
-}
\ No newline at end of file
+}
index ca6646d..7c63101 100644 (file)
@@ -302,7 +302,7 @@ class Tinebase_Model_Tree_Node_Path extends Tinebase_Record_Abstract
                 case Tinebase_Model_Container::TYPE_PERSONAL:
                     if (count($_pathParts) > 4) {
                         $subPathParts = explode('/', $_pathParts[4], 2);
-                        $owner = ($this->containerOwner) ? Tinebase_User::getInstance()->getUserByLoginName($this->containerOwner) : Tinebase_Core::getUser();
+                        $owner = ($this->containerOwner) ? Tinebase_User::getInstance()->getUserByPropertyFromSqlBackend('accountLoginName', $this->containerOwner) : Tinebase_Core::getUser();
                         $container = Tinebase_Container::getInstance()->getContainerByName(
                             $this->application->name, $subPathParts[0], Tinebase_Model_Container::TYPE_PERSONAL, $owner->getId());
                     }
index 3eddcff..e743d85 100644 (file)
@@ -601,7 +601,7 @@ class Tinebase_User_Sql extends Tinebase_User_Abstract
         Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' Login of user ' . $_loginName . ' failed.');
         
         try {
-            $user = $this->getUserByLoginName($_loginName);
+            $user = $this->getUserByPropertyFromSqlBackend('accountLoginName', $_loginName);
         } catch (Tinebase_Exception_NotFound $tenf) {
             // nothing todo => is no existing user
             return;
index 8066e6a..9280bd7 100644 (file)
@@ -302,7 +302,7 @@ class Tinebase_WebDav_PrincipalBackend implements \Sabre\DAVACL\PrincipalBackend
         
             case self::PREFIX_USERS:
                 if ($contactId !== self::SHARED) {
-                    $user = Tinebase_User::getInstance()->getUserByProperty('contactId', $contactId);
+                    $user = Tinebase_User::getInstance()->getUserByPropertyFromSqlBackend('contactId', $contactId);
                     
                     $groupIds = Tinebase_Group::getInstance()->getGroupMemberships($user);
                     $groups   = Tinebase_Group::getInstance()->getMultiple($groupIds);