blind-coder/rcmcarddav — pull request #16 by adobo (2014-01-22 11:32:43+00:00)
Title: Fix set_group when no group is specified

Some pages that list contacts (e.g. when composing a message) issue a `set_group(0)` on the addressbook object.

That means not restricting the search to a group at all. However, the plugin tries to search for contacts belonging to a group with id = 0. Generated SQL sentence follows:

[22-Jan-2014 12:03:00 +0100]: [15] SELECT id,name,firstname,surname,email FROM carddav_contacts
WHERE abook_id='2'
AND (EXISTS(
SELECT * FROM carddav_group_user WHERE group_id = '0' AND contact_id = carddav_contacts.id
))
ORDER BY (CASE WHEN showas='COMPANY' THEN organization ELSE surname END) ASC LIMIT 50;

You can see how Roundcube handles this on LDAP addressbooks (https://github.com/roundcube/roundcubemail/blob/master/program/lib/Roundcube/rcube_ldap.php#L1567).

Without this patch, the Compose window will show no contacts when clicking on a CardDAV addressbook.