X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/timetracker.git/blobdiff_plain/fd0872d9e582113346fa1e93557f370286c5c9f2..c83e33b75d24c71b29df94a061e79a3079f7fe12:/mobile/expense_edit.php diff --git a/mobile/expense_edit.php b/mobile/expense_edit.php index 7107e785..338e6c77 100644 --- a/mobile/expense_edit.php +++ b/mobile/expense_edit.php @@ -32,19 +32,23 @@ import('ttTeamHelper'); 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 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']); @@ -69,7 +73,7 @@ $form = new Form('expenseItemForm'); // Dropdown for clients in MODE_TIME. Use all active clients. if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) { - $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); + $active_clients = ttTeamHelper::getActiveClients($user->group_id, true); $form->addInput(array('type'=>'combobox', 'onchange'=>'fillProjectDropdown(this.value);', 'name'=>'client', @@ -94,7 +98,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t // Dropdown for clients if the clients plugin is enabled. if ($user->isPluginEnabled('cl')) { - $active_clients = ttTeamHelper::getActiveClients($user->team_id, true); + $active_clients = ttTeamHelper::getActiveClients($user->group_id, true); // We need an array of assigned project ids to do some trimming. foreach($project_list as $project) $projects_assigned_to_user[] = $project['id']; @@ -120,7 +124,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t } } // If predefined expenses are configured, add controls to select an expense and quantity. -$predefined_expenses = ttTeamHelper::getPredefinedExpenses($user->team_id); +$predefined_expenses = ttTeamHelper::getPredefinedExpenses($user->group_id); if ($predefined_expenses) { $form->addInput(array('type'=>'combobox', 'onchange'=>'recalculateCost();', @@ -196,7 +200,7 @@ if ($request->isPost()) { // Now, a new insert. if ($err->no()) { - if (ttExpenseHelper::insert(array('date'=>$new_date->toString(DB_DATEFORMAT),'user_id'=>$user->getActiveUser(), + if (ttExpenseHelper::insert(array('date'=>$new_date->toString(DB_DATEFORMAT),'user_id'=>$user->getActiveUser(),'group_id'=>$user->getActiveGroup(), 'client_id'=>$cl_client,'project_id'=>$cl_project,'name'=>$cl_item_name,'cost'=>$cl_cost,'status'=>1))) { header('Location: expenses.php?date='.$new_date->toString(DB_DATEFORMAT)); exit();