mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-12 23:14:18 +01:00
Dashboard: fixed issue with Null values (group by)
SVN:trunk[2051]
This commit is contained in:
@@ -615,7 +615,7 @@ abstract class DBObject
|
||||
return $oAtt->GetAsCSV($this->GetOriginal($sAttCode), $sSeparator, $sTextQualifier, $this);
|
||||
}
|
||||
|
||||
protected static function MakeHyperLink($sObjClass, $sObjKey, $sLabel = '', $sUrlMakerClass = null, $bWithNavigationContext = true)
|
||||
public static function MakeHyperLink($sObjClass, $sObjKey, $sLabel = '', $sUrlMakerClass = null, $bWithNavigationContext = true)
|
||||
{
|
||||
if ($sObjKey <= 0) return '<em>'.Dict::S('UI:UndefinedObject').'</em>'; // Objects built in memory have negative IDs
|
||||
|
||||
|
||||
@@ -366,12 +366,26 @@ class ScalarExpression extends UnaryExpression
|
||||
{
|
||||
public function __construct($value)
|
||||
{
|
||||
if (!is_scalar($value))
|
||||
if (!is_scalar($value) && !is_null($value))
|
||||
{
|
||||
throw new CoreException('Attempt to create a scalar expression from a non scalar', array('var_type'=>gettype($value)));
|
||||
}
|
||||
parent::__construct($value);
|
||||
}
|
||||
|
||||
// recursive rendering
|
||||
public function Render(&$aArgs = null, $bRetrofitParams = false)
|
||||
{
|
||||
if (is_null($this->m_value))
|
||||
{
|
||||
$sRet = 'NULL';
|
||||
}
|
||||
else
|
||||
{
|
||||
$sRet = CMDBSource::Quote($this->m_value);
|
||||
}
|
||||
return $sRet;
|
||||
}
|
||||
}
|
||||
|
||||
class TrueExpression extends ScalarExpression
|
||||
@@ -496,15 +510,31 @@ class FieldExpression extends UnaryExpression
|
||||
$sClass = $aSelectedClasses[$sParentAlias];
|
||||
|
||||
$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
|
||||
// Set a default value for the general case
|
||||
$sRes = $oAttDef->GetAsHtml($sValue);
|
||||
|
||||
// Exceptions...
|
||||
if ($oAttDef->IsExternalKey())
|
||||
{
|
||||
$sTargetClass = $oAttDef->GetTargetClass();
|
||||
$oObject = MetaModel::GetObject($sTargetClass, (int)$sValue);
|
||||
$sRes = $oObject->GetHyperlink();
|
||||
$sObjClass = $oAttDef->GetTargetClass();
|
||||
$iObjKey = (int)$sValue;
|
||||
if ($iObjKey > 0)
|
||||
{
|
||||
$oObject = MetaModel::GetObject($sObjClass, $iObjKey);
|
||||
$sRes = $oObject->GetHyperlink();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Undefined
|
||||
$sRes = DBObject::MakeHyperLink($sObjClass, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
elseif ($oAttDef->IsExternalField())
|
||||
{
|
||||
$sRes = $oAttDef->GetAsHtml($sValue);
|
||||
if (is_null($sValue))
|
||||
{
|
||||
$sRes = Dict::S('UI:UndefinedObject');
|
||||
}
|
||||
}
|
||||
return $sRes;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user