From: Nik Okuntseff Date: Wed, 14 Mar 2018 02:16:35 +0000 (+0000) Subject: A bit more progress on getting rid of canManageTeam. X-Git-Tag: timetracker_1.19-1~1040 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=585ffedd49344ba7f2cd4873f76f6ac71360a55c;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 6ba55e36..ed5c0cab 100644 --- a/WEB-INF/lib/ttReportHelper.class.php +++ b/WEB-INF/lib/ttReportHelper.class.php @@ -231,6 +231,10 @@ class ttReportHelper { global $user; $mdb2 = getConnection(); + // Determine these once as they are used in multiple places in this function. + $canViewReports = $user->can('view_reports'); + $isClient = $user->isClient(); + $group_by_option = $bean->getAttribute('group_by'); $convertTo12Hour = ('%I:%M %p' == $user->time_format) && ($bean->getAttribute('chstart') || $bean->getAttribute('chfinish')); @@ -239,7 +243,7 @@ class ttReportHelper { array_push($fields, 'l.id as id'); array_push($fields, '1 as type'); // Type 1 is for tt_log entries. array_push($fields, 'l.date as date'); - if($user->can('view_reports') || $user->isClient()) + if($canViewReports || $isClient) array_push($fields, 'u.name as user'); // Add client name if it is selected. if ($bean->getAttribute('chclient') || 'client' == $group_by_option) @@ -285,20 +289,20 @@ class ttReportHelper { array_push($fields, "null as expense"); } // Add paid status. - if ($user->canManageTeam() && $bean->getAttribute('chpaid')) + if ($canViewReports && $bean->getAttribute('chpaid')) array_push($fields, 'l.paid as paid'); // Add invoice name if it is selected. - if (($user->canManageTeam() || $user->isClient()) && $bean->getAttribute('chinvoice')) + if (($canViewReports || $isClient) && $bean->getAttribute('chinvoice')) array_push($fields, 'i.name as invoice'); // Prepare sql query part for left joins. $left_joins = null; if ($bean->getAttribute('chclient') || 'client' == $group_by_option) $left_joins .= " left join tt_clients c on (c.id = l.client_id)"; - if (($user->canManageTeam() || $user->isClient()) && $bean->getAttribute('chinvoice')) + if (($canViewReports || $isClient) && $bean->getAttribute('chinvoice')) $left_joins .= " left join tt_invoices i on (i.id = l.invoice_id and i.status = 1)"; - if ($user->canManageTeam() || $user->isClient() || $user->isPluginEnabled('ex')) + if ($canViewReports || $isClient || $user->isPluginEnabled('ex')) $left_joins .= " left join tt_users u on (u.id = l.user_id)"; if ($bean->getAttribute('chproject') || 'project' == $group_by_option) $left_joins .= " left join tt_projects p on (p.id = l.project_id)"; @@ -329,7 +333,7 @@ class ttReportHelper { array_push($fields, 'ei.id'); array_push($fields, '2 as type'); // Type 2 is for tt_expense_items entries. array_push($fields, 'ei.date'); - if($user->canManageTeam() || $user->isClient()) + if($canViewReports || $isClient) array_push($fields, 'u.name as user'); // Add client name if it is selected. if ($bean->getAttribute('chclient') || 'client' == $group_by_option) @@ -355,21 +359,21 @@ class ttReportHelper { array_push($fields, 'ei.cost as cost'); array_push($fields, 'ei.cost as expense'); // Add paid status. - if ($user->canManageTeam() && $bean->getAttribute('chpaid')) + if ($canViewReports && $bean->getAttribute('chpaid')) array_push($fields, 'ei.paid as paid'); // Add invoice name if it is selected. - if (($user->canManageTeam() || $user->isClient()) && $bean->getAttribute('chinvoice')) + if (($canViewReports || $isClient) && $bean->getAttribute('chinvoice')) array_push($fields, 'i.name as invoice'); // Prepare sql query part for left joins. $left_joins = null; - if ($user->canManageTeam() || $user->isClient()) + if ($canViewReports || $isClient) $left_joins .= " left join tt_users u on (u.id = ei.user_id)"; if ($bean->getAttribute('chclient') || 'client' == $group_by_option) $left_joins .= " left join tt_clients c on (c.id = ei.client_id)"; if ($bean->getAttribute('chproject') || 'project' == $group_by_option) $left_joins .= " left join tt_projects p on (p.id = ei.project_id)"; - if (($user->canManageTeam() || $user->isClient()) && $bean->getAttribute('chinvoice')) + if (($canViewReports || $isClient) && $bean->getAttribute('chinvoice')) $left_joins .= " left join tt_invoices i on (i.id = ei.invoice_id and i.status = 1)"; $where = ttReportHelper::getExpenseWhere($bean); @@ -387,7 +391,7 @@ class ttReportHelper { $sort_part .= 'date'; else $sort_part .= $group_by_option.', date'; - if (($user->canManageTeam() || $user->isClient()) && is_array($bean->getAttribute('users')) && 'user' != $group_by_option) + if (($canViewReports || $isClient) && is_array($bean->getAttribute('users')) && 'user' != $group_by_option) $sort_part .= ', user, type'; if ($bean->getAttribute('chstart')) $sort_part .= ', unformatted_start'; diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 9df34ecb..3da2cde9 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,8 +12,7 @@
-
 Anuko Time Tracker 1.17.43.4071 - | Copyright © Anuko | +  Anuko Time Tracker 1.17.43.4072 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve}