From c9cf1c5a3dd38a7154a9c3c72b05e6316dd995e2 Mon Sep 17 00:00:00 2001 From: Steven Sullivan Date: Wed, 14 Feb 2018 12:15:54 -0500 Subject: [PATCH] Duplicate image fix Some additional code to stop duplicate images showing. --- easy_unsubscribe.php | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/easy_unsubscribe.php b/easy_unsubscribe.php index a43ed48..1ef296c 100644 --- a/easy_unsubscribe.php +++ b/easy_unsubscribe.php @@ -2,6 +2,9 @@ class easy_unsubscribe extends rcube_plugin { + private $message_headers_done = false; + private $unsubscribe_img; + function init() { $rcmail = rcmail::get_instance(); @@ -21,19 +24,28 @@ class easy_unsubscribe extends rcube_plugin public function message_headers($p) { - $ListUnsubscribe = $p['headers']->others['list-unsubscribe']; - preg_match('/<(.*?)>/', $ListUnsubscribe, $rVal); - if($rVal[1]!='') - $O = 'Unsubscribe'; - else + if($this->message_headers_done===false) { - preg_match('#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $ListUnsubscribe, $rVal); - if($rVal[0]!='') - $O = 'Unsubscribe'; + $this->message_headers_done = true; + + $ListUnsubscribe = $p['headers']->others['list-unsubscribe']; + preg_match('/<(.*?)>/', $ListUnsubscribe, $rVal); + + if($rVal[1]!='') + $this->unsubscribe_img = 'Unsubscribe'; + else + { + preg_match('#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $ListUnsubscribe, $rVal); + if($rVal[0]!='') + $this->unsubscribe_img = 'Unsubscribe'; + } + } + + if(isset($p['output']['subject'])) + { + $p['output']['subject']['value'] = $p['output']['subject']['value'] . $this->unsubscribe_img; + $p['output']['subject']['html'] = 1; } - - $p['output']['subject']['value'] = $p['output']['subject']['value'] . $O; - $p['output']['subject']['html'] = true; return $p; }