Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recipient placeholder in email wrapper #1297

Merged
merged 14 commits into from Aug 26, 2022
Merged
60 changes: 37 additions & 23 deletions adm_program/modules/preferences/preferences.php
Expand Up @@ -513,6 +513,24 @@ function getPreferencePanel($group, $id, $parentId, $title, $icon, $body)
$formValues['mail_sendmail_name'],
array('maxLength' => 50, 'helpTextIdInline' => 'SYS_SENDER_NAME_DESC')
);

// Add js to show or hide mail options
$page->addJavascript('
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if this is the best place to add it or if there is any "default" js how to handle things like this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

until now we have no default to handle things like this. But a default could be useful :-)

$(function(){
var fieldsToHideOnSingleMode = "#mail_recipients_with_roles_group, #mail_into_to_group, #mail_number_recipients_group";
if($("#mail_sending_mode").val() == 1) {
$(fieldsToHideOnSingleMode).hide();
}
$("#mail_sending_mode").on("change", function() {
if($("#mail_sending_mode").val() == 1) {
$(fieldsToHideOnSingleMode).hide();
} else {
$(fieldsToHideOnSingleMode).show();
}
});
});
');

$selectBoxEntries = array(0 => $gL10n->get('SYS_MAIL_BULK'), 1 => $gL10n->get('SYS_MAIL_SINGLE'));
$formEmailDispatch->addSelectBox(
'mail_sending_mode',
Expand All @@ -521,30 +539,26 @@ function getPreferencePanel($group, $id, $parentId, $title, $icon, $body)
array('defaultValue' => $formValues['mail_sending_mode'], 'showContextDependentFirstEntry' => false, 'helpTextIdInline' => 'SYS_MAIL_SENDING_MODE_DESC')
);

$sendingMode = $gSettingsManager->getInt('mail_sending_mode');
$selectBoxEntries = array(0 => $gL10n->get('SYS_HIDDEN'), 1 => $gL10n->get('SYS_SENDER'), 2 => $gL10n->get('SYS_ADMINISTRATOR'));
$formEmailDispatch->addSelectBox(
'mail_recipients_with_roles',
$gL10n->get('SYS_MULTIPLE_RECIPIENTS'),
$selectBoxEntries,
array('defaultValue' => $formValues['mail_recipients_with_roles'], 'showContextDependentFirstEntry' => false, 'helpTextIdInline' => 'SYS_MULTIPLE_RECIPIENTS_DESC')
);
$formEmailDispatch->addCheckbox(
'mail_into_to',
$gL10n->get('SYS_INTO_TO'),
(bool) $formValues['mail_into_to'],
array('helpTextIdInline' => 'SYS_INTO_TO_DESC')
);
$formEmailDispatch->addInput(
'mail_number_recipients',
$gL10n->get('SYS_NUMBER_RECIPIENTS'),
$formValues['mail_number_recipients'],
array('type' => 'number', 'minNumber' => 0, 'maxNumber' => 9999, 'step' => 1, 'helpTextIdInline' => 'SYS_NUMBER_RECIPIENTS_DESC')
);

// Only show this options if SendingMode = 0 / SYS_MAIL_BULK
if($sendingMode == 0) {
$selectBoxEntries = array(0 => $gL10n->get('SYS_HIDDEN'), 1 => $gL10n->get('SYS_SENDER'), 2 => $gL10n->get('SYS_ADMINISTRATOR'));
$formEmailDispatch->addSelectBox(
'mail_recipients_with_roles',
$gL10n->get('SYS_MULTIPLE_RECIPIENTS'),
$selectBoxEntries,
array('defaultValue' => $formValues['mail_recipients_with_roles'], 'showContextDependentFirstEntry' => false, 'helpTextIdInline' => 'SYS_MULTIPLE_RECIPIENTS_DESC')
);
$formEmailDispatch->addCheckbox(
'mail_into_to',
$gL10n->get('SYS_INTO_TO'),
(bool) $formValues['mail_into_to'],
array('helpTextIdInline' => 'SYS_INTO_TO_DESC')
);
$formEmailDispatch->addInput(
'mail_number_recipients',
$gL10n->get('SYS_NUMBER_RECIPIENTS'),
$formValues['mail_number_recipients'],
array('type' => 'number', 'minNumber' => 0, 'maxNumber' => 9999, 'step' => 1, 'helpTextIdInline' => 'SYS_NUMBER_RECIPIENTS_DESC')
);
}
$selectBoxEntries = array('iso-8859-1' => $gL10n->get('SYS_ISO_8859_1'), 'utf-8' => $gL10n->get('SYS_UTF8'));
$formEmailDispatch->addSelectBox(
'mail_character_encoding',
Expand Down