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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. * @version @package_version@
  12. * @author Thomas Bruederli
  13. * @license GNU GPLv3+
  14. */
  15. class show_additional_headers extends rcube_plugin
  16. {
  17. public $task = 'mail';
  18. function init()
  19. {
  20. $rcmail = rcmail::get_instance();
  21. if ($rcmail->action == 'show' || $rcmail->action == 'preview') {
  22. $this->add_hook('storage_init', array($this, 'storage_init'));
  23. $this->add_hook('message_headers_output', array($this, 'message_headers'));
  24. } else if ($rcmail->action == '') {
  25. // with enabled_caching we're fetching additional headers before show/preview
  26. $this->add_hook('storage_init', array($this, 'storage_init'));
  27. }
  28. }
  29. function storage_init($p)
  30. {
  31. $rcmail = rcmail::get_instance();
  32. if ($add_headers = (array)$rcmail->config->get('show_additional_headers', array()))
  33. $p['fetch_headers'] = trim($p['fetch_headers'].' ' . strtoupper(join(' ', $add_headers)));
  34. return $p;
  35. }
  36. function message_headers($p)
  37. {
  38. $rcmail = rcmail::get_instance();
  39. foreach ((array)$rcmail->config->get('show_additional_headers', array()) as $header) {
  40. if ($value = $p['headers']->get($header))
  41. $p['output'][$header] = array('title' => $header, 'value' => $value);
  42. }
  43. return $p;
  44. }
  45. }