- Cleanup of 'finalclass'... (Trac #54)

SVN:trunk[383]
This commit is contained in:
Denis Flaven
2010-05-02 13:56:28 +00:00
parent c18f731660
commit ffd22acff5
4 changed files with 76 additions and 67 deletions

View File

@@ -766,16 +766,7 @@ try
$bObjectModified = false;
foreach(MetaModel::ListAttributeDefs(get_class($oObj)) as $sAttCode=>$oAttDef)
{
$iFlags = $oObj->GetAttributeFlags($sAttCode);
if ($iFlags & (OPT_ATT_HIDDEN | OPT_ATT_READONLY))
{
// Non-visible, or read-only attribute, do nothing
}
else if ($sAttCode == 'finalclass')
{
// This very specific field is read-only
}
else if ($oAttDef->IsLinkSet())
if ($oAttDef->IsLinkSet())
{
// Link set, the data is a set of link objects, encoded in JSON
$aAttributes[$sAttCode] = trim(utils::ReadPostedParam("attr_$sAttCode", ''));
@@ -787,17 +778,6 @@ try
$bObjectModified = true;
}
}
else if ($oAttDef->GetEditClass() == 'Document')
{
// There should be an uploaded file with the named attr_<attCode>
$oDocument = utils::ReadPostedDocument('file_'.$sAttCode);
if (!$oDocument->IsEmpty())
{
// A new file has been uploaded
$oObj->Set($sAttCode, $oDocument);
$bObjectModified = true;
}
}
else if (!$oAttDef->IsExternalField())
{
$rawValue = utils::ReadPostedParam("attr_$sAttCode", null);
@@ -812,6 +792,25 @@ try
}
}
}
else if ($oAttDef->IsWritable())
{
$iFlags = $oObj->GetAttributeFlags($sAttCode);
if ($iFlags & (OPT_ATT_HIDDEN | OPT_ATT_READONLY))
{
// Non-visible, or read-only attribute, do nothing
}
else if ($oAttDef->GetEditClass() == 'Document')
{
// There should be an uploaded file with the named attr_<attCode>
$oDocument = utils::ReadPostedDocument('file_'.$sAttCode);
if (!$oDocument->IsEmpty())
{
// A new file has been uploaded
$oObj->Set($sAttCode, $oDocument);
$bObjectModified = true;
}
}
}
}
if (!$bObjectModified)
{
@@ -954,9 +953,7 @@ try
$sStateAttCode = MetaModel::GetStateAttributeCode(get_class($oObj));
foreach(MetaModel::ListAttributeDefs($sClass) as $sAttCode=>$oAttDef)
{
if ( ('finalclass' != $sAttCode) && // finalclass is a reserved word, hardcoded !
($sStateAttCode != $sAttCode) &&
(!$oAttDef->IsExternalField()) )
if ( ($oAttDef->IsWritable()) )
{
$value = utils::ReadPostedParam('attr_'.$sAttCode, '');
$oObj->Set($sAttCode, $value);