From f783ff59ec9cfdbface5c6b5ba4330cb23774bad Mon Sep 17 00:00:00 2001
From: Steven Sullivan <17299026+SS88UK@users.noreply.github.com>
Date: Wed, 29 Nov 2023 12:41:51 -0500
Subject: [PATCH] Updated 2023
Works in newer RC.
---
easy_unsubscribe.js | 9 ++++
easy_unsubscribe.php | 109 ++++++++++++++++++++++++-------------------
2 files changed, 70 insertions(+), 48 deletions(-)
create mode 100644 easy_unsubscribe.js
diff --git a/easy_unsubscribe.js b/easy_unsubscribe.js
new file mode 100644
index 0000000..a16b8e6
--- /dev/null
+++ b/easy_unsubscribe.js
@@ -0,0 +1,9 @@
+function easy_unsubscribe_click(link) {
+
+ if(confirm(rcmail.get_label('confirm', 'easy_unsubscribe'))) {
+
+ if(link.dataset.href) window.open(link.dataset.href, '_blank');
+
+ }
+
+}
\ No newline at end of file
diff --git a/easy_unsubscribe.php b/easy_unsubscribe.php
index 42f5847..1927e0e 100644
--- a/easy_unsubscribe.php
+++ b/easy_unsubscribe.php
@@ -1,49 +1,62 @@
-config->get('layout');
-
- $this->add_hook('message_headers_output', array($this, 'message_headers'));
- $this->add_hook('storage_init', array($this, 'storage_init'));
-
- $this->include_stylesheet('easy_unsubscribe.css');
-
- $this->add_texts('localization/');
- }
-
- public function storage_init($p)
- {
- $p['fetch_headers'] = trim($p['fetch_headers'] . ' ' . strtoupper('List-Unsubscribe'));
- return $p;
- }
-
- public function message_headers($p)
- {
- if($this->message_headers_done===false)
- {
- $this->message_headers_done = true;
-
- $ListUnsubscribe = $p['headers']->others['list-unsubscribe'];
- if ( preg_match_all('/<(.+)>/mU', $ListUnsubscribe, $items, PREG_PATTERN_ORDER) ) {
- foreach ( $items[1] as $uri ) {
- $this->unsubscribe_img .= '';
- }
- }
- }
-
- if(isset($p['output']['subject']))
- {
- $p['output']['subject']['value'] = $p['output']['subject']['value'] . $this->unsubscribe_img;
- $p['output']['subject']['html'] = 1;
- }
-
- return $p;
- }
+config->get('layout');
+
+ $this->add_hook('message_headers_output', array($this, 'message_headers'));
+ $this->add_hook('storage_init', array($this, 'storage_init'));
+
+ $this->include_stylesheet('easy_unsubscribe.css');
+ $this->include_script('easy_unsubscribe.js');
+
+ $this->add_texts('localization/');
+
+ $rcmail->output->add_label('easy_unsubscribe.confirm');
+
+ }
+
+ public function storage_init($p) {
+
+ $p['fetch_headers'] = trim($p['fetch_headers'] . ' ' . strtoupper('List-Unsubscribe'));
+ return $p;
+
+ }
+
+ public function message_headers($p) {
+
+ if($this->message_headers_done===false) {
+
+ $this->message_headers_done = true;
+ $ListUnsubscribe = $p['headers']->others['list-unsubscribe'];
+
+ if (preg_match_all('/<(.+)>/mU', $ListUnsubscribe, $items, PREG_PATTERN_ORDER)) {
+
+ foreach ( $items[1] as $uri ) {
+
+ $this->unsubscribe_img .= '';
+
+ }
+ }
+
+ }
+
+ if(isset($p['output']['subject'])) {
+
+ $p['output']['subject']['value'] = $p['output']['subject']['value'] . $this->unsubscribe_img;
+ $p['output']['subject']['html'] = 1;
+
+ }
+
+ return $p;
+
+ }
+
}
\ No newline at end of file