From: Nik Okuntseff Date: Wed, 14 Mar 2018 15:09:05 +0000 (+0000) Subject: A bit more progress on getting rid of canManageTeam. X-Git-Tag: timetracker_1.19-1~1038 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=2cb68f81bd4dd4f4a83afc87bbc292df6b7d7039;p=timetracker.git A bit more progress on getting rid of canManageTeam. --- diff --git a/WEB-INF/lib/ttReportHelper.class.php b/WEB-INF/lib/ttReportHelper.class.php index 927892e7..223d8e4b 100644 --- a/WEB-INF/lib/ttReportHelper.class.php +++ b/WEB-INF/lib/ttReportHelper.class.php @@ -1121,6 +1121,10 @@ class ttReportHelper { global $user; global $i18n; + // Determine these once as they are used in multiple places in this function. + $canViewReports = $user->can('view_reports'); + $isClient = $user->isClient(); + $items = ttReportHelper::getItems($bean); $group_by = $bean->getAttribute('group_by'); if ($group_by && 'no_grouping' != $group_by) @@ -1183,7 +1187,7 @@ class ttReportHelper { } if ($bean->getAttribute('chcost')) { $body .= ''; - $body .= ($user->canManageTeam() || $user->isClient()) ? $subtotal['cost'] : $subtotal['expenses']; + $body .= ($canViewReports || $isClient) ? $subtotal['cost'] : $subtotal['expenses']; $body .= ''; } $body .= ''; @@ -1200,7 +1204,7 @@ class ttReportHelper { } if ($bean->getAttribute('chcost')) { $body .= ''.htmlspecialchars($user->currency).' '; - $body .= ($user->canManageTeam() || $user->isClient()) ? $totals['cost'] : $totals['expenses']; + $body .= ($canViewReports || $isClient) ? $totals['cost'] : $totals['expenses']; $body .= ''; } $body .= ''; @@ -1213,7 +1217,7 @@ class ttReportHelper { $body .= ''; $body .= ''; $body .= ''; - if ($user->canManageTeam() || $user->isClient()) + if ($canViewReports || $isClient) $body .= ''; if ($bean->getAttribute('chclient')) $body .= ''; @@ -1262,7 +1266,7 @@ class ttReportHelper { $body .= ''; $body .= ''; $subtotal_name = htmlspecialchars($subtotals[$prev_grouped_by]['name']); - if ($user->canManageTeam() || $user->isClient()) $body .= ''; + if ($canViewReports || $isClient) $body .= ''; if ($bean->getAttribute('chclient')) $body .= ''; if ($bean->getAttribute('chproject')) $body .= ''; if ($bean->getAttribute('chtask')) $body .= ''; @@ -1273,7 +1277,7 @@ class ttReportHelper { if ($bean->getAttribute('chnote')) $body .= ''; if ($bean->getAttribute('chcost')) { $body .= ''; } if ($bean->getAttribute('chpaid')) $body .= ''; @@ -1289,7 +1293,7 @@ class ttReportHelper { $row_style = ($row_style == $rowItem) ? $rowItemAlt : $rowItem; $body .= ''; $body .= ''; - if ($user->canManageTeam() || $user->isClient()) + if ($canViewReports || $isClient) $body .= ''; if ($bean->getAttribute('chclient')) $body .= ''; @@ -1329,7 +1333,7 @@ class ttReportHelper { $body .= ''; $body .= ''; $subtotal_name = htmlspecialchars($subtotals[$cur_grouped_by]['name']); - if ($user->canManageTeam() || $user->isClient()) $body .= ''; + if ($canViewReports || $isClient) $body .= ''; if ($bean->getAttribute('chclient')) $body .= ''; if ($bean->getAttribute('chproject')) $body .= ''; if ($bean->getAttribute('chtask')) $body .= ''; @@ -1340,7 +1344,7 @@ class ttReportHelper { if ($bean->getAttribute('chnote')) $body .= ''; if ($bean->getAttribute('chcost')) { $body .= ''; } if ($bean->getAttribute('chpaid')) $body .= ''; @@ -1352,7 +1356,7 @@ class ttReportHelper { $body .= ''; $body .= ''; $body .= ''; - if ($user->canManageTeam() || $user->isClient()) $body .= ''; + if ($canViewReports || $isClient) $body .= ''; if ($bean->getAttribute('chclient')) $body .= ''; if ($bean->getAttribute('chproject')) $body .= ''; if ($bean->getAttribute('chtask')) $body .= ''; @@ -1363,7 +1367,7 @@ class ttReportHelper { if ($bean->getAttribute('chnote')) $body .= ''; if ($bean->getAttribute('chcost')) { $body .= ''; } if ($bean->getAttribute('chpaid')) $body .= ''; diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index ebd19bfe..84d18319 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
'.$i18n->getKey('label.date').''.$i18n->getKey('label.user').''.$i18n->getKey('label.client').'
'.$i18n->getKey('label.subtotal').''.($group_by == 'user' ? $subtotal_name : '').''.($group_by == 'user' ? $subtotal_name : '').''.($group_by == 'client' ? $subtotal_name : '').''.($group_by == 'project' ? $subtotal_name : '').''.($group_by == 'task' ? $subtotal_name : '').''; - $body .= ($user->canManageTeam() || $user->isClient()) ? $subtotals[$prev_grouped_by]['cost'] : $subtotals[$prev_grouped_by]['expenses']; + $body .= ($canViewReports || $isClient) ? $subtotals[$prev_grouped_by]['cost'] : $subtotals[$prev_grouped_by]['expenses']; $body .= '
'.$record['date'].''.htmlspecialchars($record['user']).''.htmlspecialchars($record['client']).'
'.$i18n->getKey('label.subtotal').''.($group_by == 'user' ? $subtotal_name : '').''.($group_by == 'user' ? $subtotal_name : '').''.($group_by == 'client' ? $subtotal_name : '').''.($group_by == 'project' ? $subtotal_name : '').''.($group_by == 'task' ? $subtotal_name : '').''; - $body .= ($user->canManageTeam() || $user->isClient()) ? $subtotals[$cur_grouped_by]['cost'] : $subtotals[$cur_grouped_by]['expenses']; + $body .= ($canViewReports || $isClient) ? $subtotals[$cur_grouped_by]['cost'] : $subtotals[$cur_grouped_by]['expenses']; $body .= '
 
'.$i18n->getKey('label.total').''.htmlspecialchars($user->currency).' '; - $body .= ($user->canManageTeam() || $user->isClient()) ? $totals['cost'] : $totals['expenses']; + $body .= ($canViewReports || $isClient) ? $totals['cost'] : $totals['expenses']; $body .= '
-
 Anuko Time Tracker 1.17.43.4073 | Copyright © Anuko | +  Anuko Time Tracker 1.17.43.4074 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve}