2009-06-01 02:03:06
Email notification of the posting of an announcement
Hello. I've been modifiying some files recently and I'm attempting to put in some code that will notify the user of a posted announcement. The problem I'm having is that it only notifies the instructor. Enrolled students don't get the notification.
In /ATutor/editor/add_news.php, under:
$sql = "INSERT INTO ".TABLE_PREFIX."news VALUES (NULL, $_SESSION[course_id], $_SESSION[member_id], NOW(), $_POST[formatting], '$_POST[title]', '$_POST[body_text]')";
mysql_query($sql, $db);
$msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
I inserted:
//BOF Email notification of announcement
//send email notification if recipient has message notification enabled
$sql_notify = "SELECT first_name, last_name, email, email2, inbox_notify FROM ".TABLE_PREFIX."members WHERE member_id>0";
$result_notify = mysql_query($sql_notify, $db);
$row_notify = mysql_fetch_assoc($result_notify);
if ($row_notify['inbox_notify'] == 1) {
require(AT_INCLUDE_PATH . 'classes/phpmailer/atutormailer.class.php');
$body = _AT('notification_new_inbox', $_base_href.'bounce.php?course='.$_SESSION['course_id']);
// $sender = get_display_name($_SESSION['member_id']);
$mail = new ATutorMailer;
$mail->AddAddress($row_notify['email']);
$mail->AddAddress($row_notify['email2']);
$mail->FromName = $_config['site_name'];
$mail->From = $_config['contact_email'];
$mail->Subject = _AT('message_notification');
$mail->Body = $body;
if(!$mail->Send()) {
$msg->addError('SENDING_ERROR');
}
unset($mail);
}
//EOF Email notification of announcement
I got the code from /ATutor/inbox/send_message.php but altered it to work (mostly) with the add_news.php file.
NOTE: The refereces to "email2" are another mod that I've been working on to add a 2nd email address to the account as discussed here: http://www.atutor.ca/view/16/17600/1.html. I don't think this could be effecting anything though as the instructor receives the notification at the "email2" email address.
Thanks for your consideration.