/** * Send a notice. * * @param class $facetoface record from the facetoface table * @param class $session record from the facetoface_sessions table * @param integer $userid ID of the recipient of the email * @param array $params The parameters for the notification * @param int $icalattachmenttype The ical attachment type, or MDL_F2F_TEXT to disable ical attachments * @param int $icalattachmentmethod The ical method type: MDL_F2F_INVITE or MDL_F2F_CANCEL * @return string Error message (or empty string if successful) */ function facetoface_send_notice($facetoface, $session, $userid, $params, $icalattachmenttype = MDL_F2F_TEXT, $icalattachmentmethod = MDL_F2F_INVITE) { global $DB, $CFG; $user = $DB->get_record('user', array('id' => $userid)); if (!$user) { return 'userdoesnotexist'; } $notice = new facetoface_notification($params); if (isset($facetoface->ccmanager)) { $notice->ccmanager = $facetoface->ccmanager; } $notice->set_facetoface($facetoface); if (!isset($session->notifyuser)) { $session->notifyuser = true; } if (get_config(null, 'facetoface_oneemailperday')) { // Keep track of all sessiondates. $sessiondates = $session->sessiondates; foreach ($sessiondates as $sessiondate) { $session->sessiondates = array($sessiondate); // One day at a time. if ((int)$icalattachmenttype == MDL_F2F_BOTH) { $ical_attach = facetoface_get_ical_attachment($icalattachmentmethod, $facetoface, $session, $userid); $notice->set_ical_attachment($ical_attach); } $newevent = $notice->set_newevent($user, $session->id, $sessiondate); // print_object($newevent); if ($session->notifyuser) { echo "Test this email HEre Only"; print_object($newevent); $notice->send_to_user($newevent, $user, $session->id, $sessiondate); } $notice->send_to_manager($newevent, $user, $session->id); $notice->send_to_thirdparty($newevent, $user, $session->id); //@unlink($CFG->dataroot . DIRECTORY_SEPARATOR . $newevent->attachment); } // Restore session dates. $session->sessiondates = $sessiondates; } else { if ((int)$icalattachmenttype == MDL_F2F_BOTH) { // $ical_attach = facetoface_get_ical_attachment($icalattachmentmethod, $facetoface, $session, $userid); //$notice->set_ical_attachment($ical_attach); } // print_object($session); $newevent = $notice->set_newevent($user, $session->id); // print_object($newevent->userto); if ($session->notifyuser) { $notice->send_to_user($newevent, $user, $session->id); } $notice->send_to_manager($newevent, $user, $session->id); $notice->send_to_thirdparty($newevent, $user, $session->id); @unlink($CFG->dataroot . DIRECTORY_SEPARATOR . $newevent->attachment); } return ''; }