annotate plugins/attachment_reminder/attachment_reminder.php @ 23:5a851d965bc1

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