Skip to content

Commit

Permalink
[#2] added local endpoint (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjendres committed Dec 4, 2018
1 parent 4ae150a commit 78d247b
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 3 deletions.
5 changes: 4 additions & 1 deletion CRM/Mailingtools/Form/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,12 @@ public function buildQuickForm() {
'text',
'anonymous_open_url',
E::ts('URL Endpoint'),
array("class" => "huge"),
['class' => 'huge'],
FALSE
);
// generate example URL
$example_url = CRM_Utils_System::url('sites/all/modules/civicrm/extern/anonopen.php', NULL, TRUE);
$this->assign('anonymous_open_url_example', E::ts("e.g.: <code>%1</code>", [1 => $example_url]));

$this->add(
'select',
Expand Down
41 changes: 41 additions & 0 deletions extern/anonopen.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/*-------------------------------------------------------+
| SYSTOPIA Mailingtools Extension |
| Copyright (C) 2018 SYSTOPIA |
| Author: B. Endres ([email protected]) |
+--------------------------------------------------------+
| This program is released as free software under the |
| Affero GPL license. You can redistribute it and/or |
| modify it under the terms of this license which you |
| can read by viewing the included agpl.txt or online |
| at www.gnu.org/licenses/agpl.html. Removal of this |
| copyright header is strictly prohibited without |
| written permission from the original author(s). |
+--------------------------------------------------------*/

require_once '../civicrm.config.php';
require_once 'CRM/Core/Config.php';
require_once 'CRM/Core/Error.php';
require_once 'CRM/Utils/Array.php';

$config = CRM_Core_Config::singleton();
$mid = (int) CRM_Utils_Array::value('mid', $_GET);

require_once 'CRM/Mailingtools/AnonymousOpen.php';
if ($mid) {
CRM_Mailingtools_AnonymousOpen::processAnonymousOpenEvent($mid);
}

// return tracker gif
$filename = "../i/tracker.gif";

header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Description: File Transfer');
header('Content-type: image/gif');
header('Content-Length: ' . filesize($filename));

header('Content-Disposition: inline; filename=tracker.gif');

readfile($filename);

exit();
3 changes: 2 additions & 1 deletion templates/CRM/Mailingtools/Form/Settings.hlp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
{htxt id="id-mailtools-anonymous-url"}
<p>{ts domain="de.systopia.mailingtools"}Set the URL to be used for the tracking link.{/ts}</p>
<p>{ts domain="de.systopia.mailingtools"}It will be extended by the parameter <code>mid=XXX</code> to pass the mailing ID.{/ts}</p>
<p>{ts domain="de.systopia.mailingtools"}Without this, the anonymous open tracking feature will not work{/ts}</p>
<p>{ts domain="de.systopia.mailingtools"}For the example URL to work, you have to manually copy the file <code>de.systopia.mailingtools/extern/anonopen.php</code> to <code>civicrm/extern/anonopen.php</code>.{/ts}</p>
<p>{ts domain="de.systopia.mailingtools"}With this setting empty, the anonymous open tracking feature will not work{/ts}</p>
{/htxt}

{htxt id="id-mailtools-anonymous-permission"}
Expand Down
2 changes: 1 addition & 1 deletion templates/CRM/Mailingtools/Form/Settings.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<div class="crm-section">
<div class="label">{$form.anonymous_open_url.label} <a onclick='CRM.help("{ts domain='de.systopia.mailingtools'}Anonymous Open URL{/ts}", {literal}{"id":"id-mailtools-anonymous-url","file":"CRM\/Mailingtools\/Form\/Settings"}{/literal}); return false;' href="#" title="{ts domain='de.systopia.mailingtools'}Help{/ts}" class="helpicon">&nbsp;</a></div>
<div class="content">{$form.anonymous_open_url.html}</div>
<div class="content">{$form.anonymous_open_url.html}<br/><span>{$anonymous_open_url_example}</span></div>
<div class="clear"></div>
</div>
Expand Down

0 comments on commit 78d247b

Please sign in to comment.