Mercurial > hg > rc1
changeset 9:7a7f68b4358e
allow open-ended label inventory
author | Charlie Root |
---|---|
date | Sat, 13 Jan 2018 09:37:16 -0500 |
parents | 899c8c6a0519 |
children | 9f4e3a3141ca |
files | plugins/thunderbird_labels/.#thunderbird_labels.js# plugins/thunderbird_labels/tb_label.js plugins/thunderbird_labels/thunderbird_labels.php |
diffstat | 3 files changed, 27 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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;
--- 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'), '<span>'.rcube::Q($this->gettext('tb_label_contextmenu_title')).'</span>' . $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'] .= '<script type="text/javascript"> var tb_labels_for_message = ['.join(',', $this->message_tb_labels).']; @@ -308,7 +311,7 @@ public function read_flags($args) { - rcube::write_log($this->name, print_r($args, true)); + #rcube::write_log($this->name, print_r($args, true)); // add color information for all messages // dont loop over all messages if we dont have any highlights or no msgs if (!isset($args['messages']) or !is_array($args['messages'])) { @@ -318,7 +321,7 @@ // loop over all messages and add $LabelX info to the extra_flags foreach($args['messages'] as $message) { - rcube::write_log($this->name, print_r($message->flags, true)); + #rcube::write_log($this->name, print_r($message->flags, true)); $message->list_flags['extra_flags']['tb_labels'] = array(); # always set extra_flags, needed for javascript later! if (is_array($message->flags)) foreach ($message->flags as $flagname => $flagvalue) @@ -328,7 +331,7 @@ if (preg_match('/^\$?label/', $flag)) { $flag_no = preg_replace('/^\$?label/', '', $flag); - rcube::write_log($this->name, "Flag:".$flag." Flag_no:".$flag_no); + #rcube::write_log($this->name, "Flag:".$flag." Flag_no:".$flag_no); $message->list_flags['extra_flags']['tb_labels'][] = (int)$flag_no; } } @@ -339,7 +342,7 @@ // set flags in IMAP server function set_flags() { - rcube::write_log($this->name, print_r($_GET, true)); + #rcube::write_log($this->name, print_r($_GET, true)); $imap = $this->rc->imap; $cbox = rcube_utils::get_input_value('_cur', rcube_utils::INPUT_GET); @@ -352,8 +355,8 @@ $imap->conn->flags = array_merge($imap->conn->flags, $this->add_tb_flags); - rcube::write_log($this->name, print_r($flag_uids, true)); - rcube::write_log($this->name, print_r($unflag_uids, true)); + #rcube::write_log($this->name, print_r($flag_uids, true)); + #rcube::write_log($this->name, print_r($unflag_uids, true)); if (!is_array($unflag_uids) || !is_array($flag_uids))