From 22b2dddcf8cd56ea504fd6344d0085b65397a4ae Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 22 Oct 2013 11:09:29 +0200 Subject: [PATCH] Fix #1532 : Add checkbox on feed creation to disable email notifications --- lib/Alchemy/Phrasea/Controller/Prod/Feed.php | 2 +- lib/classes/Feed/Entry/Adapter.php | 4 ++-- lib/classes/eventsmanager/notify/feed.php | 5 +++-- templates/web/prod/actions/publish/publish.html.twig | 2 ++ www/skins/prod/000000/prodcolor.css | 8 ++++++++ www/skins/prod/959595/prodcolor.css | 8 ++++++++ 6 files changed, 24 insertions(+), 5 deletions(-) diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Feed.php b/lib/Alchemy/Phrasea/Controller/Prod/Feed.php index b85df97637..e13c099542 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Feed.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Feed.php @@ -58,7 +58,7 @@ class Feed implements ControllerProviderInterface $author_name = $request->request->get('author_name'); $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')); diff --git a/lib/classes/Feed/Entry/Adapter.php b/lib/classes/Feed/Entry/Adapter.php index ddf4c78856..8afe9b9953 100644 --- a/lib/classes/Feed/Entry/Adapter.php +++ b/lib/classes/Feed/Entry/Adapter.php @@ -508,7 +508,7 @@ class Feed_Entry_Adapter implements Feed_Entry_Interface, cache_cacheableInterfa } 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())) { 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); - $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; } diff --git a/lib/classes/eventsmanager/notify/feed.php b/lib/classes/eventsmanager/notify/feed.php index 5784bd9f5b..43f8845ed4 100644 --- a/lib/classes/eventsmanager/notify/feed.php +++ b/lib/classes/eventsmanager/notify/feed.php @@ -45,7 +45,8 @@ class eventsmanager_notify_feed extends eventsmanager_notifyAbstract public function fire($event, $params, &$entry) { $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'); @@ -91,7 +92,7 @@ class eventsmanager_notify_feed extends eventsmanager_notifyAbstract /* @var $user_to_notif \User_Adapter */ $mailed = false; - if ($this->shouldSendNotificationFor($user_to_notif->get_id())) { + if ($params['notify_email'] && $this->shouldSendNotificationFor($user_to_notif->get_id())) { $readyToSend = false; try { $token = $this->app['tokens']->getUrlToken( diff --git a/templates/web/prod/actions/publish/publish.html.twig b/templates/web/prod/actions/publish/publish.html.twig index 3bd4fcebfb..a9182d00e7 100644 --- a/templates/web/prod/actions/publish/publish.html.twig +++ b/templates/web/prod/actions/publish/publish.html.twig @@ -39,6 +39,8 @@ {% set title = publishing.basket().getName() %} {% set desc = publishing.basket().getDescription() %} {% endif %} + +
diff --git a/www/skins/prod/000000/prodcolor.css b/www/skins/prod/000000/prodcolor.css index 990ab13a14..7dd36cc001 100644 --- a/www/skins/prod/000000/prodcolor.css +++ b/www/skins/prod/000000/prodcolor.css @@ -3203,6 +3203,14 @@ dans l'onglet thesaurus : arbres, menus contextuels margin: 3px 0 10px 0; } +#modal_feed form label { + display:inline; +} + +#modal_feed form input.checkbox { + width: 20px; +} + #modal_feed form textarea { height: 60px; resize: none; diff --git a/www/skins/prod/959595/prodcolor.css b/www/skins/prod/959595/prodcolor.css index 991c6a9d15..9042ab4d5e 100644 --- a/www/skins/prod/959595/prodcolor.css +++ b/www/skins/prod/959595/prodcolor.css @@ -3283,6 +3283,14 @@ dans l'onglet thesaurus : arbres, menus contextuels margin: 3px 0 10px 0; } +#modal_feed form label { + display:inline; +} + +#modal_feed form input.checkbox { + width: 20px; +} + #modal_feed form textarea { height: 60px; resize: none;