Example #1
0
function trig_topic_notification($topicId)
{
    $tbl_mdb_names = claro_sql_get_main_tbl();
    $tbl_course_user = $tbl_mdb_names['rel_course_user'];
    $tbl_cdb_names = claro_sql_get_course_tbl();
    $tbl_user_notify = $tbl_cdb_names['bb_rel_topic_userstonotify'];
    $sql = "SELECT\n                notif.user_id\n            FROM\n                `" . $tbl_user_notify . "` AS notif\n            JOIN\n                `" . $tbl_course_user . "` AS cu\n            ON\n                notif.user_id = cu.user_id\n            AND\n                cu.code_cours = '" . claro_sql_escape(claro_get_current_course_id()) . "'\n            WHERE\n                notif.topic_id = " . (int) $topicId;
    $notifyResult = claro_sql_query_fetch_all_rows($sql);
    if (is_array($notifyResult) && count($notifyResult)) {
        $subject = get_lang('A reply to your topic has been posted');
        $url_topic = get_path('rootWeb') . 'claroline/phpbb/viewtopic.php?topic=' . $topicId . '&cidReq=' . claro_get_current_course_id();
        $url_forum = get_path('rootWeb') . 'claroline/phpbb/index.php?cidReq=' . claro_get_current_course_id();
        // send mail to registered user for notification
        $message = get_lang('You are receiving this notification because you are watching a topic on the forum of one of your courses.') . '<br/>' . "\n" . get_lang('View topic') . '<br/>' . "\n" . '<a href="' . claro_htmlspecialchars(Url::Contextualize($url_topic)) . '">' . Url::Contextualize($url_topic) . '</a><br/><br/>' . "\n" . get_lang('View forum') . '<br/>' . '<a href="' . claro_htmlspecialchars(Url::Contextualize($url_forum)) . '">' . Url::Contextualize($url_forum) . '</a><br/>' . "\n";
        require_once dirname(__FILE__) . '/../../messaging/lib/recipient/userlistrecipient.lib.php';
        require_once dirname(__FILE__) . '/../../messaging/lib/message/platformmessagetosend.lib.php';
        $recipient = new UserListRecipient();
        foreach ($notifyResult as $user) {
            $recipient->addUserId($user['user_id']);
        }
        $message = new PlatformMessageToSend($subject, $message);
        $message->setCourse(claro_get_current_course_id());
        $message->setTools('CLFRM');
        if (claro_is_in_a_group()) {
            $message->setGroup(claro_get_current_group_id());
        }
        //$message->sendTo($recipient);
        $recipient->sendMessage($message);
    }
}
Example #2
0
                 $subject = $_user['firstName'] . ' ' . $_user['lastName'] . ' : ' . get_lang('New submission posted in assignment tool.');
                 if ($assignment->getAssignmentType() == 'GROUP' && isset($_REQUEST['wrkGroup'])) {
                     $authId = $wrkForm['wrkGroup'];
                 } else {
                     $authId = $_REQUEST['authId'];
                 }
                 $url = Url::Contextualize(get_path('rootWeb') . 'claroline/work/user_work.php?authId=' . $authId . '&assigId=' . $assignmentId);
                 // email content
                 $body = get_lang('New submission posted in assignment tool.') . "\n\n" . $_user['firstName'] . ' ' . $_user['lastName'] . "\n" . '<a href="' . claro_htmlspecialchars($url) . '">' . $wrkForm['wrkTitle'] . '</a>' . "\n";
                 $message = new MessageToSend(claro_get_current_user_id(), $subject, $body);
                 // TODO use official code everywhere : $message->setCourse(claro_get_current_course_data('officialCode'));
                 $message->setCourse(claro_get_current_course_id());
                 $message->setTools('CLWRK');
                 $recipient = new UserListRecipient();
                 foreach ($userIdList as $thisUser) {
                     $recipient->addUserId((int) $thisUser['user_id']);
                 }
                 $recipient->sendMessage($message);
             }
         }
         // display flags
         $dispWrkLst = true;
     } else {
         // ask prepare form
         $cmd = "rqSubWrk";
     }
 }
 /*-----------------------------------
             STEP 1 : prepare form
   -------------------------------------*/
 if ($cmd == "rqSubWrk") {