From 225423eb7f09e6cf0c2c2c902139fe06a2d6b6b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cornelius=20Wei=C3=9F?= Date: Fri, 6 Jul 2007 10:49:24 +0000 Subject: [PATCH] new option "trash_users_records" usefull to stay in sync with external manipulated data --- .../importexport/class.import_events_csv.inc.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/calendar/importexport/class.import_events_csv.inc.php b/calendar/importexport/class.import_events_csv.inc.php index be4161f507..add2d94894 100644 --- a/calendar/importexport/class.import_events_csv.inc.php +++ b/calendar/importexport/class.import_events_csv.inc.php @@ -28,6 +28,7 @@ class import_events_csv implements iface_import_plugin { // with cat(s) from csv OR add the cat from // csv file to exeisting cat(s) of record 'num_header_lines', // int number of header lines + 'trash_users_records', // trashes all events of events owner before import 'field_conversion', // array( $csv_col_num => conversion) 'field_mapping', // array( $csv_col_num => adb_filed) 'conditions', /* => array containing condition arrays: @@ -93,7 +94,7 @@ class import_events_csv implements iface_import_plugin { )); $this->definition = $_definition; - + // user, is admin ? $this->is_admin = isset( $GLOBALS['egw_info']['user']['apps']['admin'] ) && $GLOBALS['egw_info']['user']['apps']['admin']; $this->user = $GLOBALS['egw_info']['user']['account_id']; @@ -119,6 +120,18 @@ class import_events_csv implements iface_import_plugin { $_definition->plugin_options['events_owner'] = isset( $_definition->plugin_options['events_owner'] ) ? $_definition->plugin_options['events_owner'] : $this->user; + // trash_users_records ? + if ( $_definition->plugin_options['trash_users_records'] === true ) { + if ( !$_definition->plugin_options['dry_run'] ) { + $socal = CreateObject( 'calendar.socal' ); + $socal->change_delete_user( $_definition->plugin_options['events_owner'], false ); + unset( $socal ); + } else { + $lid = $GLOBALS['egw']->accounts->id2name( $_definition->plugin_options['events_owner'] ); + echo "Attension: All Events of '$lid' would be deleted!\n"; + } + } + while ( $record = $import_csv->get_record() ) { // don't import empty events