Dashboard: fixed issue with Null values (group by)

SVN:trunk[2051]
This commit is contained in:
Romain Quetiez
2012-05-29 14:02:25 +00:00
parent 74726ff742
commit 5ecf5815b8
2 changed files with 37 additions and 7 deletions

View File

@@ -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

View File

@@ -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;
}