Author Topic: Bug in contact import  (Read 2857 times)

mailnet_uk

  • Newbie
  • *
  • Posts: 29
    • View Profile
    • Email
Bug in contact import
« on: December 15, 2009, 07:28:29 pm »
Opengoo 1.6, I've just tried importing a vCard file created using Apple's Address Book application, containing multiple contacts.

It appears that only the second e-mail address is importing.

For example in my own contact, I have the following in the vCard file:

EMAIL;type=INTERNET;type=HOME;type=pref:me@address1.com
EMAIL;type=INTERNET;type=WORK:me@address2.com

Opengoo however only associates "me@address2.com" with the new contact.

Another of my contacts has two HOME e-mails, and again only the second one is registering on his contact.

Another slight bug is that one of the address lines spans 2 lines in Apple's application, and is thus separated with a "\n" character, but Opengoo appears to ignore this and includes it as part of the address text.

item1.ADR;type=HOME;type=pref:;;1 A Street\nA Locality;A Town;A County;POST CODE;United Kingdom

I know Opengoo doesn't support multiple lines in the address fields, so my suggestion would be to either convert the "\n" to a space to get:

A Street A Locality
A Town
A County
POST CODE

or ignore everything after the character anyway as it's secondary none important data - i.e.

A Street
A Town
A County
POST CODE

is just as legal an address as

A Street
A Locality
A Town
A County
POST CODE

alvarotm01

  • Administrator
  • Sr. Member
  • *****
  • Posts: 335
    • View Profile
    • Email
Re: Bug in contact import
« Reply #1 on: December 21, 2009, 02:52:37 pm »
Hi,

To fix the issue for email addresses, you may replace line 2012 of 'application/controllers/ContactController.class.php' with this one:
Code: [Select]
} else if (preg_match('/EMAIL;type=(PREF,)?INTERNET(,PREF)?(;type=(HOME|WORK))?(;type=PREF)?:([-a-zA-Z0-9_.]+@[-a-zA-Z0-9.]+)/i', $line, $matches)) {

About the addresses, to remove the "\n" character, try replacing line 2057 of 'application/controllers/ContactController.class.php' with this one:
Code: [Select]
foreach ($addr as $k=>$v) $addr[$k] = str_replace(array("\r\n", "\n", "\r", "\t", '\r\n', '\n', '\r', '\t'), " ", trim($v));

regards

mailnet_uk

  • Newbie
  • *
  • Posts: 29
    • View Profile
    • Email
Re: Bug in contact import
« Reply #2 on: December 21, 2009, 04:28:29 pm »
Thanks for the update.  My ContactController.class.php file only has 1719 lines.

I'm running 1.5.3 because I've now got the commercial version (on-site) installed and I don't think you've released 1.6 for commercial users yet.

Is it best to wait until you release 1.6 or can you tell me which lines they are in 1.5.3?

Many thanks,
Andy

mailnet_uk

  • Newbie
  • *
  • Posts: 29
    • View Profile
    • Email
Re: Bug in contact import
« Reply #3 on: December 22, 2009, 07:35:33 pm »
Hi Alvaro,

That worked fine on both issues - it even picked up both e-mail addresses.

Feng is suddenly much more useful for us :)

Many thanks,
Andy