Author Topic: example_addressbook_backend php arrays  (Read 7624 times)

Offline php_ignorant

  • Newbie
  • *
  • Posts: 1
example_addressbook_backend php arrays
« on: August 19, 2009, 03:15:17 AM »
Roundcube 0.3-RC1 revision 2862 seems to be working fine except for the anemic addressbook functionality. I've enabled the example_addressbook plugin to give me a simple static address group that users can't edit (in addition to the standard SQL personal addressbook). However all my attempts at adding entries into the array have met with failure. I can't seem to get the proper syntax to get the addresses working.

example_addressbook_backend.php: {snippet}

public function list_records($cols=null, $subset=0)
{
   $this->result = $this->count();
   $this->result->add (array (array('ID'  => '110', 'name' => "John Doe", 'firstname' => "John", 'surname' => "Doe", 'email' => john_doe@example.com),
array('ID' => '120', 'name' => "Joe Blow", 'firstname' => "Joe", 'surname' => "Blow", 'email => joe_blow@example.com)));

This will result in the Group displaying (listed in the 'example_addressbook.php'), but nothing displaying in the 'Display Name' column, though it will list "Contacts 1 to 1 of 1" on the bottom of that column.

Changing the code to:

  $this->result->add (array('ID'  => '110', 'name' => "John Doe", 'firstname' => "John", 'surname' => "Doe", 'email' => john_doe@example.com),
array('ID' => '120', 'name' => "Joe Blow", 'firstname' => "Joe", 'surname' => "Blow", 'email => joe_blow@example.com));

results in only the first address ("John Doe") displaying in the "Display name" column along with the appropriate fields in the next window over. The bottom of the "Display name" column says "Contacts 1 to 1 of 1" again (despite more than one entry).

Changing the code once again to:

 $this->result->add (array('ID'  => '110', 'name' => "John Doe", 'firstname' => "John", 'surname' => "Doe", 'email' => john_doe@example.com));
$this->result->add (array('ID' => '120', 'name' => "Joe Blow", 'firstname' => "Joe", 'surname' => "Blow", 'email => joe_blow@example.com));

results in all of the entries appearing in the "Display name" column, however only the first entry will have any corresponding info in the last window. All other entries will be blank (though the server is contacted for the info). Repeated clicking of the Display name entries eventually results in Roundcube locking up/being unresponsive. The browser window has to be closed (Firefox 3.5.2 in this case) and reopened (which results in a logged in session that is operable).

Does anyone have any clues on how to extend the array(s) in the example_addressbook_backend.php plugin ? Looking at the PHP manual at PHP.NET doesn't seem to offer a sufficient example in this case. If I could get this to work, it would suffice for most of my needs at the moment. Implementing an LDAP server for the addressbook seems problematic and will probably result in a much more complicated setup that still won't do what I'm hoping for in an addressbook.

Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
example_addressbook_backend php arrays
« Reply #1 on: August 20, 2009, 07:33:24 AM »
Please register @ RoundCube Mailing Lists and mai to devs list. You get contact to the devs there. I tried to figure out myself but didn't get it.
Regards,
Rosali
__________________
MyRoundcube Project (commercial)

Offline pforce

  • Newbie
  • *
  • Posts: 1
example_addressbook_backend php arrays
« Reply #2 on: August 24, 2009, 05:55:17 AM »
Hi to everyone.
I don't "write" english very well.
I want to replace SquirrelMail with RoundCube.
The installation was successful but I have the same problem of the previous post but I do not understand what I have to do.
Thanks.

Offline corbosman

  • Sr. Member
  • ****
  • Posts: 260
example_addressbook_backend php arrays
« Reply #3 on: August 30, 2009, 04:26:34 AM »
Just making sure.. the code above contains an error. The second entry has an 'email' field that isnt properly terminated with a '. And you should probably also put the email address in quotes.