Merge pull request #7427 from atm-arnaud/NEW_comment_generic_element

New comment generic element
This commit is contained in:
Laurent Destailleur
2017-10-04 11:13:39 +02:00
committed by GitHub
15 changed files with 787 additions and 507 deletions

View File

@@ -308,6 +308,12 @@ abstract class CommonObject
* @var CommonObjectLine[]
*/
public $lines;
/**
* @var mixed Contains comments
* @see fetchComments()
*/
public $comments=array();
/**
* @var int
@@ -5288,5 +5294,28 @@ abstract class CommonObject
// TODO...
}
/**
* Load comments linked with current task
* @return boolean 1 if ok
*/
public function fetchComments()
{
require_once DOL_DOCUMENT_ROOT.'/core/class/comment.class.php';
$comment = new Comment($this->db);
$this->comments = Comment::fetchAllFor($this->element, $this->id);
return 1;
}
/**
* Return nb comments already posted
*
* @return int
*/
public function getNbComments()
{
return count($this->comments);
}
}