Skip to content

Commit

Permalink
Merge branch '2023.11' into 2024.11
Browse files Browse the repository at this point in the history
  • Loading branch information
gitlabci committed Feb 5, 2025
2 parents 96babff + 0cfc4ea commit 50b325a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 23 deletions.
22 changes: 6 additions & 16 deletions tine20/Timetracker/Model/TimesheetFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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()) .')';
Expand Down
8 changes: 1 addition & 7 deletions tine20/Tinebase/Controller/Record/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit 50b325a

Please sign in to comment.