Compare commits
10 Commits
5acfc11b48
...
4f84f7c31c
Author | SHA1 | Date | |
---|---|---|---|
|
4f84f7c31c | ||
|
0da7ce2a12 | ||
|
39483b56ef | ||
|
3970c082f6 | ||
|
6154d87a89 | ||
|
f783ff59ec | ||
|
3a10b296f3 | ||
|
e50726b58a | ||
|
c3ae9edb7c | ||
|
9a72724a02 |
22
README.md
22
README.md
@ -1,4 +1,22 @@
|
|||||||
# Roundcube Easy Unsubscribe
|
# Roundcube Easy Unsubscribe
|
||||||
Displays a small icon after the subject line when viewing an email, so you can very quickly unsubscribe.
|
Displays a small icon after the subject line when viewing an email, so you can very quickly unsubscribe. Multiple icons may show as the plugin is reliant upon the `List-Unsubscribe` header. Sometimes emails use multiple i.e. one mailto: and one URL.
|
||||||
|
|
||||||
![Image](https://i.imgur.com/pecWMhe.jpg)
|
|
||||||
|
## Demo Visual
|
||||||
|
![Demo SS](https://i.ibb.co/58B3P57/Screenshot-2023-11-29-at-12-42-46-PM.png)
|
||||||
|
|
||||||
|
## Deployment
|
||||||
|
|
||||||
|
Download a copy of this repo and upload the contents to:
|
||||||
|
```
|
||||||
|
/path/to/roundcube/plugins/easy_unsubscribe
|
||||||
|
```
|
||||||
|
|
||||||
|
Edit your `/path/to/roundcube/config/config.inc.php` file and add `easy_unsubscribe` to the `$config['plugins']` variable. It should look something like the following:
|
||||||
|
|
||||||
|
```
|
||||||
|
$config['plugins'] = array(
|
||||||
|
'password',
|
||||||
|
'easy_unsubscribe'
|
||||||
|
);
|
||||||
|
```
|
||||||
|
@ -5,12 +5,6 @@
|
|||||||
"license": "GPL-3.0+",
|
"license": "GPL-3.0+",
|
||||||
"keywords": ["unsubscribe","subscription", "newsletter", "mailer"],
|
"keywords": ["unsubscribe","subscription", "newsletter", "mailer"],
|
||||||
"homepage": "https://github.com/SS88UK/roundcube-easy-unsubscribe",
|
"homepage": "https://github.com/SS88UK/roundcube-easy-unsubscribe",
|
||||||
"repositories": [
|
|
||||||
{
|
|
||||||
"type": "composer",
|
|
||||||
"url": "https://plugins.roundcube.net"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"require": {
|
"require": {
|
||||||
"roundcube/plugin-installer": ">=0.1.6"
|
"roundcube/plugin-installer": ">=0.1.6"
|
||||||
}
|
}
|
||||||
|
9
easy_unsubscribe.js
Normal file
9
easy_unsubscribe.js
Normal file
@ -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');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,49 +1,64 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class easy_unsubscribe extends rcube_plugin
|
class easy_unsubscribe extends rcube_plugin {
|
||||||
{
|
|
||||||
private $message_headers_done = false;
|
public $task = 'mail';
|
||||||
private $unsubscribe_img;
|
private $message_headers_done = false;
|
||||||
|
private $unsubscribe_img;
|
||||||
function init()
|
|
||||||
{
|
function init() {
|
||||||
$rcmail = rcmail::get_instance();
|
|
||||||
$layout = $rcmail->config->get('layout');
|
$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->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_stylesheet('easy_unsubscribe.css');
|
||||||
$this->add_texts('localization/');
|
$this->include_script('easy_unsubscribe.js');
|
||||||
}
|
|
||||||
|
$this->add_texts('localization/');
|
||||||
public function storage_init($p)
|
|
||||||
{
|
$rcmail->output->add_label('easy_unsubscribe.confirm');
|
||||||
$p['fetch_headers'] = trim($p['fetch_headers'] . ' ' . strtoupper('List-Unsubscribe'));
|
|
||||||
return $p;
|
}
|
||||||
}
|
|
||||||
|
public function storage_init($p) {
|
||||||
public function message_headers($p)
|
|
||||||
{
|
$p['fetch_headers'] = trim($p['fetch_headers'] . ' ' . strtoupper('List-Unsubscribe'));
|
||||||
if($this->message_headers_done===false)
|
return $p;
|
||||||
{
|
|
||||||
$this->message_headers_done = true;
|
}
|
||||||
|
|
||||||
$ListUnsubscribe = $p['headers']->others['list-unsubscribe'];
|
public function message_headers($p) {
|
||||||
if ( preg_match_all('/<(.+)>/mU', $ListUnsubscribe, $items, PREG_PATTERN_ORDER) ) {
|
|
||||||
foreach ( $items[1] as $uri ) {
|
if($this->message_headers_done===false) {
|
||||||
$this->unsubscribe_img .= '<a class="easy_unsubscribe_link tooltip-right" data-tooltip="' . $this->gettext('click_to_unsubscribe') . '" href="'. htmlentities($uri) .'" target="_blank" onclick="return confirm(\'' . $this->gettext('confirm') . '\');"><img src="plugins/easy_unsubscribe/icon.png" alt="' . $this->gettext('unsubscribe') . '" /></a>';
|
|
||||||
}
|
$this->message_headers_done = true;
|
||||||
}
|
if(!isset($p['headers']->others['list-unsubscribe'])) return $p;
|
||||||
}
|
|
||||||
|
$ListUnsubscribe = $p['headers']->others['list-unsubscribe'];
|
||||||
if(isset($p['output']['subject']))
|
|
||||||
{
|
if (preg_match_all('/<(.+)>/mU', $ListUnsubscribe, $items, PREG_PATTERN_ORDER)) {
|
||||||
$p['output']['subject']['value'] = $p['output']['subject']['value'] . $this->unsubscribe_img;
|
|
||||||
$p['output']['subject']['html'] = 1;
|
foreach ( $items[1] as $uri ) {
|
||||||
}
|
|
||||||
|
$this->unsubscribe_img .= '<a class="easy_unsubscribe_link tooltip-right" data-tooltip="' . $this->gettext('click_to_unsubscribe') . '" data-href="'. htmlentities($uri) .'" target="_blank" onclick="easy_unsubscribe_click(this);"><img src="plugins/easy_unsubscribe/icon.png" alt="' . $this->gettext('unsubscribe') . '" /></a>';
|
||||||
return $p;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($p['output']['subject'])) {
|
||||||
|
|
||||||
|
$p['output']['subject']['value'] = $p['output']['subject']['value'] . $this->unsubscribe_img;
|
||||||
|
$p['output']['subject']['html'] = 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $p;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
7
localization/es_ES.inc
Normal file
7
localization/es_ES.inc
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$labels = array();
|
||||||
|
|
||||||
|
$labels['click_to_unsubscribe'] = "Haz click para anular la suscripción";
|
||||||
|
$labels['confirm'] = "¿Estás seguro de que deseas anular la suscripción?";
|
||||||
|
$labels['unsubscribe'] = "Anular suscripción";
|
7
localization/ru_RU.inc
Normal file
7
localization/ru_RU.inc
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$labels = array();
|
||||||
|
|
||||||
|
$labels['click_to_unsubscribe'] = "Нажмите, чтобы отписаться";
|
||||||
|
$labels['confirm'] = "Вы уверены, что хотите отказаться от подписки?";
|
||||||
|
$labels['unsubscribe'] = "Отписаться";
|
Loading…
x
Reference in New Issue
Block a user