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