Fix bug where user preference for addressbook vCard was not used in some cases

This commit is contained in:
Nathan Gray 2012-11-15 17:11:31 +00:00
parent cd9e0cfab5
commit 4fc8903129
4 changed files with 17 additions and 6 deletions

View File

@ -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 // vCard opens & closes the resource itself, but this doesn't seem to matter
$meta = stream_get_meta_data($_stream); $meta = stream_get_meta_data($_stream);
$vcard = new addressbook_vcal(); $vcard = new addressbook_vcal('addressbook','text/vcard');
$vcard->export($this->selection, $meta['uri']); $vcard->export($this->selection, $meta['uri']);
} }

View File

@ -157,10 +157,10 @@ class addressbook_hooks
$settings['vcard_charset'] = array( $settings['vcard_charset'] = array(
'type' => 'select', 'type' => 'select',
'label' => 'Charset for the vCard export', 'label' => 'Charset for the vCard import and export',
'name' => 'vcard_charset', 'name' => 'vcard_charset',
'values' => translation::get_installed_charsets(), '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, 'xmlrpc' => True,
'admin' => false, 'admin' => false,
'default'=> 'iso-8859-1', 'default'=> 'iso-8859-1',

View File

@ -111,6 +111,7 @@ class addressbook_import_vcard implements importexport_iface_import_plugin {
$this->bocontacts = new addressbook_vcal(); $this->bocontacts = new addressbook_vcal();
$charset = $_definition->plugin_options['charset']; $charset = $_definition->plugin_options['charset'];
if($charset == 'user') $charset = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset'];
// Start counting successes // Start counting successes
$this->current = 0; $this->current = 0;
@ -155,7 +156,9 @@ class addressbook_import_vcard implements importexport_iface_import_plugin {
*/ */
public function _vcard($_vcard, $owner) 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; $record['owner'] = $owner;

View File

@ -61,7 +61,15 @@
// Check file encoding matches import // Check file encoding matches import
$sample = file_get_contents($content['file']['tmp_name'],false, null, 0, 1024); $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); $encoding = translation::detect_encoding($sample);
if($encoding && strtoupper($required) != strtoupper($encoding)) 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; $count = 0;
// Some of the translation, conversion, etc look here // Some of the translation, conversion, etc look here