Update of /cvsroot/php-blog/serendipity/plugins/serendipity_event_mailer
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26896/serendipity_event_mailer
Added Files:
serendipity_event_mailer.php
Log Message:
New event plugins:
Content-Rewrite (hotwords-plugin, like the old one)
Mailer (mails entries via E-Mail)
Weblogping (performs XML-RPC weblog services pinging)
--- NEW FILE: serendipity_event_mailer.php ---
<?php # $Id: serendipity_event_mailer.php,v 1.1 2004/02/09 15:12:54 garvinhicking Exp $
switch ($serendipity['lang']) {
case 'de':
@define('PLUGIN_EVENT_MAILER_NAME', 'Artikel mailen');
@define('PLUGIN_EVENT_MAILER_DESC', 'Verschickt jeden neuen Artikel im Blog via E-Mail');
@define('PLUGIN_EVENT_MAILER_RECIPIENT', 'Mail-Empfänger');
@define('PLUGIN_EVENT_MAILER_RECIPIENTDESC', 'Die E-Mail Adresse an die die Artikel verschickt werden sollen (empfohlen: Eine Mailing-Liste)');
break;
case 'en':
case 'es':
default:
@define('PLUGIN_EVENT_MAILER_NAME', 'Mail entry');
@define('PLUGIN_EVENT_MAILER_DESC', 'Mails each new entry to your blog via E-Mail');
@define('PLUGIN_EVENT_MAILER_RECIPIENT', 'Mail recipient');
@define('PLUGIN_EVENT_MAILER_RECIPIENTDESC', 'E-Mail address you want to send the entries to (suggested: a mailing list)');
break;
}
class serendipity_event_mailer extends serendipity_event
{
function introspect(&$propbag)
{
global $serendipity;
$propbag->add('name', PLUGIN_EVENT_MAILER_NAME);
$propbag->add('description', PLUGIN_EVENT_MAILER_DESC);
$propbag->add('event_hooks', array(
'backend_publish' => true
));
$propbag->add('configuration', array('mailto'));
}
function introspect_config_item($name, &$propbag)
{
switch($name) {
case 'mailto':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_EVENT_MAILER_RECIPIENT);
$propbag->add('description', PLUGIN_EVENT_MAILER_RECIPIENTDESC);
break;
default:
break;
}
return true;
}
function generate_content(&$title) {
$title = 'Entry mailer';
}
function event_hook($event, &$bag, &$eventData) {
global $serendipity;
$hooks = &$bag->get('event_hooks');
if (isset($hooks[$event])) {
switch($event) {
case 'backend_publish':
$mail = array(
'to' => $this->get_config('mailto'),
'subject' => '[' . $serendipity['blogTitle'] . '] ' . $eventData['title'],
'body' => $eventData['body'] . $eventData['extended'] . $serendipity['signature'],
'from' => $serendipity['blogTitle'] . ' - ' . $eventData['author'] . ' <' . $serendipity['serendipityEmail'] . '>'
);
mail($mail['to'], $mail['subject'], $mail['body'], "From: {$mail['from']}\r\n{$serendipity['mailheaders']}");
return true;
break;
default:
return false;
break;
}
} else {
return false;
}
}
}
/* vim: set sts=4 ts=4 expandtab : */
?>
|