From 3d179fb7d37b1e115f7c9f48bfa9cfae8c40c6a1 Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Tue, 24 Apr 2018 09:17:03 +0200 Subject: [PATCH 1/3] FIX : Fetch function will fetch comments --- htdocs/projet/class/task.class.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 83de25b21ad..ab34ec1acb3 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -194,7 +194,7 @@ class Task extends CommonObject */ function fetch($id, $ref='', $loadparentdata=0) { - global $langs; + global $langs, $conf; $sql = "SELECT"; $sql.= " t.rowid,"; @@ -267,7 +267,11 @@ class Task extends CommonObject } // Retreive all extrafield data - $this->fetch_optionals(); + $this->fetch_optionals(); + + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK)) { + $this->fetchComments(); + } } $this->db->free($resql); From d875553648c1e41d9a2f2805f3994e77aee12b2e Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Tue, 22 May 2018 16:03:03 +0200 Subject: [PATCH 2/3] FIX : Remove fetchComments from project and task fetch function --- htdocs/projet/class/project.class.php | 8 +------- htdocs/projet/class/task.class.php | 4 ---- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 8cbb45eae37..ef5844e4ab8 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -447,18 +447,12 @@ class Project extends CommonObject // Retreive all extrafield for thirdparty $this->fetch_optionals(); - if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT)) - { - $this->fetchComments(); - } - return 1; } $this->db->free($resql); - if ($num_rows) return 1; - else return 0; + return 0; } else { diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 29cadb08ad6..c953ec58089 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -268,10 +268,6 @@ class Task extends CommonObject // Retreive all extrafield data $this->fetch_optionals(); - - if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK)) { - $this->fetchComments(); - } } $this->db->free($resql); From a455f60c42f41710536be2f23ff37c8e308798f3 Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Tue, 22 May 2018 16:07:32 +0200 Subject: [PATCH 3/3] FIX : Add calls to fetchComments function --- htdocs/projet/card.php | 1 + htdocs/projet/comment.php | 1 + htdocs/projet/contact.php | 2 ++ htdocs/projet/document.php | 1 + htdocs/projet/element.php | 1 + htdocs/projet/ganttview.php | 1 + htdocs/projet/info.php | 1 + htdocs/projet/note.php | 1 + htdocs/projet/tasks.php | 1 + htdocs/projet/tasks/comment.php | 1 + htdocs/projet/tasks/contact.php | 2 ++ htdocs/projet/tasks/document.php | 2 ++ htdocs/projet/tasks/note.php | 2 ++ htdocs/projet/tasks/task.php | 2 ++ htdocs/projet/tasks/time.php | 2 ++ 15 files changed, 21 insertions(+) diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index bd8709affaa..762fc1a7e06 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -64,6 +64,7 @@ if ($id > 0 || ! empty($ref)) $ret = $object->fetch($id,$ref); // If we create project, ref may be defined into POST but record does not yet exists into database if ($ret > 0) { $object->fetch_thirdparty(); + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); $id=$object->id; } } diff --git a/htdocs/projet/comment.php b/htdocs/projet/comment.php index a51d4872c80..236233d983c 100644 --- a/htdocs/projet/comment.php +++ b/htdocs/projet/comment.php @@ -67,6 +67,7 @@ if ($id > 0 || ! empty($ref)) $ret = $object->fetch($id,$ref); // If we create project, ref may be defined into POST but record does not yet exists into database if ($ret > 0) { $object->fetch_thirdparty(); + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); $id=$object->id; } } diff --git a/htdocs/projet/contact.php b/htdocs/projet/contact.php index f162aa9db40..5d9e8bcc056 100644 --- a/htdocs/projet/contact.php +++ b/htdocs/projet/contact.php @@ -43,6 +43,7 @@ $mine = GETPOST('mode')=='mine' ? 1 : 0; $object = new Project($db); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once +if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); // Security check $socid=0; @@ -140,6 +141,7 @@ $userstatic=new User($db); if ($id > 0 || ! empty($ref)) { + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); // To verify role of users //$userAccess = $object->restrictedProjectArea($user,'read'); $userWrite = $object->restrictedProjectArea($user,'write'); diff --git a/htdocs/projet/document.php b/htdocs/projet/document.php index fbf9574bd75..b6c69e12622 100644 --- a/htdocs/projet/document.php +++ b/htdocs/projet/document.php @@ -48,6 +48,7 @@ $result=restrictedArea($user,'projet',$id,'projet&project'); $object = new Project($db); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once +if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); if ($id > 0 || ! empty($ref)) { $upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref); diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index dd19ceeb263..e85db9b9252 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -97,6 +97,7 @@ $projectid=$id; // For backward compatibility $object = new Project($db); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once +if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); // Security check $socid=$object->socid; diff --git a/htdocs/projet/ganttview.php b/htdocs/projet/ganttview.php index 0c1e86c8ab5..473aa18b744 100644 --- a/htdocs/projet/ganttview.php +++ b/htdocs/projet/ganttview.php @@ -42,6 +42,7 @@ $mine = ($mode == 'mine' ? 1 : 0); $object = new Project($db); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once +if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); // Security check $socid=0; diff --git a/htdocs/projet/info.php b/htdocs/projet/info.php index 68f4b8b4cbb..8024977f2fa 100644 --- a/htdocs/projet/info.php +++ b/htdocs/projet/info.php @@ -97,6 +97,7 @@ if ($id > 0 || ! empty($ref)) { $object->fetch($id, $ref); $object->fetch_thirdparty(); + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); $object->info($object->id); } diff --git a/htdocs/projet/note.php b/htdocs/projet/note.php index 88217fbfb1c..bb5a769640f 100644 --- a/htdocs/projet/note.php +++ b/htdocs/projet/note.php @@ -38,6 +38,7 @@ $mine = $_REQUEST['mode']=='mine' ? 1 : 0; $object = new Project($db); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once +if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); // Security check $socid=0; diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 9bbd7891ee7..49d52a522d6 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -51,6 +51,7 @@ $extrafields_project = new ExtraFields($db); $extrafields_task = new ExtraFields($db); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once +if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); if ($id > 0 || ! empty($ref)) { diff --git a/htdocs/projet/tasks/comment.php b/htdocs/projet/tasks/comment.php index 3bf96d7d081..6eb441eb28c 100644 --- a/htdocs/projet/tasks/comment.php +++ b/htdocs/projet/tasks/comment.php @@ -105,6 +105,7 @@ if ($id > 0 || ! empty($ref)) $result=$projectstatic->fetch($object->fk_project); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments(); $object->project = clone $projectstatic; diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php index fad5466cb7f..747bf36391c 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -173,9 +173,11 @@ if ($id > 0 || ! empty($ref)) { if ($object->fetch($id, $ref) > 0) { + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); $id = $object->id; // So when doing a search from ref, id is also set correctly. $result=$projectstatic->fetch($object->fk_project); + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments(); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); $object->project = clone $projectstatic; diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php index 1cb5acb73b5..92af4a35c65 100644 --- a/htdocs/projet/tasks/document.php +++ b/htdocs/projet/tasks/document.php @@ -92,7 +92,9 @@ if ($id > 0 || ! empty($ref)) { if ($object->fetch($id,$ref) > 0) { + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); $projectstatic->fetch($object->fk_project); + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments(); if (! empty($projectstatic->socid)) { $projectstatic->fetch_thirdparty(); diff --git a/htdocs/projet/tasks/note.php b/htdocs/projet/tasks/note.php index f915aaf836a..dd5c14d3c1f 100644 --- a/htdocs/projet/tasks/note.php +++ b/htdocs/projet/tasks/note.php @@ -50,7 +50,9 @@ if ($id > 0 || ! empty($ref)) { if ($object->fetch($id,$ref) > 0) { + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); $projectstatic->fetch($object->fk_project); + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments(); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); $object->project = clone $projectstatic; diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 2f87d411c5f..12329c2ed6b 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -211,8 +211,10 @@ if ($id > 0 || ! empty($ref)) if ($object->fetch($id,$ref) > 0) { $res=$object->fetch_optionals($object->id,$extralabels); + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); $result=$projectstatic->fetch($object->fk_project); + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments(); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); $object->project = clone $projectstatic; diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 2da534e53a0..4f8755ddb6d 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -292,7 +292,9 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) } elseif ($object->fetch($id, $ref) >= 0) { + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); $result=$projectstatic->fetch($object->fk_project); + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments(); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); $res=$projectstatic->fetch_optionals($object->id,$extralabels_projet);