diff --git a/tine20/Timetracker/Model/TimesheetFilter.php b/tine20/Timetracker/Model/TimesheetFilter.php index f0bf996969b..15431959206 100644 --- a/tine20/Timetracker/Model/TimesheetFilter.php +++ b/tine20/Timetracker/Model/TimesheetFilter.php @@ -115,13 +115,7 @@ protected function _appendAclSqlFilter($_select) if (! $this->_isResolved) { // get all timeaccounts user has required grants for - $result = array(); - foreach ($this->_requiredGrants as $grant) { - if ($grant != Timetracker_Model_TimeaccountGrants::BOOK_OWN) { - $result = array_merge($result, Timetracker_Controller_Timeaccount::getInstance()->getRecordsByAcl($grant, TRUE)); - } - } - $this->_validTimeaccounts = array_unique($result); + $this->_validTimeaccounts = Timetracker_Controller_Timeaccount::getInstance()->getRecordsByAcl(array_filter($this->_requiredGrants, fn($grant) => $grant !== Timetracker_Model_TimeaccountGrants::BOOK_OWN), true); if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' valid timeaccounts' . print_r($this->_validTimeaccounts, TRUE) . ' for required grants: ' . print_r($this->_requiredGrants, TRUE)); $this->_isResolved = TRUE; @@ -133,15 +127,11 @@ protected function _appendAclSqlFilter($_select) $where = $db->quoteInto("$field IN (?)", empty($this->_validTimeaccounts) ? array('') : $this->_validTimeaccounts); // get timeaccounts with *_OWN right - $bookOwnTS = []; - foreach ([ - Timetracker_Model_TimeaccountGrants::BOOK_OWN, - Timetracker_Model_TimeaccountGrants::READ_OWN, - Timetracker_Model_TimeaccountGrants::REQUEST_OWN, - ] as $grant) { - $bookOwnTS = array_merge($bookOwnTS, Timetracker_Controller_Timeaccount::getInstance()->getRecordsByAcl($grant, true)); - } - $bookOwnTS = array_unique($bookOwnTS); + $bookOwnTS = Timetracker_Controller_Timeaccount::getInstance()->getRecordsByAcl([ + Timetracker_Model_TimeaccountGrants::BOOK_OWN, + Timetracker_Model_TimeaccountGrants::READ_OWN, + Timetracker_Model_TimeaccountGrants::REQUEST_OWN, + ], true); if (! empty($bookOwnTS)) { $where .= ' OR (' . $db->quoteInto($field . ' IN (?)', $bookOwnTS) . ' AND ' . $db->quoteInto($db->quoteIdentifier('account_id'). ' = ?', Tinebase_Core::getUser()->getId()) .')'; diff --git a/tine20/Tinebase/Controller/Record/Container.php b/tine20/Tinebase/Controller/Record/Container.php index 22b3de7aae4..fa6ab178b8a 100644 --- a/tine20/Tinebase/Controller/Record/Container.php +++ b/tine20/Tinebase/Controller/Record/Container.php @@ -251,13 +251,7 @@ public function getRecordsByAcl($_grant, $_onlyIds = FALSE) // NOTE: use id filter instead of container filter because of poor performance of container filter (setValue) $filter->addFilter(new Tinebase_Model_Filter_Id('container_id', 'in', $containerIds)); - $result = $this->_backend->search($filter); - - if ($_onlyIds) { - $result = $result->getArrayOfIds(); - } - - return $result; + return $this->_backend->search($filter, null, $_onlyIds ? Tinebase_Backend_Sql_Abstract::IDCOL : Tinebase_Backend_Sql_Abstract::ALLCOL); } /**