Feature #272 - Mailing: Corrections for the announcement tool. Still there are bugs, they should be fixed later.

skala
Ivan Tcholakov 16 years ago
parent c088a21b36
commit 5abff4192c
  1. 20
      main/announcements/announcements.inc.php
  2. 4
      main/announcements/announcements.php

@ -981,29 +981,19 @@ function edit_advalvas_item($id,$emailTitle,$newContent,$to,$file = array(), $fi
*/
function send_announcement_email($user_list, $course_code, $_course, $mail_title, $mail_content)
{
global $charset;
global $_user;
foreach ($user_list as $this_user) {
/* Header : Bericht van uw lesgever - GES ($course_code) - Morgen geen les! ($mail_title)
Body : John Doe (prenom + nom) <john_doe@hotmail.com> (email)
Morgen geen les! ($mail_title)
Morgen is er geen les, de les wordt geschrapt wegens vergadering (newContent)
*/
$mail_subject = get_lang('professorMessage').' - '.$_course['official_code'].' - '.$mail_title;
$mail_body = '['.$_course['official_code'].'] - ['.$_course['name']."]\n";
$mail_body .= api_get_person_name($this_user['firstname'], $this_user['lastname'], null, PERSON_NAME_EMAIL_ADDRESS).' <'.$this_user["email"]."> \n\n".stripslashes($mail_title)."\n\n".trim(stripslashes(api_html_entity_decode(strip_tags(str_replace(array('<p>','</p>','<br />'),array('',"\n","\n"),$mail_content)), ENT_QUOTES, $charset)))." \n\n-- \n";
$mail_body .= api_get_person_name($this_user['firstname'], $this_user['lastname'], null, PERSON_NAME_EMAIL_ADDRESS).' <'.$this_user["email"]."> \n\n".stripslashes($mail_title)."\n\n".trim(stripslashes(api_html_entity_decode(strip_tags(str_replace(array('<p>','</p>','<br />'),array('',"\n","\n"),$mail_content)), ENT_QUOTES, api_get_system_encoding())))." \n\n-- \n";
$mail_body .= api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS).' ';
$mail_body .= '<'.$_user['mail'].">\n";
$mail_body .= $_course['official_code'].' '.$_course['name'];
//set the charset and use it for the encoding of the email - small fix, not really clean (should check the content encoding origin first)
//here we use the encoding used for the webpage where the text is encoded (ISO-8859-1 in this case)
if(empty($charset)){$charset='ISO-8859-1';}
$encoding = 'Content-Type: text/plain; charset='. $charset;
$newmail = api_mail(api_get_person_name($this_user['firstname'], $this_user['lastname'], null, PERSON_NAME_EMAIL_ADDRESS), $this_user['email'], $mail_subject, $mail_body, api_get_person_name($_SESSION['_user']['firstName'], $_SESSION['_user']['lastName'], null, PERSON_NAME_EMAIL_ADDRESS), $_SESSION['_user']['mail'], $encoding);
api_mail(api_get_person_name($this_user['firstname'], $this_user['lastname'], null, PERSON_NAME_EMAIL_ADDRESS), $this_user['email'], $mail_subject, $mail_body, api_get_person_name($_SESSION['_user']['firstName'], $_SESSION['_user']['lastName'], null, PERSON_NAME_EMAIL_ADDRESS), $_SESSION['_user']['mail']);
}
}
@ -1108,7 +1098,7 @@ function add_announcement_attachment_file($announcement_id, $file_comment, $file
$announcement_id = intval($announcement_id);
if (is_array($file) && $file['error'] == 0 ) {
$courseDir = $_course['path'].'/upload/announcements';
$courseDir = $_course['path'].'/upload/announcements'; // TODO: This path is obsolete. The new document repository scheme should be kept in mind here.
$sys_course_path = api_get_path(SYS_COURSE_PATH);
$updir = $sys_course_path.$courseDir;
@ -1150,7 +1140,7 @@ function edit_announcement_attachment_file($id_attach, $file, $file_comment) {
$return = 0;
if (is_array($file) && $file['error'] == 0 ) {
$courseDir = $_course['path'].'/upload/announcements';
$courseDir = $_course['path'].'/upload/announcements'; // TODO: This path is obsolete. The new document repository scheme should be kept in mind here.
$sys_course_path = api_get_path(SYS_COURSE_PATH);
$updir = $sys_course_path.$courseDir;

@ -588,7 +588,7 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
$sender_name = api_get_person_name($_SESSION['_user']['lastName'], $_SESSION['_user']['firstName'], null, PERSON_NAME_EMAIL_ADDRESS);
$email = $_SESSION['_user']['mail'];
$headers="From:$sender_name\r\nReply-to: $email\r\nContent-type: text/html; charset=iso-8859-15";
$headers="From:$sender_name\r\nReply-to: $email";
//@mail($to,$subject,$message,$headers);
//api_send_mail($to,$subject,$message,$headers);
api_mail('',$to,$subject,$message,$sender_name,$email,$headers);
@ -703,7 +703,7 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
$message=stripslashes($newContentsix);
$sender_name = api_get_person_name($_SESSION['_user']['lastName'], $_SESSION['_user']['firstName'], null, PERSON_NAME_EMAIL_ADDRESS);
$email = $_SESSION['_user']['mail'];
$headers="From:$sender_name\r\nReply-to: $email\r\nContent-type: text/html; charset=iso-8859-15";
$headers="From:$sender_name\r\nReply-to: $email";
//@mail($myrow["email"],stripslashes($emailTitle),$message,$headers);
api_mail('',$myrow["email"],stripslashes($emailTitle),$message,$sender_name,$email);
} else {

Loading…
Cancel
Save