Implement 'extern/open.php' as a regular route
authorTim Otten <totten@civicrm.org>
Wed, 13 May 2020 06:05:38 +0000 (23:05 -0700)
committerTim Otten <totten@civicrm.org>
Wed, 13 May 2020 06:59:54 +0000 (23:59 -0700)
CRM/Mailing/Page/Open.php [new file with mode: 0644]
CRM/Mailing/xml/Menu/Mailing.xml

diff --git a/CRM/Mailing/Page/Open.php b/CRM/Mailing/Page/Open.php
new file mode 100644 (file)
index 0000000..ac26fbf
--- /dev/null
@@ -0,0 +1,58 @@
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved.                        |
+ |                                                                    |
+ | This work is published under the GNU AGPLv3 license with some      |
+ | permitted exceptions and without any warranty. For full license    |
+ | and copyright information, see https://civicrm.org/licensing       |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC https://civicrm.org/licensing
+ */
+
+/**
+ * Indicate that a CiviMail message has been opened
+ *
+ * General Usage: civicrm/mailing/open?qid={event_queue_id}
+ *
+ * NOTE: The parameter name has changed slightly from 'extern/open.php?q={event_queue_id}`.
+ */
+class CRM_Mailing_Page_Open extends CRM_Core_Page {
+
+  /**
+   * Mark the mailing as opened
+   *
+   * @throws \CRM_Core_Exception
+   */
+  public function run() {
+    $queue_id = CRM_Utils_Request::retrieveValue('qid', 'Positive', NULL, FALSE, 'GET');
+    if (!$queue_id) {
+      // Deprecated: "?q=" is problematic in Drupal integrations, but we'll accept if igiven
+      $queue_id = CRM_Utils_Request::retrieveValue('q', 'Positive', NULL, FALSE, 'GET');;
+    }
+    if (!$queue_id) {
+      echo "Missing input parameters\n";
+      exit();
+    }
+
+    CRM_Mailing_Event_BAO_Opened::open($queue_id);
+
+    $filename = Civi::paths()->getPath('[civicrm.root]/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);
+
+    CRM_Utils_System::civiExit();
+  }
+
+}
index 7fea1938a446d6f948fa9c193424c7faeb4877a3..d4cc7d274ae72f7f582c099917f90cc4a78eefdd 100644 (file)
     <page_callback>CRM_Mailing_Page_Url</page_callback>
     <access_arguments>*always allow*</access_arguments>
   </item>
+  <item>
+    <path>civicrm/mailing/open</path>
+    <page_callback>CRM_Mailing_Page_Open</page_callback>
+    <access_arguments>*always allow*</access_arguments>
+  </item>
 </menu>