Author Topic: [help] Develop my own addressbook  (Read 10763 times)

Offline rodrigocarneiro

  • Jr. Member
  • **
  • Posts: 10
[help] Develop my own addressbook
« on: August 06, 2013, 08:48:08 AM »
Dear All,

I'm new to this forum, so hopefully I posted the question in the right place.

I created a new addressbook plugin from example_addressbook located inside the plugins folder in roundcube. I deduced a lot from other implementations and read something from the documentation, but I'm having a little problem when it relates to search within my addresbook.  Strangely the autocomplete on the screen to write the e-mail works fine.

I wonder if the masters have some literature to help me implement the plugin.

Thanks for any help!

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,880
    • SKaero - Custom Roundcube development
Re: [help] Develop my own addressbook
« Reply #1 on: August 06, 2013, 02:42:48 PM »
Haven't played with the address book functions to much so I may not be of to much help, but I'll try. What do you have set for address_book_type, and the autocomplete_addressbooks options in the main.inc.php?

Offline rodrigocarneiro

  • Jr. Member
  • **
  • Posts: 10
Re: [help] Develop my own addressbook
« Reply #2 on: August 07, 2013, 10:23:02 AM »
Hello, thanks for the reply.

$rcmail_config['address_book_type'] = 'sql';
$rcmail_config['autocomplete_addressbooks'] = array('sql', 'my');

I already tried to set boot type to be equals to my autocomplete setting, but with the same result.

Note:
When i do a search in adressbook, it returns everytime the same values to my custom one, but bring correctly records of the buildin one.

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,880
    • SKaero - Custom Roundcube development
Re: [help] Develop my own addressbook
« Reply #3 on: August 08, 2013, 01:54:43 AM »
I'm not sure I understand what your saying its doing, did you code a custom search handler?

Offline rodrigocarneiro

  • Jr. Member
  • **
  • Posts: 10
Re: [help] Develop my own addressbook
« Reply #4 on: August 08, 2013, 01:29:49 PM »
Hello again,

I'm developing a plugin that read some contacts from a custom table and presents them to users. A kind of global list. For this I started to develop on top of example_addressbook and added my code to make the magic happen. My problem is that I can not make a search in the contacts list works perfectly. Here's the code I modified from example_addressbook plugin, I hope I have been clearer now:

example_addressbook:
http://codepad.org/6mK7suxN

example_addressbook_backend:
http://codepad.org/d2rJi41o

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,880
    • SKaero - Custom Roundcube development
Re: [help] Develop my own addressbook
« Reply #5 on: August 08, 2013, 01:43:04 PM »
Looking at your code in the example_addressbook_backend file in the search function you have a custom chunk of sql in the $where variable which you pass to the list_records function but it never gets added to the actual sql query.

Offline rodrigocarneiro

  • Jr. Member
  • **
  • Posts: 10
Re: [help] Develop my own addressbook
« Reply #6 on: August 08, 2013, 03:16:35 PM »
Sorry about that,

I modified the code to be able to show you, actually the where clause is added there, as I said earlier the autocoplete works on the page to write emails. So this is not my problem.

Thank you for your attention.

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,880
    • SKaero - Custom Roundcube development
Re: [help] Develop my own addressbook
« Reply #7 on: August 08, 2013, 03:23:27 PM »
Ok, I'm not sure what you mean by the following:
Code: [Select]
When i do a search in adressbook, it returns everytime the same values to my custom one, but bring correctly records of the buildin one.
Is it returning any records from your custom address book handler?

Offline rodrigocarneiro

  • Jr. Member
  • **
  • Posts: 10
Re: [help] Develop my own addressbook
« Reply #8 on: August 08, 2013, 03:43:31 PM »
What i means is:

This piece of code:
Code: [Select]
$config = rcmail::get_instance()->config;
$sources = (array) $config->get('autocomplete_addressbooks', array('sql'));
if (!in_array($this->abook_id, $sources)) {
   $sources[] = $this->abook_id;
   $config->set('autocomplete_addressbooks', $sources);
}

Do the same of:
Code: [Select]
$rcmail_config['autocomplete_addressbooks'] = array('sql', 'my');

To bring result from the both addressbooks, i presume.

But, my custom addressbook, dont bring them correctly, although the sql bring. i think i forgot to implement some functioin on the class. This is why i first ask about a literature to help me to implement the plugin.

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,880
    • SKaero - Custom Roundcube development
Re: [help] Develop my own addressbook
« Reply #9 on: August 08, 2013, 09:09:20 PM »
Does the search work if you change the address_book_type in the main.inc.php to your custom address book handler?

Offline rodrigocarneiro

  • Jr. Member
  • **
  • Posts: 10
Re: [help] Develop my own addressbook
« Reply #10 on: August 09, 2013, 08:53:33 AM »
No, i tried to put my addressbook name and a empty string:

Code: [Select]
// This indicates which type of address book to use. Possible choises:
// 'sql' (default), 'ldap' and ''.
// If set to 'ldap' then it will look at using the first writable LDAP
// address book as the primary address book and it will not display the
// SQL address book in the 'Address Book' view.
// If set to '' then no address book will be displayed or only the
// addressbook which is created by a plugin (like CardDAV).
$rcmail_config['address_book_type'] = '';

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,880
    • SKaero - Custom Roundcube development
Re: [help] Develop my own addressbook
« Reply #11 on: August 09, 2013, 12:01:49 PM »
Can you post your full code so I can test it myself?

Offline rodrigocarneiro

  • Jr. Member
  • **
  • Posts: 10
Re: [help] Develop my own addressbook
« Reply #12 on: August 09, 2013, 01:27:40 PM »
This is all i have modified on the code. What you need is to active the plugin in config and create the table on your database with the fields:

 id [int], login [varchar], nome [varchar], email [varchar], ramal [varchar], vinculo [varchar], lotacao [varchar], lista [varchar], lista_visivel [bool]

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,880
    • SKaero - Custom Roundcube development
Re: [help] Develop my own addressbook
« Reply #13 on: August 09, 2013, 03:51:36 PM »
You said that you had modified the code that you had posted before, since the search is obviously broken in that one.

Offline rodrigocarneiro

  • Jr. Member
  • **
  • Posts: 10
Re: [help] Develop my own addressbook
« Reply #14 on: August 09, 2013, 03:57:33 PM »
Indeed, just change the code to accept the where clause, I will make the changes and repost for you.