From 46cd0a687ffca6d5d5400b7bd0d7657f3a0d9e2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cornelius=20Wei=C3=9F?= Date: Thu, 21 Jun 2007 18:05:04 +0000 Subject: [PATCH] improve dry-run --- .../class.import_contacts_csv.inc.php | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/addressbook/importexport/class.import_contacts_csv.inc.php b/addressbook/importexport/class.import_contacts_csv.inc.php index 3f910e7bb4..d39b2414df 100644 --- a/addressbook/importexport/class.import_contacts_csv.inc.php +++ b/addressbook/importexport/class.import_contacts_csv.inc.php @@ -62,11 +62,9 @@ class import_contacts_csv implements iface_import_plugin { private $bocontacts; /** - * constructor of import_contacts_csv - * - public function __construct() { - $this->bocontacts = CreateObject('addressbook.bocontacts'); - }*/ + * @var bool + */ + private $dry_run = false; /** * imports entries according to given definition object. @@ -80,6 +78,9 @@ class import_contacts_csv implements iface_import_plugin { '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 $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']; } - // while ( $record = $import_csv->get_record() ) { // don't import empty contacts @@ -129,7 +129,7 @@ class import_contacts_csv implements iface_import_plugin { $this->action( $action['action'], $record ); } } else { - $action = $condition['true']; + $action = $condition['false']; $this->action( $action['action'], $record ); } break; @@ -161,7 +161,11 @@ class import_contacts_csv implements iface_import_plugin { return true; case 'update' : case 'insert' : - return $this->bocontacts->save( $_data ); + if ( $this->dry_run ) { + print_r($_data); + } else { + return $this->bocontacts->save( $_data ); + } case 'delete' : } }