Fixes MailSubject and MailBody fields see #5772

skala
Yoselyn Castillo 12 years ago
parent 4b95af1b90
commit eaf32ec78d
  1. 86
      main/survey/survey_invite.php

@ -70,6 +70,13 @@ $tool_name = get_lang('SurveyPublication');
// Displaying the header // Displaying the header
Display::display_header($tool_name,'Survey'); Display::display_header($tool_name,'Survey');
echo '<script>
$(function() {
$("#check_mail").change(function() {
$("#mail_text").toggle();
});
});
</script>';
// Checking if there is another survey with this code. // Checking if there is another survey with this code.
// If this is the case there will be a language choice // If this is the case there will be a language choice
$sql = "SELECT * FROM $table_survey WHERE c_id = $course_id AND code='".Database::escape_string($survey_data['code'])."'"; $sql = "SELECT * FROM $table_survey WHERE c_id = $course_id AND code='".Database::escape_string($survey_data['code'])."'";
@ -116,24 +123,31 @@ $users->setButtonAttributes('remove', array('class' => 'btn arrowl'));
// Additional users // Additional users
$form->addElement('textarea', 'additional_users', array(get_lang('AdditonalUsers'), get_lang('AdditonalUsersComment')), array('class' => 'span6', 'rows' => 2)); $form->addElement('textarea', 'additional_users', array(get_lang('AdditonalUsers'), get_lang('AdditonalUsersComment')), array('class' => 'span6', 'rows' => 2));
//$form->addElement('html', '<div> <h3>'.Display::return_icon('course.png', Security::remove_XSS(get_lang('SendMail')),'',ICON_SIZE_SMALL).' '.Security::remove_XSS(get_lang('SendMail')).'</h3><div>');
$form->addElement('html', '<div id="check_mail">');
$form->addElement('checkbox', 'send_mail','', get_lang('SendMail'));
$form->addElement('html', '</div>');
$form->addElement('html', '<div id="mail_text">');
// The title of the mail // The title of the mail
$form->addElement('text', 'mail_title', get_lang('MailTitle'), array('class' => 'span6')); $form->addElement('text', 'mail_title', get_lang('MailTitle'), array('class' => 'span6'));
// The text of the mail // The text of the mail
$form->addElement('html_editor', 'mail_text', array(get_lang('MailText'), get_lang('UseLinkSyntax')), null, array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '150')); $form->addElement('html_editor', 'mail_text', array(get_lang('MailText'), get_lang('UseLinkSyntax')), null, array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '150'));
$form->addElement('html', '</div>');
$form->addElement('checkbox', 'send_mail', '', get_lang('SendMail'));
// You cab send a reminder to unanswered people if the survey is not anonymous // You cab send a reminder to unanswered people if the survey is not anonymous
if ($survey_data['anonymous'] != 1) { if ($survey_data['anonymous'] != 1) {
$form->addElement('checkbox', 'remindUnAnswered', '', get_lang('RemindUnanswered')); $form->addElement('checkbox', 'remindUnAnswered', '', get_lang('RemindUnanswered'));
} }
// Allow resending to all selected users // Allow resending to all selected users
$form->addElement('checkbox', 'resend_to_all', '', get_lang('ReminderResendToAllUsers')); $form->addElement('checkbox', 'resend_to_all', '', get_lang('ReminderResendToAllUsers'));
// Submit button // Submit button
$form->addElement('style_submit_button', 'submit', get_lang('PublishSurvey'), 'class="save"'); $form->addElement('style_submit_button', 'submit', get_lang('PublishSurvey'), 'class="save"');
// The rules (required fields) // The rules (required fields)
$form->addRule('mail_title', get_lang('ThisFieldIsRequired'), 'required'); /*if ($survey_data['send_mail'] == 0) {
$form->addRule('mail_text', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('mail_title', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('mail_text', get_lang('ThisFieldIsRequired'), 'required');
}*/
$portal_url = api_get_path(WEB_PATH); $portal_url = api_get_path(WEB_PATH);
if ($_configuration['multiple_access_urls']) { if ($_configuration['multiple_access_urls']) {
$access_url_id = api_get_current_access_url_id(); $access_url_id = api_get_current_access_url_id();
@ -150,25 +164,43 @@ $form->addElement('label', null, get_lang('AutoInviteLink'));
$form->addElement('label', null, $auto_survey_link); $form->addElement('label', null, $auto_survey_link);
if ($form->validate()) { if ($form->validate()) {
$values = $form->exportValues(); $values = $form->exportValues();
// Save the invitation mail if ($values['send_mail'] == 1) {
SurveyUtil::save_invite_mail($values['mail_text'], $values['mail_title'], !empty($survey_data['invite_mail'])); if (empty($values['mail_title']) || empty($values['mail_text'])) {
// Saving the invitations for the course users Display :: display_error_message(get_lang('FormHasErrorsPleaseComplete'));
$count_course_users = SurveyUtil::save_invitations($values['course_users'], $values['mail_title'], // Getting the invited users
$values['mail_text'], $values['resend_to_all'], $values['send_mail'], $values['remindUnAnswered']); $defaults = SurveyUtil::get_invited_users($survey_data['code']);
// Saving the invitations for the additional users // Getting the survey mail text
$values['additional_users'] = $values['additional_users'].';'; // This is for the case when you enter only one email if (!empty($survey_data['reminder_mail'])) {
$temp = str_replace(',', ';', $values['additional_users']); // This is to allow , and ; as email separators $defaults['mail_text'] = $survey_data['reminder_mail'];
$additional_users = explode(';', $temp); } else {
for ($i = 0; $i < count($additional_users); $i++) { $defaults['mail_text'] = $survey_data['invite_mail'];
$additional_users[$i] = trim($additional_users[$i]); }
} $defaults['mail_title'] = $survey_data['mail_subject'];
$counter_additional_users = SurveyUtil::save_invitations($additional_users, $values['mail_title'], $defaults['send_mail'] = 1;
$values['mail_text'], $values['resend_to_all'], $values['send_mail'], $values['remindUnAnswered']); $form->setDefaults($defaults);
// Updating the invited field in the survey table $form->display();
SurveyUtil::update_count_invited($survey_data['code']); } else {
$total_count = $count_course_users + $counter_additional_users; // Save the invitation mail
Display :: display_confirmation_message($total_count.' '.get_lang('InvitationsSend')); SurveyUtil::save_invite_mail($values['mail_text'], $values['mail_title'], !empty($survey_data['invite_mail']));
// Saving the invitations for the course users
$count_course_users = SurveyUtil::save_invitations($values['course_users'], $values['mail_title'],
$values['mail_text'], $values['resend_to_all'], $values['send_mail'], $values['remindUnAnswered']);
// Saving the invitations for the additional users
$values['additional_users'] = $values['additional_users'].';'; // This is for the case when you enter only one email
$temp = str_replace(',', ';', $values['additional_users']); // This is to allow , and ; as email separators
$additional_users = explode(';', $temp);
for ($i = 0; $i < count($additional_users); $i++) {
$additional_users[$i] = trim($additional_users[$i]);
}
$counter_additional_users = SurveyUtil::save_invitations($additional_users, $values['mail_title'],
$values['mail_text'], $values['resend_to_all'], $values['send_mail'], $values['remindUnAnswered']);
// Updating the invited field in the survey table
SurveyUtil::update_count_invited($survey_data['code']);
$total_count = $count_course_users + $counter_additional_users;
Display :: display_confirmation_message($total_count.' '.get_lang('InvitationsSend'));
}
}
} else { } else {
// Getting the invited users // Getting the invited users
$defaults = SurveyUtil::get_invited_users($survey_data['code']); $defaults = SurveyUtil::get_invited_users($survey_data['code']);
@ -181,7 +213,11 @@ if ($form->validate()) {
$defaults['mail_title'] = $survey_data['mail_subject']; $defaults['mail_title'] = $survey_data['mail_subject'];
$defaults['send_mail'] = 1; $defaults['send_mail'] = 1;
$form->setDefaults($defaults); $form->setDefaults($defaults);
$form->display(); $form->display();
//$form->display();
} }
// Footer // Footer

Loading…
Cancel
Save