You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

attachment_reminder.php 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /**
  3. * Attachement Reminder
  4. *
  5. * A plugin that reminds a user to attach the files
  6. *
  7. * @version @package_version@
  8. * @author Thomas Yu - Sian, Liu
  9. * @author Aleksander Machniak <machniak@kolabsys.com>
  10. *
  11. * Copyright (C) 2013 Thomas Yu - Sian, Liu
  12. * Copyright (C) 2013, Kolab Systems AG
  13. *
  14. * This program is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation, either version 3 of the License, or
  17. * (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program. If not, see <http://www.gnu.org/licenses/>
  26. */
  27. class attachment_reminder extends rcube_plugin
  28. {
  29. public $task = 'mail|settings';
  30. public $noajax = true;
  31. function init()
  32. {
  33. $rcmail = rcube::get_instance();
  34. if ($rcmail->task == 'mail' && $rcmail->action == 'compose') {
  35. if ($rcmail->config->get('attachment_reminder')) {
  36. $this->include_script('attachment_reminder.js');
  37. $this->add_texts('localization/', array('keywords', 'forgotattachment'));
  38. $rcmail->output->add_label('addattachment', 'send');
  39. }
  40. }
  41. if ($rcmail->task == 'settings') {
  42. $dont_override = $rcmail->config->get('dont_override', array());
  43. if (!in_array('attachment_reminder', $dont_override)) {
  44. $this->add_hook('preferences_list', array($this, 'prefs_list'));
  45. $this->add_hook('preferences_save', array($this, 'prefs_save'));
  46. }
  47. }
  48. }
  49. function prefs_list($args)
  50. {
  51. if ($args['section'] == 'compose') {
  52. $this->add_texts('localization/');
  53. $reminder = rcube::get_instance()->config->get('attachment_reminder');
  54. $field_id = 'rcmfd_attachment_reminder';
  55. $checkbox = new html_checkbox(array('name' => '_attachment_reminder', 'id' => $field_id, 'value' => 1));
  56. $args['blocks']['main']['options']['attachment_reminder'] = array(
  57. 'title' => html::label($field_id, rcube::Q($this->gettext('reminderoption'))),
  58. 'content' => $checkbox->show($reminder ? 1 : 0),
  59. );
  60. }
  61. return $args;
  62. }
  63. function prefs_save($args)
  64. {
  65. if ($args['section'] == 'compose') {
  66. $dont_override = rcube::get_instance()->config->get('dont_override', array());
  67. if (!in_array('attachment_reminder', $dont_override)) {
  68. $args['prefs']['attachment_reminder'] = !empty($_POST['_attachment_reminder']);
  69. }
  70. }
  71. return $args;
  72. }
  73. }