summaryrefslogtreecommitdiff
path: root/plugins/attachment_reminder
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/attachment_reminder')
-rwxr-xr-xplugins/attachment_reminder/attachment_reminder.js68
-rwxr-xr-xplugins/attachment_reminder/attachment_reminder.php82
-rw-r--r--plugins/attachment_reminder/localization/de_CH.inc22
-rw-r--r--plugins/attachment_reminder/localization/de_DE.inc6
-rw-r--r--plugins/attachment_reminder/localization/en_US.inc22
-rw-r--r--plugins/attachment_reminder/localization/es_ES.inc6
-rw-r--r--plugins/attachment_reminder/localization/fr_FR.inc6
-rw-r--r--plugins/attachment_reminder/localization/it_IT.inc6
-rw-r--r--plugins/attachment_reminder/localization/nl_NL.inc6
-rw-r--r--plugins/attachment_reminder/localization/pl_PL.inc6
-rw-r--r--plugins/attachment_reminder/localization/zh_CN.inc6
-rw-r--r--plugins/attachment_reminder/localization/zh_TW.inc6
-rw-r--r--plugins/attachment_reminder/package.xml67
13 files changed, 309 insertions, 0 deletions
diff --git a/plugins/attachment_reminder/attachment_reminder.js b/plugins/attachment_reminder/attachment_reminder.js
new file mode 100755
index 000000000..50d661b3b
--- /dev/null
+++ b/plugins/attachment_reminder/attachment_reminder.js
@@ -0,0 +1,68 @@
+/* Attachment Reminder plugin script */
+
+function rcmail_get_compose_message()
+{
+ var msg;
+
+ if (window.tinyMCE && (ed = tinyMCE.get(rcmail.env.composebody))) {
+ msg = ed.getContent();
+ msg = msg.replace(/<blockquote[^>]*>(.|[\r\n])*<\/blockquote>/gmi, '');
+ }
+ else {
+ msg = $('#' + rcmail.env.composebody).val();
+ msg = msg.replace(/^>.*$/gmi, '');
+ }
+
+ return msg;
+};
+
+function rcmail_check_message(msg)
+{
+ var i, rx, keywords = rcmail.gettext('keywords', 'attachment_reminder').split(",").concat([".doc", ".pdf"]);
+
+ $.each(keywords, function(n) { return RegExp.escape(n); });
+ rx = new RegExp('(' + keywords.join('|') + ')', 'i');
+
+ return msg.search(rx) != -1;
+};
+
+function rcmail_have_attachments()
+{
+ return rcmail.env.attachments && $('li', rcmail.gui_objects.attachmentlist).length;
+};
+
+function rcmail_attachment_reminder_dialog()
+{
+ var buttons = {};
+
+ buttons[rcmail.gettext('addattachment')] = function() {
+ $(this).remove();
+ if (window.UI && UI.show_uploadform) // Larry skin
+ UI.show_uploadform();
+ else if (window.rcmail_ui && rcmail_ui.show_popup) // classic skin
+ rcmail_ui.show_popup('uploadmenu', true);
+ };
+ buttons[rcmail.gettext('send')] = function(e) {
+ $(this).remove();
+ rcmail.env.attachment_reminder = true;
+ rcmail.command('send', '', e);
+ };
+
+ rcmail.env.attachment_reminder = false;
+ rcmail.show_popup_dialog(rcmail.gettext('attachment_reminder.forgotattachment'), '', buttons);
+};
+
+
+if (window.rcmail) {
+ rcmail.addEventListener('beforesend', function(evt) {
+ var msg = rcmail_get_compose_message(),
+ subject = $('#compose-subject').val();
+
+ if (!rcmail.env.attachment_reminder && !rcmail_have_attachments()
+ && (rcmail_check_message(msg) || rcmail_check_message(subject))
+ ) {
+ rcmail_attachment_reminder_dialog();
+ return false;
+ }
+ });
+}
diff --git a/plugins/attachment_reminder/attachment_reminder.php b/plugins/attachment_reminder/attachment_reminder.php
new file mode 100755
index 000000000..a215ff57c
--- /dev/null
+++ b/plugins/attachment_reminder/attachment_reminder.php
@@ -0,0 +1,82 @@
+<?php
+/**
+ * Attachement Reminder
+ *
+ * A plugin that reminds a user to attach the files
+ *
+ * @version @package_version@
+ * @author Thomas Yu - Sian, Liu
+ * @author Aleksander Machniak <machniak@kolabsys.com>
+ *
+ * Copyright (C) 2013 Thomas Yu - Sian, Liu
+ * Copyright (C) 2013, Kolab Systems AG
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ */
+
+class attachment_reminder extends rcube_plugin
+{
+ public $task = 'mail|settings';
+ public $noajax = true;
+
+
+ function init()
+ {
+ $rcmail = rcube::get_instance();
+
+ if ($rcmail->task == 'mail' && $rcmail->action == 'compose') {
+ $this->include_script('attachment_reminder.js');
+ $this->add_texts('localization/', array('keywords', 'forgotattachment'));
+ $rcmail->output->add_label('addattachment', 'send');
+ }
+
+ if ($rcmail->task == 'settings') {
+ $dont_override = $rcmail->config->get('dont_override', array());
+
+ if (!in_array('attachment_reminder', $dont_override)) {
+ $this->add_hook('preferences_list', array($this, 'prefs_list'));
+ $this->add_hook('preferences_save', array($this, 'prefs_save'));
+ }
+ }
+ }
+
+ function prefs_list($args)
+ {
+ if ($args['section'] == 'compose') {
+ $this->add_texts('localization/');
+ $reminder = rcube::get_instance()->config->get('attachment_reminder');
+ $field_id = 'rcmfd_attachment_reminder';
+ $checkbox = new html_checkbox(array('name' => '_attachment_reminder', 'id' => $field_id, 'value' => 1));
+
+ $args['blocks']['main']['options']['attachment_reminder'] = array(
+ 'title' => html::label($field_id, rcube::Q($this->gettext('reminderoption'))),
+ 'content' => $checkbox->show($reminder ? 1 : 0),
+ );
+ }
+
+ return $args;
+ }
+
+ function prefs_save($args)
+ {
+ if ($args['section'] == 'compose') {
+ $dont_override = rcube::get_instance()->config->get('dont_override', array());
+ if (!in_array('attachment_reminder', $dont_override)) {
+ $args['prefs']['attachment_reminder'] = !empty($_POST['_attachment_reminder']);
+ }
+ }
+ return $args;
+ }
+
+}
diff --git a/plugins/attachment_reminder/localization/de_CH.inc b/plugins/attachment_reminder/localization/de_CH.inc
new file mode 100644
index 000000000..ad9f8d4f4
--- /dev/null
+++ b/plugins/attachment_reminder/localization/de_CH.inc
@@ -0,0 +1,22 @@
+<?php
+
+/*
+ +-----------------------------------------------------------------------+
+ | plugins/attachment_reminder/localization/<lang>.inc |
+ | |
+ | Localization file of the Roundcube Webmail Archive plugin |
+ | Copyright (C) 2013, The Roundcube Dev Team |
+ | |
+ | Licensed under the GNU General Public License version 3 or |
+ | any later version with exceptions for skins & plugins. |
+ | See the README file for a full license statement. |
+ | |
+ +-----------------------------------------------------------------------+
+
+ For translation see https://www.transifex.com/projects/p/roundcube-webmail/resource/plugin-attachment_reminder/
+*/
+
+$messages = array();
+$messages['forgotattachment'] = "Haben Sie möglicherweise vergessen eine Datei anzuhängen?";
+$messages['reminderoption'] = "Vor vergessenen Anhängen warnen";
+$messages['keywords'] = "anbei,anhang,angehängt,angefügt,beigefügt,beliegend";
diff --git a/plugins/attachment_reminder/localization/de_DE.inc b/plugins/attachment_reminder/localization/de_DE.inc
new file mode 100644
index 000000000..7de41d1fc
--- /dev/null
+++ b/plugins/attachment_reminder/localization/de_DE.inc
@@ -0,0 +1,6 @@
+<?php
+
+$messages = array();
+$messages['forgotattachment'] = "Haben Sie möglicherweise vergessen eine Datei anzuhängen?";
+$messages['reminderoption'] = "Remind about forgotten attachments";
+$messages['keywords'] = "anbei,im anhang,angehängt,angefügt,beigefügt,beliegend";
diff --git a/plugins/attachment_reminder/localization/en_US.inc b/plugins/attachment_reminder/localization/en_US.inc
new file mode 100644
index 000000000..488b0df37
--- /dev/null
+++ b/plugins/attachment_reminder/localization/en_US.inc
@@ -0,0 +1,22 @@
+<?php
+
+/*
+ +-----------------------------------------------------------------------+
+ | plugins/attachment_reminder/localization/<lang>.inc |
+ | |
+ | Localization file of the Roundcube Webmail Archive plugin |
+ | Copyright (C) 2013, The Roundcube Dev Team |
+ | |
+ | Licensed under the GNU General Public License version 3 or |
+ | any later version with exceptions for skins & plugins. |
+ | See the README file for a full license statement. |
+ | |
+ +-----------------------------------------------------------------------+
+
+ For translation see https://www.transifex.com/projects/p/roundcube-webmail/resource/plugin-attachment_reminder/
+*/
+
+$messages = array();
+$messages['forgotattachment'] = "Did you forget to attach a file?";
+$messages['reminderoption'] = "Remind about forgotten attachments";
+$messages['keywords'] = "attachment,file,attach,attached,attaching,enclosed,CV,cover letter";
diff --git a/plugins/attachment_reminder/localization/es_ES.inc b/plugins/attachment_reminder/localization/es_ES.inc
new file mode 100644
index 000000000..79225d77e
--- /dev/null
+++ b/plugins/attachment_reminder/localization/es_ES.inc
@@ -0,0 +1,6 @@
+<?php
+
+$messages = array();
+$messages['forgotattachment'] = "¿Olvidó adjuntar un fichero al mensaje?";
+$messages['reminderoption'] = "Remind about forgotten attachments";
+$messages['keywords'] = "adjunto";
diff --git a/plugins/attachment_reminder/localization/fr_FR.inc b/plugins/attachment_reminder/localization/fr_FR.inc
new file mode 100644
index 000000000..78522c2e1
--- /dev/null
+++ b/plugins/attachment_reminder/localization/fr_FR.inc
@@ -0,0 +1,6 @@
+<?php
+
+$messages = array();
+$messages['forgotattachment'] = "Avez vous oublié d'attacher un fichier ?";
+$messages['reminderoption'] = "Remind about forgotten attachments";
+$messages['keywords'] = "joins,joint,attaché,CV";
diff --git a/plugins/attachment_reminder/localization/it_IT.inc b/plugins/attachment_reminder/localization/it_IT.inc
new file mode 100644
index 000000000..d326a6065
--- /dev/null
+++ b/plugins/attachment_reminder/localization/it_IT.inc
@@ -0,0 +1,6 @@
+<?php
+
+$messages = array();
+$messages['forgotattachment'] = "Sembra che tu abbia dimenticato di allegare un file!\nPremere Annulla per inviare lo stesso.\nOK per tornare al messaggio senza inviare.";
+$messages['reminderoption'] = "Remind about forgotten attachments";
+$messages['keywords'] = "allegato,allegati,allegata,allegate,allega,allego,alleghi,attaccato,file,attachment,attach";
diff --git a/plugins/attachment_reminder/localization/nl_NL.inc b/plugins/attachment_reminder/localization/nl_NL.inc
new file mode 100644
index 000000000..d80bfe9a9
--- /dev/null
+++ b/plugins/attachment_reminder/localization/nl_NL.inc
@@ -0,0 +1,6 @@
+<?php
+
+$messages = array();
+$messages['forgotattachment'] = "Ben je vergeten het bestand bij te voegen?";
+$messages['reminderoption'] = "Remind about forgotten attachments";
+$messages['keywords'] = "attachment,bestand,bijgaand,bijgaande,brief,bijgevoegd,bijgesloten,CV";
diff --git a/plugins/attachment_reminder/localization/pl_PL.inc b/plugins/attachment_reminder/localization/pl_PL.inc
new file mode 100644
index 000000000..96f4f4989
--- /dev/null
+++ b/plugins/attachment_reminder/localization/pl_PL.inc
@@ -0,0 +1,6 @@
+<?php
+
+$messages = array();
+$messages['forgotattachment'] = "Czy nie zapomniałeś załączyć pliku?";
+$messages['reminderoption'] = "Włącz przypominanie o brakującym załączniku";
+$messages['keywords'] = "załącznik,plik,załącz,CV";
diff --git a/plugins/attachment_reminder/localization/zh_CN.inc b/plugins/attachment_reminder/localization/zh_CN.inc
new file mode 100644
index 000000000..367191ffb
--- /dev/null
+++ b/plugins/attachment_reminder/localization/zh_CN.inc
@@ -0,0 +1,6 @@
+<?php
+
+$messages = array();
+$messages['forgotattachment'] = "您似乎忘記加入附件了,你確定要寄出?";
+$messages['reminderoption'] = "Remind about forgotten attachments";
+$messages['keywords'] = "附件,附加,附檔,附上,附加檔案";
diff --git a/plugins/attachment_reminder/localization/zh_TW.inc b/plugins/attachment_reminder/localization/zh_TW.inc
new file mode 100644
index 000000000..367191ffb
--- /dev/null
+++ b/plugins/attachment_reminder/localization/zh_TW.inc
@@ -0,0 +1,6 @@
+<?php
+
+$messages = array();
+$messages['forgotattachment'] = "您似乎忘記加入附件了,你確定要寄出?";
+$messages['reminderoption'] = "Remind about forgotten attachments";
+$messages['keywords'] = "附件,附加,附檔,附上,附加檔案";
diff --git a/plugins/attachment_reminder/package.xml b/plugins/attachment_reminder/package.xml
new file mode 100644
index 000000000..78768d534
--- /dev/null
+++ b/plugins/attachment_reminder/package.xml
@@ -0,0 +1,67 @@
+<?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>Attachment Reminder</name>
+ <summary>Roundcube plugin that prompts you if it looks like you wanted to attach a file but you didn't.</summary>
+ <description>
+ This Roundcube plugin reminds the user to attach a file if the composed message text indicates that there should be any.
+ </description>
+ <lead>
+ <name>Aleksander Machniak</name>
+ <user>alec</user>
+ <email>alec@alec.pl</email>
+ <active>yes</active>
+ </lead>
+ <lead>
+ <name>Thomas Yu - Sian, Liu</name>
+ <active>yes</active>
+ </lead>
+ <date>2013-05-20</date>
+ <version>
+ <release>1.1</release>
+ <api>1.0</api>
+ </version>
+ <stability>
+ <release>stable</release>
+ <api>stable</api>
+ </stability>
+ <license uri="http://www.gnu.org/licenses/gpl.html">GNU GPLv3+</license>
+ <notes>-</notes>
+ <contents>
+ <dir baseinstalldir="/" name="/">
+ <file name="attachment_reminder.php" role="php">
+ <tasks:replace from="@name@" to="name" type="package-info"/>
+ <tasks:replace from="@package_version@" to="version" type="package-info"/>
+ </file>
+ <file name="attachment_reminder.js" role="data">
+ <tasks:replace from="@name@" to="name" type="package-info"/>
+ <tasks:replace from="@package_version@" to="version" type="package-info"/>
+ </file>
+
+ <file name="localization/de_CH.inc" role="data"></file>
+ <file name="localization/de_DE.inc" role="data"></file>
+ <file name="localization/en_US.inc" role="data"></file>
+ <file name="localization/es_ES.inc" role="data"></file>
+ <file name="localization/fr_FR.inc" role="data"></file>
+ <file name="localization/it_IT.inc" role="data"></file>
+ <file name="localization/nl_NL.inc" role="data"></file>
+ <file name="localization/pl_PL.inc" role="data"></file>
+ <file name="localization/zh_CN.inc" role="data"></file>
+ <file name="localization/zh_TW.inc" role="data"></file>
+ </dir>
+ <!-- / -->
+ </contents>
+ <dependencies>
+ <required>
+ <php>
+ <min>5.2.1</min>
+ </php>
+ <pearinstaller>
+ <min>1.7.0</min>
+ </pearinstaller>
+ </required>
+ </dependencies>
+ <phprelease/>
+</package>