Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

attachment_reminder.php 2.9KB

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