diff --git a/de.systopia.civiproxy/CRM/Admin/Form/Setting/ProxySettings.php b/de.systopia.civiproxy/CRM/Admin/Form/Setting/ProxySettings.php
index 233ddfc..e5a33cf 100644
--- a/de.systopia.civiproxy/CRM/Admin/Form/Setting/ProxySettings.php
+++ b/de.systopia.civiproxy/CRM/Admin/Form/Setting/ProxySettings.php
@@ -16,7 +16,7 @@ class CRM_Admin_Form_Setting_ProxySettings extends CRM_Admin_Form_Setting
$this->addElement('text', 'proxy_url', ts('Proxy URL'), array('disabled' => 'disabled'));
$this->addElement('static', 'proxy_version', ts('Proxy version'));
- $this->addElement('text', 'civimail_external_optout', ts('CiviMail: External opt-out page'), array('disabled' => 'disabled'));
+ $this->addElement('text', 'custom_mailing_base', ts('Custom Subscribe/Unsubscribe Pages'), array('disabled' => 'disabled'));
$this->addButtons(array(
array('type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE),
@@ -28,7 +28,7 @@ class CRM_Admin_Form_Setting_ProxySettings extends CRM_Admin_Form_Setting
function addRules() {
$this->addRule('proxy_url', ts('This may only contain a valid URL'), 'onlyValidURL');
- $this->addRule('civimail_external_optout', ts('This may only contain a valid URL'), 'onlyValidURL');
+ $this->addRule('custom_mailing_base', ts('This may only contain a valid URL'), 'onlyValidURL');
}
function preProcess() {
@@ -51,7 +51,7 @@ class CRM_Admin_Form_Setting_ProxySettings extends CRM_Admin_Form_Setting
$this->setDefaults(array(
'proxy_url' => $proxyUrl,
'proxy_version' => $proxyVersion, // watch out, this might contain an error message
- 'civimail_external_optout' => CRM_Core_BAO_Setting::getItem('CiviProxy Settings', 'civimail_extoptout')
+ 'custom_mailing_base' => CRM_Core_BAO_Setting::getItem('CiviProxy Settings', 'custom_mailing_base')
));
}
@@ -66,8 +66,13 @@ class CRM_Admin_Form_Setting_ProxySettings extends CRM_Admin_Form_Setting
if (isset($values['proxy_url'])) {
CRM_Core_BAO_Setting::setItem($values['proxy_url'],'CiviProxy Settings', 'proxy_url');
}
- if (isset($values['civimail_external_optout'])) {
- CRM_Core_BAO_Setting::setItem($values['civimail_external_optout'],'CiviProxy Settings', 'civimail_extoptout');
+ if (isset($values['custom_mailing_base'])) {
+ // check if it is simply default ({$proxy_url}/mailing)
+ if ($values['custom_mailing_base'] == $values['proxy_url'] . '/mailing') {
+ // ...in which case we'll simply set it to ''
+ $values['custom_mailing_base'] = '';
+ }
+ CRM_Core_BAO_Setting::setItem($values['custom_mailing_base'],'CiviProxy Settings', 'custom_mailing_base');
}
// give feedback to user
diff --git a/de.systopia.civiproxy/civiproxy.php b/de.systopia.civiproxy/civiproxy.php
index dd597d7..f77b589 100644
--- a/de.systopia.civiproxy/civiproxy.php
+++ b/de.systopia.civiproxy/civiproxy.php
@@ -16,15 +16,27 @@ function civiproxy_civicrm_alterMailParams( &$params, $context ) {
$proxy_base = CRM_Core_BAO_Setting::getItem('CiviProxy Settings', 'proxy_url');
// fields to replace:
- $external_urls = array('url.php', 'open.php');
$fields2replace = array('html', 'text');
foreach ($fields2replace as $field) {
$value = $params[$field];
+
+ // General external functions
$value = preg_replace("#{$system_base}sites/all/modules/civicrm/extern/url.php#i", $proxy_base.'/url.php', $value);
$value = preg_replace("#{$system_base}sites/all/modules/civicrm/extern/open.php#i", $proxy_base.'/open.php', $value);
$value = preg_replace("#{$system_base}sites/default/files/civicrm/persist/#i", $proxy_base.'/file.php?id=', $value);
- $value = preg_replace("#{$system_base}civicrm/mailing/view#i", $proxy_base.'/mail.php', $value);
- $value = preg_replace("#{$system_base}civicrm/mailing/optout#i", $proxy_base.'/index.php', $value);
+
+ // Mailing related functions
+ $value = preg_replace("#{$system_base}civicrm/mailing/view#i", $proxy_base.'/mailing/mail.php', $value);
+ $custom_mailing_base = CRM_Core_BAO_Setting::getItem('CiviProxy Settings', 'custom_mailing_base');
+ foreach ($other_mailing_functions as $function) {
+ if (empty($custom_mailing_base)) {
+ $new_url = "{$proxy_base}/mailing/{$function}.php";
+ } else {
+ $new_url = "{$custom_mailing_base}/{$function}.php";
+ }
+ $value = preg_replace("#{$system_base}civicrm/mailing/{$function}#i", $new_url, $value);
+ }
+
$params[$field] = $value;
}
}
diff --git a/de.systopia.civiproxy/info.xml b/de.systopia.civiproxy/info.xml
index 4fac229..fbb94d1 100644
--- a/de.systopia.civiproxy/info.xml
+++ b/de.systopia.civiproxy/info.xml
@@ -9,7 +9,7 @@
- {ts}TODO #2{/ts} + {ts}TADDAAAA{/ts}
{/htxt} diff --git a/de.systopia.civiproxy/templates/CRM/Admin/Form/Setting/ProxySettings.tpl b/de.systopia.civiproxy/templates/CRM/Admin/Form/Setting/ProxySettings.tpl index a331ade..21f334b 100644 --- a/de.systopia.civiproxy/templates/CRM/Admin/Form/Setting/ProxySettings.tpl +++ b/de.systopia.civiproxy/templates/CRM/Admin/Form/Setting/ProxySettings.tpl @@ -20,21 +20,21 @@ - {* ==== advanced settings disabled ======== +