ATutor

Learning Management Tools







Pages:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15


Email notification of the posting of an announcement


  • 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.

  • 2009-06-01 08:49:51

    Re: Email notification of the posting of an announcement

    Take a look at Course Email scripts.
    http://atutorsvn.atrc.utoronto.ca/repos/atutor/trunk/docs/tools/course_email.php

  • 2009-06-01 09:23:43

    Re: Email notification of the posting of an announcement

    Greg,

    I did look at the Course Email file, but I went with the code from send_message.php file because I want it to be an automatic notification.

    What were you wanting me to see in course email?

    Thanks.

  • 2009-06-02 04:14:17

    Re: Email notification of the posting of an announcement

    have you had a look at the "subscribe to announcement" feature we made?

    http://atutor.no/contribs/subscribe-announcements and
    http://atutor.no/2008/07/announcement-subscription-and-improved-directory

    this will let the user subscribe and unsubscribe to announcement. if you install this you could probably tweak it to work as you wish too!

    (Greg, maybe you could review and possibly get this patch in core?)

  • 2009-06-04 10:20:44

    Re: Email notification of the posting of an announcement

    Vegard,

    That lookgs great.

    However, when I went to install it I got:

    Warning
    This patch is for ATutor version 1.6.1. Does not match with your current ATutor version. The installation of it may break ATutor. Are you sure you want to proceed?


    Will it work on 1.6.2 without causing other things to break?

    Thanks.

  • 2009-06-04 12:20:30

    Re: Email notification of the posting of an announcement

    hia, yes it'll work on 1.6.2 as well

  • 2009-06-04 16:36:21

    Re: Email notification of the posting of an announcement

    If you are asking for help, provide lots of detail so problems can be reproduced.

    Things to describe:
    Operating system ATutor is installed on -
    ATutor version -
    Patch #s applied -
    ATutor theme name -
    PHP version -
    MySQL version -
    Webserver & version -
    Copies of error messages -
    Changes to default settings -
    Web browser being used -
    ...and anything else relevant -