A bit more progress with renaming teams to groups.
[timetracker.git] / expense_delete.php
index 06c9690..49bb8ac 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();
 }
-
-$cl_id = $request->getParameter('id');
+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->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.