Pause training: Change setting allow_notifications to disable_emails

pull/3400/head
Julio Montoya 5 years ago
parent e8a4ed4a11
commit 2b069b59ad
  1. 7
      main/auth/pausetraining.php
  2. 2
      main/auth/profile.php
  3. 19
      main/inc/lib/message.lib.php
  4. 2
      main/webservices/api/tests/UpdateUserPauseTrainingTest.php
  5. 15
      plugin/pausetraining/PauseTraining.php
  6. 4
      plugin/pausetraining/lang/english.php
  7. 5
      plugin/pausetraining/lang/french.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);

@ -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

@ -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'],

@ -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);

@ -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'),
''
);
}

@ -1,5 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
$strings['plugin_title'] = "Pause training";
$strings['plugin_comment'] = "";
$strings['tool_enable'] = 'Enable plugin';
@ -10,7 +12,7 @@ $strings['cron_alert_users_if_inactive_days'] = 'Alert users if inactive days (v
$strings['PauseFormation'] = 'Pause my formation';
$strings['StartPauseDateTime'] = 'Start pause date';
$strings['EndPauseDateTime'] = 'End pause date';
$strings['AllowEmailNotification'] = 'Allow email notifications';
$strings['DisableEmails'] = 'Disable email notifications';
$strings['InactivityXDays'] = 'Inactivity for %s days';
$strings['YouAreConnectedInPlatformXLinkXSinceXDays'] = '
We have noticed that you have not connected to the platform %s (%s) for %s days.

@ -1,4 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
$strings['plugin_title'] = "Pause training";
$strings['plugin_comment'] = "";
$strings['tool_enable'] = 'Enable plugin';
@ -9,7 +12,7 @@ $strings['cron_alert_users_if_inactive_days'] = 'Alert users if inactive days (v
$strings['PauseFormation'] = 'Mettre en pause ma formation';
$strings['StartPauseDateTime'] = 'Date de début de pause';
$strings['EndPauseDateTime'] = 'Date de fin de pause';
$strings['AllowEmailNotification'] = 'Continuer à recevoir les mails de la plateforme';
$strings['DisableEmails'] = 'Désactiver les e-mails ';
$strings['InactivityXDays'] = 'Inactivité sur la plateforme depuis %s jours';
$strings['YouAreConnectedInPlatformXLinkXSinceXDays'] = '
Nous avons remarqué que vous ne vous êtes pas connecté à la plateforme %s (%s) depuis %s jours.

Loading…
Cancel
Save