Fix #1532 : Add checkbox on feed creation to disable email notifications

This commit is contained in:
Romain Neutron
2013-10-22 11:09:29 +02:00
parent 7bfe89a15e
commit 22b2dddcf8
6 changed files with 24 additions and 5 deletions

View File

@@ -58,7 +58,7 @@ class Feed implements ControllerProviderInterface
$author_name = $request->request->get('author_name'); $author_name = $request->request->get('author_name');
$author_mail = $request->request->get('author_mail'); $author_mail = $request->request->get('author_mail');
$entry = \Feed_Entry_Adapter::create($app, $feed, $publisher, $title, $subtitle, $author_name, $author_mail); $entry = \Feed_Entry_Adapter::create($app, $feed, $publisher, $title, $subtitle, $author_name, $author_mail, $request->request->get('notify'));
$publishing = RecordsRequest::fromRequest($app, $request, true, array(), array('bas_chupub')); $publishing = RecordsRequest::fromRequest($app, $request, true, array(), array('bas_chupub'));

View File

@@ -508,7 +508,7 @@ class Feed_Entry_Adapter implements Feed_Entry_Interface, cache_cacheableInterfa
} }
public static function create(Application $app, Feed_Adapter $feed public static function create(Application $app, Feed_Adapter $feed
, Feed_Publisher_Adapter $publisher, $title, $subtitle, $author_name, $author_mail) , Feed_Publisher_Adapter $publisher, $title, $subtitle, $author_name, $author_mail, $notify = true)
{ {
if ( ! $feed->is_publisher($publisher->get_user())) { if ( ! $feed->is_publisher($publisher->get_user())) {
throw new Exception_Feed_PublisherNotFound("Publisher not found"); throw new Exception_Feed_PublisherNotFound("Publisher not found");
@@ -544,7 +544,7 @@ class Feed_Entry_Adapter implements Feed_Entry_Interface, cache_cacheableInterfa
$entry = new self($app, $feed, $entry_id); $entry = new self($app, $feed, $entry_id);
$app['events-manager']->trigger('__FEED_ENTRY_CREATE__', array('entry_id' => $entry_id), $entry); $app['events-manager']->trigger('__FEED_ENTRY_CREATE__', array('entry_id' => $entry_id, 'notify_email' => (Boolean) $notify), $entry);
return $entry; return $entry;
} }

View File

@@ -45,7 +45,8 @@ class eventsmanager_notify_feed extends eventsmanager_notifyAbstract
public function fire($event, $params, &$entry) public function fire($event, $params, &$entry)
{ {
$params = array( $params = array(
'entry_id' => $entry->get_id() 'entry_id' => $entry->get_id(),
'notify_email' => $params['notify_email'],
); );
$dom_xml = new DOMDocument('1.0', 'UTF-8'); $dom_xml = new DOMDocument('1.0', 'UTF-8');
@@ -91,7 +92,7 @@ class eventsmanager_notify_feed extends eventsmanager_notifyAbstract
/* @var $user_to_notif \User_Adapter */ /* @var $user_to_notif \User_Adapter */
$mailed = false; $mailed = false;
if ($this->shouldSendNotificationFor($user_to_notif->get_id())) { if ($params['notify_email'] && $this->shouldSendNotificationFor($user_to_notif->get_id())) {
$readyToSend = false; $readyToSend = false;
try { try {
$token = $this->app['tokens']->getUrlToken( $token = $this->app['tokens']->getUrlToken(

View File

@@ -39,6 +39,8 @@
{% set title = publishing.basket().getName() %} {% set title = publishing.basket().getName() %}
{% set desc = publishing.basket().getDescription() %} {% set desc = publishing.basket().getDescription() %}
{% endif %} {% endif %}
<input class="required_text checkbox" checked="checked" type="checkbox" name="notify" id="feed_add_notify" value="1" />
<label for="feed_add_notify">{% trans 'Notify users about this publication' %}</label><br/>
<label for="feed_add_title">{% trans 'publication : titre' %}</label> <label for="feed_add_title">{% trans 'publication : titre' %}</label>
<input class="required_text" type="text" name="title" id="feed_add_title" value="{{title}}" /> <input class="required_text" type="text" name="title" id="feed_add_title" value="{{title}}" />
<label for="feed_add_subtitle">{% trans 'publication : sous titre' %}</label> <label for="feed_add_subtitle">{% trans 'publication : sous titre' %}</label>

View File

@@ -3203,6 +3203,14 @@ dans l'onglet thesaurus : arbres, menus contextuels
margin: 3px 0 10px 0; margin: 3px 0 10px 0;
} }
#modal_feed form label {
display:inline;
}
#modal_feed form input.checkbox {
width: 20px;
}
#modal_feed form textarea { #modal_feed form textarea {
height: 60px; height: 60px;
resize: none; resize: none;

View File

@@ -3283,6 +3283,14 @@ dans l'onglet thesaurus : arbres, menus contextuels
margin: 3px 0 10px 0; margin: 3px 0 10px 0;
} }
#modal_feed form label {
display:inline;
}
#modal_feed form input.checkbox {
width: 20px;
}
#modal_feed form textarea { #modal_feed form textarea {
height: 60px; height: 60px;
resize: none; resize: none;