diff --git a/main/auth/pausetraining.php b/main/auth/pausetraining.php index d1fd8a0739..fbddef0d60 100644 --- a/main/auth/pausetraining.php +++ b/main/auth/pausetraining.php @@ -32,7 +32,7 @@ $return = $extraField->addElements( [], false, false, - ['pause_formation', 'start_pause_date', 'end_pause_date', 'allow_notifications'], + ['pause_formation', 'start_pause_date', 'end_pause_date'], [], [], false, @@ -54,11 +54,6 @@ if ($form->validate()) { if (!isset($values['extra_pause_formation'])) { $values['extra_pause_formation'] = 0; } - - if (!isset($values['extra_allow_notifications'])) { - $values['extra_allow_notifications'] = 0; - } - $extraField = new ExtraFieldValue('user'); $extraField->saveFieldValues($values, true, false, [], [], true); diff --git a/main/auth/profile.php b/main/auth/profile.php index df80a30723..f1a17c5457 100755 --- a/main/auth/profile.php +++ b/main/auth/profile.php @@ -348,7 +348,7 @@ if ($showPassword && $form->addHtml($extraLink); $extraField = new ExtraField('user'); -$return = $extraField->addElements($form, api_get_user_id()); +$return = $extraField->addElements($form, api_get_user_id(), ['pause_formation', 'start_pause_date', 'end_pause_date']); $jquery_ready_content = $return['jquery_ready_content']; // the $jquery_ready_content variable collects all functions that diff --git a/main/inc/lib/message.lib.php b/main/inc/lib/message.lib.php index 71b168f96d..3b21c271d2 100755 --- a/main/inc/lib/message.lib.php +++ b/main/inc/lib/message.lib.php @@ -500,26 +500,29 @@ class MessageManager if ($allowPauseFormation) { $extraFieldValue = new ExtraFieldValue('user'); - $allowEmailNotifications = $extraFieldValue->get_values_by_handler_and_field_variable( + $disableEmails = $extraFieldValue->get_values_by_handler_and_field_variable( $receiverUserId, - 'allow_notifications' + 'disable_emails' ); - // User doesn't want email notifications but chamilo inbox still available (Option was not set) - if (empty($allowEmailNotifications)) { + // User doesn't want email but chamilo inbox still available. + if (empty($disableEmails)) { $sendEmail = false; } - // User doesn't want email notifications but chamilo inbox still available. (Option was set to "No") - if (!empty($allowEmailNotifications) && - isset($allowEmailNotifications['value']) && 0 === (int) $allowEmailNotifications['value'] + // User doesn't want email notifications but chamilo inbox still available. + if (!empty($disableEmails) && + isset($disableEmails['value']) && 1 === (int) $disableEmails['value'] ) { $sendEmail = false; } if ($sendEmail) { // Check if user pause his formation. - $pause = $extraFieldValue->get_values_by_handler_and_field_variable($receiverUserId, 'pause_formation'); + $pause = $extraFieldValue->get_values_by_handler_and_field_variable( + $receiverUserId, + 'pause_formation' + ); if (!empty($pause) && isset($pause['value']) && 1 === (int) $pause['value']) { $startDate = $extraFieldValue->get_values_by_handler_and_field_variable( $receiverUserInfo['user_id'], diff --git a/main/webservices/api/tests/UpdateUserPauseTrainingTest.php b/main/webservices/api/tests/UpdateUserPauseTrainingTest.php index e8b54877ad..8018b80467 100644 --- a/main/webservices/api/tests/UpdateUserPauseTrainingTest.php +++ b/main/webservices/api/tests/UpdateUserPauseTrainingTest.php @@ -27,7 +27,7 @@ class UpdateUserPauseTrainingTest extends V2TestCase 'pause_formation' => 0, 'start_pause_date' => '2020-06-30 10:00', 'end_pause_date' => '2020-06-30 11:00', - 'allow_notifications' => 0, + 'disable_emails' => 1, ]; $userId = $this->integer($params); diff --git a/plugin/pausetraining/PauseTraining.php b/plugin/pausetraining/PauseTraining.php index 2f2f105473..decb17fbb3 100644 --- a/plugin/pausetraining/PauseTraining.php +++ b/plugin/pausetraining/PauseTraining.php @@ -36,7 +36,7 @@ class PauseTraining extends Plugin 'pause_formation', 'start_pause_date', 'end_pause_date', - 'allow_notifications', + 'disable_emails', ]; $valuesToUpdate = [ @@ -61,12 +61,12 @@ class PauseTraining extends Plugin $valuesToUpdate['extra_pause_formation']['extra_pause_formation'] = $pause; } - $notification = (int) $valuesToUpdate['extra_allow_notifications']; + $notification = (int) $valuesToUpdate['extra_disable_emails']; if (empty($notification)) { - $valuesToUpdate['extra_allow_notifications'] = 0; + $valuesToUpdate['extra_disable_emails'] = 0; } else { - $valuesToUpdate['extra_allow_notifications'] = []; - $valuesToUpdate['extra_allow_notifications']['extra_allow_notifications'] = $notification; + $valuesToUpdate['extra_disable_emails'] = []; + $valuesToUpdate['extra_disable_emails']['extra_disable_emails'] = $notification; } $check = DateTime::createFromFormat('Y-m-d H:i', $valuesToUpdate['extra_start_pause_date']); @@ -153,7 +153,6 @@ class PauseTraining extends Plugin if (!empty($usersNotificationPerDay)) { ksort($usersNotificationPerDay); - $extraFieldValue = new ExtraFieldValue('user'); foreach ($usersNotificationPerDay as $day => $userList) { $template = new Template(); $title = sprintf($this->get_lang('InactivityXDays'), $day); @@ -193,9 +192,9 @@ class PauseTraining extends Plugin ); UserManager::create_extra_field( - 'allow_notifications', + 'disable_emails', ExtraField::FIELD_TYPE_CHECKBOX, - $this->get_lang('AllowEmailNotification'), + $this->get_lang('DisableEmails'), '' ); } diff --git a/plugin/pausetraining/lang/english.php b/plugin/pausetraining/lang/english.php index aa64fe3294..1b6ab52bce 100644 --- a/plugin/pausetraining/lang/english.php +++ b/plugin/pausetraining/lang/english.php @@ -1,5 +1,7 @@