From 6b24c1f7c23b2cf0cb0285ae43a6290bc98e4335 Mon Sep 17 00:00:00 2001 From: ralf Date: Tue, 29 Oct 2024 12:32:08 +0100 Subject: [PATCH] improve speed for read access / grants to a lot of accounts first check then spend time generating the list ;) --- timesheet/inc/class.timesheet_ui.inc.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/timesheet/inc/class.timesheet_ui.inc.php b/timesheet/inc/class.timesheet_ui.inc.php index ee7a06114a..1ebb1225c4 100644 --- a/timesheet/inc/class.timesheet_ui.inc.php +++ b/timesheet/inc/class.timesheet_ui.inc.php @@ -1031,26 +1031,30 @@ class timesheet_ui extends timesheet_bo { $content['nm']['no_kanban'] = true; } - $read_grants = $this->grant_list(Acl::READ); - $content['nm']['no_owner_col'] = count($read_grants) == 1; if($GLOBALS['egw_info']['user']['preferences']['timesheet']['nextmatch-timesheet.index.rows']) { $content['nm']['selectcols'] = $GLOBALS['egw_info']['user']['preferences']['timesheet']['nextmatch-timesheet.index.rows']; } $sel_options = array( - 'ts_owner' => $read_grants, 'pm_id' => array(lang('No project')), 'cat_id' => array(array('value' => '', 'label' => lang('all categories')), array('value' => 0, 'label' => lang('None'))), 'ts_status' => $this->status_labels + array(lang('No status')), ); - // Special handling for if you have a LOT of accounts - use a regular account widget - if(count($sel_options['ts_owner']) > Api\Accounts::HUGE_LIMIT) + // Special handling for having access to a LOT of accounts - use a regular account widget + if(count(array_filter($this->grants, static function($grant) + { + return (bool)($grant & Acl::READ); + })) > Api\Accounts::HUGE_LIMIT) { - unset($sel_options['ts_owner']); $etpl->setElementAttribute('ts_owner', 'type', 'et2-nextmatch-header-account'); $etpl->setElementAttribute('ts_owner', 'accountType', 'accounts'); } + else + { + $sel_options['ts_owner'] = $this->grant_list(Acl::READ); + $content['nm']['no_owner_col'] = count($sel_options['ts_owner']) === 1; + } if($this->config_data['history']) { $sel_options['ts_status'][self::DELETED_STATUS] = 'Deleted'; @@ -1060,7 +1064,7 @@ class timesheet_ui extends timesheet_bo if ($this->pm_integration != 'full') { - $projects =& $this->query_list('ts_project'); + $projects = $this->query_list('ts_project'); if (!is_array($projects)) $projects = array(); $sel_options['ts_project'] = $projects + array(lang('No project')); }