comparison 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
comparison
equal deleted inserted replaced
34:50ac5484d514 35:05c4c32948af
43 $this->include_script('tb_label.js'); 43 $this->include_script('tb_label.js');
44 $this->add_hook('messages_list', array($this, 'read_flags')); 44 $this->add_hook('messages_list', array($this, 'read_flags'));
45 $this->add_hook('message_load', array($this, 'read_single_flags')); 45 $this->add_hook('message_load', array($this, 'read_single_flags'));
46 $this->add_hook('template_object_messageheaders', array($this, 'color_headers')); 46 $this->add_hook('template_object_messageheaders', array($this, 'color_headers'));
47 $this->add_hook('render_page', array($this, 'tblabelpopup')); 47 $this->add_hook('render_page', array($this, 'tblabelpopup'));
48 $this->add_hook('message_outgoing_headers', array($this, 'whiteMessage')); 48 $this->add_hook('message_ready', array($this, 'whiteMessage'));
49 # The above hook is described as 'Depracated', but no alternative for
50 # non-intrusive access to the headers is available
51 $this->include_stylesheet($this->local_skin_path() . '/tb_label.css'); 49 $this->include_stylesheet($this->local_skin_path() . '/tb_label.css');
52 50
53 $this->name = get_class($this); 51 $this->name = get_class($this);
54 # -- additional TB flags 52 # -- additional TB flags
55 $this->add_tb_flags = array(); 53 $this->add_tb_flags = array();
87 ); 85 );
88 86
89 // JS function "set_flags" => PHP function "set_flags" 87 // JS function "set_flags" => PHP function "set_flags"
90 $this->register_action('plugin.thunderbird_labels.set_flags', array($this, 'set_flags')); 88 $this->register_action('plugin.thunderbird_labels.set_flags', array($this, 'set_flags'));
91 89
92 rcube::write_log('lab','set_flags registered'); 90 #rcube::write_log('lab','set_flags registered');
93 91
94 if (method_exists($this, 'require_plugin') 92 if (method_exists($this, 'require_plugin')
95 && in_array('contextmenu', $this->rc->config->get('plugins')) 93 && in_array('contextmenu', $this->rc->config->get('plugins'))
96 && $this->require_plugin('contextmenu') 94 && $this->require_plugin('contextmenu')
97 && $this->rc->config->get('tb_label_enable_contextmenu')) 95 && $this->rc->config->get('tb_label_enable_contextmenu'))
326 $flag = is_numeric("$flagvalue")? $flagname:$flagvalue;// for compatibility with < 0.5.4 324 $flag = is_numeric("$flagvalue")? $flagname:$flagvalue;// for compatibility with < 0.5.4
327 $flag = strtolower($flag); 325 $flag = strtolower($flag);
328 if (preg_match('/^\$?label/', $flag)) 326 if (preg_match('/^\$?label/', $flag))
329 { 327 {
330 $flag_no = preg_replace('/^\$?label/', '', $flag); 328 $flag_no = preg_replace('/^\$?label/', '', $flag);
331 rcube::write_log($this->name, "Single message Flag: ".$flag." Flag_no:".$flag_no); 329 #rcube::write_log($this->name, "Single message Flag: ".$flag." Flag_no:".$flag_no);
332 $this->message_tb_labels[] = (int)$flag_no; 330 $this->message_tb_labels[] = (int)$flag_no;
333 } 331 }
334 } 332 }
335 } 333 }
336 # -- no return value for this hook 334 # -- no return value for this hook
551 $this->rc->output->add_footer($out); 549 $this->rc->output->add_footer($out);
552 } 550 }
553 551
554 public static function whiteMessage($data) { 552 public static function whiteMessage($data) {
555 require_once 'Mail/RFC822.php'; 553 require_once 'Mail/RFC822.php';
556 $hdrs = $data['headers']; 554 $message = $data['message'];
555 $hdrs = $message->headers();
557 $to = $hdrs['To']; 556 $to = $hdrs['To'];
558 $cc = $hdrs['Cc']; 557 $cc = $hdrs['Cc'];
559 $addrs = Mail_RFC822::parseAddressList($to); 558 $util = new Mail_RFC822();
559 $addrs = $util->parseAddressList($to);
560 if ($cc) { 560 if ($cc) {
561 foreach (Mail_RFC822::parseAddressList($cc) as $addr) { 561 foreach ($util->parseAddressList($cc) as $addr) {
562 $addrs[]=$addr; 562 $addrs[]=$addr;
563 } 563 }
564 } 564 }
565 #rcube::write_log('lab',"cc: ".print_r($cca,true)); 565 #rcube::write_log('lab',"cc: ".print_r($cca,true));
566 $wp = popen("/usr/local/bin/makeWhite.sh >>/var/log/white.log 2>&1",'w'); 566 $wp = popen("/usr/local/bin/makeWhite.sh >>/var/log/white.log 2>&1",'w');