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