Mercurial > hg > rc1
comparison plugins/thunderbird_labels/thunderbird_labels.php @ 19:49706603be30
begin to add UI support for parameterised labels, e.g. Dates
author | Charlie Root |
---|---|
date | Mon, 15 Jan 2018 10:29:29 -0500 |
parents | 7a7f68b4358e |
children | c3a974bdb435 |
comparison
equal
deleted
inserted
replaced
18:e8f197ce1af3 | 19:49706603be30 |
---|---|
188 { | 188 { |
189 $old = $this->rc->config->get($key); | 189 $old = $this->rc->config->get($key); |
190 $max_id = $this->rc->config->get('tb_max_label'); | 190 $max_id = $this->rc->config->get('tb_max_label'); |
191 for($i=1; $i<=$max_id; $i++) | 191 for($i=1; $i<=$max_id; $i++) |
192 { | 192 { |
193 $oldVal = $old[$i]; | |
194 $oname=substr($oldVal,0,-1); | |
195 $oparm=substr($oldVal,-1); | |
193 $input = new html_inputfield(array( | 196 $input = new html_inputfield(array( |
194 'name' => $key.$i, | 197 'name' => $key.$i, |
195 'id' => $key.$i, | 198 'id' => $key.$i, |
196 'type' => 'text', | 199 'type' => 'text', |
197 'autocomplete' => 'off', | 200 'autocomplete' => 'off', |
198 'value' => $old[$i])); | 201 'value' => $oname)); |
199 | 202 $parmBox = new html_checkbox(array( |
203 'name' => $key.$i.'parm', | |
204 'id' => $key.$i.'parm', | |
205 'value' => 1)); | |
200 $args['blocks']['tb_label']['options'][$key.$i] = array( | 206 $args['blocks']['tb_label']['options'][$key.$i] = array( |
201 'title' => $this->gettext('tb_label_label')." ".$i, | 207 'title' => $this->gettext('tb_label_label')." ".$i, |
202 'content' => $input->show() | 208 'content' => $input->show()." ".$parmBox->show($oparm) |
203 ); | 209 ); |
204 } | 210 } |
205 } | 211 } |
206 | 212 |
207 return $args; | 213 return $args; |
232 { | 238 { |
233 $max_id = $this->rc->config->get('tb_max_label'); | 239 $max_id = $this->rc->config->get('tb_max_label'); |
234 $tb_lab_prefs = array(); | 240 $tb_lab_prefs = array(); |
235 $tb_lab_prefs[0] = $this->gettext('label0'); | 241 $tb_lab_prefs[0] = $this->gettext('label0'); |
236 for ($i = 1; $i <= $max_id; $i++) { | 242 for ($i = 1; $i <= $max_id; $i++) { |
237 $tb_lab_prefs[$i] = rcube_utils::get_input_value('tb_label_custom_labels'.$i, rcube_utils::INPUT_POST); | 243 $parm=rcube_utils::get_input_value('tb_label_custom_labels'.$i.'parm', rcube_utils::INPUT_POST)?'1':'0'; |
244 $tb_lab_prefs[$i] = rcube_utils::get_input_value('tb_label_custom_labels'.$i, rcube_utils::INPUT_POST).$parm; | |
238 } | 245 } |
239 $args['prefs']['tb_label_custom_labels'] = $tb_lab_prefs; | 246 $args['prefs']['tb_label_custom_labels'] = $tb_lab_prefs; |
240 } | 247 } |
241 | 248 |
242 return $args; | 249 return $args; |
285 $flag = is_numeric("$flagvalue")? $flagname:$flagvalue;// for compatibility with < 0.5.4 | 292 $flag = is_numeric("$flagvalue")? $flagname:$flagvalue;// for compatibility with < 0.5.4 |
286 $flag = strtolower($flag); | 293 $flag = strtolower($flag); |
287 if (preg_match('/^\$?label/', $flag)) | 294 if (preg_match('/^\$?label/', $flag)) |
288 { | 295 { |
289 $flag_no = preg_replace('/^\$?label/', '', $flag); | 296 $flag_no = preg_replace('/^\$?label/', '', $flag); |
290 #rcube::write_log($this->name, "Single message Flag: ".$flag." Flag_no:".$flag_no); | 297 rcube::write_log($this->name, "Single message Flag: ".$flag." Flag_no:".$flag_no); |
291 $this->message_tb_labels[] = (int)$flag_no; | 298 $this->message_tb_labels[] = (int)$flag_no; |
292 } | 299 } |
293 } | 300 } |
294 } | 301 } |
295 # -- no return value for this hook | 302 # -- no return value for this hook |
309 return $p; | 316 return $p; |
310 } | 317 } |
311 | 318 |
312 public function read_flags($args) | 319 public function read_flags($args) |
313 { | 320 { |
314 #rcube::write_log($this->name, print_r($args, true)); | 321 rcube::write_log($this->name, "read: ".print_r($args, true)); |
315 // add color information for all messages | 322 // add color information for all messages |
316 // dont loop over all messages if we dont have any highlights or no msgs | 323 // dont loop over all messages if we dont have any highlights or no msgs |
317 if (!isset($args['messages']) or !is_array($args['messages'])) { | 324 if (!isset($args['messages']) or !is_array($args['messages'])) { |
318 return $args; | 325 return $args; |
319 } | 326 } |
329 $flag = is_numeric("$flagvalue")? $flagname:$flagvalue;// for compatibility with < 0.5.4 | 336 $flag = is_numeric("$flagvalue")? $flagname:$flagvalue;// for compatibility with < 0.5.4 |
330 $flag = strtolower($flag); | 337 $flag = strtolower($flag); |
331 if (preg_match('/^\$?label/', $flag)) | 338 if (preg_match('/^\$?label/', $flag)) |
332 { | 339 { |
333 $flag_no = preg_replace('/^\$?label/', '', $flag); | 340 $flag_no = preg_replace('/^\$?label/', '', $flag); |
334 #rcube::write_log($this->name, "Flag:".$flag." Flag_no:".$flag_no); | 341 rcube::write_log($this->name, "Flag:".$flag." Flag_no:".$flag_no); |
335 $message->list_flags['extra_flags']['tb_labels'][] = (int)$flag_no; | 342 $message->list_flags['extra_flags']['tb_labels'][] = (int)$flag_no; |
336 } | 343 } |
337 } | 344 } |
338 } | 345 } |
339 return($args); | 346 return($args); |
340 } | 347 } |
341 | 348 |
342 // set flags in IMAP server | 349 // set flags in IMAP server |
343 function set_flags() | 350 function set_flags() |
344 { | 351 { |
345 #rcube::write_log($this->name, print_r($_GET, true)); | 352 rcube::write_log($this->name, "set: ".print_r($_GET, true)); |
346 | 353 |
347 $imap = $this->rc->imap; | 354 $imap = $this->rc->imap; |
348 $cbox = rcube_utils::get_input_value('_cur', rcube_utils::INPUT_GET); | 355 $cbox = rcube_utils::get_input_value('_cur', rcube_utils::INPUT_GET); |
349 $mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_GET); | 356 $mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_GET); |
350 $toggle_label = rcube_utils::get_input_value('_toggle_label', rcube_utils::INPUT_GET); | 357 $toggle_label = rcube_utils::get_input_value('_toggle_label', rcube_utils::INPUT_GET); |