implemented URL replacement for outgoing mails
This commit is contained in:
parent
2824cc3c18
commit
011b556f83
|
|
@ -1 +0,0 @@
|
||||||
deleteme
|
|
||||||
|
|
@ -6,16 +6,29 @@ require_once 'civiproxy.civix.php';
|
||||||
* POC email
|
* POC email
|
||||||
*/
|
*/
|
||||||
function civiproxy_civicrm_alterMailParams( &$params, $context ) {
|
function civiproxy_civicrm_alterMailParams( &$params, $context ) {
|
||||||
foreach (array('html', 'text') as $key) {
|
// check if the proxy is enabled
|
||||||
$value = $params[$key];
|
$enabled = CRM_Core_BAO_Setting::getItem('CiviProxy Settings', 'proxy_enabled');
|
||||||
$value = str_replace('http://localhost:8888/mh/sites/all/modules/civicrm/extern/url.php', 'http://localhost:8888/proxy/url.php', $value);
|
if (!$enabled) return;
|
||||||
$value = str_replace('http://localhost:8888/mh/sites/all/modules/civicrm/extern/open.php', 'http://localhost:8888/proxy/open.php', $value);
|
|
||||||
$value = str_replace('http://localhost:8888/mh/sites/default/files/civicrm/persist', 'http://localhost:8888/proxy/file.php?q=', $value);
|
// get the URLs
|
||||||
$params[$key] = $value;
|
$config = CRM_Core_Config::singleton();
|
||||||
|
$system_base = $config->userFrameworkBaseURL;
|
||||||
|
$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];
|
||||||
|
$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);
|
||||||
|
$params[$field] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of hook_civicrm_config
|
* Implementation of hook_civicrm_config
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue