Access check improvements for time and expense edits and deletes.
authorNik Okuntseff <support@anuko.com>
Sun, 25 Mar 2018 22:31:31 +0000 (22:31 +0000)
committerNik Okuntseff <support@anuko.com>
Sun, 25 Mar 2018 22:31:31 +0000 (22:31 +0000)
WEB-INF/templates/footer.tpl
expense_delete.php
expense_edit.php
mobile/expense_delete.php
mobile/expense_edit.php
mobile/time_delete.php
mobile/time_edit.php
time_delete.php
time_edit.php

index 2be4b93..658d120 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.17.71.4167 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+          <td align="center">&nbsp;Anuko Time Tracker 1.17.72.4168 | 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 1f7fbb3..49bb8ac 100644 (file)
@@ -40,12 +40,14 @@ if (!$user->isPluginEnabled('ex')) {
   header('Location: feature_disabled.php');
   exit();
 }
-
-$cl_id = $request->getParameter('id');
+$cl_id = (int)$request->getParameter('id');
+// Get the expense item we are deleting.
 $expense_item = ttExpenseHelper::getItem($cl_id, $user->getActiveUser());
-
-// Prohibit deleting invoiced records.
-if ($expense_item['invoice_id']) die($i18n->get('error.sys'));
+if (!$expense_item || $expense_item['invoice_id']) {
+  // Prohibit deleting not ours or invoiced items.
+  header('Location: access_denied.php');
+  exit();
+}
 
 if ($request->isPost()) {
   if ($request->getParameter('delete_button')) { // Delete button pressed.
index 15cfcfa..99503b0 100644 (file)
@@ -41,14 +41,14 @@ if (!$user->isPluginEnabled('ex')) {
   header('Location: feature_disabled.php');
   exit();
 }
-
-$cl_id = $request->getParameter('id');
-
+$cl_id = (int)$request->getParameter('id');
 // Get the expense item we are editing.
 $expense_item = ttExpenseHelper::getItem($cl_id, $user->getActiveUser());
-
-// Prohibit editing invoiced items.
-if ($expense_item['invoice_id']) die($i18n->get('error.sys'));
+if (!$expense_item || $expense_item['invoice_id']) {
+  // Prohibit editing not ours or invoiced items.
+  header('Location: access_denied.php');
+  exit();
+}
 
 $item_date = new DateAndTime(DB_DATEFORMAT, $expense_item['date']);
 
index cca61b7..a6f0989 100644 (file)
@@ -40,12 +40,14 @@ if (!$user->isPluginEnabled('ex')) {
   header('Location: feature_disabled.php');
   exit();
 }
-
-$cl_id = $request->getParameter('id');
+$cl_id = (int)$request->getParameter('id');
+// Get the expense item we are deleting.
 $expense_item = ttExpenseHelper::getItem($cl_id, $user->getActiveUser());
-
-// Prohibit deleting invoiced records.
-if ($expense_item['invoice_id']) die($i18n->get('error.sys'));
+if (!$expense_item || $expense_item['invoice_id']) {
+  // Prohibit deleting not ours or invoiced items.
+  header('Location: access_denied.php');
+  exit();
+}
 
 if ($request->isPost()) {
   if ($request->getParameter('delete_button')) { // Delete button pressed.
index 8da55a1..1611378 100644 (file)
@@ -41,14 +41,14 @@ if (!$user->isPluginEnabled('ex')) {
   header('Location: feature_disabled.php');
   exit();
 }
-
-$cl_id = $request->getParameter('id');
-
+$cl_id = (int)$request->getParameter('id');
 // Get the expense item we are editing.
 $expense_item = ttExpenseHelper::getItem($cl_id, $user->getActiveUser());
-
-// Prohibit editing invoiced items.
-if ($expense_item['invoice_id']) die($i18n->get('error.sys'));
+if (!$expense_item || $expense_item['invoice_id']) {
+  // Prohibit editing not ours or invoiced items.
+  header('Location: access_denied.php');
+  exit();
+}
 
 $item_date = new DateAndTime(DB_DATEFORMAT, $expense_item['date']);
 
index 33ba614..5d6918c 100644 (file)
@@ -32,17 +32,19 @@ import('ttUserHelper');
 import('ttTimeHelper');
 import('DateAndTime');
 
-// Access check.
+// Access checks.
 if (!ttAccessAllowed('track_own_time')) {
   header('Location: access_denied.php');
   exit();
 }
-
-$cl_id = $request->getParameter('id');
+$cl_id = (int)$request->getParameter('id');
+// Get the time record we are deleting.
 $time_rec = ttTimeHelper::getRecord($cl_id, $user->getActiveUser());
-
-// Prohibit deleting invoiced records.
-if ($time_rec['invoice_id']) die($i18n->get('error.sys'));
+if (!$time_rec || $time_rec['invoice_id']) {
+  // Prohibit deleting not ours or invoiced records.
+  header('Location: access_denied.php');
+  exit();
+}
 
 // Escape comment for presentation.
 $time_rec['comment'] = htmlspecialchars($time_rec['comment']);
index 683bab7..eff9b33 100644 (file)
@@ -39,6 +39,14 @@ if (!ttAccessAllowed('track_own_time')) {
   header('Location: access_denied.php');
   exit();
 }
+$cl_id = (int)$request->getParameter('id');
+// Get the time record we are editing.
+$time_rec = ttTimeHelper::getRecord($cl_id, $user->getActiveUser());
+if (!$time_rec || $time_rec['invoice_id']) {
+  // Prohibit editing not ours or invoiced records.
+  header('Location: access_denied.php');
+  exit();
+}
 
 // Use custom fields plugin if it is enabled.
 if ($user->isPluginEnabled('cf')) {
@@ -47,14 +55,6 @@ if ($user->isPluginEnabled('cf')) {
   $smarty->assign('custom_fields', $custom_fields);
 }
 
-$cl_id = $request->getParameter('id');
-
-// Get the time record we are editing.
-$time_rec = ttTimeHelper::getRecord($cl_id, $user->getActiveUser());
-
-// Prohibit editing invoiced records.
-if ($time_rec['invoice_id']) die($i18n->get('error.sys'));
-
 $item_date = new DateAndTime(DB_DATEFORMAT, $time_rec['date']);
 
 // Initialize variables.
index ec3c677..060311e 100644 (file)
@@ -32,17 +32,19 @@ import('ttUserHelper');
 import('ttTimeHelper');
 import('DateAndTime');
 
-// Access check.
+// Access checks.
 if (!(ttAccessAllowed('track_own_time') || ttAccessAllowed('track_time'))) {
   header('Location: access_denied.php');
   exit();
 }
-
-$cl_id = $request->getParameter('id');
+$cl_id = (int)$request->getParameter('id');
+// Get the time record we are deleting.
 $time_rec = ttTimeHelper::getRecord($cl_id, $user->getActiveUser());
-
-// Prohibit deleting invoiced records.
-if ($time_rec['invoice_id']) die($i18n->get('error.sys'));
+if (!$time_rec || $time_rec['invoice_id']) {
+  // Prohibit deleting not ours or invoiced records.
+  header('Location: access_denied.php');
+  exit();
+}
 
 // Escape comment for presentation.
 $time_rec['comment'] = htmlspecialchars($time_rec['comment']);
index c14928f..05db97c 100644 (file)
@@ -34,11 +34,19 @@ import('ttClientHelper');
 import('ttTimeHelper');
 import('DateAndTime');
 
-// Access check.
+// Access checks.
 if (!(ttAccessAllowed('track_own_time') || ttAccessAllowed('track_time'))) {
   header('Location: access_denied.php');
   exit();
 }
+$cl_id = (int)$request->getParameter('id');
+// Get the time record we are editing.
+$time_rec = ttTimeHelper::getRecord($cl_id, $user->getActiveUser());
+if (!$time_rec || $time_rec['invoice_id']) {
+  // Prohibit editing not ours or invoiced records.
+  header('Location: access_denied.php');
+  exit();
+}
 
 // Use custom fields plugin if it is enabled.
 if ($user->isPluginEnabled('cf')) {
@@ -47,14 +55,6 @@ if ($user->isPluginEnabled('cf')) {
   $smarty->assign('custom_fields', $custom_fields);
 }
 
-$cl_id = $request->getParameter('id');
-
-// Get the time record we are editing.
-$time_rec = ttTimeHelper::getRecord($cl_id, $user->getActiveUser());
-
-// Prohibit editing invoiced records.
-if ($time_rec['invoice_id']) die($i18n->get('error.sys'));
-
 $item_date = new DateAndTime(DB_DATEFORMAT, $time_rec['date']);
 
 // Initialize variables.