diff options
Diffstat (limited to 'plugins/listcommands')
-rw-r--r-- | plugins/listcommands/listcommands.php | 106 | ||||
-rw-r--r-- | plugins/listcommands/localization/en_US.inc | 12 | ||||
-rw-r--r-- | plugins/listcommands/localization/es_ES.inc | 12 | ||||
-rw-r--r-- | plugins/listcommands/localization/fr_FR.inc | 13 | ||||
-rw-r--r-- | plugins/listcommands/localization/nl_NL.inc | 12 | ||||
-rw-r--r-- | plugins/listcommands/localization/pl_PL.inc | 12 | ||||
-rw-r--r-- | plugins/listcommands/localization/ru_RU.inc | 12 | ||||
-rw-r--r-- | plugins/listcommands/package.xml | 18 |
8 files changed, 197 insertions, 0 deletions
diff --git a/plugins/listcommands/listcommands.php b/plugins/listcommands/listcommands.php new file mode 100644 index 000000000..7a7948fd6 --- /dev/null +++ b/plugins/listcommands/listcommands.php @@ -0,0 +1,106 @@ +<?php + +/** + * This plugin parses email headers looking for mailinglist specific + * information. If headers are found, it uses them to create an additional + * header in the header box to easily perform certain mailinglist commands + * like subscribing, unsubscribing, asking for help, and sending a new mail. + * + * @version 2.1 + * @author Cor Bosman + * + */ + +class listcommands extends rcube_plugin +{ + public $task = 'mail'; + + function init() + { + $rcmail = rcmail::get_instance(); + if (!$rcmail->action || in_array($rcmail->action, array('list', 'show', 'preview'))) { + $this->add_hook('storage_init', array($this, 'storage_init')); + $this->add_hook('message_headers_output', array($this, 'listcommands_output')); + } + } + + function storage_init($p) + { + $rcmail = rcmail::get_instance(); + $mailinglist_headers = array_keys($this->get_list_headers()); + $p['fetch_headers'] .= trim($p['fetch_headers']. ' ' . strtoupper(join(' ', $mailinglist_headers))); + return($p); + } + + function listcommands_output($p) + { + $list_output = ""; + $rcmail = rcmail::get_instance(); + $this->add_texts('localization/', false); + $mailinglist_headers = $this->get_list_headers(); + + foreach ($mailinglist_headers as $header => $title) { + $key = strtolower($header); + + if($value = $p['headers']->others[$key]) { + if(is_string($value)){ + $list_output .= $this->create_link($key, $value, $title) . ' '; + } + else{ + $list_output .= $this->create_link($key, $value[0], $title) . ' '; + } + } + } + if($list_output != "") + $p['output']['Mailinglist'] = array( + 'title' => $this->gettext('listcommands_mailinglist'), 'value' => $list_output); + return($p); + } + + private function get_list_headers() + { + $mailinglist_headers = array( + 'List-Help' => $this->gettext('listcommands_help'), + 'List-Subscribe' => $this->gettext('listcommands_subscribe'), + 'List-Unsubscribe' => $this->gettext('listcommands_unsubscribe'), + 'List-Post' => $this->gettext('listcommands_post'), + 'List-Owner' => $this->gettext('listcommands_admin'), + 'List-Archive' => $this->gettext('listcommands_archive') + ); + return($mailinglist_headers); + } + + private function create_link($key, $value, $title) + { + $proto = ""; + + // some headers have multiple targets + $targets = explode(',', $value); + + // only use 1 of the targets + $target = strip_quotes($targets[0]); + + // first strip angle brackets + $link = trim($target, "<>"); + + if(preg_match('/^(mailto|http|https)(:\/\/|:)(.*)$/', $link, $matches)) { + $proto = $matches[1]; + $target = $matches[3]; + } + + // use RC for emailing instead of relying on the mailto header + if($proto == "mailto") { + $onclick = "return rcmail.command('compose','$target',this)"; + } else { + $onclick = ""; + } + + $a = html::a(array('href' => $link , + 'target' => '_blank', + 'onclick' => $onclick + ), $title); + + return($a); + } +} +?> diff --git a/plugins/listcommands/localization/en_US.inc b/plugins/listcommands/localization/en_US.inc new file mode 100644 index 000000000..8af9bdc78 --- /dev/null +++ b/plugins/listcommands/localization/en_US.inc @@ -0,0 +1,12 @@ +<?php + +$labels = array(); +$labels['listcommands_mailinglist'] = 'Mailing List'; +$labels['listcommands_help'] = 'Help'; +$labels['listcommands_subscribe'] = 'Subscribe'; +$labels['listcommands_unsubscribe'] = 'Unsubscribe'; +$labels['listcommands_post'] = 'Post'; +$labels['listcommands_admin'] = 'Contact Administrator'; +$labels['listcommands_archive'] = 'List Archive'; + +?> diff --git a/plugins/listcommands/localization/es_ES.inc b/plugins/listcommands/localization/es_ES.inc new file mode 100644 index 000000000..e27cb8774 --- /dev/null +++ b/plugins/listcommands/localization/es_ES.inc @@ -0,0 +1,12 @@ +<?php + +$labels = array(); +$labels['listcommands_mailinglist'] = 'Lista de correo'; +$labels['listcommands_help'] = 'Ayuda'; +$labels['listcommands_subscribe'] = 'Darse de alta'; +$labels['listcommands_unsubscribe'] = 'Darse de baja'; +$labels['listcommands_post'] = 'Publicar'; +$labels['listcommands_admin'] = 'Contactar con el administrador'; +$labels['listcommands_archive'] = 'Archivo de la lista'; + +?> diff --git a/plugins/listcommands/localization/fr_FR.inc b/plugins/listcommands/localization/fr_FR.inc new file mode 100644 index 000000000..1a08a1a7b --- /dev/null +++ b/plugins/listcommands/localization/fr_FR.inc @@ -0,0 +1,13 @@ +<?php + +$labels = array(); + +$labels['listcommands_mailinglist'] = 'Mailing List'; +$labels['listcommands_help'] = 'Aide'; +$labels['listcommands_subscribe'] = 'S\'abonner'; +$labels['listcommands_unsubscribe'] = 'Se désabonner'; +$labels['listcommands_post'] = 'Envoyer'; +$labels['listcommands_admin'] = 'Contactez l\'administrateur'; +$labels['listcommands_archive'] = 'Archives de la liste'; + +?>
\ No newline at end of file diff --git a/plugins/listcommands/localization/nl_NL.inc b/plugins/listcommands/localization/nl_NL.inc new file mode 100644 index 000000000..373870a83 --- /dev/null +++ b/plugins/listcommands/localization/nl_NL.inc @@ -0,0 +1,12 @@ +<?php + +$labels = array(); +$labels['listcommands_mailinglist'] = 'Email Lijst'; +$labels['listcommands_help'] = 'Hulp'; +$labels['listcommands_subscribe'] = 'Aanmelden'; +$labels['listcommands_unsubscribe'] = 'Afmelden'; +$labels['listcommands_post'] = 'Nieuw Bericht'; +$labels['listcommands_admin'] = 'Email Beheerder'; +$labels['listcommands_archive'] = 'Lijst Archief'; + +?> diff --git a/plugins/listcommands/localization/pl_PL.inc b/plugins/listcommands/localization/pl_PL.inc new file mode 100644 index 000000000..faefae7ba --- /dev/null +++ b/plugins/listcommands/localization/pl_PL.inc @@ -0,0 +1,12 @@ +<?php + +$labels = array(); +$labels['listcommands_mailinglist'] = 'Lista'; +$labels['listcommands_help'] = 'Pomoc'; +$labels['listcommands_subscribe'] = 'Subskrybuj'; +$labels['listcommands_unsubscribe'] = 'Odsubskrybuj'; +$labels['listcommands_post'] = 'Wyślij'; +$labels['listcommands_admin'] = 'Kontakt z administratorem'; +$labels['listcommands_archive'] = 'Archiwum listy'; + +?> diff --git a/plugins/listcommands/localization/ru_RU.inc b/plugins/listcommands/localization/ru_RU.inc new file mode 100644 index 000000000..3565d6cb5 --- /dev/null +++ b/plugins/listcommands/localization/ru_RU.inc @@ -0,0 +1,12 @@ +<?php + +$labels = array(); +$labels['listcommands_mailinglist'] = 'Рассылка'; +$labels['listcommands_help'] = 'Помощь'; +$labels['listcommands_subscribe'] = 'Подписаться'; +$labels['listcommands_unsubscribe'] = 'Отписаться'; +$labels['listcommands_post'] = 'Ответить в рассылку'; +$labels['listcommands_admin'] = 'Связаться с администратором'; +$labels['listcommands_archive'] = 'Просмотреть Архив'; + +?>
\ No newline at end of file diff --git a/plugins/listcommands/package.xml b/plugins/listcommands/package.xml new file mode 100644 index 000000000..6c18bbc1f --- /dev/null +++ b/plugins/listcommands/package.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<package xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" packagerversion="1.9.0" version="2.0" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 + http://pear.php.net/dtd/tasks-1.0.xsd + http://pear.php.net/dtd/package-2.0 + http://pear.php.net/dtd/package-2.0.xsd"> + <name>listcommands</name> + <lead> + <name>Cor Bosman</name> + <user>cor</user> + <email>cor@roundcu.be</email> + <active>yes</active> + </lead> + <uri>https://github.com/corbosman/listcommands</uri> + <version> + <release>2.0</release> + </version> + <license uri="http://www.gnu.org/licenses/gpl-2.0.html">GNU GPLv2</license> +</package> |