From be7cbabe8d5d44cbb687df5862b104cc4369a78b Mon Sep 17 00:00:00 2001 From: Loic d'Anterroches Date: Wed, 28 Jan 2009 14:59:51 +0100 Subject: [PATCH] Added the notification of changes for the documentation pages. --- src/IDF/Form/WikiCreate.php | 19 +++++++++++++++++ src/IDF/Form/WikiUpdate.php | 19 +++++++++++++++++ .../templates/idf/wiki/wiki-created-email.txt | 16 ++++++++++++++ .../templates/idf/wiki/wiki-updated-email.txt | 21 +++++++++++++++++++ 4 files changed, 75 insertions(+) create mode 100644 src/IDF/templates/idf/wiki/wiki-created-email.txt create mode 100644 src/IDF/templates/idf/wiki/wiki-updated-email.txt diff --git a/src/IDF/Form/WikiCreate.php b/src/IDF/Form/WikiCreate.php index ee1190f..caee52f 100644 --- a/src/IDF/Form/WikiCreate.php +++ b/src/IDF/Form/WikiCreate.php @@ -199,6 +199,25 @@ Add your content here. Format your content with: $rev->submitter = $this->user; $rev->summary = __('Initial page creation'); $rev->create(); + // send the notification + if ('' != $this->project->getConf()->getVal('wiki_notification_email', '')) { + $context = new Pluf_Template_Context( + array( + 'page' => $page, + 'rev' => $rev, + 'project' => $this->project, + 'url_base' => Pluf::f('url_base'), + ) + ); + $tmpl = new Pluf_Template('idf/wiki/wiki-created-email.txt'); + $text_email = $tmpl->render($context); + $email = new Pluf_Mail(Pluf::f('from_email'), + $this->project->getConf()->getVal('wiki_notification_email'), + sprintf(__('New Documentation Page %s - %s (%s)'), + $page->title, $page->summary, $this->project->shortname)); + $email->addTextMessage($text_email); + $email->sendMail(); + } return $page; } } diff --git a/src/IDF/Form/WikiUpdate.php b/src/IDF/Form/WikiUpdate.php index 06b2c4b..98b4253 100644 --- a/src/IDF/Form/WikiUpdate.php +++ b/src/IDF/Form/WikiUpdate.php @@ -236,6 +236,25 @@ class IDF_Form_WikiUpdate extends Pluf_Form $rev->summary = $this->cleaned_data['comment']; $rev->changes = $changes; $rev->create(); + // send the notification + if ('' != $this->project->getConf()->getVal('wiki_notification_email', '')) { + $context = new Pluf_Template_Context( + array( + 'page' => $this->page, + 'rev' => $rev, + 'project' => $this->project, + 'url_base' => Pluf::f('url_base'), + ) + ); + $tmpl = new Pluf_Template('idf/wiki/wiki-updated-email.txt'); + $text_email = $tmpl->render($context); + $email = new Pluf_Mail(Pluf::f('from_email'), + $this->project->getConf()->getVal('wiki_notification_email'), + sprintf(__('Documentation Page Changed %s - %s (%s)'), + $this->page->title, $this->page->summary, $this->project->shortname)); + $email->addTextMessage($text_email); + $email->sendMail(); + } return $this->page; } } diff --git a/src/IDF/templates/idf/wiki/wiki-created-email.txt b/src/IDF/templates/idf/wiki/wiki-created-email.txt new file mode 100644 index 0000000..884723d --- /dev/null +++ b/src/IDF/templates/idf/wiki/wiki-created-email.txt @@ -0,0 +1,16 @@ +{trans 'Hello,'} + +{blocktrans}A new documentation page has been created:{/blocktrans} + +{$page.title|safe} - {$page.summary|safe} +{trans 'Project:'} {$project.name|safe} +{trans 'Created by:'} {$rev.get_submitter|safe} +{assign $tags = $page.get_tags_list()}{if $tags.count()}{trans 'Labels:'} +{foreach $tags as $tag} {$tag.class|safe}:{$tag.name|safe} +{/foreach}{/if} +{trans 'Content:'} + +{$rev.content} + +-- +{trans 'Documentation page:'} {$url_base}{url 'IDF_Views_Wiki::view', array($project.shortname, $page.title)} diff --git a/src/IDF/templates/idf/wiki/wiki-updated-email.txt b/src/IDF/templates/idf/wiki/wiki-updated-email.txt new file mode 100644 index 0000000..8b53610 --- /dev/null +++ b/src/IDF/templates/idf/wiki/wiki-updated-email.txt @@ -0,0 +1,21 @@ +{trans 'Hello,'} + +{blocktrans}The following documentation page has been updated:{/blocktrans} + +{$page.title|safe} - {$page.summary|safe} +{trans 'Project:'} {$project.name|safe} +{trans 'Summary:'} {$rev.summary|safe} +{trans 'Updated by:'} {$page.get_submitter|safe} +{trans 'Created by:'} {$rev.get_submitter|safe} +{assign $tags = $page.get_tags_list()}{if $tags.count()}{trans 'Labels:'} +{foreach $tags as $tag} {$tag.class|safe}:{$tag.name|safe} +{/foreach}{/if}{if $rev.changedRevision()}{trans 'Changes:'} +{foreach $rev.changes as $w => $v} + {if $w == 'su'}{trans 'Summary:'}{/if}{if $w == 'lb'}{trans 'Labels:'}{/if} {if $w == 'lb'}{assign $l = implode(', ', $v)}{$l}{else}{$v}{/if}{/foreach}{/if} + +{trans 'New content:'} + +{$rev.content} + +-- +{trans 'Documentation page:'} {$url_base}{url 'IDF_Views_Wiki::view', array($project.shortname, $page.title)}