]> wagnertech.de Git - timetracker.git/blobdiff - expense_delete.php
Adjusting client_add.php and client_edit.php for subgroups.
[timetracker.git] / expense_delete.php
index 06c9690b0fca79cfd673e56f13268dd584935183..fcb039f07ae1daa931bd52f73831bb04cc7db672 100644 (file)
@@ -31,17 +31,23 @@ import('form.Form');
 import('DateAndTime');
 import('ttExpenseHelper');
 
-// Access check.
-if (!ttAccessAllowed('track_own_expenses') || !$user->isPluginEnabled('ex')) {
+// Access checks.
+if (!(ttAccessAllowed('track_own_expenses') || ttAccessAllowed('track_expenses'))) {
+  header('Location: access_denied.php');
+  exit();
+}
+if (!$user->isPluginEnabled('ex')) {
+  header('Location: feature_disabled.php');
+  exit();
+}
+$cl_id = (int)$request->getParameter('id');
+// Get the expense item we are deleting.
+$expense_item = ttExpenseHelper::getItem($cl_id, $user->getUser());
+if (!$expense_item || $expense_item['invoice_id']) {
+  // Prohibit deleting not ours or invoiced items.
   header('Location: access_denied.php');
   exit();
 }
-
-$cl_id = $request->getParameter('id');
-$expense_item = ttExpenseHelper::getItem($cl_id, $user->getActiveUser());
-
-// Prohibit deleting invoiced records.
-if ($expense_item['invoice_id']) die($i18n->get('error.sys'));
 
 if ($request->isPost()) {
   if ($request->getParameter('delete_button')) { // Delete button pressed.
@@ -53,7 +59,7 @@ if ($request->isPost()) {
 
     if ($err->no()) {
       // Mark the record as deleted.
-      if (ttExpenseHelper::markDeleted($cl_id, $user->getActiveUser())) {
+      if (ttExpenseHelper::markDeleted($cl_id, $user->getUser())) {
         header('Location: expenses.php');
         exit();
       } else