# HG changeset patch # User Charlie Root # Date 1515854236 18000 # Node ID 7a7f68b4358eae9135213e605c804d044ea354c7 # Parent 899c8c6a0519db378c31b8eca049abcedc911fce allow open-ended label inventory diff -r 899c8c6a0519 -r 7a7f68b4358e plugins/thunderbird_labels/.#thunderbird_labels.js# --- a/plugins/thunderbird_labels/.#thunderbird_labels.js# Sat Jan 13 09:21:07 2018 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -root@markup.co.uk.2365 \ No newline at end of file diff -r 899c8c6a0519 -r 7a7f68b4358e plugins/thunderbird_labels/tb_label.js --- a/plugins/thunderbird_labels/tb_label.js Sat Jan 13 09:21:07 2018 -0500 +++ b/plugins/thunderbird_labels/tb_label.js Sat Jan 13 09:37:16 2018 -0500 @@ -35,6 +35,7 @@ { if (typeof rcmail.env == 'undefined' || typeof rcmail.env.messages == 'undefined') return; + var max_id = rcmail.env.tb_max_label; var message = rcmail.env.messages[uid]; var rowobj = $(row.obj); // add span container for little colored bullets @@ -181,7 +182,8 @@ function rcm_tb_label_create_popupmenu() { - for (i = 0; i < 7; i++) + var max_id = rcmail.env.tb_max_label; + for (i = 0; i <= max_id; i++) { var cur_a = $('li.label' + i +' a'); @@ -197,7 +199,8 @@ function rcm_tb_label_init_onclick() { - for (i = 0; i < 7; i++) + var max_id = rcmail.env.tb_max_label; + for (i = 0; i <= max_id ; i++) { // find the "HTML a tags" of tb-label submenus var cur_a = $('#tb_label_popup li.label' + i +' a'); @@ -213,16 +216,17 @@ return; var from = toggle_label_no; - var to = toggle_label_no + 1; + var to = toggle_label_no; var unset_all = false; // special case flag 0 means remove all flags if (toggle_label_no == 0) { from = 1; - to = 7; + to = rcmail.env.tb_max_label; +; unset_all = true; } - for (i = from; i < to; i++) + for (i = from; i <= to; i++) { toggle_label = 'label' + i; toggle_label_no = i; diff -r 899c8c6a0519 -r 7a7f68b4358e plugins/thunderbird_labels/thunderbird_labels.php --- a/plugins/thunderbird_labels/thunderbird_labels.php Sat Jan 13 09:21:07 2018 -0500 +++ b/plugins/thunderbird_labels/thunderbird_labels.php Sat Jan 13 09:37:16 2018 -0500 @@ -32,7 +32,11 @@ // disable plugin according to prefs return; - // pass 'tb_label_enable_shortcuts' and 'tb_label_style' prefs to JS + // how many labels? + $max_id = $this->rc->config->get('tb_max_label'); + // pass 'tb_max_label', 'tb_label_enable_shortcuts' + // and 'tb_label_style' prefs to JS + $this->rc->output->set_env('tb_max_label', $max_id); $this->rc->output->set_env('tb_label_enable_shortcuts', $this->rc->config->get('tb_label_enable_shortcuts')); $this->rc->output->set_env('tb_label_style', $this->rc->config->get('tb_label_style')); @@ -46,7 +50,6 @@ $this->name = get_class($this); # -- additional TB flags $this->add_tb_flags = array(); - $max_id = $this->rc->config->get('tb_max_label'); for ($i = 1; $i <= $max_id; $i++) { $this->add_tb_flags['LABEL'.$i]='$Label'.$i; } @@ -77,10 +80,10 @@ { if ($this->rc->action == 'list') $this->add_hook('render_mailboxlist', array($this, 'show_tb_label_contextmenu')); - rcube::write_log('lab','ctxt: '.$this->rc->action); + #rcube::write_log('lab','ctxt: '.$this->rc->action); } else { - rcube::write_log('lab','no ctxt'); + #rcube::write_log('lab','no ctxt'); } } elseif ($this->rc->task == 'settings') @@ -207,7 +210,7 @@ // save prefs after modified in UI public function prefs_save($args) { - rcube::write_log('lab','saving: '.print_r($args,true)); + #rcube::write_log('lab','saving: '.print_r($args,true)); if ($args['section'] != 'thunderbird_labels') return $args; @@ -242,7 +245,7 @@ public function show_tb_label_contextmenu($args) { #$this->api->output->add_label('copymessage.copyingmessage'); - rcube::write_log('lab',"stblc"); + #rcube::write_log('lab',"stblc"); $li = html::tag('li', array('class' => 'submenu'), ''.rcube::Q($this->gettext('tb_label_contextmenu_title')).'' . $this->_gen_label_submenu($args, 'tb_label_ctxm_submenu')); @@ -269,7 +272,7 @@ public function read_single_flags($args) { - rcube::write_log($this->name, print_r(($args['object']), true)); + #rcube::write_log($this->name, print_r(($args['object']), true)); if (!isset($args['object'])) { return; } @@ -284,7 +287,7 @@ if (preg_match('/^\$?label/', $flag)) { $flag_no = preg_replace('/^\$?label/', '', $flag); - rcube::write_log($this->name, "Single message Flag: ".$flag." Flag_no:".$flag_no); + #rcube::write_log($this->name, "Single message Flag: ".$flag." Flag_no:".$flag_no); $this->message_tb_labels[] = (int)$flag_no; } } @@ -298,7 +301,7 @@ */ public function color_headers($p) { - rcube::write_log($this->name, print_r($p, true)); + #rcube::write_log($this->name, print_r($p, true)); # -- always write array, even when empty $p['content'] .= '