Merge pull request #8671 from ATM-Nicolas/fix_comments_on_tasks

FIX : Fetch task will now fetch comments
This commit is contained in:
Laurent Destailleur 2018-08-21 13:36:20 +02:00 committed by GitHub
commit 4fdd521d61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 24 additions and 9 deletions

View File

@ -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 $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) { if ($ret > 0) {
$object->fetch_thirdparty(); $object->fetch_thirdparty();
if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments();
$id=$object->id; $id=$object->id;
} }
} }

View File

@ -447,18 +447,12 @@ class Project extends CommonObject
// Retreive all extrafield for thirdparty // Retreive all extrafield for thirdparty
$this->fetch_optionals(); $this->fetch_optionals();
if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT))
{
$this->fetchComments();
}
return 1; return 1;
} }
$this->db->free($resql); $this->db->free($resql);
if ($num_rows) return 1; return 0;
else return 0;
} }
else else
{ {

View File

@ -194,7 +194,7 @@ class Task extends CommonObject
*/ */
function fetch($id, $ref='', $loadparentdata=0) function fetch($id, $ref='', $loadparentdata=0)
{ {
global $langs; global $langs, $conf;
$sql = "SELECT"; $sql = "SELECT";
$sql.= " t.rowid,"; $sql.= " t.rowid,";
@ -267,7 +267,7 @@ class Task extends CommonObject
} }
// Retreive all extrafield data // Retreive all extrafield data
$this->fetch_optionals(); $this->fetch_optionals();
} }
$this->db->free($resql); $this->db->free($resql);

View File

@ -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 $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) { if ($ret > 0) {
$object->fetch_thirdparty(); $object->fetch_thirdparty();
if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments();
$id=$object->id; $id=$object->id;
} }
} }

View File

@ -43,6 +43,7 @@ $mine = GETPOST('mode')=='mine' ? 1 : 0;
$object = new Project($db); $object = new Project($db);
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once 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 // Security check
$socid=0; $socid=0;
@ -140,6 +141,7 @@ $userstatic=new User($db);
if ($id > 0 || ! empty($ref)) 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 // To verify role of users
//$userAccess = $object->restrictedProjectArea($user,'read'); //$userAccess = $object->restrictedProjectArea($user,'read');
$userWrite = $object->restrictedProjectArea($user,'write'); $userWrite = $object->restrictedProjectArea($user,'write');

View File

@ -48,6 +48,7 @@ $result=restrictedArea($user,'projet',$id,'projet&project');
$object = new Project($db); $object = new Project($db);
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once 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)) { if ($id > 0 || ! empty($ref)) {
$upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref); $upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref);

View File

@ -97,6 +97,7 @@ $projectid=$id; // For backward compatibility
$object = new Project($db); $object = new Project($db);
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once 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 // Security check
$socid=$object->socid; $socid=$object->socid;

View File

@ -42,6 +42,7 @@ $mine = ($mode == 'mine' ? 1 : 0);
$object = new Project($db); $object = new Project($db);
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once 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 // Security check
$socid=0; $socid=0;

View File

@ -97,6 +97,7 @@ if ($id > 0 || ! empty($ref))
{ {
$object->fetch($id, $ref); $object->fetch($id, $ref);
$object->fetch_thirdparty(); $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); $object->info($object->id);
} }

View File

@ -38,6 +38,7 @@ $mine = $_REQUEST['mode']=='mine' ? 1 : 0;
$object = new Project($db); $object = new Project($db);
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once 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 // Security check
$socid=0; $socid=0;

View File

@ -51,6 +51,7 @@ $extrafields_project = new ExtraFields($db);
$extrafields_task = new ExtraFields($db); $extrafields_task = new ExtraFields($db);
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once 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)) if ($id > 0 || ! empty($ref))
{ {

View File

@ -105,6 +105,7 @@ if ($id > 0 || ! empty($ref))
$result=$projectstatic->fetch($object->fk_project); $result=$projectstatic->fetch($object->fk_project);
if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); 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; $object->project = clone $projectstatic;

View File

@ -173,9 +173,11 @@ if ($id > 0 || ! empty($ref))
{ {
if ($object->fetch($id, $ref) > 0) 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. $id = $object->id; // So when doing a search from ref, id is also set correctly.
$result=$projectstatic->fetch($object->fk_project); $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(); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty();
$object->project = clone $projectstatic; $object->project = clone $projectstatic;

View File

@ -92,7 +92,9 @@ if ($id > 0 || ! empty($ref))
{ {
if ($object->fetch($id,$ref) > 0) 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); $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)) { if (! empty($projectstatic->socid)) {
$projectstatic->fetch_thirdparty(); $projectstatic->fetch_thirdparty();

View File

@ -50,7 +50,9 @@ if ($id > 0 || ! empty($ref))
{ {
if ($object->fetch($id,$ref) > 0) 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); $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(); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty();
$object->project = clone $projectstatic; $object->project = clone $projectstatic;

View File

@ -211,8 +211,10 @@ if ($id > 0 || ! empty($ref))
if ($object->fetch($id,$ref) > 0) if ($object->fetch($id,$ref) > 0)
{ {
$res=$object->fetch_optionals($object->id,$extralabels); $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); $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(); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty();
$object->project = clone $projectstatic; $object->project = clone $projectstatic;

View File

@ -292,7 +292,9 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
} }
elseif ($object->fetch($id, $ref) >= 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); $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(); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty();
$res=$projectstatic->fetch_optionals($object->id,$extralabels_projet); $res=$projectstatic->fetch_optionals($object->id,$extralabels_projet);