Set default status when importing, if not specified in file

This commit is contained in:
Nathan Gray 2011-12-06 23:05:46 +00:00
parent 220afbf728
commit f7b8997be3

View File

@ -161,15 +161,24 @@ class infolog_import_infologs_csv implements importexport_iface_import_plugin {
if( count( array_unique( $record ) ) < 2 ) continue; if( count( array_unique( $record ) ) < 2 ) continue;
$lookups = $_lookups; $lookups = $_lookups;
if($record['info_type'] && $this->boinfolog->status[$record['info_type']]) { if($record['info_type'] && $this->boinfolog->status[$record['info_type']])
{
$lookups['info_status'] = $this->boinfolog->status[$record['info_type']]; $lookups['info_status'] = $this->boinfolog->status[$record['info_type']];
} }
importexport_import_csv::convert($record, infolog_egw_record::$types, 'infolog', $lookups, $_definition->plugin_options['convert']); importexport_import_csv::convert($record, infolog_egw_record::$types, 'infolog', $lookups, $_definition->plugin_options['convert']);
// Set default status for type, if not specified
if(!$record['info_status'] && $record['info_type'])
{
$record['info_status'] = $this->boinfolog->status['defaults'][$record['info_type']];
}
// Set owner, unless it's supposed to come from CSV file // Set owner, unless it's supposed to come from CSV file
if($_definition->plugin_options['owner_from_csv']) { if($_definition->plugin_options['owner_from_csv'])
if(!is_numeric($record['info_owner'])) { {
if(!is_numeric($record['info_owner']))
{
$this->errors[$import_csv->get_current_position()] = lang( $this->errors[$import_csv->get_current_position()] = lang(
'Invalid owner ID: %1. Might be a bad field translation. Used %2 instead.', 'Invalid owner ID: %1. Might be a bad field translation. Used %2 instead.',
$record['info_owner'], $record['info_owner'],
@ -177,7 +186,9 @@ class infolog_import_infologs_csv implements importexport_iface_import_plugin {
); );
$record['info_owner'] = $_definition->plugin_options['record_owner']; $record['info_owner'] = $_definition->plugin_options['record_owner'];
} }
} else { }
else
{
$record['info_owner'] = $_definition->plugin_options['record_owner']; $record['info_owner'] = $_definition->plugin_options['record_owner'];
} }
if (!isset($record['info_owner'])) $record['info_owner'] = $GLOBALS['egw_info']['user']['account_id']; if (!isset($record['info_owner'])) $record['info_owner'] = $GLOBALS['egw_info']['user']['account_id'];
@ -192,10 +203,13 @@ class infolog_import_infologs_csv implements importexport_iface_import_plugin {
$record['projectmanager'] = self::project_id($record['projectmanager']); $record['projectmanager'] = self::project_id($record['projectmanager']);
} }
if ( $_definition->plugin_options['conditions'] ) { if ( $_definition->plugin_options['conditions'] )
foreach ( $_definition->plugin_options['conditions'] as $condition ) { {
foreach ( $_definition->plugin_options['conditions'] as $condition )
{
$results = array(); $results = array();
switch ( $condition['type'] ) { switch ( $condition['type'] )
{
// exists // exists
case 'exists' : case 'exists' :
if($record[$condition['string']]) { if($record[$condition['string']]) {
@ -231,7 +245,9 @@ class infolog_import_infologs_csv implements importexport_iface_import_plugin {
} }
if ($action['last']) break; if ($action['last']) break;
} }
} else { }
else
{
// unconditional insert // unconditional insert
$success = $this->action( 'insert', $record, $import_csv->get_current_position() ); $success = $this->action( 'insert', $record, $import_csv->get_current_position() );
} }