fix comment task
This commit is contained in:
parent
592a97f9a5
commit
03873038d5
@ -7,20 +7,22 @@ class Comment extends CommonObject
|
|||||||
public $element='comment'; //!< Id that identify managed objects
|
public $element='comment'; //!< Id that identify managed objects
|
||||||
public $table_element='comment'; //!< Name of table without prefix where object is stored
|
public $table_element='comment'; //!< Name of table without prefix where object is stored
|
||||||
|
|
||||||
var $fk_element;
|
public $fk_element;
|
||||||
var $element_type;
|
public $element_type;
|
||||||
|
|
||||||
var $description;
|
public $description;
|
||||||
|
|
||||||
var $tms;
|
public $tms;
|
||||||
|
|
||||||
var $datec;
|
public $datec;
|
||||||
|
|
||||||
var $fk_user_author;
|
public $fk_user_author;
|
||||||
|
|
||||||
var $entity;
|
public $entity;
|
||||||
|
|
||||||
var $import_key;
|
public $import_key;
|
||||||
|
|
||||||
|
public $comments = array();
|
||||||
|
|
||||||
public $oldcopy;
|
public $oldcopy;
|
||||||
|
|
||||||
@ -289,10 +291,10 @@ class Comment extends CommonObject
|
|||||||
* @param int $fk_element Id of element
|
* @param int $fk_element Id of element
|
||||||
* @return array Comment array
|
* @return array Comment array
|
||||||
*/
|
*/
|
||||||
public static function fetchAllFor($element_type, $fk_element)
|
public function fetchAllFor($element_type, $fk_element)
|
||||||
{
|
{
|
||||||
global $db,$conf;
|
global $db,$conf;
|
||||||
$TComments = array();
|
$this->comments = array();
|
||||||
if(!empty($element_type) && !empty($fk_element)) {
|
if(!empty($element_type) && !empty($fk_element)) {
|
||||||
$sql = "SELECT";
|
$sql = "SELECT";
|
||||||
$sql.= " c.rowid";
|
$sql.= " c.rowid";
|
||||||
@ -302,7 +304,7 @@ class Comment extends CommonObject
|
|||||||
$sql.= " AND c.entity = ".$conf->entity;
|
$sql.= " AND c.entity = ".$conf->entity;
|
||||||
$sql.= " ORDER BY c.tms DESC";
|
$sql.= " ORDER BY c.tms DESC";
|
||||||
|
|
||||||
dol_syslog("Comment::fetchAllFor", LOG_DEBUG);
|
dol_syslog(get_class($this).'::'.__METHOD__, LOG_DEBUG);
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
@ -313,12 +315,17 @@ class Comment extends CommonObject
|
|||||||
{
|
{
|
||||||
$comment = new self($db);
|
$comment = new self($db);
|
||||||
$comment->fetch($obj->rowid);
|
$comment->fetch($obj->rowid);
|
||||||
$TComments[] = $comment;
|
$this->comments[] = $comment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$db->free($resql);
|
$db->free($resql);
|
||||||
|
} else {
|
||||||
|
$error++; $this->errors[]="Error ".$this->db->lasterror();
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return $TComments;
|
|
||||||
|
return count($this->comments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6528,8 +6528,14 @@ abstract class CommonObject
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/comment.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/comment.class.php';
|
||||||
|
|
||||||
$comment = new Comment($this->db);
|
$comment = new Comment($this->db);
|
||||||
$this->comments = Comment::fetchAllFor($this->element, $this->id);
|
$result=$comment->fetchAllFor($this->element, $this->id);
|
||||||
return 1;
|
if ($result<0) {
|
||||||
|
$this->errors=array_merge($this->errors,$comment->errors);
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
$this->comments = $comment->comments;
|
||||||
|
}
|
||||||
|
return count($this->comments);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -97,7 +97,11 @@ if ($id > 0 || ! empty($ref))
|
|||||||
{
|
{
|
||||||
if ($object->fetch($id,$ref) > 0)
|
if ($object->fetch($id,$ref) > 0)
|
||||||
{
|
{
|
||||||
$res=$object->fetch_optionals($object->id,$extralabels);
|
$result=$object->fetchComments();
|
||||||
|
if ($result<0){
|
||||||
|
setEventMessage($object->errors,'errors');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$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();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user