Index: trunk/kernel/include/customfield.php =================================================================== diff -u -r3534 -r4077 --- trunk/kernel/include/customfield.php (.../customfield.php) (revision 3534) +++ trunk/kernel/include/customfield.php (.../customfield.php) (revision 4077) @@ -95,21 +95,32 @@ } } - function LoadFieldsAndValues($ResourceId) + function LoadFieldsAndValues($ResourceId, $main_prefix, $temp_table = false) { $this->Clear(); - $table = $this->SourceTable; - $DataTable = GetTablePrefix()."CustomMetaData"; - $sql = "SELECT $table.*,$DataTable.Value as Value, $DataTable.CustomDataId as CustomDataId FROM ".$table." LEFT JOIN $DataTable ON "; - $sql .= "(".$table.".CustomFieldId=$DataTable.CustomFieldId AND $DataTable.ResourceId=$ResourceId) WHERE Type=".$this->Type; - if( isset($GLOBALS["debuglevel"]) && $GLOBALS["debuglevel"]) echo $sql."
\n"; - $rs = $this->adodbConnection->Execute($sql); - while($rs && !$rs->EOF) - { - $data = $rs->fields; - $this->AddItemFromArray($data); - $rs->MoveNext(); - } + + $table = $this->Application->getUnitOption($main_prefix.'-cdata', 'TableName'); + if ($temp_table) { + $table = kTempTablesHandler::GetTempName($table); + } + + $sql = 'SELECT * + FROM '.$table.' + WHERE ResourceId = '.$ResourceId; + $custom_data = $this->adodbConnection->GetRow($sql); + + $sql = 'SELECT * + FROM '.TABLE_PREFIX.'CustomField + WHERE Type = '.$this->Application->getUnitOption($main_prefix, 'ItemType'); + $custom_fields = $this->Conn->Query($sql, 'CustomFieldId'); + + $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); + foreach ($custom_fields as $custom_id => $custom_info) { + $custom_name = $ml_formatter->LangFieldName('cust_'.$custom_id); + $custom_info['Value'] = getArrayValue($custom_data, $custom_name) ? $custom_data[$custom_name] : ''; + $custom_info['CustomDataId'] = 0; + $this->AddItemFromArray($custom_info); + } } function GetFieldUIList($GeneralTab=FALSE)