From 629c6d93f66dabcb8c15252e2575a62439b3fff2 Mon Sep 17 00:00:00 2001 From: Nicolas Leichtle Date: Sun, 1 Oct 2017 14:33:59 +0200 Subject: [PATCH] FIX: REST function addTimeSpent --- htdocs/projet/class/api_tasks.class.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/projet/class/api_tasks.class.php b/htdocs/projet/class/api_tasks.class.php index d6303c18a16..168afc2cb0c 100644 --- a/htdocs/projet/class/api_tasks.class.php +++ b/htdocs/projet/class/api_tasks.class.php @@ -19,6 +19,7 @@ use Luracast\Restler\RestException; require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; /** * API class for projects @@ -501,15 +502,17 @@ class Tasks extends DolibarrApi */ function addTimeSpent($id, $date, $duration, $user_id=0, $note='') { - if(! DolibarrApiAccess::$user->rights->projet->creer) { + + + if( ! DolibarrApiAccess::$user->rights->projet->creer) { throw new RestException(401); } $result = $this->task->fetch($id); if ($result <= 0) { throw new RestException(404, 'Task not found'); } - - if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) { + + if( ! DolibarrApi::_checkAccessToResource('project', $this->task->fk_project)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); }