comparison plugins/thunderbird_labels/thunderbird_labels.php @ 31:b2d0a9781472

add whitelisting
author Charlie Root
date Tue, 13 Mar 2018 13:01:26 -0400
parents ea061c743982
children 05c4c32948af
comparison
equal deleted inserted replaced
30:7498e7cacd71 31:b2d0a9781472
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'));
49 # The above hook is described as 'Depracated', but no alternative for
50 # non-intrusive access to the headers is available
48 $this->include_stylesheet($this->local_skin_path() . '/tb_label.css'); 51 $this->include_stylesheet($this->local_skin_path() . '/tb_label.css');
49 52
50 $this->name = get_class($this); 53 $this->name = get_class($this);
51 # -- additional TB flags 54 # -- additional TB flags
52 $this->add_tb_flags = array(); 55 $this->add_tb_flags = array();
62 # ends up with display: none??? 65 # ends up with display: none???
63 # Bother, missed it, it's before this.container.show 66 # Bother, missed it, it's before this.container.show
64 # Afeter ul.appendnd -- inside menu.show on 307 67 # Afeter ul.appendnd -- inside menu.show on 307
65 # 567? Yes -- that's calling 'hide', but overriding 68 # 567? Yes -- that's calling 'hide', but overriding
66 # doesn't fix :-( 69 # doesn't fix :-(
67 #rcube::write_log('lab','add_button');
68 $this->add_button( 70 $this->add_button(
69 array( 71 array(
70 #'command' => 'plugin.thunderbird_labels.rcm_tb_label_submenu', 72 #'command' => 'plugin.thunderbird_labels.rcm_tb_label_submenu',
71 'name' => 'tblabellink', 73 'name' => 'tblabellink',
72 'id' => 'tblabelpopuplink', 74 'id' => 'tblabelpopuplink',
85 ); 87 );
86 88
87 // JS function "set_flags" => PHP function "set_flags" 89 // JS function "set_flags" => PHP function "set_flags"
88 $this->register_action('plugin.thunderbird_labels.set_flags', array($this, 'set_flags')); 90 $this->register_action('plugin.thunderbird_labels.set_flags', array($this, 'set_flags'));
89 91
92 rcube::write_log('lab','set_flags registered');
90 93
91 if (method_exists($this, 'require_plugin') 94 if (method_exists($this, 'require_plugin')
92 && in_array('contextmenu', $this->rc->config->get('plugins')) 95 && in_array('contextmenu', $this->rc->config->get('plugins'))
93 && $this->require_plugin('contextmenu') 96 && $this->require_plugin('contextmenu')
94 && $this->rc->config->get('tb_label_enable_contextmenu')) 97 && $this->rc->config->get('tb_label_enable_contextmenu'))
323 $flag = is_numeric("$flagvalue")? $flagname:$flagvalue;// for compatibility with < 0.5.4 326 $flag = is_numeric("$flagvalue")? $flagname:$flagvalue;// for compatibility with < 0.5.4
324 $flag = strtolower($flag); 327 $flag = strtolower($flag);
325 if (preg_match('/^\$?label/', $flag)) 328 if (preg_match('/^\$?label/', $flag))
326 { 329 {
327 $flag_no = preg_replace('/^\$?label/', '', $flag); 330 $flag_no = preg_replace('/^\$?label/', '', $flag);
328 #rcube::write_log($this->name, "Single message Flag: ".$flag." Flag_no:".$flag_no); 331 rcube::write_log($this->name, "Single message Flag: ".$flag." Flag_no:".$flag_no);
329 $this->message_tb_labels[] = (int)$flag_no; 332 $this->message_tb_labels[] = (int)$flag_no;
330 } 333 }
331 } 334 }
332 } 335 }
333 # -- no return value for this hook 336 # -- no return value for this hook
545 </div>'; 548 </div>';
546 $this->rc->output->add_gui_object('tblabelpopup_obj', 'tblabelpopup'); 549 $this->rc->output->add_gui_object('tblabelpopup_obj', 'tblabelpopup');
547 #rcube::write_log('lab',"tblp $out"); 550 #rcube::write_log('lab',"tblp $out");
548 $this->rc->output->add_footer($out); 551 $this->rc->output->add_footer($out);
549 } 552 }
553
554 public static function whiteMessage($data) {
555 require_once 'Mail/RFC822.php';
556 $hdrs = $data['headers'];
557 $to = $hdrs['To'];
558 $cc = $hdrs['Cc'];
559 $addrs = Mail_RFC822::parseAddressList($to);
560 if ($cc) {
561 foreach (Mail_RFC822::parseAddressList($cc) as $addr) {
562 $addrs[]=$addr;
563 }
564 }
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');
567 foreach ($addrs as $addr) {
568 fwrite($wp,$addr->mailbox.'@'.$addr->host."\n");
569 }
570 fclose($wp);
571 return $data;
572 }
573
550 } 574 }
551 575