annotate plugins/thunderbird_labels/thunderbird_labels.php @ 35:05c4c32948af

.hgignore: add vendor tree composer.json: new packages plugins/thunderbird_labels/thunderbird_labels.php: change hook and RFC822 use wrt whitelisting to avoid deprecated stuff index.php: commented debugging hooks others: new releases of vendor packages?
author Charlie Root
date Thu, 30 Aug 2018 16:21:59 -0400
parents b2d0a9781472
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 * Thunderbird Labels Plugin for Roundcube Webmail
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 * Plugin to show the 5 Message Labels Thunderbird Email-Client provides for IMAP
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 * @version $Revision$
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
8 * @author Michael Kefeder
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
9 * @url http://code.google.com/p/rcmail-thunderbird-labels/
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
10 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
11 class thunderbird_labels extends rcube_plugin
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 public $task = 'mail|settings';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
14 private $rc;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
15 private $map;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
16
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
17 function init()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
18 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
19 $this->rc = rcmail::get_instance();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
20 $this->load_config();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
21 $this->add_texts('localization/', false);
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 $this->setCustomLabels();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
24
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
25 if ($this->rc->task == 'mail')
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 # -- disable plugin when printing message
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
28 if ($this->rc->action == 'print')
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
29 return;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
30
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
31 if (!$this->rc->config->get('tb_label_enable'))
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
32 // disable plugin according to prefs
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
33 return;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
34
9
7a7f68b4358e allow open-ended label inventory
Charlie Root
parents: 2
diff changeset
35 // how many labels?
7a7f68b4358e allow open-ended label inventory
Charlie Root
parents: 2
diff changeset
36 $max_id = $this->rc->config->get('tb_max_label');
7a7f68b4358e allow open-ended label inventory
Charlie Root
parents: 2
diff changeset
37 // pass 'tb_max_label', 'tb_label_enable_shortcuts'
7a7f68b4358e allow open-ended label inventory
Charlie Root
parents: 2
diff changeset
38 // and 'tb_label_style' prefs to JS
7a7f68b4358e allow open-ended label inventory
Charlie Root
parents: 2
diff changeset
39 $this->rc->output->set_env('tb_max_label', $max_id);
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
40 $this->rc->output->set_env('tb_label_enable_shortcuts', $this->rc->config->get('tb_label_enable_shortcuts'));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
41 $this->rc->output->set_env('tb_label_style', $this->rc->config->get('tb_label_style'));
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 $this->include_script('tb_label.js');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
44 $this->add_hook('messages_list', array($this, 'read_flags'));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
45 $this->add_hook('message_load', array($this, 'read_single_flags'));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
46 $this->add_hook('template_object_messageheaders', array($this, 'color_headers'));
26
b2b6c0af2383 remove _ from name, lots of other hacks to get label context menu working
Charlie Root
parents: 25
diff changeset
47 $this->add_hook('render_page', array($this, 'tblabelpopup'));
35
05c4c32948af .hgignore: add vendor tree
Charlie Root
parents: 31
diff changeset
48 $this->add_hook('message_ready', array($this, 'whiteMessage'));
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
49 $this->include_stylesheet($this->local_skin_path() . '/tb_label.css');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
50
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
51 $this->name = get_class($this);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
52 # -- additional TB flags
1
5821049f1791 most of the way to allowing arbitrarily many labels
Charlie Root
parents: 0
diff changeset
53 $this->add_tb_flags = array();
5821049f1791 most of the way to allowing arbitrarily many labels
Charlie Root
parents: 0
diff changeset
54 for ($i = 1; $i <= $max_id; $i++) {
5821049f1791 most of the way to allowing arbitrarily many labels
Charlie Root
parents: 0
diff changeset
55 $this->add_tb_flags['LABEL'.$i]='$Label'.$i;
5821049f1791 most of the way to allowing arbitrarily many labels
Charlie Root
parents: 0
diff changeset
56 }
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
57 $this->message_tb_labels = array();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
58
26
b2b6c0af2383 remove _ from name, lots of other hacks to get label context menu working
Charlie Root
parents: 25
diff changeset
59 # This builds the toolbar button, but
b2b6c0af2383 remove _ from name, lots of other hacks to get label context menu working
Charlie Root
parents: 25
diff changeset
60 # it's also used by the ctxtmenu initialisation
b2b6c0af2383 remove _ from name, lots of other hacks to get label context menu working
Charlie Root
parents: 25
diff changeset
61 # contextmenu.js:rcube_context_menu to build
b2b6c0af2383 remove _ from name, lots of other hacks to get label context menu working
Charlie Root
parents: 25
diff changeset
62 # the context menu, and that somehow
b2b6c0af2383 remove _ from name, lots of other hacks to get label context menu working
Charlie Root
parents: 25
diff changeset
63 # ends up with display: none???
b2b6c0af2383 remove _ from name, lots of other hacks to get label context menu working
Charlie Root
parents: 25
diff changeset
64 # Bother, missed it, it's before this.container.show
b2b6c0af2383 remove _ from name, lots of other hacks to get label context menu working
Charlie Root
parents: 25
diff changeset
65 # Afeter ul.appendnd -- inside menu.show on 307
b2b6c0af2383 remove _ from name, lots of other hacks to get label context menu working
Charlie Root
parents: 25
diff changeset
66 # 567? Yes -- that's calling 'hide', but overriding
b2b6c0af2383 remove _ from name, lots of other hacks to get label context menu working
Charlie Root
parents: 25
diff changeset
67 # doesn't fix :-(
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
68 $this->add_button(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
69 array(
26
b2b6c0af2383 remove _ from name, lots of other hacks to get label context menu working
Charlie Root
parents: 25
diff changeset
70 #'command' => 'plugin.thunderbird_labels.rcm_tb_label_submenu',
b2b6c0af2383 remove _ from name, lots of other hacks to get label context menu working
Charlie Root
parents: 25
diff changeset
71 'name' => 'tblabellink',
b2b6c0af2383 remove _ from name, lots of other hacks to get label context menu working
Charlie Root
parents: 25
diff changeset
72 'id' => 'tblabelpopuplink',
29
ea061c743982 localise title and label exactly once each :-)
Charlie Root
parents: 27
diff changeset
73 'domain' => $this->ID,
26
b2b6c0af2383 remove _ from name, lots of other hacks to get label context menu working
Charlie Root
parents: 25
diff changeset
74 'type' => 'link',
b2b6c0af2383 remove _ from name, lots of other hacks to get label context menu working
Charlie Root
parents: 25
diff changeset
75 'class' => 'button tblabel',
29
ea061c743982 localise title and label exactly once each :-)
Charlie Root
parents: 27
diff changeset
76 'label' => 'tb_label_button_label',
ea061c743982 localise title and label exactly once each :-)
Charlie Root
parents: 27
diff changeset
77 'title' => 'tb_label_button_title',
26
b2b6c0af2383 remove _ from name, lots of other hacks to get label context menu working
Charlie Root
parents: 25
diff changeset
78 'onclick' => "UI.toggle_popup('tblabelpopup',event);return false",
b2b6c0af2383 remove _ from name, lots of other hacks to get label context menu working
Charlie Root
parents: 25
diff changeset
79 'aria-haspopup' => true,
b2b6c0af2383 remove _ from name, lots of other hacks to get label context menu working
Charlie Root
parents: 25
diff changeset
80 'aria-expanded' => false,
b2b6c0af2383 remove _ from name, lots of other hacks to get label context menu working
Charlie Root
parents: 25
diff changeset
81 'aria-owns' => 'plugin.thunderbird_labels.rcm_tb_label_submenu-menu'
b2b6c0af2383 remove _ from name, lots of other hacks to get label context menu working
Charlie Root
parents: 25
diff changeset
82 #'classact' => 'listbutton add',
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
83 ),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
84 'toolbar'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
85 );
26
b2b6c0af2383 remove _ from name, lots of other hacks to get label context menu working
Charlie Root
parents: 25
diff changeset
86
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
87 // JS function "set_flags" => PHP function "set_flags"
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
88 $this->register_action('plugin.thunderbird_labels.set_flags', array($this, 'set_flags'));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
89
35
05c4c32948af .hgignore: add vendor tree
Charlie Root
parents: 31
diff changeset
90 #rcube::write_log('lab','set_flags registered');
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
91
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
92 if (method_exists($this, 'require_plugin')
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
93 && in_array('contextmenu', $this->rc->config->get('plugins'))
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
94 && $this->require_plugin('contextmenu')
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
95 && $this->rc->config->get('tb_label_enable_contextmenu'))
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
96 {
1
5821049f1791 most of the way to allowing arbitrarily many labels
Charlie Root
parents: 0
diff changeset
97 if ($this->rc->action == 'list')
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
98 $this->add_hook('render_mailboxlist', array($this, 'show_tb_label_contextmenu'));
27
e097905863b9 turn off logging
Charlie Root
parents: 26
diff changeset
99 #rcube::write_log('lab','ctxt: '.$this->rc->action);
1
5821049f1791 most of the way to allowing arbitrarily many labels
Charlie Root
parents: 0
diff changeset
100 }
5821049f1791 most of the way to allowing arbitrarily many labels
Charlie Root
parents: 0
diff changeset
101 else {
27
e097905863b9 turn off logging
Charlie Root
parents: 26
diff changeset
102 #rcube::write_log('lab','no ctxt');
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
103 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
104 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
105 elseif ($this->rc->task == 'settings')
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
106 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
107 $this->include_stylesheet($this->local_skin_path() . '/tb_label.css');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
108 $this->add_hook('preferences_list', array($this, 'prefs_list'));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
109 $this->add_hook('preferences_sections_list', array($this, 'prefs_section'));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
110 $this->add_hook('preferences_save', array($this, 'prefs_save'));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
111 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
112 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
113
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
114 private function setCustomLabels()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
115 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
116 $c = $this->rc->config->get('tb_label_custom_labels');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
117 if (empty($c))
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
118 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
119 // if no user specific labels, use localized strings by default
1
5821049f1791 most of the way to allowing arbitrarily many labels
Charlie Root
parents: 0
diff changeset
120 $max_id = $this->rc->config->get('tb_max_label');
23
5a851d965bc1 sorting, some better displays
Charlie Root
parents: 21
diff changeset
121 $parmLabs = array();
1
5821049f1791 most of the way to allowing arbitrarily many labels
Charlie Root
parents: 0
diff changeset
122 $tb_flag_text = array();
5821049f1791 most of the way to allowing arbitrarily many labels
Charlie Root
parents: 0
diff changeset
123 for ($i = 0; $i <= $max_id; $i++) {
23
5a851d965bc1 sorting, some better displays
Charlie Root
parents: 21
diff changeset
124 $lab=$this->getText('label'.$i);
5a851d965bc1 sorting, some better displays
Charlie Root
parents: 21
diff changeset
125 $isParm=($lab[-1]=='1');
5a851d965bc1 sorting, some better displays
Charlie Root
parents: 21
diff changeset
126 $lab=substr($lab,0,strlen($lab)-1);
5a851d965bc1 sorting, some better displays
Charlie Root
parents: 21
diff changeset
127 $tb_flag_text[$i] = $lab;
5a851d965bc1 sorting, some better displays
Charlie Root
parents: 21
diff changeset
128 if ($isParm) {
5a851d965bc1 sorting, some better displays
Charlie Root
parents: 21
diff changeset
129 $parmLabs[$i]=strtolower($lab);
5a851d965bc1 sorting, some better displays
Charlie Root
parents: 21
diff changeset
130 }
1
5821049f1791 most of the way to allowing arbitrarily many labels
Charlie Root
parents: 0
diff changeset
131 }
5821049f1791 most of the way to allowing arbitrarily many labels
Charlie Root
parents: 0
diff changeset
132 $this->rc->config->set('tb_label_custom_labels',
23
5a851d965bc1 sorting, some better displays
Charlie Root
parents: 21
diff changeset
133 $tb_flag_text);
5a851d965bc1 sorting, some better displays
Charlie Root
parents: 21
diff changeset
134 $this->rc->config->set('tb_label_parm_labels',
5a851d965bc1 sorting, some better displays
Charlie Root
parents: 21
diff changeset
135 $parmLabs);
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
136 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
137 // pass label strings to JS
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
138 $this->rc->output->set_env('tb_label_custom_labels', $this->rc->config->get('tb_label_custom_labels'));
23
5a851d965bc1 sorting, some better displays
Charlie Root
parents: 21
diff changeset
139 $this->rc->output->set_env('tb_label_parm_labels', $this->rc->config->get('tb_label_parm_labels'));
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
140 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
141
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
142 // create a section for the tb-labels Settings
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
143 public function prefs_section($args)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
144 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
145 $args['list']['thunderbird_labels'] = array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
146 'id' => 'thunderbird_labels',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
147 'section' => rcube::Q($this->gettext('tb_label_options'))
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
148 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
149
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
150 return $args;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
151 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
152
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
153 // display thunderbird-labels prefs in Roundcube Settings
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
154 public function prefs_list($args)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
155 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
156 if ($args['section'] != 'thunderbird_labels')
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
157 return $args;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
158
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
159 $this->load_config();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
160 $dont_override = (array) $this->rc->config->get('dont_override', array());
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
161
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
162 $args['blocks']['tb_label'] = array();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
163 $args['blocks']['tb_label']['name'] = $this->gettext('tb_label_options');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
164
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
165 $key = 'tb_label_enable';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
166 if (!in_array($key, $dont_override))
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
167 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
168 $input = new html_checkbox(array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
169 'name' => $key,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
170 'id' => $key,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
171 'value' => 1
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
172 ));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
173 $content = $input->show($this->rc->config->get($key));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
174 $args['blocks']['tb_label']['options'][$key] = array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
175 'title' => $this->gettext('tb_label_enable_option'),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
176 'content' => $content
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
177 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
178 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
179
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
180 $key = 'tb_label_enable_shortcuts';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
181 if (!in_array($key, $dont_override))
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
182 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
183 $input = new html_checkbox(array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
184 'name' => $key,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
185 'id' => $key,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
186 'value' => 1
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
187 ));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
188 $content = $input->show($this->rc->config->get($key));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
189 $args['blocks']['tb_label']['options'][$key] = array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
190 'title' => $this->gettext('tb_label_enable_shortcuts_option'),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
191 'content' => $content
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
192 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
193 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
194
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
195 $key = 'tb_label_style';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
196 if (!in_array($key, $dont_override))
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
197 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
198 $select = new html_select(array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
199 'name' => $key,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
200 'id' => $key
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
201 ));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
202 $select->add(array($this->gettext('thunderbird'), $this->gettext('bullets')), array('thunderbird', 'bullets'));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
203 $content = $select->show($this->rc->config->get($key));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
204
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
205 $args['blocks']['tb_label']['options'][$key] = array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
206 'title' => $this->gettext('tb_label_style_option'),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
207 'content' => $content
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
208 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
209 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
210
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
211 $key = 'tb_label_custom_labels';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
212 if (!in_array($key, $dont_override)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
213 && $this->rc->config->get('tb_label_modify_labels'))
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
214 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
215 $old = $this->rc->config->get($key);
23
5a851d965bc1 sorting, some better displays
Charlie Root
parents: 21
diff changeset
216 $oldParms = $this->rc->config->get('tb_label_parm_labels');
1
5821049f1791 most of the way to allowing arbitrarily many labels
Charlie Root
parents: 0
diff changeset
217 $max_id = $this->rc->config->get('tb_max_label');
5821049f1791 most of the way to allowing arbitrarily many labels
Charlie Root
parents: 0
diff changeset
218 for($i=1; $i<=$max_id; $i++)
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
219 {
19
49706603be30 begin to add UI support for parameterised labels, e.g. Dates
Charlie Root
parents: 9
diff changeset
220 $oldVal = $old[$i];
23
5a851d965bc1 sorting, some better displays
Charlie Root
parents: 21
diff changeset
221 $oparm=$oldParms[$i]?1:0;
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
222 $input = new html_inputfield(array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
223 'name' => $key.$i,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
224 'id' => $key.$i,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
225 'type' => 'text',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
226 'autocomplete' => 'off',
23
5a851d965bc1 sorting, some better displays
Charlie Root
parents: 21
diff changeset
227 'value' => $oldVal));
19
49706603be30 begin to add UI support for parameterised labels, e.g. Dates
Charlie Root
parents: 9
diff changeset
228 $parmBox = new html_checkbox(array(
49706603be30 begin to add UI support for parameterised labels, e.g. Dates
Charlie Root
parents: 9
diff changeset
229 'name' => $key.$i.'parm',
49706603be30 begin to add UI support for parameterised labels, e.g. Dates
Charlie Root
parents: 9
diff changeset
230 'id' => $key.$i.'parm',
49706603be30 begin to add UI support for parameterised labels, e.g. Dates
Charlie Root
parents: 9
diff changeset
231 'value' => 1));
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
232 $args['blocks']['tb_label']['options'][$key.$i] = array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
233 'title' => $this->gettext('tb_label_label')." ".$i,
19
49706603be30 begin to add UI support for parameterised labels, e.g. Dates
Charlie Root
parents: 9
diff changeset
234 'content' => $input->show()."&nbsp;".$parmBox->show($oparm)
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
235 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
236 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
237 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
238
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
239 return $args;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
240 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
241
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
242 // save prefs after modified in UI
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
243 public function prefs_save($args)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
244 {
9
7a7f68b4358e allow open-ended label inventory
Charlie Root
parents: 2
diff changeset
245 #rcube::write_log('lab','saving: '.print_r($args,true));
2
c828b0fd4a6e fix missing line to store changed labels
Charlie Root
parents: 1
diff changeset
246 if ($args['section'] != 'thunderbird_labels')
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
247 return $args;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
248
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
249
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
250 $this->load_config();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
251 $dont_override = (array) $this->rc->config->get('dont_override', array());
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
252
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
253 if (!in_array('tb_label_enable', $dont_override))
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
254 $args['prefs']['tb_label_enable'] = rcube_utils::get_input_value('tb_label_enable', rcube_utils::INPUT_POST) ? true : false;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
255
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
256 if (!in_array('tb_label_enable_shortcuts', $dont_override))
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
257 $args['prefs']['tb_label_enable_shortcuts'] = rcube_utils::get_input_value('tb_label_enable_shortcuts', rcube_utils::INPUT_POST) ? true : false;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
258
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
259 if (!in_array('tb_label_style', $dont_override))
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
260 $args['prefs']['tb_label_style'] = rcube_utils::get_input_value('tb_label_style', rcube_utils::INPUT_POST);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
261
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
262 if (!in_array('tb_label_custom_labels', $dont_override)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
263 && $this->rc->config->get('tb_label_modify_labels'))
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
264 {
1
5821049f1791 most of the way to allowing arbitrarily many labels
Charlie Root
parents: 0
diff changeset
265 $max_id = $this->rc->config->get('tb_max_label');
5821049f1791 most of the way to allowing arbitrarily many labels
Charlie Root
parents: 0
diff changeset
266 $tb_lab_prefs = array();
23
5a851d965bc1 sorting, some better displays
Charlie Root
parents: 21
diff changeset
267 $tb_parm_prefs = array();
1
5821049f1791 most of the way to allowing arbitrarily many labels
Charlie Root
parents: 0
diff changeset
268 $tb_lab_prefs[0] = $this->gettext('label0');
5821049f1791 most of the way to allowing arbitrarily many labels
Charlie Root
parents: 0
diff changeset
269 for ($i = 1; $i <= $max_id; $i++) {
23
5a851d965bc1 sorting, some better displays
Charlie Root
parents: 21
diff changeset
270 $tb_lab_prefs[$i] = rcube_utils::get_input_value('tb_label_custom_labels'.$i, rcube_utils::INPUT_POST);
5a851d965bc1 sorting, some better displays
Charlie Root
parents: 21
diff changeset
271 if (rcube_utils::get_input_value('tb_label_custom_labels'.$i.'parm', rcube_utils::INPUT_POST)) {
5a851d965bc1 sorting, some better displays
Charlie Root
parents: 21
diff changeset
272 $tb_parm_prefs[$i] = strtolower($tb_lab_prefs[$i]);
5a851d965bc1 sorting, some better displays
Charlie Root
parents: 21
diff changeset
273 }
1
5821049f1791 most of the way to allowing arbitrarily many labels
Charlie Root
parents: 0
diff changeset
274 }
2
c828b0fd4a6e fix missing line to store changed labels
Charlie Root
parents: 1
diff changeset
275 $args['prefs']['tb_label_custom_labels'] = $tb_lab_prefs;
23
5a851d965bc1 sorting, some better displays
Charlie Root
parents: 21
diff changeset
276 $args['prefs']['tb_label_parm_labels'] = $tb_parm_prefs;
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
277 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
278
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
279 return $args;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
280 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
281
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
282 public function show_tb_label_contextmenu($args)
26
b2b6c0af2383 remove _ from name, lots of other hacks to get label context menu working
Charlie Root
parents: 25
diff changeset
283 # never called?
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
284 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
285 #$this->api->output->add_label('copymessage.copyingmessage');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
286 $li = html::tag('li',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
287 array('class' => 'submenu'),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
288 '<span>'.rcube::Q($this->gettext('tb_label_contextmenu_title')).'</span>' . $this->_gen_label_submenu($args, 'tb_label_ctxm_submenu'));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
289 $out .= html::tag('ul', array('id' => 'tb_label_ctxm_mainmenu'), $li);
29
ea061c743982 localise title and label exactly once each :-)
Charlie Root
parents: 27
diff changeset
290 #rcube::write_log('lab',"stblc $out");
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
291 $this->api->output->add_footer(html::div(array('style' => 'display: none;'), $out));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
292 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
293
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
294 private function _gen_label_submenu($args, $id)
26
b2b6c0af2383 remove _ from name, lots of other hacks to get label context menu working
Charlie Root
parents: 25
diff changeset
295 # never called?
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
296 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
297 $out = '';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
298 $custom_labels = $this->rc->config->get('tb_label_custom_labels');
1
5821049f1791 most of the way to allowing arbitrarily many labels
Charlie Root
parents: 0
diff changeset
299 $max_id = $this->rc->config->get('tb_max_label');
5821049f1791 most of the way to allowing arbitrarily many labels
Charlie Root
parents: 0
diff changeset
300 for ($i = 0; $i <= $max_id; $i++)
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
301 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
302 $separator = ($i == 0)? ' separator_below' :'';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
303 $out .= '<li class="label'.$i.$separator.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
304 ' ctxm_tb_label"><a href="#ctxm_tb_label" class="active" onclick="rcmail_ctxm_label_set('.$i.')"><span>'.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
305 $i.' '.$custom_labels[$i].
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
306 '</span></a></li>';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
307 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
308 $out = html::tag('ul', array('class' => 'popupmenu toolbarmenu folders', 'id' => $id), $out);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
309 return $out;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
310 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
311
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
312 public function read_single_flags($args)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
313 {
9
7a7f68b4358e allow open-ended label inventory
Charlie Root
parents: 2
diff changeset
314 #rcube::write_log($this->name, print_r(($args['object']), true));
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
315 if (!isset($args['object'])) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
316 return;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
317 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
318
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
319 if (is_array($args['object']->headers->flags))
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
320 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
321 $this->message_tb_labels = array();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
322 foreach ($args['object']->headers->flags as $flagname => $flagvalue)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
323 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
324 $flag = is_numeric("$flagvalue")? $flagname:$flagvalue;// for compatibility with < 0.5.4
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
325 $flag = strtolower($flag);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
326 if (preg_match('/^\$?label/', $flag))
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
327 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
328 $flag_no = preg_replace('/^\$?label/', '', $flag);
35
05c4c32948af .hgignore: add vendor tree
Charlie Root
parents: 31
diff changeset
329 #rcube::write_log($this->name, "Single message Flag: ".$flag." Flag_no:".$flag_no);
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
330 $this->message_tb_labels[] = (int)$flag_no;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
331 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
332 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
333 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
334 # -- no return value for this hook
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
335 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
336
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
337 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
338 * Writes labelnumbers for single message display
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
339 * Coloring of Message header table happens via Javascript
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
340 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
341 public function color_headers($p)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
342 {
9
7a7f68b4358e allow open-ended label inventory
Charlie Root
parents: 2
diff changeset
343 #rcube::write_log($this->name, print_r($p, true));
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
344 # -- always write array, even when empty
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
345 $p['content'] .= '<script type="text/javascript">
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
346 var tb_labels_for_message = ['.join(',', $this->message_tb_labels).'];
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
347 </script>';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
348 return $p;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
349 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
350
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
351 public function read_flags($args)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
352 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
353 // add color information for all messages
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
354 // dont loop over all messages if we dont have any highlights or no msgs
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
355 if (!isset($args['messages']) or !is_array($args['messages'])) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
356 return $args;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
357 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
358 // loop over all messages and add $LabelX info to the extra_flags
24
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
359 $mbox = $this->rc->output->get_env('mailbox') ?: $this->rc->storage->get_folder();
29
ea061c743982 localise title and label exactly once each :-)
Charlie Root
parents: 27
diff changeset
360 #rcube::write_log($this->name, "mbox: $mbox");
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
361 foreach($args['messages'] as $message)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
362 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
363 $message->list_flags['extra_flags']['tb_labels'] = array(); # always set extra_flags, needed for javascript later!
24
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
364 $message->list_flags['extra_flags']['tb_lparms'] = array();
23
5a851d965bc1 sorting, some better displays
Charlie Root
parents: 21
diff changeset
365 $keyPos = array_search($_SESSION['sort_col'],$this->rc->config->get('tb_label_parm_labels'));
29
ea061c743982 localise title and label exactly once each :-)
Charlie Root
parents: 27
diff changeset
366 #rcube::write_log($this->name,"sort? $keyPos ".$_SESSION['sort_order']." ".print_r($this->rc->config->get('tb_label_parm_labels'),true));
21
678dcc5152a8 restore mistaken deletion
Charlie Root
parents: 20
diff changeset
367 if (is_array($message->flags))
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
368 foreach ($message->flags as $flagname => $flagvalue)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
369 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
370 $flag = is_numeric("$flagvalue")? $flagname:$flagvalue;// for compatibility with < 0.5.4
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
371 $flag = strtolower($flag);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
372 if (preg_match('/^\$?label/', $flag))
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
373 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
374 $flag_no = preg_replace('/^\$?label/', '', $flag);
29
ea061c743982 localise title and label exactly once each :-)
Charlie Root
parents: 27
diff changeset
375 #rcube::write_log($this->name, "Flag:".$flag." Flag_no:".$flag_no);
20
c3a974bdb435 a bit further on flag+parm
Charlie Root
parents: 19
diff changeset
376 if ($ppos = strpos($flag_no,'_') > -1) {
c3a974bdb435 a bit further on flag+parm
Charlie Root
parents: 19
diff changeset
377 // We have a flag parameter value...
23
5a851d965bc1 sorting, some better displays
Charlie Root
parents: 21
diff changeset
378 $pn=(int)substr($flag_no,0,$ppos);
5a851d965bc1 sorting, some better displays
Charlie Root
parents: 21
diff changeset
379 $pv=substr($flag_no,$ppos+1);
20
c3a974bdb435 a bit further on flag+parm
Charlie Root
parents: 19
diff changeset
380 $message->list_flags['extra_flags']['tb_lparms'][]=array(
23
5a851d965bc1 sorting, some better displays
Charlie Root
parents: 21
diff changeset
381 'number' => $pn,
5a851d965bc1 sorting, some better displays
Charlie Root
parents: 21
diff changeset
382 'parm' => $pv);
24
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
383 if ($keyPos && $message->depth==0) {
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
384 $message->sortKey=array_map('intval',preg_split('#[/-]#',$pv));
23
5a851d965bc1 sorting, some better displays
Charlie Root
parents: 21
diff changeset
385 }
20
c3a974bdb435 a bit further on flag+parm
Charlie Root
parents: 19
diff changeset
386 }
c3a974bdb435 a bit further on flag+parm
Charlie Root
parents: 19
diff changeset
387 else {
c3a974bdb435 a bit further on flag+parm
Charlie Root
parents: 19
diff changeset
388 $message->list_flags['extra_flags']['tb_labels'][] = (int)$flag_no;
c3a974bdb435 a bit further on flag+parm
Charlie Root
parents: 19
diff changeset
389 }
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
390 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
391 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
392 }
23
5a851d965bc1 sorting, some better displays
Charlie Root
parents: 21
diff changeset
393 if ($keyPos) {
5a851d965bc1 sorting, some better displays
Charlie Root
parents: 21
diff changeset
394 $rev = $_SESSION['sort_order']=='DESC';
24
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
395 $datesSort =
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
396 function($a, $b) use ($rev) {
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
397 if ($ak=$a->sortKey) {
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
398 if ($bk=$b->sortKey) {
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
399 // each key is sd sm ed em
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
400 if ($ak[1]<$bk[1]) return $rev?1:-1;
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
401 if ($ak[1]>$bk[1]) return $rev?-1:1;
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
402 // start month is the same
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
403 if ($ak[0]<$bk[0]) return $rev?1:-1;
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
404 if ($ak[0]>$bk[0]) return $rev?-1:1;
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
405 // start date is the same
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
406 if ($ak[3]<$bk[3]) return $rev?1:-1;
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
407 if ($ak[3]>$bk[3]) return $rev?-1:1;
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
408 // end month is the same
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
409 if ($ak[2]<$bk[2]) return $rev?1:-1;
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
410 if ($ak[2]>$bk[2]) return $rev?-1:1;
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
411 // both dates are the same
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
412 return 0;
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
413 }
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
414 else {
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
415 return $rev?1:-1;
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
416 }
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
417 }
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
418 else if ($b->sortKey) {
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
419 return $rev?-1:1;
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
420 }
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
421 else {
23
5a851d965bc1 sorting, some better displays
Charlie Root
parents: 21
diff changeset
422 return 0;
5a851d965bc1 sorting, some better displays
Charlie Root
parents: 21
diff changeset
423 }
24
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
424 };
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
425 if ($this->rc->config->get('message_threading')[$mbox]) {
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
426 // The threading information is contained in three fields:
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
427 // depth, parent_uid and uid
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
428 // I _think_ if you gave every depth0 message its dates as key
25
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
429 // every depth>0 [already sorted by date, see list.inc:71]
24
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
430 // Then first sort all the depth0 messages into a new array
25
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
431 // then iterate over them, pull all depth1 with shared parent
24
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
432 // insert after parent
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
433 // repeat at depth 1, etc.
25
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
434 $sm = array(); // sorted result accumulates here
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
435 $rm = array(); // unprocessed remnant
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
436 foreach ($args['messages'] as $m) {
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
437 if ($m->depth===0) {
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
438 $sm[]=$m;
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
439 }
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
440 else {
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
441 $rm[]=$m;
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
442 }
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
443 }
27
e097905863b9 turn off logging
Charlie Root
parents: 26
diff changeset
444 #rcube::write_log($this->name,"ts0: |".$rm[0]->depth."| |".($rm[0]->depth===0)."|");
25
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
445 usort($sm,$datesSort);
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
446 $depth=0;
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
447 $foundSome=true;
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
448 while ($foundSome) {
27
e097905863b9 turn off logging
Charlie Root
parents: 26
diff changeset
449 #rcube::write_log($this->name,"ts: $depth ".count($sm).' '.count($rm));
25
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
450 $foundSome=false;
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
451 $tsm = array();
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
452 $trm = array();
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
453 foreach ($sm as $m) {
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
454 $tsm[]=$m;
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
455 if ($m->depth===$depth) {
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
456 $puid = $m->uid;
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
457 foreach ($rm as $c) {
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
458 if ($c->parent_uid===$puid) {
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
459 $tsm[]=$c;
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
460 $foundSome=true;
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
461 }
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
462 else {
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
463 $trm[]=$c;
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
464 }
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
465 }
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
466 $rm = $trm;
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
467 $trm = array();
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
468 }
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
469 }
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
470 $sm = $tsm;
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
471 $depth+=1;
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
472 }
4b2bc456ce42 threaded dates sort working
Charlie Root
parents: 24
diff changeset
473 $args['messages']=$sm;
24
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
474 }
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
475 else {
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
476 usort($args['messages'],$datesSort);
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
477 }
23
5a851d965bc1 sorting, some better displays
Charlie Root
parents: 21
diff changeset
478 }
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
479 return($args);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
480 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
481
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
482 // set flags in IMAP server
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
483 function set_flags()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
484 {
29
ea061c743982 localise title and label exactly once each :-)
Charlie Root
parents: 27
diff changeset
485 #rcube::write_log($this->name, "set: ".print_r($_GET, true));
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
486
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
487 $imap = $this->rc->imap;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
488 $cbox = rcube_utils::get_input_value('_cur', rcube_utils::INPUT_GET);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
489 $mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_GET);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
490 $toggle_label = rcube_utils::get_input_value('_toggle_label', rcube_utils::INPUT_GET);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
491 $flag_uids = rcube_utils::get_input_value('_flag_uids', rcube_utils::INPUT_GET);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
492 $flag_uids = explode(',', $flag_uids);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
493 $unflag_uids = rcube_utils::get_input_value('_unflag_uids', rcube_utils::INPUT_GET);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
494 $unflag_uids = explode(',', $unflag_uids);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
495
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
496 $imap->conn->flags = array_merge($imap->conn->flags, $this->add_tb_flags);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
497
9
7a7f68b4358e allow open-ended label inventory
Charlie Root
parents: 2
diff changeset
498 #rcube::write_log($this->name, print_r($flag_uids, true));
7a7f68b4358e allow open-ended label inventory
Charlie Root
parents: 2
diff changeset
499 #rcube::write_log($this->name, print_r($unflag_uids, true));
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
500
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
501 if (!is_array($unflag_uids)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
502 || !is_array($flag_uids))
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
503 return false;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
504
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
505 $imap->set_flag($flag_uids, $toggle_label, $mbox);
24
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
506 // belt and braces
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
507 if (count($unflag_uids)>0) {
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
508 $flaggedMsgs = $imap->list_flags($mbox,$unflag_uids);
27
e097905863b9 turn off logging
Charlie Root
parents: 26
diff changeset
509 #rcube::write_log($this->name,'oldFlags: '.print_r($flaggedMsgs,true));
24
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
510 $fullFlags=array();
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
511 foreach ($flaggedMsgs as $uid => $flags) {
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
512 foreach ($flags as $flag => $x) {
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
513 $pos=strpos(strtolower($flag),$toggle_label);
27
e097905863b9 turn off logging
Charlie Root
parents: 26
diff changeset
514 #rcube::write_log($this->name,"flag?: $flag $toggle_label $pos");
24
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
515 if ($pos>-1 && $pos<2 && !in_array($flag,$fullFlags)) {
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
516 $fullFlags[]=$flag;
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
517 }
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
518 }
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
519 }
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
520 if (count($fullFlags)==0) {
27
e097905863b9 turn off logging
Charlie Root
parents: 26
diff changeset
521 #rcube::write_log('errors',"no full flags for $toggle_label in ".print_r($flaggedMsgs,true));
24
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
522 $imap->set_flag($unflag_uids, "UN$toggle_label", $mbox);
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
523 }
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
524 else {
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
525 foreach ($fullFlags as $flag) {
27
e097905863b9 turn off logging
Charlie Root
parents: 26
diff changeset
526 #rcube::write_log($this->name,"UNsetting $flag in $mbox for ".join(',',$unflag_uids));
24
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
527 $imap->set_flag($unflag_uids, "UN$flag", $mbox);
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
528 }
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
529 }
4869fae20b88 do better at flag deletion, unthreaded dates sort working, preparing for threaded
Charlie Root
parents: 23
diff changeset
530 }
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
531 $this->api->output->send();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
532 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
533
26
b2b6c0af2383 remove _ from name, lots of other hacks to get label context menu working
Charlie Root
parents: 25
diff changeset
534 function tblabelpopup()
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
535 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
536 $custom_labels = $this->rc->config->get('tb_label_custom_labels');
1
5821049f1791 most of the way to allowing arbitrarily many labels
Charlie Root
parents: 0
diff changeset
537 $max_id = $this->rc->config->get('tb_max_label');
26
b2b6c0af2383 remove _ from name, lots of other hacks to get label context menu working
Charlie Root
parents: 25
diff changeset
538 $out = '<div id="tblabelpopup" class="popupmenu">
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
539 <ul class="toolbarmenu">';
1
5821049f1791 most of the way to allowing arbitrarily many labels
Charlie Root
parents: 0
diff changeset
540 for ($i = 0; $i <= $max_id; $i++)
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
541 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
542 $separator = ($i == 0)? ' separator_below' :'';
26
b2b6c0af2383 remove _ from name, lots of other hacks to get label context menu working
Charlie Root
parents: 25
diff changeset
543 $out .= '<li class="label'.$i.$separator.'"><a href="#" id="tblabel'.$i.'" class="active">'.$i.' '.$custom_labels[$i].'</a></li>';
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
544 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
545 $out .= '</ul>
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
546 </div>';
26
b2b6c0af2383 remove _ from name, lots of other hacks to get label context menu working
Charlie Root
parents: 25
diff changeset
547 $this->rc->output->add_gui_object('tblabelpopup_obj', 'tblabelpopup');
27
e097905863b9 turn off logging
Charlie Root
parents: 26
diff changeset
548 #rcube::write_log('lab',"tblp $out");
26
b2b6c0af2383 remove _ from name, lots of other hacks to get label context menu working
Charlie Root
parents: 25
diff changeset
549 $this->rc->output->add_footer($out);
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
550 }
31
b2d0a9781472 add whitelisting
Charlie Root
parents: 29
diff changeset
551
b2d0a9781472 add whitelisting
Charlie Root
parents: 29
diff changeset
552 public static function whiteMessage($data) {
b2d0a9781472 add whitelisting
Charlie Root
parents: 29
diff changeset
553 require_once 'Mail/RFC822.php';
35
05c4c32948af .hgignore: add vendor tree
Charlie Root
parents: 31
diff changeset
554 $message = $data['message'];
05c4c32948af .hgignore: add vendor tree
Charlie Root
parents: 31
diff changeset
555 $hdrs = $message->headers();
31
b2d0a9781472 add whitelisting
Charlie Root
parents: 29
diff changeset
556 $to = $hdrs['To'];
b2d0a9781472 add whitelisting
Charlie Root
parents: 29
diff changeset
557 $cc = $hdrs['Cc'];
35
05c4c32948af .hgignore: add vendor tree
Charlie Root
parents: 31
diff changeset
558 $util = new Mail_RFC822();
05c4c32948af .hgignore: add vendor tree
Charlie Root
parents: 31
diff changeset
559 $addrs = $util->parseAddressList($to);
31
b2d0a9781472 add whitelisting
Charlie Root
parents: 29
diff changeset
560 if ($cc) {
35
05c4c32948af .hgignore: add vendor tree
Charlie Root
parents: 31
diff changeset
561 foreach ($util->parseAddressList($cc) as $addr) {
31
b2d0a9781472 add whitelisting
Charlie Root
parents: 29
diff changeset
562 $addrs[]=$addr;
b2d0a9781472 add whitelisting
Charlie Root
parents: 29
diff changeset
563 }
b2d0a9781472 add whitelisting
Charlie Root
parents: 29
diff changeset
564 }
b2d0a9781472 add whitelisting
Charlie Root
parents: 29
diff changeset
565 #rcube::write_log('lab',"cc: ".print_r($cca,true));
b2d0a9781472 add whitelisting
Charlie Root
parents: 29
diff changeset
566 $wp = popen("/usr/local/bin/makeWhite.sh >>/var/log/white.log 2>&1",'w');
b2d0a9781472 add whitelisting
Charlie Root
parents: 29
diff changeset
567 foreach ($addrs as $addr) {
b2d0a9781472 add whitelisting
Charlie Root
parents: 29
diff changeset
568 fwrite($wp,$addr->mailbox.'@'.$addr->host."\n");
b2d0a9781472 add whitelisting
Charlie Root
parents: 29
diff changeset
569 }
b2d0a9781472 add whitelisting
Charlie Root
parents: 29
diff changeset
570 fclose($wp);
b2d0a9781472 add whitelisting
Charlie Root
parents: 29
diff changeset
571 return $data;
b2d0a9781472 add whitelisting
Charlie Root
parents: 29
diff changeset
572 }
b2d0a9781472 add whitelisting
Charlie Root
parents: 29
diff changeset
573
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
574 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
575