1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/roundcube_ynh.git synced 2024-09-03 20:16:28 +02:00

Handle multiple CardDAV apps of each type

Can now include contacts from, e.g. apps nextcloud, nextcloud__2, etc.
This commit is contained in:
tituspijean 2020-11-22 14:05:49 +01:00
parent b5f342e88b
commit 87e2f1e38d
5 changed files with 56 additions and 81 deletions

16
conf/baikal.inc.php Normal file
View file

@ -0,0 +1,16 @@
$prefs['{baikal_id}'] = array(
// required attributes
'name' => '{baikal_id}',
'username' => '%u',
'password' => '%p',
'url' => '{baikal_url}/card.php/addressbooks/%u/',
// optional attributes
'active' => true,
'readonly' => false,
'refresh_time' => '00:05:00',
'fixed' => array('username', 'password'),
'hide' => false,
);

View file

@ -1,59 +0,0 @@
<?php
// RCMCardDAV Plugin Admin Settings
// ** ADDRESSBOOK PRESETS
/* PRESET FOR: baikal
$prefs['Baïkal'] = array(
// required attributes
'name' => 'Baïkal',
'username' => '%u',
'password' => '%p',
'url' => '{baikal_url}/card.php/addressbooks/%u/',
// optional attributes
'active' => true,
'readonly' => false,
'refresh_time' => '00:05:00',
'fixed' => array('username', 'password'),
'hide' => false,
);
END: baikal */
/* PRESET FOR: owncloud
$prefs['ownCloud'] = array(
// required attributes
'name' => 'ownCloud',
'username' => '%u',
'password' => '%p',
'url' => '{owncloud_url}/remote.php/dav/addressbooks/users/%u/default/',
// optional attributes
'active' => true,
'readonly' => false,
'refresh_time' => '00:05:00',
'fixed' => array('username', 'password'),
'hide' => false,
);
END: owncloud */
/* PRESET FOR: nextcloud
$prefs['NextCloud'] = array(
// required attributes
'name' => 'nextCloud',
'username' => '%u',
'password' => '%p',
'url' => '{nextcloud_url}/remote.php/dav/addressbooks/users/%u/contacts/',
// optional attributes
'active' => true,
'readonly' => false,
'refresh_time' => '00:05:00',
'fixed' => array('username', 'password'),
'hide' => false,
);
END: nextcloud */

16
conf/nextcloud.inc.php Normal file
View file

@ -0,0 +1,16 @@
$prefs['{nextcloud_id}'] = array(
// required attributes
'name' => '{nextcloud_id}',
'username' => '%u',
'password' => '%p',
'url' => '{nextcloud_url}/remote.php/dav/addressbooks/users/%u/contacts/',
// optional attributes
'active' => true,
'readonly' => false,
'refresh_time' => '00:05:00',
'fixed' => array('username', 'password'),
'hide' => false,
);

View file

@ -159,27 +159,28 @@ then
carddav_tmp_config="../conf/carddav.config.inc.php" carddav_tmp_config="../conf/carddav.config.inc.php"
carddav_server=0 carddav_server=0
# Copy the plugin configuration file
cp $final_path/plugins/carddav/config.inc.php{.dist,}
# Look for installed and supported CardDAV servers # Look for installed and supported CardDAV servers
for carddav_app in "nextcloud" "baikal" for carddav_app in "nextcloud" "baikal"
do do
carddav_app_id=$(yunohost app list | grep "id: $carddav_app" | grep -Po 'id: \K(.*)' | head -n 1) carddav_app_ids=$(yunohost app list | grep "id: $carddav_app" | grep -Po 'id: \K(.*)' || echo "")
if [ -n "$carddav_app_id" ] for carddav_app_id in $carddav_app_ids
then do
carddav_server=1 carddav_server=1
# Append preset configuration to the config file
cat "../conf/${carddav_app}.inc.php" >> $final_path/plugins/carddav/config.inc.php
# Retrieve app settings and enable relevant preset # Retrieve app settings and enable relevant preset
carddav_domain=$(ynh_app_setting_get --app=$carddav_app_id --key=domain) carddav_domain=$(ynh_app_setting_get --app=$carddav_app_id --key=domain)
carddav_path=$(ynh_app_setting_get --app=$carddav_app_id --key=path) carddav_path=$(ynh_app_setting_get --app=$carddav_app_id --key=path)
carddav_url="https://${carddav_domain}${carddav_path%/}" carddav_url="https://${carddav_domain}${carddav_path%/}"
ynh_replace_string --match_string="{${carddav_app}_url}" --replace_string="$carddav_url" --target_file="$carddav_tmp_config" ynh_replace_string --match_string="{${carddav_app}_id}" --replace_string="$carddav_app_id" --target_file="$final_path/plugins/carddav/config.inc.php"
ynh_replace_string --match_string="\/\* PRESET FOR: $carddav_app" --replace_string="" --target_file="$carddav_tmp_config" ynh_replace_string --match_string="{${carddav_app}_url}" --replace_string="$carddav_url" --target_file="$final_path/plugins/carddav/config.inc.php"
ynh_replace_string --match_string="END: $carddav_app \*\/" --replace_string="" --target_file="$carddav_tmp_config" done
fi
done done
# Copy the plugin configuration file # Do not actualy add the carddav plugin if there's no carddav server available...
cp "$carddav_tmp_config" ""$final_path/plugins/carddav/config.inc.php""
# Do not actualy add the carddav plugin if there's no CardDAV server available...
if [ $carddav_server -eq 1 ] if [ $carddav_server -eq 1 ]
then then
installed_plugins+=" 'carddav'," installed_plugins+=" 'carddav',"

View file

@ -206,27 +206,28 @@ then
carddav_tmp_config="../conf/carddav.config.inc.php" carddav_tmp_config="../conf/carddav.config.inc.php"
carddav_server=0 carddav_server=0
# Copy the plugin configuration file
cp $final_path/plugins/carddav/config.inc.php{.dist,}
# Look for installed and supported CardDAV servers # Look for installed and supported CardDAV servers
for carddav_app in "nextcloud" "baikal" for carddav_app in "nextcloud" "baikal"
do do
carddav_app_id=$(yunohost app list | grep "id: $carddav_app" | grep -Po 'id: \K(.*)' | head -n 1) carddav_app_ids=$(yunohost app list | grep "id: $carddav_app" | grep -Po 'id: \K(.*)' || echo "")
if [ -n "$carddav_app_id" ] for carddav_app_id in $carddav_app_ids
then do
carddav_server=1 carddav_server=1
# Append preset configuration to the config file
cat "../conf/${carddav_app}.inc.php" >> $final_path/plugins/carddav/config.inc.php
# Retrieve app settings and enable relevant preset # Retrieve app settings and enable relevant preset
carddav_domain=$(ynh_app_setting_get --app=$carddav_app_id --key=domain) carddav_domain=$(ynh_app_setting_get --app=$carddav_app_id --key=domain)
carddav_path=$(ynh_app_setting_get --app=$carddav_app_id --key=path) carddav_path=$(ynh_app_setting_get --app=$carddav_app_id --key=path)
carddav_url="https://${carddav_domain}${carddav_path%/}" carddav_url="https://${carddav_domain}${carddav_path%/}"
ynh_replace_string --match_string="{${carddav_app}_url}" --replace_string="$carddav_url" --target_file="$carddav_tmp_config" ynh_replace_string --match_string="{${carddav_app}_id}" --replace_string="$carddav_app_id" --target_file="$final_path/plugins/carddav/config.inc.php"
ynh_replace_string --match_string="\/\* PRESET FOR: $carddav_app" --replace_string="" --target_file="$carddav_tmp_config" ynh_replace_string --match_string="{${carddav_app}_url}" --replace_string="$carddav_url" --target_file="$final_path/plugins/carddav/config.inc.php"
ynh_replace_string --match_string="END: $carddav_app \*\/" --replace_string="" --target_file="$carddav_tmp_config" done
fi
done done
# Copy the plugin configuration file # Do not actually add the carddav plugin if there's no carddav server available...
cp "$carddav_tmp_config" ""$final_path/plugins/carddav/config.inc.php""
# Do not actually add the cardDAV plugin if there's no carddav server available...
if [ $carddav_server -eq 1 ] if [ $carddav_server -eq 1 ]
then then
installed_plugins+=" 'carddav'," installed_plugins+=" 'carddav',"