Author Topic: google_contacts: Email field blank  (Read 6906 times)

Offline Mighty

  • Jr. Member
  • **
  • Posts: 12
google_contacts: Email field blank
« on: July 30, 2011, 05:56:08 AM »
I finally got google_contacts installed and running.  I found the installation instructions to be inadequate.  While I'm an experienced programmer, I am not a RoundCube guru, nor a MySQL guru.  But after a couple of hours I was able to stumble through the installation.

For those who missed it, this message was invaluable.  There are two spots that require that edit.

So, it's finally up and running.  It imports my 404 Google contacts.  But the email field is blank in all of them.  I logged out of RoundCube and logged back in, to force a new session and another sync.  (I'd like to see a "Sync now" button to force a sync.)  No change.

Should it be pulling in more than just the email address?  Or, is that brief mention in the README for v0.6 only?

I don't see any mention of this elsewhere on the board.

Rcube 0.5.3, new install, the only other plugin is message_highlight.

Drake

Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
google_contacts: Email field blank
« Reply #1 on: July 30, 2011, 11:53:19 PM »
google_contacts originally has been developed by me. Meanwhile deltatech has taken the plugin. His plugin is for the 0.6 branche only. If you want to use it along 0.5.3 you have to use my old plugin (download see footer), which is readonly.
Regards,
Rosali
__________________
MyRoundcube Project (commercial)

Offline Mighty

  • Jr. Member
  • **
  • Posts: 12
google_contacts: Email field blank
« Reply #2 on: July 31, 2011, 01:13:08 AM »
Thank you very much.  That sounds like it will suit my needs.

Maybe deltatech can update his README to clarify that it's for v0.6 and later, only.

Drake

Offline Mighty

  • Jr. Member
  • **
  • Posts: 12
google_contacts: Email field blank
« Reply #3 on: July 31, 2011, 03:00:32 AM »
I deleted all of the entries created with the 0.6 version from within the Roundcube addressbook interface.  Then I deleted the google_contacts folder.

I checked that the .sql files were identical.  In the 0.5.3 version I copied the config.inc.php file, no changes.  Then I uploaded the google_contacts folder to my server.  Then I logged out of RoundCube and logged back in to force a refresh.

According to Google I have 400 contacts.  The plugin reports that there are now 253 contacts in the Google Contacts folder.  The first 18 are blank, and I cannot delete them.

Just eyeballing the beginning of the list, it grabbed seven of the first fifteen entries.  I don't really see any pattern on which entries it included and which it didn't.  Some of those it included have email address and some don't.  Some it skipped have email addresses and some don't.

I've skimmed the code, but it's not immediately obvious in which cases it discards an entry.

Do you have any suggestions on the quickest way to narrow down why it's ignoring so many?

Thanks,
Drake

Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
google_contacts: Email field blank
« Reply #4 on: July 31, 2011, 04:42:08 AM »
Did you configure the plugin?

/* max results */
$rcmail_config['google_contacts_max_results'] = 250;
Regards,
Rosali
__________________
MyRoundcube Project (commercial)

Offline Mighty

  • Jr. Member
  • **
  • Posts: 12
google_contacts: Email field blank
« Reply #5 on: July 31, 2011, 05:11:06 AM »
Ah.  I looked at that, but I must have been looking at the other verson of file in the editor.  *face palm*

I now have over 70 blank entries.  Is that familiar to anyone?

Thanks,
Drake

Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
google_contacts: Email field blank
« Reply #6 on: July 31, 2011, 05:23:49 AM »
2 ways:

Either debug 'google_contacts' method 'sync_contacts' yourself or give me access to your google addressbook (myroundcube at mail4us dot net).

Maybe Google has changed the API. Since I have passed the code, I didn't check if Google-API/Roundcube import methods are still up to date.

As far as I remember I coded the framework for Roundcube 0.3.

It still works for me with my own addressbook. So, no debugging without reproducing ...
Regards,
Rosali
__________________
MyRoundcube Project (commercial)

Offline Mighty

  • Jr. Member
  • **
  • Posts: 12
google_contacts: Email field blank
« Reply #7 on: July 31, 2011, 11:00:04 PM »
Okay, I think I figured it out.  This is happening on any contact where I have no person name and no email address.  This most often happens when I have a phone number for a company, but no contact person nor email address.

For this read-only situation I think I'm going to add a test down at the bottom.  If there's no email address then there's no point in even adding it to my webmail addressbook.  Or, is there some other portion of the system that makes use of the Vcard that you're saving with the contacts?

In the v0.6 version, where extra fields are tracked and it's read/write then it might make sense to mirror the entire addressbook.  Assuming *all* of the information is mirrored, or just the changed fields are sent back to Google Contacts.

I suppose if I were re-releasing this code I'd add a setting on how to handle Google Contacts that have no email address.

Does the new maintainer read these threads for feature requests?

Drake

Offline Mighty

  • Jr. Member
  • **
  • Posts: 12
google_contacts: Email field blank
« Reply #8 on: August 01, 2011, 12:15:09 AM »
Apparently I need a PHP lesson.

When I write_log $contact[0] I get NULL for some of them.  So, I've been trying to test for that.  I've tried isset(), !is_null(), !empty() and != NULL and all four of those come back as true whether the write_log displays an array or NULL.

Code: [Select]
write_log('myt', $contacts[0]);
      $contacts[0]['vcard'] = $vcard;
 if (!empty($contacts[0])) {
write_log('myt', 'writing');
$CONTACTS->update($insert_id[0],$contacts[0]);
 }


What should I be testing for?  I can't seem to figure out when that array is empty.

Thanks,
Drake

Offline Mighty

  • Jr. Member
  • **
  • Posts: 12
google_contacts: Email field blank
« Reply #9 on: August 01, 2011, 01:31:15 AM »
And, forget that previous one.  I was looking in the wrong place, anyway.

I finally managed to change the logic to discard any contact without an email address.  Seems to be working.

Drake

Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
google_contacts: Email field blank
« Reply #10 on: August 01, 2011, 02:41:11 AM »
Not tested, but I think you have just to remove line 258 ff. from my old code:

Code: [Select]
     if(!$contacts[0]){
        $contact = array(
          'email' => '', // this should be responsible to import contacts without an email address
          'name' => $val->name,
          'firstname' => $name[0],
          'surname' => $name[1],
          'vcard' => ''
        );
        $insert_id[] = $CONTACTS->insert($contact, false);
      }
« Last Edit: August 01, 2011, 02:43:33 AM by rosali »
Regards,
Rosali
__________________
MyRoundcube Project (commercial)

Offline Mighty

  • Jr. Member
  • **
  • Posts: 12
google_contacts: Email field blank
« Reply #11 on: August 01, 2011, 03:26:14 AM »
That's kind of what I found.  I turned that test around and wrapped it around the rest of the function.  Deleted those assignments statements.

I've been trying to think of the easiest way to add a "Sync Now" button.  Maybe on the Setting screen?

I added a line in the save function to set the cookie to false, and changed the test at the top of sync to look at the actual value returned.  But, I have to actually change something and then change it back to trigger the line.  Which is only slightly more convenient than deleting the entire Roundcube session cookie from within Firefox.  Albeit, I'm not really adding contacts on a regular basis, so I can probably live with it as-is.

Drake