Merge branch 'notifications'

This commit is contained in:
Loic d'Anterroches 2009-01-26 21:52:13 +01:00
commit 2ec653ad43
2 changed files with 28 additions and 0 deletions

View File

@ -159,6 +159,22 @@ class IDF_Form_Upload extends Pluf_Form
foreach ($tags as $tag) { foreach ($tags as $tag) {
$upload->setAssoc($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; return $upload;
} }
} }

View File

@ -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}