Mercurial > hg > rc1
diff plugins/thunderbird_labels/thunderbird_labels.php @ 1:5821049f1791
most of the way to allowing arbitrarily many labels
author | Charlie Root |
---|---|
date | Thu, 04 Jan 2018 16:23:36 -0500 |
parents | 1e000243b222 |
children | c828b0fd4a6e |
line wrap: on
line diff
--- a/plugins/thunderbird_labels/thunderbird_labels.php Thu Jan 04 15:50:29 2018 -0500 +++ b/plugins/thunderbird_labels/thunderbird_labels.php Thu Jan 04 16:23:36 2018 -0500 @@ -45,13 +45,11 @@ $this->name = get_class($this); # -- additional TB flags - $this->add_tb_flags = array( - 'LABEL1' => '$Label1', - 'LABEL2' => '$Label2', - 'LABEL3' => '$Label3', - 'LABEL4' => '$Label4', - 'LABEL5' => '$Label5', - ); + $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; + } $this->message_tb_labels = array(); $this->add_button( @@ -77,8 +75,12 @@ && $this->require_plugin('contextmenu') && $this->rc->config->get('tb_label_enable_contextmenu')) { - if ($this->rc->action == '') + if ($this->rc->action == 'list') $this->add_hook('render_mailboxlist', array($this, 'show_tb_label_contextmenu')); + rcube::write_log('lab','ctxt: '.$this->rc->action); + } + else { + rcube::write_log('lab','no ctxt'); } } elseif ($this->rc->task == 'settings') @@ -96,14 +98,13 @@ if (empty($c)) { // if no user specific labels, use localized strings by default - $this->rc->config->set('tb_label_custom_labels', array( - 0 => $this->getText('label0'), - 1 => $this->getText('label1'), - 2 => $this->getText('label2'), - 3 => $this->getText('label3'), - 4 => $this->getText('label4'), - 5 => $this->getText('label5') - )); + $max_id = $this->rc->config->get('tb_max_label'); + $tb_flag_text = array(); + for ($i = 0; $i <= $max_id; $i++) { + $tb_flag_text[$i] = $this->getText('label'.$i); + } + $this->rc->config->set('tb_label_custom_labels', + tb_flag_text); } // pass label strings to JS $this->rc->output->set_env('tb_label_custom_labels', $this->rc->config->get('tb_label_custom_labels')); @@ -183,7 +184,8 @@ && $this->rc->config->get('tb_label_modify_labels')) { $old = $this->rc->config->get($key); - for($i=1; $i<=5; $i++) + $max_id = $this->rc->config->get('tb_max_label'); + for($i=1; $i<=$max_id; $i++) { $input = new html_inputfield(array( 'name' => $key.$i, @@ -224,14 +226,12 @@ if (!in_array('tb_label_custom_labels', $dont_override) && $this->rc->config->get('tb_label_modify_labels')) { - $args['prefs']['tb_label_custom_labels'] = array( - 0 => $this->gettext('label0'), - 1 => rcube_utils::get_input_value('tb_label_custom_labels1', rcube_utils::INPUT_POST), - 2 => rcube_utils::get_input_value('tb_label_custom_labels2', rcube_utils::INPUT_POST), - 3 => rcube_utils::get_input_value('tb_label_custom_labels3', rcube_utils::INPUT_POST), - 4 => rcube_utils::get_input_value('tb_label_custom_labels4', rcube_utils::INPUT_POST), - 5 => rcube_utils::get_input_value('tb_label_custom_labels5', rcube_utils::INPUT_POST) - ); + $max_id = $this->rc->config->get('tb_max_label'); + $tb_lab_prefs = array(); + $tb_lab_prefs[0] = $this->gettext('label0'); + for ($i = 1; $i <= $max_id; $i++) { + $tb_lab_prefs[$i] = rcube_utils::get_input_value('tb_label_custom_labels'.$i, rcube_utils::INPUT_POST); + } } return $args; @@ -240,7 +240,7 @@ public function show_tb_label_contextmenu($args) { #$this->api->output->add_label('copymessage.copyingmessage'); - + 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')); @@ -252,7 +252,8 @@ { $out = ''; $custom_labels = $this->rc->config->get('tb_label_custom_labels'); - for ($i = 0; $i < 6; $i++) + $max_id = $this->rc->config->get('tb_max_label'); + for ($i = 0; $i <= $max_id; $i++) { $separator = ($i == 0)? ' separator_below' :''; $out .= '<li class="label'.$i.$separator. @@ -365,9 +366,10 @@ function tb_label_popup() { $custom_labels = $this->rc->config->get('tb_label_custom_labels'); + $max_id = $this->rc->config->get('tb_max_label'); $out = '<div id="tb_label_popup" class="popupmenu"> <ul class="toolbarmenu">'; - for ($i = 0; $i < 6; $i++) + for ($i = 0; $i <= $max_id; $i++) { $separator = ($i == 0)? ' separator_below' :''; $out .= '<li class="label'.$i.$separator.'"><a href="#" class="active">'.$i.' '.$custom_labels[$i].'</a></li>';