Duplicate image fix

Some additional code to stop duplicate images showing.
This commit is contained in:
Steven Sullivan 2018-02-14 12:15:54 -05:00 committed by GitHub
parent fed5dd63b2
commit c9cf1c5a3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2,6 +2,9 @@
class easy_unsubscribe extends rcube_plugin class easy_unsubscribe extends rcube_plugin
{ {
private $message_headers_done = false;
private $unsubscribe_img;
function init() function init()
{ {
$rcmail = rcmail::get_instance(); $rcmail = rcmail::get_instance();
@ -21,19 +24,28 @@ class easy_unsubscribe extends rcube_plugin
public function message_headers($p) public function message_headers($p)
{ {
$ListUnsubscribe = $p['headers']->others['list-unsubscribe']; if($this->message_headers_done===false)
preg_match('/<(.*?)>/', $ListUnsubscribe, $rVal);
if($rVal[1]!='')
$O = '<a class="easy_unsubscribe_link" title="Unsubscribe" href="'.$rVal[1].'" target="_blank" onclick="return confirm(\'Are you sure you want to unsubscribe?\');"><img src="plugins/easy_unsubscribe/icon.png" alt="Unsubscribe" /></a>';
else
{ {
preg_match('#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $ListUnsubscribe, $rVal); $this->message_headers_done = true;
if($rVal[0]!='')
$O = '<a class="easy_unsubscribe_link" title="Unsubscribe" href="'.$rVal[0].'" target="_blank" onclick="return confirm(\'Are you sure you want to unsubscribe?\');"><img src="plugins/easy_unsubscribe/icon.png" alt="Unsubscribe" /></a>'; $ListUnsubscribe = $p['headers']->others['list-unsubscribe'];
preg_match('/<(.*?)>/', $ListUnsubscribe, $rVal);
if($rVal[1]!='')
$this->unsubscribe_img = '<a class="easy_unsubscribe_link" title="Unsubscribe" href="'.$rVal[1].'" target="_blank" onclick="return confirm(\'Are you sure you want to unsubscribe?\');"><img src="plugins/easy_unsubscribe/icon.png" alt="Unsubscribe" /></a>';
else
{
preg_match('#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $ListUnsubscribe, $rVal);
if($rVal[0]!='')
$this->unsubscribe_img = '<a class="easy_unsubscribe_link" title="Unsubscribe" href="'.$rVal[0].'" target="_blank" onclick="return confirm(\'Are you sure you want to unsubscribe?\');"><img src="plugins/easy_unsubscribe/icon.png" alt="Unsubscribe" /></a>';
}
} }
$p['output']['subject']['value'] = $p['output']['subject']['value'] . $O; if(isset($p['output']['subject']))
$p['output']['subject']['html'] = true; {
$p['output']['subject']['value'] = $p['output']['subject']['value'] . $this->unsubscribe_img;
$p['output']['subject']['html'] = 1;
}
return $p; return $p;
} }