Fix link conversion only works the first time

This commit is contained in:
Nathan Gray 2012-12-18 16:36:05 +00:00
parent 1c4f15078d
commit e99ab7aff5
2 changed files with 22 additions and 20 deletions

View File

@ -282,19 +282,20 @@ class importexport_export_csv implements importexport_iface_export_record
if($appname) {
if(!self::$cf_parse_cache[$appname]) {
$c_fields = self::convert_parse_custom_fields($appname, $selects, $links, $methods);
// Add in any fields that are keys to another app
foreach((array)$fields['links'] as $link_field => $app)
{
if(is_numeric($link_field)) continue;
$links[$link_field] = $app;
// Set it as a normal link field
$fields['links'][] = $link_field;
unset($fields['links'][$link_field]);
}
self::$cf_parse_cache[$appname] = array($c_fields, $selects, $links, $methods);
}
list($c_fields, $c_selects, $links, $methods) = self::$cf_parse_cache[$appname];
// Add in any fields that are keys to another app
foreach((array)$fields['links'] as $link_field => $app)
{
if(is_numeric($link_field)) continue;
$links[$link_field] = $app;
// Set it as a normal link field
$fields['links'][] = $link_field;
unset($fields['links'][$link_field]);
}
// Not quite a recursive merge, since only one level
foreach($fields as $type => &$list) {
if($c_fields[$type]) {
@ -304,7 +305,6 @@ class importexport_export_csv implements importexport_iface_export_record
}
$fields += $c_fields;
$selects += $c_selects;
}
foreach((array)$fields['select'] as $name) {
if($record->$name != null && is_array($selects) && $selects[$name]) {

View File

@ -272,18 +272,20 @@ class importexport_import_csv implements importexport_iface_import_record { //,
if(!self::$cf_parse_cache[$appname]) {
$c_fields = importexport_export_csv::convert_parse_custom_fields($appname, $selects, $links, $methods);
// Add in any fields that are keys to another app
foreach((array)$fields['links'] as $link_field => $app)
{
if(is_numeric($link_field)) continue;
$links[$link_field] = $app;
// Set it as a normal link field
$fields['links'][] = $link_field;
unset($fields['links'][$link_field]);
}
self::$cf_parse_cache[$appname] = array($c_fields, $selects, $links, $methods);
}
list($c_fields, $c_selects, $links, $methods) = self::$cf_parse_cache[$appname];
// Add in any fields that are keys to another app
foreach((array)$fields['links'] as $link_field => $app)
{
if(is_numeric($link_field)) continue;
$links[$link_field] = $app;
// Set it as a normal link field
$fields['links'][] = $link_field;
unset($fields['links'][$link_field]);
}
// Not quite a recursive merge, since only one level
foreach($fields as $type => &$list)
{