1<?php 2/** 3 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 4 * @author Matthias Schulte <dokuwiki@lupo49.de> 5 */ 6 7// must be run within Dokuwiki 8if (!defined('DOKU_INC')) die(); 9 10if (!defined('DOKU_LF')) define('DOKU_LF', "\n"); 11if (!defined('DOKU_TAB')) define('DOKU_TAB', "\t"); 12if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 13 14require_once(DOKU_PLUGIN.'action.php'); 15 16class action_plugin_sendpagecontent extends DokuWiki_Action_Plugin{ 17 18 function register(Doku_Event_Handler $controller) { 19 $controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'handle_act_preprocess', array()); 20 $controller->register_hook('TPL_ACT_UNKNOWN', 'BEFORE', $this, 'handle_tpl_act_unknown'); 21 } 22 23 /** 24 * Handles sendpagecontent action 25 */ 26 function handle_act_preprocess(&$event, $param) { 27 global $ID; 28 global $INFO; 29 global $conf; 30 31 if ($event->data == 'sendpagecontent') { 32 // we can handle it -> prevent others 33 $event->preventDefault(); 34 $event->stopPropagation(); 35 36 // fetch raw wiki code 37 $raw = rawWiki($ID); 38 $err = mail_send('HIER E-MAIL-ADRESSE EINTRAGEN', 'Automatic Mail from DokuWiki at ...', $raw, $this->getConf('mailfrom')); 39 40 if($err) { 41 msg('Mail sent.'); 42 } else { 43 msg('Mail failed'); 44 } 45 46 // We are done. Output normal page content. 47 $event->data = 'show'; 48 49 return true; 50 } 51 return true; 52 } 53 54 function handle_tpl_act_unknown(&$event, $param) { 55 global $ID; 56 if($event->data != 'sendpagecontent') return false; 57 $event->preventDefault(); 58 $event->stopPropagation(); 59 } 60} 61