CiviMail - Add status-check for civimail_unsubscribe_methods
authorTim Otten <totten@civicrm.org>
Thu, 11 Jan 2024 00:13:20 +0000 (16:13 -0800)
committerTim Otten <totten@civicrm.org>
Wed, 24 Jan 2024 08:47:36 +0000 (00:47 -0800)
CRM/Utils/Check/Component/Mailing.php [new file with mode: 0644]

diff --git a/CRM/Utils/Check/Component/Mailing.php b/CRM/Utils/Check/Component/Mailing.php
new file mode 100644 (file)
index 0000000..b7288fb
--- /dev/null
@@ -0,0 +1,46 @@
+<?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
+ */
+class CRM_Utils_Check_Component_Mailing extends CRM_Utils_Check_Component {
+
+  /**
+   * @return CRM_Utils_Check_Message[]
+   */
+  public function checkUnsubscribeMethods() {
+    if (!\CRM_Core_Component::isEnabled('CiviMail')) {
+      return [];
+    }
+
+    $methods = Civi::settings()->get('civimail_unsubscribe_methods');
+    if (in_array('oneclick', $methods)) {
+      return [];
+    }
+
+    // OK, all guards passed. Show message.
+    $message = new CRM_Utils_Check_Message(
+      __FUNCTION__,
+      '<p>' . ts('Beginning in 2024, some web-mail services (Google and Yahoo) will require that large mailing-lists support another unsubscribe method: "HTTP One-Click" (RFC 8058). Please review the documentation and update the settings.') . '</p>',
+      ts('CiviMail: Enable One-Click Unsubscribe'),
+      \Psr\Log\LogLevel::NOTICE,
+      'fa-server'
+    );
+    $message->addAction(ts('Learn more'), FALSE, 'href', ['url' => 'https://civicrm.org/redirect/unsubscribe-one-click'], 'fa-info-circle');
+    $message->addAction(ts('Update settings'), FALSE, 'href', ['path' => 'civicrm/admin/mail', 'query' => 'reset=1'], 'fa-wrench');
+
+    return [$message];
+  }
+
+}