@@ -501,7 +501,7 @@ public static function send_message(
501
501
if ($ allowPauseFormation ) {
502
502
$ extraFieldValue = new ExtraFieldValue ('user ' );
503
503
$ allowEmailNotifications = $ extraFieldValue ->get_values_by_handler_and_field_variable (
504
- $ receiverUserInfo [ ' user_id ' ] ,
504
+ $ receiverUserId ,
505
505
'allow_notifications '
506
506
);
507
507
@@ -518,25 +518,29 @@ public static function send_message(
518
518
}
519
519
520
520
if ($ sendEmail ) {
521
- $ startDate = $ extraFieldValue ->get_values_by_handler_and_field_variable (
522
- $ receiverUserInfo ['user_id ' ],
523
- 'start_pause_date '
524
- );
525
- $ endDate = $ extraFieldValue ->get_values_by_handler_and_field_variable (
526
- $ receiverUserInfo ['user_id ' ],
527
- 'end_pause_date '
528
- );
529
-
530
- if (
531
- !empty ($ startDate ) && isset ($ startDate ['value ' ]) && !empty ($ startDate ['value ' ]) &&
532
- !empty ($ endDate ) && isset ($ endDate ['value ' ]) && !empty ($ endDate ['value ' ])
533
- ) {
534
- $ now = time ();
535
- $ start = api_strtotime ($ startDate ['value ' ]);
536
- $ end = api_strtotime ($ startDate ['value ' ]);
521
+ // Check if user pause his formation.
522
+ $ pause = $ extraFieldValue ->get_values_by_handler_and_field_variable ($ receiverUserId , 'pause_formation ' );
523
+ if (!empty ($ pause ) && isset ($ pause ['value ' ]) && 1 === (int ) $ pause ['value ' ]) {
524
+ $ startDate = $ extraFieldValue ->get_values_by_handler_and_field_variable (
525
+ $ receiverUserInfo ['user_id ' ],
526
+ 'start_pause_date '
527
+ );
528
+ $ endDate = $ extraFieldValue ->get_values_by_handler_and_field_variable (
529
+ $ receiverUserInfo ['user_id ' ],
530
+ 'end_pause_date '
531
+ );
537
532
538
- if ($ now > $ start && $ now < $ end ) {
539
- $ sendEmail = false ;
533
+ if (
534
+ !empty ($ startDate ) && isset ($ startDate ['value ' ]) && !empty ($ startDate ['value ' ]) &&
535
+ !empty ($ endDate ) && isset ($ endDate ['value ' ]) && !empty ($ endDate ['value ' ])
536
+ ) {
537
+ $ now = time ();
538
+ $ start = api_strtotime ($ startDate ['value ' ]);
539
+ $ end = api_strtotime ($ startDate ['value ' ]);
540
+
541
+ if ($ now > $ start && $ now < $ end ) {
542
+ $ sendEmail = false ;
543
+ }
540
544
}
541
545
}
542
546
}
0 commit comments