started developing mail subscribe/unsubscribe pages
This commit is contained in:
parent
d69e543853
commit
be1a118ec7
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
<email>endres@systopia.de</email>
|
||||
</maintainer>
|
||||
<releaseDate></releaseDate>
|
||||
<version>0.2</version>
|
||||
<version>0.3</version>
|
||||
<develStage>alpha</develStage>
|
||||
<compatibility>
|
||||
<ver>4.4</ver>
|
||||
|
|
|
|||
|
|
@ -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' => '',
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@
|
|||
</p>
|
||||
{/htxt}
|
||||
|
||||
{htxt id='id-extoptout-url'}
|
||||
{htxt id='id-custom-mailing-base'}
|
||||
<p>
|
||||
{ts}TODO #2{/ts}
|
||||
{ts}TADDAAAA{/ts}
|
||||
</p>
|
||||
{/htxt}
|
||||
|
|
|
|||
|
|
@ -20,21 +20,21 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{* ==== advanced settings disabled ========
|
||||
<br/>
|
||||
<div>
|
||||
<h3>{ts}Advanced Settings{/ts}</h3>
|
||||
<h3>{ts}Mailing Settings{/ts}</h3>
|
||||
<div>
|
||||
<div>
|
||||
<table id="component_settings" class="no-border">
|
||||
<table id="core_settings" class="no-border">
|
||||
<tr>
|
||||
<td class="label">{$form.civimail_external_optout.label} <a onclick='CRM.help("{ts}CiviMail: External opt-out page{/ts}", {literal}{"id":"id-extoptout-url","file":"CRM\/Admin\/Form\/Setting\/ProxySettings"}{/literal}); return false;' href="#" title="{ts}Help{/ts}" class="helpicon"> </a></td>
|
||||
<td>{$form.civimail_external_optout.html}</td>
|
||||
<td class="label">{$form.custom_mailing_base.label} <a onclick='CRM.help("{ts}CiviMail: Custom pages{/ts}", {literal}{"id":"id-custom-mailing-base","file":"CRM\/Admin\/Form\/Setting\/ProxySettings"}{/literal}); return false;' href="#" title="{ts}Help{/ts}" class="helpicon"> </a></td>
|
||||
<td>{$form.custom_mailing_base.html}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
==== advanced settings disabled ======== *}
|
||||
<br/>
|
||||
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -42,24 +42,29 @@
|
|||
<script type="text/javascript">
|
||||
function enableInput() {
|
||||
cj('#proxy_url').attr('disabled',!this.checked);
|
||||
cj('#civimail_external_optout').attr('disabled', !this.checked);
|
||||
cj('#custom_mailing_base').attr('disabled', !this.checked);
|
||||
}
|
||||
|
||||
function enableInputGlobal() {
|
||||
var is_enabled = cj('#proxy_enabled').attr('checked') == 'checked';
|
||||
cj('#proxy_url').attr('disabled', !is_enabled);
|
||||
cj('#civimail_external_optout').attr('disabled', !is_enabled);
|
||||
cj('#custom_mailing_base').attr('disabled', !is_enabled);
|
||||
}
|
||||
|
||||
(function(cj) {
|
||||
cj('#proxy_enabled').click(enableInput);
|
||||
enableInputGlobal();
|
||||
|
||||
// set the default value to {$proxy_url}/mailing
|
||||
if (cj("#custom_mailing_base").val().length == 0) {
|
||||
cj("#custom_mailing_base").val(cj("#proxy_url").val() + '/mailing');
|
||||
}
|
||||
|
||||
})(cj);
|
||||
</script>
|
||||
|
||||
<style type="text/css">
|
||||
#proxy_url, #civimail_external_optout {
|
||||
#proxy_url, #custom_mailing_base {
|
||||
width: 350px;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,13 +25,17 @@ $target_civicrm = 'https://your.civicrm.installation.org';
|
|||
****************************************************************/
|
||||
|
||||
// default paths, override if you want. Set to NULL to disable
|
||||
$target_rest = $target_civicrm . '/sites/all/modules/civicrm/extern/rest.php';
|
||||
$target_url = $target_civicrm . '/sites/all/modules/civicrm/extern/url.php';
|
||||
$target_open = $target_civicrm . '/sites/all/modules/civicrm/extern/open.php';
|
||||
$target_file = $target_civicrm . '/sites/default/files/civicrm/persist/';
|
||||
$target_mail = $target_civicrm . '/civicrm/mailing/view';
|
||||
$target_rest = $target_civicrm . '/sites/all/modules/civicrm/extern/rest.php';
|
||||
$target_url = $target_civicrm . '/sites/all/modules/civicrm/extern/url.php';
|
||||
$target_open = $target_civicrm . '/sites/all/modules/civicrm/extern/open.php';
|
||||
$target_file = $target_civicrm . '/sites/default/files/civicrm/persist/';
|
||||
$target_mail_view = $target_civicrm . '/civicrm/mailing/view';
|
||||
|
||||
// CAREFUL: only enable on debug systems. Will log all queries to given PUBLIC file
|
||||
// target_mail_base CANNOT be "$target_civicrm . '/civicrm/mailing'",
|
||||
// since these pages cannot be easily proxied.
|
||||
$target_mail_base = NULL;
|
||||
|
||||
// CAREFUL: only enable temporarily on debug systems. Will log all queries to given PUBLIC file
|
||||
$debug = NULL; //'debug.log';
|
||||
|
||||
|
||||
|
|
@ -68,6 +72,7 @@ $file_cache_include = array(
|
|||
** REST API OPTIONS **
|
||||
****************************************************************/
|
||||
$rest_allowed_actions = array(
|
||||
// this is an example:
|
||||
'Contact' => array(
|
||||
'getsingle' => array(
|
||||
'email' => 'string'
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
/*--------------------------------------------------------+
|
||||
| SYSTOPIA CiviProxy |
|
||||
| a simple proxy solution for external access to CiviCRM |
|
||||
| Copyright (C) 2015 SYSTOPIA |
|
||||
| Author: B. Endres (endres -at- systopia.de) |
|
||||
| http://www.systopia.de/ |
|
||||
+---------------------------------------------------------*/
|
||||
|
||||
require_once "../config.php";
|
||||
require_once "../proxy.php";
|
||||
|
||||
// see if mail open tracking is enabled
|
||||
if (!$target_mail_base) civiproxy_http_error("Feature disabled", 405);
|
||||
|
||||
// basic check
|
||||
civiproxy_security_check('mail-confirm');
|
||||
|
||||
// basic restraints
|
||||
$valid_parameters = array( 'sid' => 'int',
|
||||
'cid' => 'int',
|
||||
'h' => 'hex');
|
||||
$parameters = civiproxy_get_parameters($valid_parameters);
|
||||
|
||||
// check if parameters specified
|
||||
if (empty($parameters['sid'])) civiproxy_http_error("Missing/invalid parameter 'sid'.");
|
||||
if (empty($parameters['cid'])) civiproxy_http_error("Missing/invalid parameter 'cid'.");
|
||||
if (empty($parameters['h'])) civiproxy_http_error("Missing/invalid parameter 'h'.");
|
||||
|
||||
civiproxy_redirect($target_mail_base . '/confirm', $parameters);
|
||||
|
|
@ -7,14 +7,14 @@
|
|||
| http://www.systopia.de/ |
|
||||
+---------------------------------------------------------*/
|
||||
|
||||
require_once "config.php";
|
||||
require_once "proxy.php";
|
||||
require_once "../config.php";
|
||||
require_once "../proxy.php";
|
||||
|
||||
// see if mail open tracking is enabled
|
||||
if (!$target_mail) civiproxy_http_error("Feature disabled", 405);
|
||||
if (!$target_mail_view) civiproxy_http_error("Feature disabled", 405);
|
||||
|
||||
// basic check
|
||||
civiproxy_security_check('viewmail');
|
||||
civiproxy_security_check('mail-view');
|
||||
|
||||
// basic restraints
|
||||
$valid_parameters = array( 'id' => 'int' );
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
/*--------------------------------------------------------+
|
||||
| SYSTOPIA CiviProxy |
|
||||
| a simple proxy solution for external access to CiviCRM |
|
||||
| Copyright (C) 2015 SYSTOPIA |
|
||||
| Author: B. Endres (endres -at- systopia.de) |
|
||||
| http://www.systopia.de/ |
|
||||
+---------------------------------------------------------*/
|
||||
|
||||
require_once "../config.php";
|
||||
require_once "../proxy.php";
|
||||
|
||||
// see if mail open tracking is enabled
|
||||
if (!$target_mail_base) civiproxy_http_error("Feature disabled", 405);
|
||||
|
||||
// basic check
|
||||
civiproxy_security_check('mail-resubscribe');
|
||||
|
||||
// basic restraints
|
||||
$valid_parameters = array( 'jid' => 'int',
|
||||
'qid' => 'int',
|
||||
'h' => 'hex');
|
||||
$parameters = civiproxy_get_parameters($valid_parameters);
|
||||
|
||||
// check if parameters specified
|
||||
if (empty($parameters['jid'])) civiproxy_http_error("Missing/invalid parameter 'jid'.");
|
||||
if (empty($parameters['qid'])) civiproxy_http_error("Missing/invalid parameter 'qid'.");
|
||||
if (empty($parameters['h'])) civiproxy_http_error("Missing/invalid parameter 'h'.");
|
||||
|
||||
civiproxy_redirect($target_mail_base . '/resubscribe', $parameters);
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
/*--------------------------------------------------------+
|
||||
| SYSTOPIA CiviProxy |
|
||||
| a simple proxy solution for external access to CiviCRM |
|
||||
| Copyright (C) 2015 SYSTOPIA |
|
||||
| Author: B. Endres (endres -at- systopia.de) |
|
||||
| http://www.systopia.de/ |
|
||||
+---------------------------------------------------------*/
|
||||
|
||||
require_once "../config.php";
|
||||
require_once "../proxy.php";
|
||||
|
||||
// see if mail open tracking is enabled
|
||||
if (!$target_mail_base) civiproxy_http_error("Feature disabled", 405);
|
||||
|
||||
// basic check
|
||||
civiproxy_security_check('mail-subscribe');
|
||||
|
||||
// just forward, no parameters
|
||||
civiproxy_redirect($target_mail_base . '/subscribe', array());
|
||||
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
/*--------------------------------------------------------+
|
||||
| SYSTOPIA CiviProxy |
|
||||
| a simple proxy solution for external access to CiviCRM |
|
||||
| Copyright (C) 2015 SYSTOPIA |
|
||||
| Author: B. Endres (endres -at- systopia.de) |
|
||||
| http://www.systopia.de/ |
|
||||
+---------------------------------------------------------*/
|
||||
|
||||
require_once "../config.php";
|
||||
require_once "../proxy.php";
|
||||
|
||||
// see if mail open tracking is enabled
|
||||
if (!$target_mail_base) civiproxy_http_error("Feature disabled", 405);
|
||||
|
||||
// basic check
|
||||
civiproxy_security_check('mail-unsubscribe');
|
||||
|
||||
// basic restraints
|
||||
$valid_parameters = array( 'jid' => 'int',
|
||||
'qid' => 'int',
|
||||
'h' => 'hex');
|
||||
$parameters = civiproxy_get_parameters($valid_parameters);
|
||||
|
||||
// check if parameters specified
|
||||
if (empty($parameters['jid'])) civiproxy_http_error("Missing/invalid parameter 'jid'.");
|
||||
if (empty($parameters['qid'])) civiproxy_http_error("Missing/invalid parameter 'qid'.");
|
||||
if (empty($parameters['h'])) civiproxy_http_error("Missing/invalid parameter 'h'.");
|
||||
|
||||
civiproxy_redirect($target_mail_base . '/unsubscribe', $parameters);
|
||||
|
|
@ -155,6 +155,19 @@ function civiproxy_get_parameters($valid_parameters) {
|
|||
} elseif ($type == 'float2') {
|
||||
// TODO: check if safe wrt l10n. rather use sprintf
|
||||
$value = number_format($value, 2, '.', '');
|
||||
} elseif ($type == 'hex') {
|
||||
// hex code
|
||||
if (!preg_match("#^[0-9a-f]*$#gi", $value)) {
|
||||
error_log("CiviProxy: removed invalid hex parameter");
|
||||
$value = '';
|
||||
}
|
||||
} elseif ($type == 'email') {
|
||||
// valid email
|
||||
// TODO: regex email address
|
||||
// if (!preg_match("#^[0-9a-f]*$#gi", $value)) {
|
||||
// error_log("CiviProxy: removed invalid hex parameter");
|
||||
// $value = '';
|
||||
// }
|
||||
} elseif (is_array($type)) {
|
||||
// this is a list of valid options
|
||||
$requested_value = $value;
|
||||
|
|
|
|||
Loading…
Reference in New Issue