From be1a118ec764a06d49c86626b22cca3e8cfc21f7 Mon Sep 17 00:00:00 2001
From: systopia
Date: Wed, 18 Mar 2015 08:02:31 +0100
Subject: [PATCH] started developing mail subscribe/unsubscribe pages
---
.../CRM/Admin/Form/Setting/ProxySettings.php | 15 ++++++----
de.systopia.civiproxy/civiproxy.php | 18 +++++++++--
de.systopia.civiproxy/info.xml | 2 +-
.../settings/civiproxy.setting.php | 18 +++++++++--
.../CRM/Admin/Form/Setting/ProxySettings.hlp | 4 +--
.../CRM/Admin/Form/Setting/ProxySettings.tpl | 23 ++++++++------
proxy/config.php | 17 +++++++----
proxy/mailing/confirm.php | 30 +++++++++++++++++++
proxy/{ => mailing}/mail.php | 8 ++---
proxy/mailing/resubscribe.php | 30 +++++++++++++++++++
proxy/mailing/subscribe.php | 21 +++++++++++++
proxy/mailing/unsubscribe.php | 30 +++++++++++++++++++
proxy/proxy.php | 13 ++++++++
13 files changed, 196 insertions(+), 33 deletions(-)
create mode 100644 proxy/mailing/confirm.php
rename proxy/{ => mailing}/mail.php (81%)
create mode 100644 proxy/mailing/resubscribe.php
create mode 100644 proxy/mailing/subscribe.php
create mode 100644 proxy/mailing/unsubscribe.php
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 @@
endres@systopia.de
- 0.2
+ 0.3
alpha
4.4
diff --git a/de.systopia.civiproxy/settings/civiproxy.setting.php b/de.systopia.civiproxy/settings/civiproxy.setting.php
index c46f6a1..19e8665 100644
--- a/de.systopia.civiproxy/settings/civiproxy.setting.php
+++ b/de.systopia.civiproxy/settings/civiproxy.setting.php
@@ -16,7 +16,7 @@ return array(
'is_domain' => 1,
'is_contact' => 0,
'description' => 'Enables or disables the proxy',
- 'help_text' => 'TODO',
+ 'help_text' => '',
),
'proxy_url' => array(
'group_name' => 'CiviProxy Settings',
@@ -28,7 +28,7 @@ return array(
'is_domain' => 1,
'is_contact' => 0,
'description' => 'The URL from which the proxy will be available for requests',
- 'help_text' => 'TODO',
+ 'help_text' => '',
),
'proxy_version' => array(
'group_name' => 'CiviProxy Settings',
@@ -40,6 +40,18 @@ return array(
'is_domain' => 1,
'is_contact' => 0,
'description' => 'The version of the currently selected proxy',
- 'help_text' => 'TODO',
+ 'help_text' => '',
+ ),
+ 'custom_mailing_base' => array(
+ 'group_name' => 'CiviProxy Settings',
+ 'group' => 'de.systopia',
+ 'name' => 'custom_mailing_base',
+ 'type' => 'String',
+ 'default' => "",
+ 'add' => '4.3',
+ 'is_domain' => 1,
+ 'is_contact' => 0,
+ 'description' => 'The URL can override the proxy for custom designed mailing subscribe/unsubscribe pages',
+ 'help_text' => '',
),
);
diff --git a/de.systopia.civiproxy/templates/CRM/Admin/Form/Setting/ProxySettings.hlp b/de.systopia.civiproxy/templates/CRM/Admin/Form/Setting/ProxySettings.hlp
index 1db0b3a..9db8bce 100644
--- a/de.systopia.civiproxy/templates/CRM/Admin/Form/Setting/ProxySettings.hlp
+++ b/de.systopia.civiproxy/templates/CRM/Admin/Form/Setting/ProxySettings.hlp
@@ -16,8 +16,8 @@
{/htxt}
-{htxt id='id-extoptout-url'}
+{htxt id='id-custom-mailing-base'}
- {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 ========
+
-
{ts}Advanced Settings{/ts}
+
{ts}Mailing Settings{/ts}
-
+
- | {$form.civimail_external_optout.label} |
- {$form.civimail_external_optout.html} |
+ {$form.custom_mailing_base.label} |
+ {$form.custom_mailing_base.html} |
- ==== advanced settings disabled ======== *}
+
{include file="CRM/common/formButtons.tpl" location="bottom"}
@@ -42,24 +42,29 @@