Wrote ttUser::isPluginEnabled() function.
authorNik Okuntseff <support@anuko.com>
Wed, 30 Mar 2016 16:32:40 +0000 (16:32 +0000)
committerNik Okuntseff <support@anuko.com>
Wed, 30 Mar 2016 16:32:40 +0000 (16:32 +0000)
WEB-INF/lib/common.lib.php
WEB-INF/lib/ttExpenseHelper.class.php
WEB-INF/lib/ttInvoiceHelper.class.php
WEB-INF/lib/ttReportHelper.class.php
WEB-INF/lib/ttUser.class.php
WEB-INF/templates/footer.tpl
time.php

index 3644c05..124b78f 100644 (file)
@@ -340,10 +340,3 @@ function ttAccessCheck($required_rights)
     
   return true;
 }
-
-// ttPluginEnabled is used to check whether a plugin is enabled for user.
-function ttPluginEnabled($plugin)
-{
-  global $user;
-  return in_array($plugin, explode(',', $user->plugins));
-}
index 86ccbcd..23ea390 100644 (file)
@@ -109,17 +109,17 @@ class ttExpenseHelper {
   
   // getItem - retrieves an entry from tt_expense_items table.
   static function getItem($id, $user_id) {
-       global $user;
+    global $user;
        
     $mdb2 = getConnection();
     
     $client_field = null;
-    if (ttPluginEnabled('cl'))
+    if ($user->isPluginEnabled('cl'))
       $client_field = ", c.name as client_name";
       
     $left_joins = "";
     $left_joins = " left join tt_projects p on (ei.project_id = p.id)";
-    if (ttPluginEnabled('cl'))
+    if ($user->isPluginEnabled('cl'))
       $left_joins .= " left join tt_clients c on (ei.client_id = c.id)";
       
     $sql = "select ei.id, ei.date, ei.client_id, ei.project_id, ei.name, ei.cost, ei.invoice_id $client_field, p.name as project_name
@@ -159,18 +159,18 @@ class ttExpenseHelper {
 
   // getItems - returns expense items for a user for a given date.
   static function getItems($user_id, $date) {
-       global $user;
+    global $user;
                
     $result = array();
     $mdb2 = getConnection();
 
     $client_field = null;
-    if (ttPluginEnabled('cl'))
+    if ($user->isPluginEnabled('cl'))
       $client_field = ", c.name as client";
     
     $left_joins = "";
     $left_joins = " left join tt_projects p on (ei.project_id = p.id)";
-    if (ttPluginEnabled('cl'))
+    if ($user->isPluginEnabled('cl'))
       $left_joins .= " left join tt_clients c on (ei.client_id = c.id)";
 
     $sql = "select ei.id as id $client_field, p.name as project, ei.name as item, ei.cost as cost,
index d506830..b5a3c59 100644 (file)
@@ -129,7 +129,7 @@ class ttInvoiceHelper {
     }
 
     // If we have expenses, we need to do a union with a separate query for expense items from tt_expense_items table.
-    if (ttPluginEnabled('ex')) { // if ex(penses) plugin is enabled
+    if ($user->isPluginEnabled('ex')) {
       $sql_for_expense_items = "select ei.date as date, 2 as type, u.name as user_name, p.name as project_name,
         null as task_name, ei.name as note,
         null as duration, ei.cost as cost from tt_expense_items ei
@@ -336,7 +336,7 @@ class ttInvoiceHelper {
     foreach($invoice_items as $item)
       $subtotal += $item['cost'];
     if ($tax_percent) {
-      $tax_expenses = ttPluginEnabled('et');
+      $tax_expenses = $user->isPluginEnabled('et');
       foreach($invoice_items as $item) {
         if ($item['type'] == 2 && !$tax_expenses)
           continue;
index 3520dfd..9d0fc87 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)";
index 959649e..84b229f 100644 (file)
@@ -31,8 +31,8 @@ class ttUser {
   var $name = null;         // User name.
   var $id = null;           // User id.
   var $team_id = null;      // Team id.
-  var $role = null;                    // User role (user, client, comanager, manager, admin).
-  var $client_id = null;       // Client id for client user role.
+  var $role = null;         // User role (user, client, comanager, manager, admin).
+  var $client_id = null;    // Client id for client user role.
   var $behalf_id = null;    // User id, on behalf of whom we are working.
   var $behalf_name = null;  // User name, on behalf of whom we are working.
   var $email = null;        // User email.
@@ -45,10 +45,10 @@ class ttUser {
   var $record_type = 0;     // Record type (duration vs start and finish, or both).
   var $currency = null;     // Currency.
   var $plugins = null;      // Comma-separated list of enabled plugins.
-  var $team = null;            // Team name.
+  var $team = null;         // Team name.
   var $custom_logo = 0;     // Whether to use a custom logo for team.
-  var $address = null;         // Address for invoices.
-  var $lock_interval = 0;      // Lock interval in days for time records.
+  var $address = null;      // Address for invoices.
+  var $lock_interval = 0;   // Lock interval in days for time records.
   var $rights = 0;          // A mask of user rights.
   
   // Constructor.
@@ -149,6 +149,12 @@ class ttUser {
     return (right_manage_team & $this->role);
   }
   
+  // isPluginEnabled checks whether a plugin is enabled for user.
+  function isPluginEnabled($plugin)
+  {
+    return in_array($plugin, explode(',', $this->plugins));
+  }
+
   // getAssignedProjects - returns an array of assigned projects.
   function getAssignedProjects()
   {
index 1a1cf38..b1b27b0 100644 (file)
@@ -12,7 +12,7 @@
       <br>
       <table cellspacing="0" cellpadding="4" width="100%" border="0">
         <tr>
-          <td align="center">&nbsp;Anuko Time Tracker 1.9.20.3457 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+          <td align="center">&nbsp;Anuko Time Tracker 1.9.20.3458 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
             <a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
             <a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
             <a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>
index d5a28bb..193f7a2 100644 (file)
--- a/time.php
+++ b/time.php
@@ -57,7 +57,7 @@ if(!$cl_date)
 $_SESSION['date'] = $cl_date;
 
 // Use custom fields plugin if it is enabled.
-if (ttPluginEnabled('cf')) {
+if ($user->isPluginEnabled('cf')) {
   require_once('plugins/CustomFields.class.php');
   $custom_fields = new CustomFields($user->team_id);
   $smarty->assign('custom_fields', $custom_fields);