Aleksander Machniak
2013-05-08 864745bc9a14afaee640f9960e16ccdbc57e237d
Attachment_reminder plugin - ported from https://github.com/thomasysliu/Roundcube-Plugin-Attachment-Reminder
and added user preference to disable plugin, larry support, some fixes/improvements
13 files added
1 files modified
255 ■■■■■ changed files
CHANGELOG 1 ●●●● patch | view | raw | blame | history
plugins/attachment_reminder/attachment_reminder.js 54 ●●●●● patch | view | raw | blame | history
plugins/attachment_reminder/attachment_reminder.php 81 ●●●●● patch | view | raw | blame | history
plugins/attachment_reminder/localization/de_CH.inc 5 ●●●●● patch | view | raw | blame | history
plugins/attachment_reminder/localization/de_DE.inc 5 ●●●●● patch | view | raw | blame | history
plugins/attachment_reminder/localization/en_US.inc 6 ●●●●● patch | view | raw | blame | history
plugins/attachment_reminder/localization/es_ES.inc 5 ●●●●● patch | view | raw | blame | history
plugins/attachment_reminder/localization/fr_FR.inc 5 ●●●●● patch | view | raw | blame | history
plugins/attachment_reminder/localization/it_IT.inc 6 ●●●●● patch | view | raw | blame | history
plugins/attachment_reminder/localization/nl_NL.inc 5 ●●●●● patch | view | raw | blame | history
plugins/attachment_reminder/localization/pl_PL.inc 6 ●●●●● patch | view | raw | blame | history
plugins/attachment_reminder/localization/zh_CN.inc 5 ●●●●● patch | view | raw | blame | history
plugins/attachment_reminder/localization/zh_TW.inc 5 ●●●●● patch | view | raw | blame | history
plugins/attachment_reminder/package.xml 66 ●●●●● patch | view | raw | blame | history
CHANGELOG
@@ -1,6 +1,7 @@
CHANGELOG Roundcube Webmail
===========================
- Added attachment_reminder plugin
- Fix IMAP connection issue with default_socket_timeout < 0 and imap_timeout < 0 (#1489090)
- Fix various PHP code bugs found using static analysis (#1489086)
- Fix backslash character handling on vCard import (#1489085)
plugins/attachment_reminder/attachment_reminder.js
New file
@@ -0,0 +1,54 @@
/* 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, rg, keywords = rcmail.gettext('keywords', 'attachment_reminder').split(",").concat([".doc", ".pdf"]);
  for (i=0; i<keywords.length; i++) {
    rg = new RegExp(keywords[i],'i');
    if (msg.search(rg) != -1)
      return true;
  }
  return false;
}
function rcmail_have_attachments()
{
  return rcmail.env.attachments && $('li', rcmail.gui_objects.attachmentlist).length;
}
if (window.rcmail) {
  rcmail.addEventListener('beforesend', function(evt) {
    var msg = rcmail_get_compose_message(),
      subject = $('#compose-subject').val();
    if (!rcmail_have_attachments() && (rcmail_check_message(msg) || rcmail_check_message(subject))) {
      if (confirm(rcmail.gettext('forgotattachment', 'attachment_reminder'))) {
        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);
        return false;
      }
    }
  });
}
plugins/attachment_reminder/attachment_reminder.php
New file
@@ -0,0 +1,81 @@
<?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 version 2
 * as published by the Free Software Foundation.
 *
 * 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, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
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'));
        }
        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;
    }
}
plugins/attachment_reminder/localization/de_CH.inc
New file
@@ -0,0 +1,5 @@
<?php
$messages = array();
$messages['forgotattachment'] = "Haben Sie möglicherweise vergessen eine Datei anzuhängen?";
$messages['keywords'] = "anbei,im anhang,angehängt,angefügt,beigefügt,beliegend";
plugins/attachment_reminder/localization/de_DE.inc
New file
@@ -0,0 +1,5 @@
<?php
$messages = array();
$messages['forgotattachment'] = "Haben Sie möglicherweise vergessen eine Datei anzuhängen?";
$messages['keywords'] = "anbei,im anhang,angehängt,angefügt,beigefügt,beliegend";
plugins/attachment_reminder/localization/en_US.inc
New file
@@ -0,0 +1,6 @@
<?php
$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";
plugins/attachment_reminder/localization/es_ES.inc
New file
@@ -0,0 +1,5 @@
<?php
$messages = array();
$messages['forgotattachment'] = "¿Olvidó adjuntar un fichero al mensaje?";
$messages['keywords'] = "adjunto";
plugins/attachment_reminder/localization/fr_FR.inc
New file
@@ -0,0 +1,5 @@
<?php
$messages = array();
$messages['forgotattachment'] = "Avez vous oublié d'attacher un fichier ?";
$messages['keywords'] = "joins,joint,attaché,CV";
plugins/attachment_reminder/localization/it_IT.inc
New file
@@ -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['keywords'] = "allegato,allegati,allegata,allegate,allega,allego,alleghi,attaccato,file,attachment,attach";
plugins/attachment_reminder/localization/nl_NL.inc
New file
@@ -0,0 +1,5 @@
<?php
$messages = array();
$messages['forgotattachment'] = "Ben je vergeten het bestand bij te voegen?";
$messages['keywords'] = "attachment,bestand,bijgaand,bijgaande,brief,bijgevoegd,bijgesloten,CV";
plugins/attachment_reminder/localization/pl_PL.inc
New file
@@ -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";
plugins/attachment_reminder/localization/zh_CN.inc
New file
@@ -0,0 +1,5 @@
<?php
$messages = array();
$messages['forgotattachment'] = "您似乎忘記加入附件了,你確定要寄出?";
$messages['keywords'] = "附件,附加,附檔,附上,附加檔案";
plugins/attachment_reminder/localization/zh_TW.inc
New file
@@ -0,0 +1,5 @@
<?php
$messages = array();
$messages['forgotattachment'] = "您似乎忘記加入附件了,你確定要寄出?";
$messages['keywords'] = "附件,附加,附檔,附上,附加檔案";
plugins/attachment_reminder/package.xml
New file
@@ -0,0 +1,66 @@
<?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>
    <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-2.0.html">GNU GPLv2</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>