From b6922a0296ca72e23f6d8421b0a2cfa5cdbbda5e Mon Sep 17 00:00:00 2001 From: Loic d'Anterroches Date: Mon, 26 Jan 2009 21:51:51 +0100 Subject: [PATCH] Added the notifications on the new uploaded files. --- src/IDF/Form/Upload.php | 16 ++++++++++++++++ .../idf/downloads/download-created-email.txt | 12 ++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 src/IDF/templates/idf/downloads/download-created-email.txt diff --git a/src/IDF/Form/Upload.php b/src/IDF/Form/Upload.php index 91807fd..917a2f7 100644 --- a/src/IDF/Form/Upload.php +++ b/src/IDF/Form/Upload.php @@ -159,6 +159,22 @@ class IDF_Form_Upload extends Pluf_Form foreach ($tags as $tag) { $upload->setAssoc($tag); } + // Send the notification + if ('' != $this->project->getConf()->getVal('downloads_notification_email', '')) { + $context = new Pluf_Template_Context( + array('file' => $upload, + 'urlfile' => $upload->getAbsoluteUrl($this->project), + 'project' => $this->project, + 'tags' => $upload->get_tags_list(), + )); + $tmpl = new Pluf_Template('idf/downloads/download-created-email.txt'); + $text_email = $tmpl->render($context); + $email = new Pluf_Mail(Pluf::f('from_email'), $this->project->getConf()->getVal('downloads_notification_email'), + sprintf(__('New download - %s (%s)'), + $upload->summary, $this->project->shortname)); + $email->addTextMessage($text_email); + $email->sendMail(); + } return $upload; } } diff --git a/src/IDF/templates/idf/downloads/download-created-email.txt b/src/IDF/templates/idf/downloads/download-created-email.txt new file mode 100644 index 0000000..0022a39 --- /dev/null +++ b/src/IDF/templates/idf/downloads/download-created-email.txt @@ -0,0 +1,12 @@ +{trans 'Hello,'} + +{blocktrans}A new file is available for download:{/blocktrans} + +{$file.summary|safe} +{$file} - {$file.filesize|ssize} +{trans 'Project:'} {$project.name|safe} +{trans 'Submitted by:'} {$file.get_submitter|safe} +{if $tags.count()}{trans 'Labels:'} +{foreach $tags as $tag} {$tag.class|safe}:{$tag.name|safe} +{/foreach}{/if} +{trans 'Download:'} {$urlfile}