diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b2c31f9 --- /dev/null +++ b/LICENSE @@ -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. diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..7dc81f3 --- /dev/null +++ b/composer.json @@ -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" + } +} diff --git a/easy_unsubscribe.css b/easy_unsubscribe.css new file mode 100644 index 0000000..8492248 --- /dev/null +++ b/easy_unsubscribe.css @@ -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; } \ No newline at end of file diff --git a/easy_unsubscribe.php b/easy_unsubscribe.php new file mode 100644 index 0000000..a43ed48 --- /dev/null +++ b/easy_unsubscribe.php @@ -0,0 +1,40 @@ +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 = 'Unsubscribe'; + else + { + preg_match('#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $ListUnsubscribe, $rVal); + if($rVal[0]!='') + $O = 'Unsubscribe'; + } + + $p['output']['subject']['value'] = $p['output']['subject']['value'] . $O; + $p['output']['subject']['html'] = true; + + return $p; + } +} diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..9349467 Binary files /dev/null and b/icon.png differ