From 4fc89031291b167f5f4e56bd667a89e3841f27fe Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Thu, 15 Nov 2012 17:11:31 +0000 Subject: [PATCH] Fix bug where user preference for addressbook vCard was not used in some cases --- .../inc/class.addressbook_export_vcard.inc.php | 2 +- addressbook/inc/class.addressbook_hooks.inc.php | 4 ++-- .../inc/class.addressbook_import_vcard.inc.php | 5 ++++- .../inc/class.importexport_import_ui.inc.php | 12 ++++++++++-- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/addressbook/inc/class.addressbook_export_vcard.inc.php b/addressbook/inc/class.addressbook_export_vcard.inc.php index 7963d15e21..c20e280726 100644 --- a/addressbook/inc/class.addressbook_export_vcard.inc.php +++ b/addressbook/inc/class.addressbook_export_vcard.inc.php @@ -73,7 +73,7 @@ class addressbook_export_vcard implements importexport_iface_export_plugin { // vCard opens & closes the resource itself, but this doesn't seem to matter $meta = stream_get_meta_data($_stream); - $vcard = new addressbook_vcal(); + $vcard = new addressbook_vcal('addressbook','text/vcard'); $vcard->export($this->selection, $meta['uri']); } diff --git a/addressbook/inc/class.addressbook_hooks.inc.php b/addressbook/inc/class.addressbook_hooks.inc.php index e9d39f1014..5b087c31f4 100644 --- a/addressbook/inc/class.addressbook_hooks.inc.php +++ b/addressbook/inc/class.addressbook_hooks.inc.php @@ -157,10 +157,10 @@ class addressbook_hooks $settings['vcard_charset'] = array( 'type' => 'select', - 'label' => 'Charset for the vCard export', + 'label' => 'Charset for the vCard import and export', 'name' => 'vcard_charset', 'values' => translation::get_installed_charsets(), - 'help' => 'Which charset should be used for the vCard export.', + 'help' => 'Which charset should be used for the vCard import and export.', 'xmlrpc' => True, 'admin' => false, 'default'=> 'iso-8859-1', diff --git a/addressbook/inc/class.addressbook_import_vcard.inc.php b/addressbook/inc/class.addressbook_import_vcard.inc.php index eabcbd903a..34b920254b 100644 --- a/addressbook/inc/class.addressbook_import_vcard.inc.php +++ b/addressbook/inc/class.addressbook_import_vcard.inc.php @@ -111,6 +111,7 @@ class addressbook_import_vcard implements importexport_iface_import_plugin { $this->bocontacts = new addressbook_vcal(); $charset = $_definition->plugin_options['charset']; + if($charset == 'user') $charset = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset']; // Start counting successes $this->current = 0; @@ -155,7 +156,9 @@ class addressbook_import_vcard implements importexport_iface_import_plugin { */ public function _vcard($_vcard, $owner) { - $record = $this->bocontacts->vcardtoegw($_vcard,$this->definition->plugin_options['charset']); + $charset = $_definition->plugin_options['charset']; + if($charset == 'user') $charset = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset']; + $record = $this->bocontacts->vcardtoegw($_vcard,$charset); $record['owner'] = $owner; diff --git a/importexport/inc/class.importexport_import_ui.inc.php b/importexport/inc/class.importexport_import_ui.inc.php index abbd19412a..9344e3335f 100644 --- a/importexport/inc/class.importexport_import_ui.inc.php +++ b/importexport/inc/class.importexport_import_ui.inc.php @@ -61,7 +61,15 @@ // Check file encoding matches import $sample = file_get_contents($content['file']['tmp_name'],false, null, 0, 1024); - $required = $options['charset'] == 'user' || !$options['charset'] ? $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset'] : $options['charset']; + if($appname == 'addressbook' && $definition_obj->plugin == 'addressbook_import_vcard') + { + $preference = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset']; + } + else + { + $preference = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset']; + } + $required = $options['charset'] == 'user' || !$options['charset'] ? $preference : $options['charset']; $encoding = translation::detect_encoding($sample); if($encoding && strtoupper($required) != strtoupper($encoding)) { @@ -71,7 +79,7 @@ ); } - $file = fopen($content['file']['tmp_name'], 'r'); + $file = fopen($content['file']['tmp_name'], 'rb'); $count = 0; // Some of the translation, conversion, etc look here