From 444f714020cfaaf229c17f9f867d2be51a43a12a Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Sat, 27 Feb 2010 17:31:46 +0000 Subject: [PATCH] Let calendar import return import errors --- .../class.import_events_csv.inc.php | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/calendar/importexport/class.import_events_csv.inc.php b/calendar/importexport/class.import_events_csv.inc.php index 1c659791fb..ae2a4178d4 100644 --- a/calendar/importexport/class.import_events_csv.inc.php +++ b/calendar/importexport/class.import_events_csv.inc.php @@ -81,6 +81,11 @@ class import_events_csv implements iface_import_plugin { */ private $user = null; + /** + * List of import errors + */ + protected $errors = array(); + /** * imports entries according to given definition object. * @param resource $_stream @@ -132,6 +137,8 @@ class import_events_csv implements iface_import_plugin { } } + $this->errors = array(); + while ( $record = $import_csv->get_record() ) { // don't import empty events @@ -224,7 +231,12 @@ class import_events_csv implements iface_import_plugin { if ( $this->dry_run ) { print_r($_data); } else { - return $this->bocalupdate->update( $_data, true, !$_data['modified'], $this->is_admin); + $messages = array(); + $result = $this->bocalupdate->update( $_data, true, !$_data['modified'], $this->is_admin, true, $messages); + if(!$result) { + $this->errors = implode(',', $messages); + } + return $result; } case 'delete' : @@ -283,5 +295,17 @@ class import_events_csv implements iface_import_plugin { // lets do it! } + /** + * Returns errors that were encountered during importing + * Maximum of one error message per record, but you can append if you need to + * + * @return Array ( + * record_# => error message + * ) + */ + public function get_errors() { + return $this->errors; + } + } // end of iface_export_plugin ?>