Initial Commit
This commit is contained in:
parent
9883f14b40
commit
fed5dd63b2
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 Steven Sullivan
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
17
composer.json
Normal file
17
composer.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "ss88/easy_unsubscribe",
|
||||
"type": "roundcube-plugin",
|
||||
"description": "Displays a small icon after the subject line when viewing an email, so you can very quickly unsubscribe.",
|
||||
"license": "GPL-3.0+",
|
||||
"keywords": ["unsubscribe","subscription", "newsletter", "mailer"],
|
||||
"homepage": "https://github.com/SS88UK/roundcube-easy-unsubscribe",
|
||||
"repositories": [
|
||||
{
|
||||
"type": "composer",
|
||||
"url": "https://plugins.roundcube.net"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"roundcube/plugin-installer": ">=0.1.6"
|
||||
}
|
||||
}
|
2
easy_unsubscribe.css
Normal file
2
easy_unsubscribe.css
Normal file
@ -0,0 +1,2 @@
|
||||
.easy_unsubscribe_link img { height: 13px; margin-left: 10px; vertical-align: middle; opacity: 0.5; transition:all 0.3s ease; }
|
||||
.easy_unsubscribe_link:hover img { opacity:1; }
|
40
easy_unsubscribe.php
Normal file
40
easy_unsubscribe.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
class easy_unsubscribe extends rcube_plugin
|
||||
{
|
||||
function init()
|
||||
{
|
||||
$rcmail = rcmail::get_instance();
|
||||
$layout = $rcmail->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');
|
||||
}
|
||||
|
||||
public function storage_init($p)
|
||||
{
|
||||
$p['fetch_headers'] = trim($p['fetch_headers'] . ' ' . strtoupper('List-Unsubscribe'));
|
||||
return $p;
|
||||
}
|
||||
|
||||
public function message_headers($p)
|
||||
{
|
||||
$ListUnsubscribe = $p['headers']->others['list-unsubscribe'];
|
||||
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);
|
||||
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>';
|
||||
}
|
||||
|
||||
$p['output']['subject']['value'] = $p['output']['subject']['value'] . $O;
|
||||
$p['output']['subject']['html'] = true;
|
||||
|
||||
return $p;
|
||||
}
|
||||
}
|
BIN
icon.png
Normal file
BIN
icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
Loading…
x
Reference in New Issue
Block a user