(Retrofit from trunk) r4969

N°1098 Fix CSV import by id. Fix a regression introduced in rev 4885.
---------------------
r4968
N°1100 - External field pointing to a magic attribute * A specific pass has been added in MetaModel::InitClasses() to generate the magic attributes before the external fields.
---------------------

SVN:2.4[4987]
This commit is contained in:
Eric Espié
2017-10-05 16:00:49 +00:00
parent 134a9aa684
commit 3ac5131a19
2 changed files with 13 additions and 7 deletions

View File

@@ -468,10 +468,11 @@ class BulkChange
//
foreach ($this->m_aAttList as $sAttCode => $iCol)
{
$oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $sAttCode);
// skip the private key, if any
if ($sAttCode == 'id') continue;
$oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $sAttCode);
// skip reconciliation keys
if (!$oAttDef->IsWritable() && in_array($sAttCode, $this->m_aReconcilKeys)){ continue; }

View File

@@ -1866,15 +1866,13 @@ abstract class MetaModel
}
}
// Prepare external fields and filters
// Add final class to external keys
//
// Add magic attributes to the classes
foreach (self::GetClasses() as $sClass)
{
$sRootClass = self::$m_aRootClasses[$sClass];
// Create the friendly name attribute
$sFriendlyNameAttCode = 'friendlyname';
$sFriendlyNameAttCode = 'friendlyname';
$oFriendlyName = new AttributeFriendlyName($sFriendlyNameAttCode);
self::AddMagicAttribute($oFriendlyName, $sClass);
@@ -1884,7 +1882,7 @@ abstract class MetaModel
$oArchiveFlag = new AttributeArchiveFlag('archive_flag');
self::AddMagicAttribute($oArchiveFlag, $sClass);
$oArchiveDate = new AttributeArchiveDate('archive_date', array('magic' => true, "allowed_values"=>null, "sql"=>'archive_date', "default_value"=>'', "is_null_allowed"=>true, "depends_on"=>array()));
$oArchiveDate = new AttributeArchiveDate('archive_date', array('magic' => true, "allowed_values" => null, "sql" => 'archive_date', "default_value" => '', "is_null_allowed" => true, "depends_on" => array()));
self::AddMagicAttribute($oArchiveDate, $sClass);
}
elseif (self::$m_aClassParams[$sClass]["archive"])
@@ -1918,6 +1916,13 @@ abstract class MetaModel
self::$m_aAttribOrigins[$sClass]['obsolescence_date'] = $sRootClass;
}
}
}
// Prepare external fields and filters
// Add final class to external keys
// Add magic attributes to external keys (finalclass, friendlyname, archive_flag, obsolescence_flag)
foreach (self::GetClasses() as $sClass)
{
foreach (self::$m_aAttribDefs[$sClass] as $sAttCode => $oAttDef)
{
// Compute the filter codes