Make default_addressbook settable from a preset like other special addressbooks
TCB13 opened this issue · 8 comments
Hello,
Thank you very much for this amazing plugin.
As suggested here #372 (comment) set this $config['address_book_type'] = '';
in order to disable the built in address book of RC.
After loading the UI on the contacts section I get no contacts at all:
I believe this happens because collected addresses appear first on the address book list:
Is there a way to make sure my DAV default address book appears before the others? This obviously is manageable to me but I've a few less tech savvy family members that will never figure that out and will simply assume there are no contacts.
Thank you.
Hi, this list is created by roundcube and I do not know if / how it is sorted and whether it can be influenced by rcmcarddav. Rcmcarddav just provides a list of carddav addressbooks to roundcube with no particular order.
However, normally roundcube will automatically select the default addressbook configured by the user. I have configured a carddav addressbook as my default and when I open the contacts pane, it will always be initially selected although it is not first in the list.
The default addressbook can currently only be set by each user for their own account, but it should be possible to allow an admin set it to a preset like it is already possible for collected senders / recipients. I'll keep it as a feature request.
However, normally roundcube will automatically select the default addressbook configured by the user
Here it didn't. I had to go into the settings > contacts > save. After doing that it gets automatically selected, but it doesn't happen by default.
Anyways, I was reading about this global config:
// Defines address book (internal index) to which new contacts will be added
// By default it is the first writeable addressbook.
// Note: Use '0' for built-in address book.
$config['default_addressbook'] = null;
Even setting it as $config['default_addressbook'] = 0;
doesn't help on a new user. I believe that number is the id of book and that changes with every carddav setup.
Thank you for the prompt reply.
Yes, that is what I mean by every user has to configure it.
The default_addressbook
option must be set to an addressbook ID, e.g. carddav_1
. However, the number is the database ID of the CardDAV addressbook and it is different for every addressbook. That's why it is not currently possible for the admin to configure it.
This config option is similar to collected_recipients
and collected_senders
, for which I already implemented a way for the admin to set them to carddav addressbooks based on matches against URL or name of the addressbook. It should be straightforward to also enable it for default_addressbook
, I just was not aware of the option.
Well, I'm not sure if I'm missing the point or if this feature isn't working. I tried to setup this like:
$prefs['_GLOBAL']['default_addressbook'] = [
'preset' => 'main',
'matchurl' => '#https://server.example.org/dav/dav.php/addressbooks/%u/default/#',
];
And what happens is that under RC > Contacts I still don't get the default
address book called Address Book
selected by default:
For reference, here is the setup of the address book in Baikal:
Side question, should I keep the # under the url? matchurl' => '#htt
?? Even without it, same result.
Is there anything in carddav.log? Does the addressbook show up as the default_addressbook in the roundcube settings?
Regarding the matchurl setting, it must contain a regular expression and therefore have the delimiters, so yes the # (or any other valid delimiter character) is needed. When the preset only contains a single addressbook you can also omit the matchurl and matchname settings.
Also which roundcube version do you use? It looks like default_addressbook only affects the initially selected addressbook in the contacts view from version 1.5 and later, i.e. for a 1.4 roundcube it will not have an effect regarding this aspect.
Is there anything in carddav.log?
Apparently it does:
[29-Sep-2023 11:23:33 +0100]: <5p6kb994> [5 ERR] Cannot set special addressbook default_addressbook, there are 0 candidates (need: 1)
[29-Sep-2023 11:23:38 +0100]: <5p6kb994> [5 ERR] Cannot set special addressbook default_addressbook, there are 0 candidates (need: 1)
[29-Sep-2023 11:23:38 +0100]: <5p6kb994> [5 ERR] Cannot set special addressbook default_addressbook, there are 0 candidates (need: 1)
Does the addressbook show up as the default_addressbook in the roundcube settings?
I believe so. But that happens even without the plugin enabled:
When the preset only contains a single addressbook you can also omit the matchurl and matchname settings.
In this case there's always an Address Book called "default" and user might add others, I would like it to default do the "default" one.
Also which roundcube version do you use?
RC 1.6.0
For reference my RoundCube config looks like this:
$config['address_book_type'] = '';
$config['addressbook_sort_col'] = 'firstname';
$config['addressbook_name_listing'] = 1;
$config['autocomplete_addressbooks'] = [];
$config['collected_recipients'] = true;
$config['collected_senders'] = true;
$config['default_addressbook'] = 'carddav_*';
Thank you.
Please do not set default_addressbook in the roundcube config. Not that it really matters in case rcmcarddav overrides it, but it case it fails the value you set there makes no sense as it’s no valid addressbook id.
As to why it does not match I cannot tell. It looks good to be but there are parts that are blurred. l
Maybe try simpler if the last component of the url is always default
:
$prefs['_GLOBAL']['default_addressbook'] = [
'preset' => 'main',
'matchurl' => '#/default/$#',
];
Please check the URL for the addressbook shown in the carddav settings, the match is applied to the URL as shown there. Simple things like presence or absence of a trailing slash could cause the match to fail. Also mind that matchurl is a regex and certain characters carry a special meaning.