comparison plugins/attachment_reminder/attachment_reminder.php @ 0:1e000243b222

vanilla 1.3.3 distro, I hope
author Charlie Root
date Thu, 04 Jan 2018 15:50:29 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:1e000243b222
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
27 class attachment_reminder extends rcube_plugin
28 {
29 public $task = 'mail|settings';
30 public $noajax = true;
31
32
33 function init()
34 {
35 $rcmail = rcube::get_instance();
36
37 if ($rcmail->task == 'mail' && $rcmail->action == 'compose') {
38 if ($rcmail->config->get('attachment_reminder')) {
39 $this->include_script('attachment_reminder.js');
40 $this->add_texts('localization/', array('keywords', 'forgotattachment'));
41 $rcmail->output->add_label('addattachment', 'send');
42 }
43 }
44
45 if ($rcmail->task == 'settings') {
46 $dont_override = $rcmail->config->get('dont_override', array());
47
48 if (!in_array('attachment_reminder', $dont_override)) {
49 $this->add_hook('preferences_list', array($this, 'prefs_list'));
50 $this->add_hook('preferences_save', array($this, 'prefs_save'));
51 }
52 }
53 }
54
55 function prefs_list($args)
56 {
57 if ($args['section'] == 'compose') {
58 $this->add_texts('localization/');
59 $reminder = rcube::get_instance()->config->get('attachment_reminder');
60 $field_id = 'rcmfd_attachment_reminder';
61 $checkbox = new html_checkbox(array('name' => '_attachment_reminder', 'id' => $field_id, 'value' => 1));
62
63 $args['blocks']['main']['options']['attachment_reminder'] = array(
64 'title' => html::label($field_id, rcube::Q($this->gettext('reminderoption'))),
65 'content' => $checkbox->show($reminder ? 1 : 0),
66 );
67 }
68
69 return $args;
70 }
71
72 function prefs_save($args)
73 {
74 if ($args['section'] == 'compose') {
75 $dont_override = rcube::get_instance()->config->get('dont_override', array());
76 if (!in_array('attachment_reminder', $dont_override)) {
77 $args['prefs']['attachment_reminder'] = !empty($_POST['_attachment_reminder']);
78 }
79 }
80 return $args;
81 }
82
83 }