N°7157 - Fix usage of Enum case value

This commit is contained in:
Molkobain
2024-03-06 23:05:16 +01:00
parent 02efea4e55
commit e05b4e772c
4 changed files with 31 additions and 8 deletions

View File

@@ -83,7 +83,7 @@ class NotificationsCenterController extends Controller
// Add the action notification to the list of actions notifications for the trigger
$oActionsNotificationsByTrigger[$iTriggerId][] = $oSubscribedActionNotification;
// Add the subscribed status to the list of subscribed actions notifications for the trigger
$aSubscribedActionsNotificationsByTrigger[$iTriggerId][$oSubscribedActionNotification->GetKey()] = $oLnkActionsNotifications->Get('subscribed') || $oTrigger->Get('subscription_policy') === SubscriptionPolicy::ForceAllChannels;
$aSubscribedActionsNotificationsByTrigger[$iTriggerId][$oSubscribedActionNotification->GetKey()] = $oLnkActionsNotifications->Get('subscribed') || $oTrigger->Get('subscription_policy') === SubscriptionPolicy::ForceAllChannels->value;
}
// Build table rows
@@ -156,7 +156,7 @@ class NotificationsCenterController extends Controller
$oChannelSet->SetOptionsTemplate('application/object/set/option_renderer.html.twig');
$oChannelSet->SetItemsTemplate('application/preferences/notification-center/item_renderer.html.twig');
// Disable the input set if the subscription policy is 'force_all_channels'
if ($sTriggerSubscriptionPolicy === SubscriptionPolicy::ForceAllChannels) {
if ($sTriggerSubscriptionPolicy === SubscriptionPolicy::ForceAllChannels->value) {
$oChannelSet->SetIsDisabled(true);
}
// Add a CSRF Token
@@ -192,7 +192,7 @@ $.ajax({
JS
);
// Set the minimum number of channels to 1 if the subscription policy is {@see SubscriptionPolicy::ForceAtLeastOneChannel}
if($sTriggerSubscriptionPolicy === SubscriptionPolicy::ForceAtLeastOneChannel)
if($sTriggerSubscriptionPolicy === SubscriptionPolicy::ForceAtLeastOneChannel->value)
{
$oChannelSet->SetMinItems(1);
}
@@ -290,7 +290,7 @@ JS
// Add the action notification to the list of actions notifications for the trigger
$oActionsNotificationsByTrigger[$iTriggerId][] = $oSubscribedActionNotification;
// Add the subscribed status to the list of subscribed actions notifications for the trigger
$aSubscribedActionsNotificationsByTrigger[$iTriggerId][$oSubscribedActionNotification->GetKey()] = $oLnkActionsNotifications->Get('subscribed') || $oTrigger->Get('subscription_policy') === SubscriptionPolicy::ForceAllChannels;
$aSubscribedActionsNotificationsByTrigger[$iTriggerId][$oSubscribedActionNotification->GetKey()] = $oLnkActionsNotifications->Get('subscribed') || $oTrigger->Get('subscription_policy') === SubscriptionPolicy::ForceAllChannels->value;
}
$oPage->AddTabContainer('NotificationsCenter', '', $oNotificationsPanel);
@@ -492,7 +492,7 @@ JS
throw new \Exception('Invalid trigger');
}
// Check the trigger subscription policy
if ($oTrigger->Get('subscription_policy') === SubscriptionPolicy::ForceAllChannels) {
if ($oTrigger->Get('subscription_policy') === SubscriptionPolicy::ForceAllChannels->value) {
throw new \Exception('You are not allowed to unsubscribe from this channel');
}
@@ -502,7 +502,7 @@ JS
throw new \Exception('You are not subscribed to any channel');
}
// Check the trigger subscription policy and if we are subscribed to at least 1 channel if necessary
if($oTrigger->Get('subscription_policy') === SubscriptionPolicy::ForceAtLeastOneChannel) {
if($oTrigger->Get('subscription_policy') === SubscriptionPolicy::ForceAtLeastOneChannel->value) {
$oTotalSubscribedActionsNotificationsSet = NotificationsRepository::GetInstance()->SearchSubscriptionByTriggerContactAndSubscription($iTriggerId, \UserRights::GetContactId(), '1');
if (($oTotalSubscribedActionsNotificationsSet->Count() - $oSubscribedActionsNotificationsSet->Count()) === 0) {
throw new \Exception('You can\'t unsubscribe from this channel, you must be subscribed to at least one channel');