Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make default_addressbook settable from a preset like other special addressbooks #440

Closed
TCB13 opened this issue May 8, 2023 · 8 comments
Milestone

Comments

@TCB13
Copy link

TCB13 commented May 8, 2023

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:

Screenshot 2023-05-08 185728

I believe this happens because collected addresses appear first on the address book list:

Screenshot 2023-05-08 185241

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.

@mstilkerich
Copy link
Owner

mstilkerich commented May 9, 2023

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.

@TCB13
Copy link
Author

TCB13 commented May 9, 2023

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.

@mstilkerich
Copy link
Owner

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.

@mstilkerich mstilkerich changed the title Order of Address Books Make default_addressbook settable from a preset like other special addressbooks May 11, 2023
@mstilkerich mstilkerich added this to the 5.1.0 milestone Aug 19, 2023
@TCB13
Copy link
Author

TCB13 commented Sep 28, 2023

@mstilkerich ,

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:

image

For reference, here is the setup of the address book in Baikal:

image

Side question, should I keep the # under the url? matchurl' => '#htt?? Even without it, same result.

@mstilkerich
Copy link
Owner

mstilkerich commented Sep 29, 2023

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.

@TCB13
Copy link
Author

TCB13 commented Sep 29, 2023

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:

image

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.

@mstilkerich
Copy link
Owner

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.

@TCB13
Copy link
Author

TCB13 commented Sep 29, 2023

Hey,

I just changed the url match to 'matchurl' => '#/default/$#', and it works now! :)

image

The only thing that isn't happening - but that you probably can't control - is when we try to compose an email it doesn't select the Address book:

image

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants