improve dry-run

This commit is contained in:
Cornelius Weiß 2007-06-21 18:08:17 +00:00
parent 1c7e180154
commit f7b3b2cd3f

View File

@ -62,11 +62,9 @@ class import_contacts_csv implements iface_import_plugin {
private $bocontacts; private $bocontacts;
/** /**
* constructor of import_contacts_csv * @var bool
* */
public function __construct() { private $dry_run = false;
$this->bocontacts = CreateObject('addressbook.bocontacts');
}*/
/** /**
* imports entries according to given definition object. * imports entries according to given definition object.
@ -80,6 +78,9 @@ class import_contacts_csv implements iface_import_plugin {
'charset' => $_definition->plugin_options['charset'], 'charset' => $_definition->plugin_options['charset'],
)); ));
// dry run?
$this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] : false;
// fetch the addressbook bo // fetch the addressbook bo
$this->bocontacts = CreateObject('addressbook.bocontacts'); $this->bocontacts = CreateObject('addressbook.bocontacts');
@ -100,7 +101,6 @@ class import_contacts_csv implements iface_import_plugin {
$record['contact_owner'] = $_definition->plugin_options['contact_owner']; $record['contact_owner'] = $_definition->plugin_options['contact_owner'];
} }
//
while ( $record = $import_csv->get_record() ) { while ( $record = $import_csv->get_record() ) {
// don't import empty contacts // don't import empty contacts
@ -129,7 +129,7 @@ class import_contacts_csv implements iface_import_plugin {
$this->action( $action['action'], $record ); $this->action( $action['action'], $record );
} }
} else { } else {
$action = $condition['true']; $action = $condition['false'];
$this->action( $action['action'], $record ); $this->action( $action['action'], $record );
} }
break; break;
@ -161,7 +161,11 @@ class import_contacts_csv implements iface_import_plugin {
return true; return true;
case 'update' : case 'update' :
case 'insert' : case 'insert' :
return $this->bocontacts->save( $_data ); if ( $this->dry_run ) {
print_r($_data);
} else {
return $this->bocontacts->save( $_data );
}
case 'delete' : case 'delete' :
} }
} }