Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lupo49 committed Nov 6, 2011
0 parents commit 2f2b002
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
====== sendpagecontent Plugin for DokuWiki ======

All documentation for the sendpagecontent Plugin is available online at:

* http://dokuwiki.org/plugin:sendpagecontent

(c) 2011 by Matthias Schulte <dokuwiki@lupo49.de>
60 changes: 60 additions & 0 deletions action.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Matthias Schulte <dokuwiki@lupo49.de>
*/

// must be run within Dokuwiki
if (!defined('DOKU_INC')) die();

if (!defined('DOKU_LF')) define('DOKU_LF', "\n");
if (!defined('DOKU_TAB')) define('DOKU_TAB', "\t");
if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');

require_once(DOKU_PLUGIN.'action.php');

class action_plugin_sendpagecontent extends DokuWiki_Action_Plugin{

function register(&$controller) {
$controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'handle_act_preprocess', array());
$controller->register_hook('TPL_ACT_UNKNOWN', 'BEFORE', $this, 'handle_tpl_act_unknown');
}

/**
* Handles sendmail action
*/
function handle_act_preprocess(&$event, $param) {
global $ID;
global $INFO;
global $conf;

if ($event->data == 'sendmail') {
// we can handle it -> prevent others
$event->preventDefault();
$event->stopPropagation();

// fetch raw wiki code
$raw = rawWiki($ID);
$err = mail_send('HIER E-MAIL-ADRESSE EINTRAGEN', 'Automatic Mail from DokuWiki at ...', $raw, $this->getConf('mailfrom'));

if($err) {
msg('Mail sent.');
} else {
msg('Mail failed');
}

// We are done. Output normal page content.
$event->data = 'show';

return true;
}
return true;
}

function handle_tpl_act_unknown(&$event, $param) {
global $ID;
if($event->data != 'sendmail') return false;
$event->preventDefault();
$event->stopPropagation();
}
}
6 changes: 6 additions & 0 deletions plugin.info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
author Matthias Schulte
email dokuwiki@lupo49.de
date 2011-11-06
name sendpagecontent
desc Send the raw page content to a given mail address
url http://dokuwiki.org/plugin:sendpagecontent

0 comments on commit 2f2b002

Please sign in to comment.