commit | author | age
|
48e9c1
|
1 |
<?php |
T |
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 |
* |
461a30
|
9 |
* Enable the plugin in config.inc.php and add your desired headers: |
bcedf0
|
10 |
* $config['show_additional_headers'] = array('User-Agent'); |
48e9c1
|
11 |
* |
T |
12 |
* @version @package_version@ |
|
13 |
* @author Thomas Bruederli |
07c6c6
|
14 |
* @license GNU GPLv3+ |
48e9c1
|
15 |
*/ |
T |
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) { |
eb78fd
|
45 |
if ($value = $p['headers']->get($header)) |
543895
|
46 |
$p['output'][$header] = array('title' => $header, 'value' => $value); |
48e9c1
|
47 |
} |
T |
48 |
|
|
49 |
return $p; |
|
50 |
} |
|
51 |
} |