New method to test if a field is read only in the current DBObject state

SVN:trunk[5228]
This commit is contained in:
Pierre Goiffon
2018-01-10 14:08:29 +00:00
parent 95941f4dc5
commit cc08613304

View File

@@ -1060,12 +1060,9 @@ abstract class DBObject implements iDisplay
$iFlags = 0; // By default (if no life cycle) no flag at all
$aReadOnlyAtts = $this->GetReadOnlyAttributes();
if ($aReadOnlyAtts != null)
if (($aReadOnlyAtts != null) && (in_array($sAttCode, $aReadOnlyAtts)))
{
if (in_array($sAttCode, $aReadOnlyAtts))
{
return OPT_ATT_READONLY;
}
return OPT_ATT_READONLY;
}
$sStateAttCode = MetaModel::GetStateAttributeCode(get_class($this));
@@ -1089,6 +1086,19 @@ abstract class DBObject implements iDisplay
return $iFlags | $iSynchroFlags; // Combine both sets of flags
}
/**
* @param string $sAttCode
* @param array $aReasons To store the reasons why the attribute is read-only (info about the synchro replicas)
*
* @throws \CoreException
*/
public function IsAttributeReadOnlyForCurrentState($sAttCode, &$aReasons = array())
{
$iAttFlags = $this->GetAttributeFlags($sAttCode, $aReasons);
return ($iAttFlags & OPT_ATT_READONLY);
}
/**
* Returns the set of flags (OPT_ATT_HIDDEN, OPT_ATT_READONLY, OPT_ATT_MANDATORY...)
* for the given attribute in a transition