1<?php 2/** 3 * DokuWiki Plugin bez (Action Component) 4 * 5 */ 6 7// must be run within Dokuwiki 8if(!defined('DOKU_INC')) die(); 9 10class action_plugin_bez_maildebug extends DokuWiki_Action_Plugin { 11 12 /** 13 * Registers a callback function for a given event 14 * 15 * @param Doku_Event_Handler $controller DokuWiki's event controller object 16 * @return void 17 */ 18 public function register(Doku_Event_Handler $controller) 19 { 20 $controller->register_hook('MAIL_MESSAGE_SEND', 'BEFORE', $this, 'handle_debug', null, -3999); 21 } 22 23 /** 24 * [Custom event handler which performs action] 25 * 26 * @param Doku_Event $event event object by reference 27 * @param mixed $param [the parameters passed as fifth argument to register_hook() when this 28 * handler was registered] 29 * @return void 30 */ 31 public function handle_debug(Doku_Event &$event, $param) { 32 global $dryrun; 33 34 if ($dryrun) { 35 $event->preventDefault(); 36 $event->stopPropagation(); 37 38 $mail = $event->data['mail']; 39 $reflection = new \ReflectionClass($mail); 40 $property = $reflection->getProperty('html'); 41 $property->setAccessible(true); 42 $html = $property->getValue($mail); 43 echo "To: " . $event->data['to'] . "\n"; 44 echo $html; 45 echo "\n\n"; 46 } 47 } 48} 49