You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

show_additional_headers.php 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * Show additional message headers
  4. *
  5. * Proof-of-concept plugin which will fetch additional headers
  6. * and display them in the message view.
  7. *
  8. * Enable the plugin in config.inc.php and add your desired headers:
  9. * $config['show_additional_headers'] = array('User-Agent');
  10. *
  11. * @author Thomas Bruederli
  12. * @license GNU GPLv3+
  13. */
  14. class show_additional_headers extends rcube_plugin
  15. {
  16. public $task = 'mail';
  17. function init()
  18. {
  19. $rcmail = rcmail::get_instance();
  20. if ($rcmail->action == 'show' || $rcmail->action == 'preview') {
  21. $this->add_hook('storage_init', array($this, 'storage_init'));
  22. $this->add_hook('message_headers_output', array($this, 'message_headers'));
  23. } else if ($rcmail->action == '') {
  24. // with enabled_caching we're fetching additional headers before show/preview
  25. $this->add_hook('storage_init', array($this, 'storage_init'));
  26. }
  27. }
  28. function storage_init($p)
  29. {
  30. $rcmail = rcmail::get_instance();
  31. if ($add_headers = (array)$rcmail->config->get('show_additional_headers', array()))
  32. $p['fetch_headers'] = trim($p['fetch_headers'].' ' . strtoupper(join(' ', $add_headers)));
  33. return $p;
  34. }
  35. function message_headers($p)
  36. {
  37. $rcmail = rcmail::get_instance();
  38. foreach ((array)$rcmail->config->get('show_additional_headers', array()) as $header) {
  39. if ($value = $p['headers']->get($header))
  40. $p['output'][$header] = array('title' => $header, 'value' => $value);
  41. }
  42. return $p;
  43. }
  44. }