From 7a8fd37a4a28562d7644bcc11f39f939a9e1b789 Mon Sep 17 00:00:00 2001 From: mc2contributor Date: Fri, 28 Apr 2023 10:07:46 -0600 Subject: [PATCH] Fix issues identified by CI in pull request. --- htdocs/projet/class/api_tasks.class.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/htdocs/projet/class/api_tasks.class.php b/htdocs/projet/class/api_tasks.class.php index 2fb1908ddc7..ada4b220020 100644 --- a/htdocs/projet/class/api_tasks.class.php +++ b/htdocs/projet/class/api_tasks.class.php @@ -584,7 +584,7 @@ class Tasks extends DolibarrApi if (!DolibarrApiAccess::$user->rights->projet->creer) { throw new RestException(401); } - $this->_timespentRecordChecks($id, $timespent_id); + $this->timespentRecordChecks($id, $timespent_id); if (!DolibarrApi::_checkAccessToResource('task', $this->task->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); @@ -624,12 +624,12 @@ class Tasks extends DolibarrApi * * @return array */ - public function deleteTimeSpent($id, $timespent_id, $user_id) + public function deleteTimeSpent($id, $timespent_id) { if (!DolibarrApiAccess::$user->rights->projet->supprimer) { throw new RestException(401); } - $this->_timespentRecordChecks($id, $timespent_id); + $this->timespentRecordChecks($id, $timespent_id); if (!DolibarrApi::_checkAccessToResource('task', $this->task->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); @@ -647,7 +647,14 @@ class Tasks extends DolibarrApi ); } - protected function _timespentRecordChecks($id, $timespent_id) + /** + * Validate task & timespent IDs for timespent API methods. + * Loads the selected task & timespent records. + * + * @param int $id Task ID + * @param int $timespent_id Time spent ID (llx_projet_task_time.rowid) + */ + protected function timespentRecordChecks($id, $timespent_id) { if ($this->task->fetch($id) <= 0) { throw new RestException(404, 'Task not found');