changeset 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 e8f197ce1af3
children c3a974bdb435
files plugins/thunderbird_labels/thunderbird_labels.php
diffstat 1 files changed, 15 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/thunderbird_labels/thunderbird_labels.php	Mon Jan 15 10:28:32 2018 -0500
+++ b/plugins/thunderbird_labels/thunderbird_labels.php	Mon Jan 15 10:29:29 2018 -0500
@@ -190,16 +190,22 @@
 			$max_id = $this->rc->config->get('tb_max_label');
 			for($i=1; $i<=$max_id; $i++)
 			{
+			  $oldVal = $old[$i];
+			  $oname=substr($oldVal,0,-1);
+			  $oparm=substr($oldVal,-1);
 				$input = new html_inputfield(array(
 					'name' => $key.$i,
 					'id' => $key.$i,
 					'type' => 'text',
 					'autocomplete' => 'off',
-					'value' => $old[$i]));
-			
+					'value' => $oname));
+				$parmBox = new html_checkbox(array(
+					     'name' => $key.$i.'parm',
+					     'id' => $key.$i.'parm',
+					     'value' => 1));
 				$args['blocks']['tb_label']['options'][$key.$i] = array(
 					'title' => $this->gettext('tb_label_label')." ".$i,
-					'content' => $input->show()
+					'content' => $input->show()."&nbsp;".$parmBox->show($oparm)
 					);
 			}
 		}
@@ -234,7 +240,8 @@
 		  $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);
+		    $parm=rcube_utils::get_input_value('tb_label_custom_labels'.$i.'parm', rcube_utils::INPUT_POST)?'1':'0';
+		    $tb_lab_prefs[$i] = rcube_utils::get_input_value('tb_label_custom_labels'.$i, rcube_utils::INPUT_POST).$parm;
 		  }
 		  $args['prefs']['tb_label_custom_labels'] = $tb_lab_prefs;
 		}
@@ -287,7 +294,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;
 				}
 			}
@@ -311,7 +318,7 @@
 	
 	public function read_flags($args)
 	{
-		#rcube::write_log($this->name, print_r($args, true));
+		rcube::write_log($this->name, "read: ".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'])) {
@@ -331,7 +338,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;
 				}
 			}
@@ -342,7 +349,7 @@
 	// set flags in IMAP server
 	function set_flags()
 	{
-		#rcube::write_log($this->name, print_r($_GET, true));
+		rcube::write_log($this->name, "set: ".print_r($_GET, true));
 
 		$imap = $this->rc->imap;
 		$cbox = rcube_utils::get_input_value('_cur', rcube_utils::INPUT_GET);