/**
* Get the ID of entity assigned to the object
*
* @return ID of the entity
**/
function getEntityID()
{
// Case of Duplicate Entity info to child
if (parent::isEntityAssign()) {
return parent::getEntityID();
}
if (preg_match('/^itemtype/', $this->itemtype)) {
$type = $this->fields[$this->itemtype];
} else {
$type = $this->itemtype;
}
if (class_exists($type)) {
$item = new $type();
if ($item->getFromDB($this->fields[$this->items_id]) && $item->isEntityAssign()) {
return $item->getEntityID();
}
}
return -1;
}