* Infolog / Tracker: Change timesheet total columns to ignore timesheet ACL

Use "Respect timesheet run and read permissions for time totals" configuration setting for previous behaviour, which may exclude some timesheet entries
This commit is contained in:
nathan 2023-06-09 13:18:32 -06:00
parent 7799ef9a97
commit b1fe818527
5 changed files with 110 additions and 57 deletions

View File

@ -208,12 +208,23 @@ class infolog_ui
{ {
$info['class'] .= 'rowNoSubs '; $info['class'] .= 'rowNoSubs ';
} }
if ($info['info_id_parent']) $info['class'] .= 'infolog_rowHasParent '; if($info['info_id_parent'])
if ($info['info_anz_subs'] > 0) $info['class'] .= 'infolog_rowHasSubs '; {
$info['class'] .= 'infolog_rowHasParent ';
}
if($info['info_anz_subs'] > 0)
{
$info['class'] .= 'infolog_rowHasSubs ';
}
$info['row_mod'] = $info['info_datemodified']; $info['row_mod'] = $info['info_datemodified'];
$timesheet_bo = new timesheet_bo();
$config = Api\Config::read('infolog');
if (!$show_links) $show_links = $this->prefs['show_links']; if(!$show_links)
{
$show_links = $this->prefs['show_links'];
}
if(($show_links != 'none' && $show_links != 'no_describtion' || if(($show_links != 'none' && $show_links != 'no_describtion' ||
$this->prefs['show_times'] || isset($GLOBALS['egw_info']['user']['apps']['timesheet'])) && $this->prefs['show_times'] || isset($GLOBALS['egw_info']['user']['apps']['timesheet'])) &&
(isset($info['links']) || ($info['links'] = Link::get_links('infolog', $info['info_id'], '', 'link_lastmod DESC', true, true)))) (isset($info['links']) || ($info['links'] = Link::get_links('infolog', $info['info_id'], '', 'link_lastmod DESC', true, true))))
@ -223,9 +234,15 @@ class infolog_ui
{ {
// incl. link modification time into row_mod (link's lastmod is always in server-time!) // incl. link modification time into row_mod (link's lastmod is always in server-time!)
$link_mod = Api\DateTime::server2user($link['lastmod']); $link_mod = Api\DateTime::server2user($link['lastmod']);
if ($info['row_mod'] < $link_mod) $info['row_mod'] = $link_mod; if($info['row_mod'] < $link_mod)
{
$info['row_mod'] = $link_mod;
}
if ($link['deleted']) continue; // skip deleted links, but incl. them in row_mod! if($link['deleted'])
{
continue;
} // skip deleted links, but incl. them in row_mod!
if($show_links != 'none' && $show_links != 'no_describtion' && if($show_links != 'none' && $show_links != 'no_describtion' &&
$link['link_id'] != $info['info_link_id'] && $link['link_id'] != $info['info_link_id'] &&
@ -242,7 +259,7 @@ class infolog_ui
} }
if ($this->prefs['show_times'] && isset($GLOBALS['egw_info']['user']['apps']['timesheet']) && $timesheets) if ($this->prefs['show_times'] && isset($GLOBALS['egw_info']['user']['apps']['timesheet']) && $timesheets)
{ {
$sum = ExecMethod('timesheet.timesheet_bo.sum',$timesheets); $sum = $timesheet_bo->sum($timesheets, !$config['respect_timesheet_rights']);
$info['info_sum_timesheets'] = $sum['duration']; $info['info_sum_timesheets'] = $sum['duration'];
// incl. max timesheet modification in row_mod // incl. max timesheet modification in row_mod
if ($info['row_mod'] < $sum['max_modified']) $info['row_mod'] = $sum['max_modified']; if ($info['row_mod'] < $sum['max_modified']) $info['row_mod'] = $sum['max_modified'];
@ -448,6 +465,14 @@ class infolog_ui
// set old show_times pref, that get_info calculates the cumulated time of the timesheets (we only check used&planned to work for both time cols) // set old show_times pref, that get_info calculates the cumulated time of the timesheets (we only check used&planned to work for both time cols)
$this->prefs['show_times'] = strpos($this->prefs[$query['columnselection_pref']], 'info_used_time_info_planned_time') !== false; $this->prefs['show_times'] = strpos($this->prefs[$query['columnselection_pref']], 'info_used_time_info_planned_time') !== false;
$reset_timesheet = false;
$config = Api\Config::read('infolog');
if(!$config['respect_timesheet_rights'] && !isset($GLOBALS['egw_info']['user']['apps']['timesheet']))
{
$reset_timesheet = true;
$GLOBALS['egw_info']['user']['apps']['timesheet'] = true;
}
// query all links and sub counts in one go // query all links and sub counts in one go
if($infos && (!$query['csv_export'] || !is_array($query['csv_export']))) if($infos && (!$query['csv_export'] || !is_array($query['csv_export'])))
{ {
@ -469,7 +494,11 @@ class infolog_ui
$parent_first = !empty($parents) && count($parents) == 1; $parent_first = !empty($parents) && count($parents) == 1;
$parent_index = 0; $parent_index = 0;
// et2 nextmatch listens to total, and only displays that many rows, so add parent in or we'll lose the last row // et2 nextmatch listens to total, and only displays that many rows, so add parent in or we'll lose the last row
if($parent_first || $query['action'] == 'sp' && is_array($query['action_id'])) $query['total']++; if($parent_first || $query['action'] == 'sp' && is_array($query['action_id']))
{
$query['total']++;
}
// Check to see if we need to remove description // Check to see if we need to remove description
foreach($infos as $id => $info) foreach($infos as $id => $info)
@ -514,9 +543,19 @@ class infolog_ui
} }
unset($links); unset($links);
if ($query['cat_id']) $rows['no_cat_id'] = true; if($query['cat_id'])
if ($query['no_actions']) $rows['no_actions'] = true; {
$rows['no_cat_id'] = true;
}
if($query['no_actions'])
{
$rows['no_actions'] = true;
}
$rows['no_timesheet'] = !isset($GLOBALS['egw_info']['user']['apps']['timesheet']); $rows['no_timesheet'] = !isset($GLOBALS['egw_info']['user']['apps']['timesheet']);
if($reset_timesheet)
{
unset($GLOBALS['egw_info']['user']['apps']['timesheet']);
}
if($clear_status_filter) if($clear_status_filter)
{ {
$rows['info_status'] = ''; $rows['info_status'] = '';

View File

@ -397,6 +397,7 @@ removed infolog de Entfernt
removed category infolog de Kategorie erfolgreich entfernt removed category infolog de Kategorie erfolgreich entfernt
replacement infolog de Platzhalter replacement infolog de Platzhalter
replacements for inserting entries into documents infolog de Platzhalter für das Einfügen in Dokumente replacements for inserting entries into documents infolog de Platzhalter für das Einfügen in Dokumente
respect timesheet run and read permissions for time totals infolog de Respektieren Sie die Ausführungs- und Leseberechtigungen für Zeittabellen
responsible infolog de verantwortlich responsible infolog de verantwortlich
responsible open infolog de verantwortlich offen responsible open infolog de verantwortlich offen
responsible open and upcoming infolog de verantwortlich offene und zukünftige responsible open and upcoming infolog de verantwortlich offene und zukünftige

View File

@ -397,6 +397,7 @@ removed infolog en Removed.
removed category infolog en removed category removed category infolog en removed category
replacement infolog en Replacement replacement infolog en Replacement
replacements for inserting entries into documents infolog en Replacements for inserting entries into documents replacements for inserting entries into documents infolog en Replacements for inserting entries into documents
respect timesheet run and read permissions for time totals infolog en Respect timesheet run and read permissions for time totals
responsible infolog en Responsible responsible infolog en Responsible
responsible open infolog en Responsible open responsible open infolog en Responsible open
responsible open and upcoming infolog en Responsible open and upcoming responsible open and upcoming infolog en Responsible open and upcoming

View File

@ -32,6 +32,10 @@
<row class="th"> <row class="th">
<et2-description value="Other configurations" span="all"></et2-description> <et2-description value="Other configurations" span="all"></et2-description>
</row> </row>
<row>
<et2-description value="Respect timesheet run and read permissions for time totals" labelFor="respect_timesheet_rights"></et2-description>
<et2-checkbox id="respect_timesheet_rights"></et2-checkbox>
</row>
<row> <row>
<et2-description value="Fields to exclude when copying an infolog:"></et2-description> <et2-description value="Fields to exclude when copying an infolog:"></et2-description>
<et2-select id="copy_excludefields" rows="6" multiple="1"></et2-select> <et2-select id="copy_excludefields" rows="6" multiple="1"></et2-select>

View File

@ -464,7 +464,10 @@ class timesheet_bo extends Api\Storage
} }
else else
{ {
if (!is_array($filter['ts_owner'])) $filter['ts_owner'] = array($filter['ts_owner']); if(!is_array($filter['ts_owner']))
{
$filter['ts_owner'] = array($filter['ts_owner']);
}
foreach($filter['ts_owner'] as $key => $owner) foreach($filter['ts_owner'] as $key => $owner)
{ {
@ -483,7 +486,7 @@ class timesheet_bo extends Api\Storage
$filter[] = '(ts_status ' . ($filter['ts_status'] == self::DELETED_STATUS ? '=' : '!= ') . self::DELETED_STATUS . $filter[] = '(ts_status ' . ($filter['ts_status'] == self::DELETED_STATUS ? '=' : '!= ') . self::DELETED_STATUS .
($filter['ts_status'] == self::DELETED_STATUS ? '' : ' OR ts_status IS NULL') . ')'; ($filter['ts_status'] == self::DELETED_STATUS ? '' : ' OR ts_status IS NULL') . ')';
} }
if (!count($filter['ts_owner'])) if(is_array($filter['ts_owner']) && !count($filter['ts_owner']))
{ {
$this->total = 0; $this->total = 0;
$this->summary = array(); $this->summary = array();
@ -779,13 +782,18 @@ class timesheet_bo extends Api\Storage
* @param array $ids array of timesheet id's * @param array $ids array of timesheet id's
* @return array with values for keys "duration", "price", "max_modified" and "quantity" * @return array with values for keys "duration", "price", "max_modified" and "quantity"
*/ */
function sum($ids) function sum($ids, $ignore_acl = false)
{ {
if(!$ids) if(!$ids)
{ {
return array('duration' => 0, 'quantity' => 0, 'price' => 0, 'max_modified' => null); return array('duration' => 0, 'quantity' => 0, 'price' => 0, 'max_modified' => null);
} }
return $this->search(array('ts_id'=>$ids),true,'','','',false,'AND',false,null,'',false,true); $filter = [];
if($ignore_acl)
{
$filter['ts_owner'] = false;
}
return $this->search(array('ts_id' => $ids), true, '', '', '', false, 'AND', false, $filter, '', false, true);
} }
/** /**