Project owners can now enter multiple email addresses for each notification type.
Each email must be separated by a comma from the other. (Based on a patch from Pierre Marechal, fixes issue 372).
This commit is contained in:
parent
784c9718eb
commit
51c42a65c5
@ -309,13 +309,16 @@ class IDF_Commit extends Pluf_Model
|
||||
);
|
||||
$tmpl = new Pluf_Template('idf/source/commit-created-email.txt');
|
||||
$text_email = $tmpl->render($context);
|
||||
$addresses = explode(',', $conf->getVal('source_notification_email'));
|
||||
foreach ($addresses as $address) {
|
||||
$email = new Pluf_Mail(Pluf::f('from_email'),
|
||||
$conf->getVal('source_notification_email'),
|
||||
$address,
|
||||
sprintf(__('New Commit %s - %s (%s)'),
|
||||
$this->scm_id, $this->summary,
|
||||
$this->get_project()->shortname));
|
||||
$email->addTextMessage($text_email);
|
||||
$email->sendMail();
|
||||
}
|
||||
Pluf_Translation::loadSetLocale($current_locale);
|
||||
}
|
||||
}
|
||||
|
51
src/IDF/Form/Field/EmailList.php
Normal file
51
src/IDF/Form/Field/EmailList.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# This file is part of InDefero, an open source project management application.
|
||||
# Copyright (C) 2010 Céondo Ltd and contributors.
|
||||
#
|
||||
# Plume Framework is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Plume Framework is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/**
|
||||
* Similar to Pluf_Form_Field_Email, this form field validates one or more
|
||||
* email addresses separated by a comma
|
||||
*/
|
||||
class IDF_Form_Field_EmailList extends Pluf_Form_Field
|
||||
{
|
||||
public $widget = 'Pluf_Form_Widget_TextInput';
|
||||
|
||||
public function clean($value)
|
||||
{
|
||||
parent::clean($value);
|
||||
if (in_array($value, $this->empty_values)) {
|
||||
$value = '';
|
||||
}
|
||||
if ($value == '') {
|
||||
return $value;
|
||||
}
|
||||
$emails = preg_split('/\s*,\s*/', $value, -1, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($emails as $email) {
|
||||
if (!Pluf_Utils::isValidEmail($email)) {
|
||||
throw new Pluf_Form_Invalid(__(
|
||||
'Please enter one or more valid email addresses.'
|
||||
));
|
||||
}
|
||||
}
|
||||
return implode(',', $emails);
|
||||
}
|
||||
}
|
@ -63,10 +63,11 @@ class IDF_Form_TabsConf extends Pluf_Form
|
||||
'source_notification_email',
|
||||
'issues_notification_email',);
|
||||
foreach ($ak as $key) {
|
||||
$this->fields[$key] = new Pluf_Form_Field_Email(
|
||||
$this->fields[$key] = new IDF_Form_Field_EmailList(
|
||||
array('required' => false,
|
||||
'label' => $key,
|
||||
'initial' => $this->conf->getVal($key, ''),
|
||||
'widget_attrs' => array('size' => 40),
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -242,8 +242,10 @@ class IDF_Issue extends Pluf_Model
|
||||
$to_email = array();
|
||||
if ('' != $conf->getVal('issues_notification_email', '')) {
|
||||
$langs = Pluf::f('languages', array('en'));
|
||||
$to_email[] = array($conf->getVal('issues_notification_email'),
|
||||
$langs[0]);
|
||||
$addresses = explode(',', $conf->getVal('issues_notification_email'));
|
||||
foreach ($addresses as $address) {
|
||||
$to_email[] = array($address, $langs[0]);
|
||||
}
|
||||
}
|
||||
$current_locale = Pluf_Translation::getLocale();
|
||||
$id = '<'.md5($this->id.md5(Pluf::f('secret_key'))).'@'.Pluf::f('mail_host', 'localhost').'>';
|
||||
|
@ -197,14 +197,17 @@ class IDF_Review_Patch extends Pluf_Model
|
||||
);
|
||||
$tmpl = new Pluf_Template('idf/review/review-created-email.txt');
|
||||
$text_email = $tmpl->render($context);
|
||||
$addresses = explode(';',$conf->getVal('review_notification_email'));
|
||||
foreach ($addresses as $address) {
|
||||
$email = new Pluf_Mail(Pluf::f('from_email'),
|
||||
$conf->getVal('review_notification_email'),
|
||||
$address,
|
||||
sprintf(__('New Code Review %s - %s (%s)'),
|
||||
$this->get_review()->id,
|
||||
$this->get_review()->summary,
|
||||
$this->get_review()->get_project()->shortname));
|
||||
$email->addTextMessage($text_email);
|
||||
$email->sendMail();
|
||||
}
|
||||
Pluf_Translation::loadSetLocale($current_locale);
|
||||
}
|
||||
}
|
||||
|
@ -237,14 +237,16 @@ class IDF_Upload extends Pluf_Model
|
||||
));
|
||||
$tmpl = new Pluf_Template('idf/downloads/download-created-email.txt');
|
||||
$text_email = $tmpl->render($context);
|
||||
$addresses = explode(',', $conf->getVal('downloads_notification_email'));
|
||||
foreach ($addresses as $address) {
|
||||
$email = new Pluf_Mail(Pluf::f('from_email'),
|
||||
$conf->getVal('downloads_notification_email'),
|
||||
$address,
|
||||
sprintf(__('New download - %s (%s)'),
|
||||
$this->summary,
|
||||
$this->get_project()->shortname));
|
||||
$email->addTextMessage($text_email);
|
||||
$email->sendMail();
|
||||
|
||||
}
|
||||
Pluf_Translation::loadSetLocale($current_locale);
|
||||
}
|
||||
}
|
@ -272,11 +272,16 @@ class IDF_WikiRevision extends Pluf_Model
|
||||
}
|
||||
$tmpl = new Pluf_Template($template);
|
||||
$text_email = $tmpl->render($context);
|
||||
|
||||
$addresses = explode(',', $conf->getVal('wiki_notification_email'));
|
||||
foreach ($addresses as $address) {
|
||||
$email = new Pluf_Mail(Pluf::f('from_email'),
|
||||
$conf->getVal('wiki_notification_email'),
|
||||
$address,
|
||||
$title);
|
||||
$email->addTextMessage($text_email);
|
||||
$email->sendMail();
|
||||
}
|
||||
|
||||
Pluf_Translation::loadSetLocale($current_locale);
|
||||
}
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ password or SSH key.{/blocktrans}
|
||||
<div class="issue-submit-info">
|
||||
<p><strong>{trans 'Instructions:'}</strong></p>
|
||||
<p>{blocktrans}You can configure here the project tabs access rights and notification emails.{/blocktrans}</p>
|
||||
<p>{blocktrans}Notification emails will be sent from the <strong>{$from_email}</strong> address, if you send the email to a mailing list, you may need to register this email address. If you do not want to send emails for a given type of changes, simply leave the corresponding field empty.{/blocktrans}</p>
|
||||
<p>{blocktrans}Notification emails will be sent from the <strong>{$from_email}</strong> address, if you send the email to a mailing list, you may need to register this email address. Multiple email addresses must be separated through commas (','). If you do not want to send emails for a given type of changes, simply leave the corresponding field empty.{/blocktrans}</p>
|
||||
<p>{blocktrans}If you mark a project as private, only the project members and administrators, together with the extra authorized users you provide will have access to the project. You will still be able to define further access rights for the different tabs but the "Open to all" and "Signed in users" will default to authorized users only.{/blocktrans}</p>
|
||||
<p>{blocktrans}Specify each person by its login. Each person must have already registered with the given login. Separate the logins with commas and/or new lines.{/blocktrans}</p>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user