From 938c92b0c128f75951cd3f19660be950ca6b7517 Mon Sep 17 00:00:00 2001 From: Thibaud Fabre Date: Mon, 2 Nov 2015 15:49:46 +0100 Subject: [PATCH] Disable demand status emails when mail notifications are disabled --- .../Controller/Admin/UserController.php | 18 +++++++++--------- lib/Alchemy/Phrasea/Model/Entities/User.php | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/Alchemy/Phrasea/Controller/Admin/UserController.php b/lib/Alchemy/Phrasea/Controller/Admin/UserController.php index a579125b5c..db7bc59ab2 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/UserController.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/UserController.php @@ -490,18 +490,18 @@ class UserController extends Controller }); unset ($cacheToUpdate); - $hookName = WebhookEvent::USER_REGISTRATION_REJECTED; - $hookType = WebhookEvent::USER_REGISTRATION_TYPE; - $hookData = [ - 'user_id' => $user->getId(), - 'granted' => [], - 'rejected' => [] - ]; - foreach ($done as $usr => $bases) { $user = $userRepository->find($usr); $acceptColl = $denyColl = []; + $hookName = WebhookEvent::USER_REGISTRATION_REJECTED; + $hookType = WebhookEvent::USER_REGISTRATION_TYPE; + $hookData = [ + 'user_id' => $user->getId(), + 'granted' => [], + 'rejected' => [] + ]; + foreach ($bases as $bas => $isok) { $collection = \collection::get_from_base_id($this->app, $bas); $label = $collection->get_label($this->app['locale']); @@ -518,7 +518,7 @@ class UserController extends Controller $this->app['manipulator.webhook-event']->create($hookName, $hookType, $hookData); - if (0 !== count($acceptColl) || 0 !== count($denyColl)) { + if ($user->hasMailNotificationsActivated() && (0 !== count($acceptColl) || 0 !== count($denyColl))) { $message = ''; if (0 !== count($acceptColl)) { $message .= "\n" . $this->app->trans('login::register:email: Vous avez ete accepte sur les collections suivantes : ') . implode(', ', $acceptColl). "\n"; diff --git a/lib/Alchemy/Phrasea/Model/Entities/User.php b/lib/Alchemy/Phrasea/Model/Entities/User.php index 26860008a4..04dce1d3ba 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/User.php +++ b/lib/Alchemy/Phrasea/Model/Entities/User.php @@ -1001,7 +1001,7 @@ class User } /** - * @return ArrayCollection + * @return ArrayCollection|UserNotificationSetting[] */ public function getNotificationSettings() {