N°653 Portal: Lifecycle: Flags on transitions part 2

SVN:trunk[4767]
This commit is contained in:
Guillaume Lajarige
2017-06-22 13:38:45 +00:00
parent 43b8522b85
commit 71ec3da4ac
4 changed files with 29 additions and 20 deletions

View File

@@ -2944,10 +2944,10 @@ EOF
* Updates the object from a flat array of values
* @param $aAttList array $aAttList array of attcode
* @param $aErrors array Returns information about slave attributes
* @param $sTargetState string Target state for which to evaluate the writeable attributes (=current state is empty)
* @param $aAttFlags array Attribute codes => Flags to use instead of those from the MetaModel
* @return array of attcodes that can be used for writing on the current object
*/
public function GetWriteableAttList($aAttList, &$aErrors, $sTargetState = '')
public function GetWriteableAttList($aAttList, &$aErrors, $aAttFlags = array())
{
if (!is_array($aAttList))
{
@@ -2956,14 +2956,19 @@ EOF
// WARNING: if you change this also check the functions DisplayModifyForm and DisplayCaseLog
foreach(MetaModel::ListAttributeDefs(get_class($this)) as $sAttCode => $oAttDef)
{
if ($this->IsNew())
if(array_key_exists($sAttCode, $aAttFlags))
{
$iFlags = $aAttFlags[$sAttCode];
}
elseif ($this->IsNew())
{
$iFlags = $this->GetInitialStateAttributeFlags($sAttCode);
}
else
{
$aVoid = array();
$iFlags = $this->GetAttributeFlags($sAttCode, $aVoid, $sTargetState);
$iFlags = $this->GetAttributeFlags($sAttCode, $aVoid);
}
if ($oAttDef instanceof AttributeCaseLog)
{
@@ -2979,15 +2984,19 @@ EOF
foreach($aAttList as $sAttCode)
{
$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
if ($this->IsNew())
if(array_key_exists($sAttCode, $aAttFlags))
{
$iFlags = $aAttFlags[$sAttCode];
}
elseif ($this->IsNew())
{
$iFlags = $this->GetInitialStateAttributeFlags($sAttCode);
}
else
{
$aVoid = array();
$iFlags = $this->GetAttributeFlags($sAttCode, $aVoid, $sTargetState);
$iFlags = $this->GetAttributeFlags($sAttCode, $aVoid);
}
if ($oAttDef->IsWritable())
{
@@ -3172,7 +3181,7 @@ EOF
/**
* Updates the object from the POSTed parameters (form)
*/
public function UpdateObjectFromPostedForm($sFormPrefix = '', $aAttList = null, $sTargetState = '')
public function UpdateObjectFromPostedForm($sFormPrefix = '', $aAttList = null, $aAttFlags = array())
{
if (is_null($aAttList))
{
@@ -3280,7 +3289,7 @@ EOF
$aErrors = array();
$aFinalValues = array();
foreach($this->GetWriteableAttList(array_keys($aValues), $aErrors, $sTargetState) as $sAttCode => $oAttDef)
foreach($this->GetWriteableAttList(array_keys($aValues), $aErrors, $aAttFlags) as $sAttCode => $oAttDef)
{
$aFinalValues[$sAttCode] = $aValues[$sAttCode];
}
@@ -3302,7 +3311,7 @@ EOF
/**
* Updates the object from a given page argument
*/
public function UpdateObjectFromArg($sArgName, $aAttList = null, $sTargetState = '')
public function UpdateObjectFromArg($sArgName, $aAttList = null, $aAttFlags = array())
{
if (is_null($aAttList))
{
@@ -3320,7 +3329,7 @@ EOF
$aErrors = array();
$aFinalValues = array();
foreach($this->GetWriteableAttList(array_keys($aValues), $aErrors, $sTargetState) as $sAttCode => $oAttDef)
foreach($this->GetWriteableAttList(array_keys($aValues), $aErrors, $aAttFlags) as $sAttCode => $oAttDef)
{
$aFinalValues[$sAttCode] = $aValues[$sAttCode];
}