/** * Overload the standard behavior */ public function ComputeValues() { parent::ComputeValues(); if ($this->IsNew()) { // Compute the database_table_name $sDataTable = $this->Get('database_table_name'); if (!empty($sDataTable)) { $this->Set('database_table_name', $this->ComputeDataTableName()); } // When inserting a new datasource object, also create the SynchroAttribute objects // for each field of the target class // Create all the SynchroAttribute records $oAttributeSet = $this->Get('attribute_list'); if ($oAttributeSet->Count() == 0) { foreach (MetaModel::ListAttributeDefs($this->GetTargetClass()) as $sAttCode => $oAttDef) { if ($oAttDef->IsWritable()) { $oAttDef = MetaModel::GetAttributeDef($this->GetTargetClass(), $sAttCode); if ($oAttDef->IsExternalKey()) { $oAttribute = new SynchroAttExtKey(); $oAttribute->Set('reconciliation_attcode', ''); // Blank means by pkey } elseif ($oAttDef->IsLinkSet() && $oAttDef->IsIndirect()) { $oAttribute = new SynchroAttLinkSet(); // Todo - set those value from the form $oAttribute->Set('row_separator', MetaModel::GetConfig()->Get('link_set_item_separator')); $oAttribute->Set('attribute_separator', MetaModel::GetConfig()->Get('link_set_attribute_separator')); $oAttribute->Set('value_separator', MetaModel::GetConfig()->Get('link_set_value_separator')); $oAttribute->Set('attribute_qualifier', MetaModel::GetConfig()->Get('link_set_attribute_qualifier')); } elseif ($oAttDef->IsScalar()) { $oAttribute = new SynchroAttribute(); } else { $oAttribute = null; } if (!is_null($oAttribute)) { $oAttribute->Set('sync_source_id', $this->GetKey()); $oAttribute->Set('attcode', $sAttCode); $oAttribute->Set('reconcile', MetaModel::IsReconcKey($this->GetTargetClass(), $sAttCode) ? 1 : 0); $oAttribute->Set('update', 1); $oAttribute->Set('update_policy', 'master_locked'); $oAttributeSet->AddObject($oAttribute); } } } $this->Set('attribute_list', $oAttributeSet); } } }