From f2ad6e630bbe25bf4e3b17681f818f8903d51f3a Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Tue, 27 Feb 2018 16:23:46 +0100 Subject: [PATCH] Make notifications popup_or_email option to consider email only if user is not available. --- notifications/inc/class.notifications.inc.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/notifications/inc/class.notifications.inc.php b/notifications/inc/class.notifications.inc.php index c96de02177..d69836bc93 100644 --- a/notifications/inc/class.notifications.inc.php +++ b/notifications/inc/class.notifications.inc.php @@ -90,7 +90,7 @@ class notifications { 'email_only' => 'E-Mail only', 'all' => 'all possible notification backends', 'popup_only' => 'eGroupWare-Popup only', - 'popup_or_email' => 'eGroupWare-Popup first, if that fails notify me by E-Mail', + 'popup_or_email' => 'Email notifications only, if user is not logged in', 'popup_and_email' => 'eGroupWare-Popup and E-Mail', 'popup_and_winpopup' => 'eGroupWare-Popup and Windows-Popup', 'winpopup_only' => 'Windows-Popup only', @@ -552,6 +552,14 @@ class notifications { if (is_array($this->popup_data)) $popup_data = $this->popup_data; } $obj->send($this->prepend_message($messages, $prepend_message), $lsubject, $llinks, $this->attachments, $popup_data); + + // This is to make popup_or_email option sensfull since + // we save popup notifications in database anyway, email + // notifications should be based on user availability. + if ($backend == 'popup' && $action== 'fail' && !Api\Session::notifications_active($receiver->account_id)) + { + throw new Exception(); + } } catch (Exception $exception) { $backend_errors[] = $notification_backend.' failed: '.$exception->getMessage(); @@ -799,7 +807,7 @@ class notifications { 'appname' => $_appname, 'data' => $_data ); - + return true; } }