diff plugins/thunderbird_labels/thunderbird_labels.php @ 35:05c4c32948af

.hgignore: add vendor tree composer.json: new packages plugins/thunderbird_labels/thunderbird_labels.php: change hook and RFC822 use wrt whitelisting to avoid deprecated stuff index.php: commented debugging hooks others: new releases of vendor packages?
author Charlie Root
date Thu, 30 Aug 2018 16:21:59 -0400
parents b2d0a9781472
children
line wrap: on
line diff
--- a/plugins/thunderbird_labels/thunderbird_labels.php	Sun May 27 16:53:56 2018 -0400
+++ b/plugins/thunderbird_labels/thunderbird_labels.php	Thu Aug 30 16:21:59 2018 -0400
@@ -45,9 +45,7 @@
 			$this->add_hook('message_load', array($this, 'read_single_flags'));
 			$this->add_hook('template_object_messageheaders', array($this, 'color_headers'));
 			$this->add_hook('render_page', array($this, 'tblabelpopup'));
-			$this->add_hook('message_outgoing_headers', array($this, 'whiteMessage'));
-			# The above hook is described as 'Depracated', but no alternative for
-			#  non-intrusive access to the headers is available
+			$this->add_hook('message_ready', array($this, 'whiteMessage'));
 			$this->include_stylesheet($this->local_skin_path() . '/tb_label.css');
 			
 			$this->name = get_class($this);
@@ -89,7 +87,7 @@
 			// JS function "set_flags" => PHP function "set_flags"
 			$this->register_action('plugin.thunderbird_labels.set_flags', array($this, 'set_flags'));
     
-			rcube::write_log('lab','set_flags registered');
+			#rcube::write_log('lab','set_flags registered');
     
 			if (method_exists($this, 'require_plugin')
 				&& in_array('contextmenu', $this->rc->config->get('plugins'))
@@ -328,7 +326,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;
 				}
 			}
@@ -553,12 +551,14 @@
 
 	public static function whiteMessage($data) {
 	  require_once 'Mail/RFC822.php';
-	  $hdrs = $data['headers'];
+	  $message = $data['message'];
+	  $hdrs = $message->headers();
 	  $to = $hdrs['To'];
 	  $cc = $hdrs['Cc'];
-	  $addrs = Mail_RFC822::parseAddressList($to);
+	  $util = new Mail_RFC822();
+	  $addrs = $util->parseAddressList($to);
 	  if ($cc) {
-	    foreach (Mail_RFC822::parseAddressList($cc) as $addr) {
+	    foreach ($util->parseAddressList($cc) as $addr) {
 	      $addrs[]=$addr;
 	    }
 	  }