#!/bin/bash

#
# Configure the hnost CMS with CMSes
#
# --> Drupal
if [[ ! -z "${DRUPAL_DATABASE}" ]]; then
  # TODO: enable/configure necessary modules
  :

# --> WordPress
elif [[ ! -z "${WORDPRESS_DATABASE}" ]]; then
  wp plugin activate user-last-login

# --> Standalone!
else
  # TODO: is there anything that is not CiviCRM-related?
  :
fi

#
# Install mandatory extensions
#
cv en civiimport civicrm_admin_ui civicrm_search_ui message_admin firewall formprotection easycopy
cv dis tellafriend
cv en com.cividesk.commons org.civicrm.recentmenu riverlea
cv en com.aghstrategies.airmail

#
# Configure CiviCRM settings
#
cv setting:set --scope=domain:* theme_backend=walbrook theme_frontend=default
# increase timeout to fill registration forms as some require longer than default 20 mins
cv ev 'Civi::settings()->set("secure_cache_timeout_minutes", 40);';

# not working ...
# cv setting:set --scope=domain:* formprotection_enable_test=false formprotection_enable_firewall_integration=true \
#               formprotection_enable_floodcontrol=false formprotection_enable_honeypot=false \\ 
#               formprotection_floodcontrol_recaptcha=v2checkbox formprotection_recaptcha_threshold=0.5 \\
#               formprotection_recaptcha_enabled_quickforms=[] +l formprotection_recaptcha_enabled_quickforms[]=all
# cv setting:set --scope=domain:* formprotection_enable_test=false formprotection_enable_firewall_integration=true formprotection_enable_floodcontrol=false formprotection_enable_honeypot=false formprotection_floodcontrol_recaptcha=v2checkbox formprotection_recaptcha_threshold=0.5 formprotection_recaptcha_enabled_quickforms=[] +l formprotection_recaptcha_enabled_quickforms[]=all

# clear cache
cv flush
