Soem refactoring to keep things a bit more consistent.
[timetracker.git] / WEB-INF / lib / ttReportHelper.class.php
index 3520dfd..56a4aa8 100644 (file)
@@ -286,7 +286,7 @@ class ttReportHelper {
       $left_joins .= " left join tt_clients c on (c.id = l.client_id)";
     if (($user->canManageTeam() || $user->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() || ttPluginEnabled('ex'))
+    if ($user->canManageTeam() || $user->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)";
@@ -311,7 +311,7 @@ class ttReportHelper {
     // with an exception of sorting part, that is added in the end.
 
     // However, when we have expenses, we need to do a union with a separate query for expense items from tt_expense_items table.
-    if ($bean->getAttribute('chcost') && ttPluginEnabled('ex')) { // if ex(penses) plugin is enabled
+    if ($bean->getAttribute('chcost') && $user->isPluginEnabled('ex')) { // if ex(penses) plugin is enabled
 
       $fields = array(); // An array of fields for database query.
       array_push($fields, 'ei.id');
@@ -492,7 +492,7 @@ class ttReportHelper {
       $left_joins .= " left join tt_clients c on (c.id = l.client_id)";
     if (($user->canManageTeam() || $user->isClient()) && $report['show_invoice'])
       $left_joins .= " left join tt_invoices i on (i.id = l.invoice_id and i.status = 1)";
-    if ($user->canManageTeam() || $user->isClient() || ttPluginEnabled('ex'))
+    if ($user->canManageTeam() || $user->isClient() || $user->isPluginEnabled('ex'))
        $left_joins .= " left join tt_users u on (u.id = l.user_id)";
     if ($report['show_project'] || 'project' == $group_by_option)
       $left_joins .= " left join tt_projects p on (p.id = l.project_id)";
@@ -517,7 +517,7 @@ class ttReportHelper {
     // with an exception of sorting part, that is added in the end.
 
     // However, when we have expenses, we need to do a union with a separate query for expense items from tt_expense_items table.
-    if ($report['show_cost'] && in_array('ex', explode(',', $user->plugins))) { // if ex(penses) plugin is enabled
+    if ($report['show_cost'] && $user->isPluginEnabled('ex')) { // if ex(penses) plugin is enabled
 
       $fields = array(); // An array of fields for database query.
       array_push($fields, 'ei.id');
@@ -697,7 +697,7 @@ class ttReportHelper {
     // By now we have sql for time items.
 
     // However, when we have expenses, we need to do a union with a separate query for expense items from tt_expense_items table.
-    if ($bean->getAttribute('chcost') && in_array('ex', explode(',', $user->plugins))) { // if ex(penses) plugin is enabled
+    if ($bean->getAttribute('chcost') && $user->isPluginEnabled('ex')) { // if ex(penses) plugin is enabled
 
       // Determine group by field and a required join.
       $group_join = null;
@@ -825,7 +825,7 @@ class ttReportHelper {
     // By now we have sql for time items.
 
     // However, when we have expenses, we need to do a union with a separate query for expense items from tt_expense_items table.
-    if ($report['show_cost'] && in_array('ex', explode(',', $user->plugins))) { // if ex(penses) plugin is enabled
+    if ($report['show_cost'] && $user->isPluginEnabled('ex')) { // if ex(penses) plugin is enabled
 
       // Determine group by field and a required join.
       $group_join = null;
@@ -912,7 +912,7 @@ class ttReportHelper {
       $sql = "select sum(time_to_sec(l.duration)) as time, null as cost, null as expenses from tt_log l $where";
 
     // If we have expenses, query becomes a bit more complex.
-    if ($bean->getAttribute('chcost') && in_array('ex', explode(',', $user->plugins))) {
+    if ($bean->getAttribute('chcost') && $user->isPluginEnabled('ex')) {
       $where = ttReportHelper::getExpenseWhere($bean);
       $sql_for_expenses = "select null as time, sum(cost) as cost, sum(cost) as expenses from tt_expense_items ei $where";
       // Create a combined query.
@@ -982,7 +982,7 @@ class ttReportHelper {
       $sql = "select sum(time_to_sec(l.duration)) as time, null as cost, null as expenses from tt_log l $where";
 
     // If we have expenses, query becomes a bit more complex.
-    if ($report['show_cost'] && in_array('ex', explode(',', $user->plugins))) {
+    if ($report['show_cost'] && $user->isPluginEnabled('ex')) {
       $where = ttReportHelper::getFavExpenseWhere($report);
       $sql_for_expenses = "select null as time, sum(cost) as cost, sum(cost) as expenses from tt_expense_items ei $where";
       // Create a combined query.
@@ -1055,7 +1055,7 @@ class ttReportHelper {
     $totals = ttReportHelper::getTotals($bean);
 
     // Use custom fields plugin if it is enabled.
-    if (in_array('cf', explode(',', $user->plugins)))
+    if ($user->isPluginEnabled('cf'))
       $custom_fields = new CustomFields($user->team_id);
 
     // Define some styles to use in email.
@@ -1313,7 +1313,7 @@ class ttReportHelper {
     $totals = ttReportHelper::getFavTotals($report);
 
     // Use custom fields plugin if it is enabled.
-    if (in_array('cf', explode(',', $user->plugins)))
+    if ($user->isPluginEnabled('cf'))
       $custom_fields = new CustomFields($user->team_id);
 
     // Define some styles to use in email.
@@ -1574,7 +1574,7 @@ class ttReportHelper {
     $mailer->setContentType('text/html');
     $mailer->setSender(SENDER);
     $mailer->setReceiver($email);
-    $mailer->setSendType(MAIL_MODE);
+    $mailer->setMailMode(MAIL_MODE);
     if (!$mailer->send($report['name'], $body))
       return false;